安裝MySQLphp
[root@zabbix ~]# mkdir -p /usr/local/src [root@zabbix ~]# cd /usr/local/src/ [root@zabbix src]# pwd /usr/local/src [root@zabbix src]# useradd -s /sbin/nologin -M mysql [root@zabbix src]# mkdir -p /usr/local/mysql [root@zabbix src]# mkdir -p /usr/local/mysql/data/mysql [root@zabbix src]# mkdir -p /home/data/mysql [root@zabbix src]# yum -y install gcc gcc-c++ zlib-devel libtool ncurses-devel libxml2-devel cmake [root@zabbix src]# wget -q http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [root@zabbix src]# tar xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [root@zabbix src]# cd mysql-5.6.35 [root@zabbix mysql-5.6.35]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci [root@zabbix mysql-5.6.35]# make && make install [root@zabbix mysql-5.6.35]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@zabbix mysql-5.6.35]# chmod +x /etc/init.d/mysqld [root@zabbix mysql-5.6.35]# chown -R mysql:mysql /usr/local/mysql/data/mysql [root@zabbix mysql-5.6.35]# chown -R mysql:mysql /usr/local/mysql/ [root@zabbix mysql-5.6.35]# cd /usr/local/mysql/scripts/ [root@zabbix scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/mysql [root@zabbix scripts]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf'? y [root@zabbix scripts]# vim /etc/my.cnf [root@zabbix scripts]# vim /etc/profile datadir = /usr/local/mysql/data/mysql port = 3306 server_id = 2 socket = /usr/local/mysql/mysql.sock lower_case_table_names = 1 wait_timeout=3600 log_bin_trust_function_creators=1 max_connections=500 [root@zabbix scripts]# source /etc/profile [root@zabbix scripts]# /etc/init.d/mysqld start Starting MySQL. SUCCESS! [root@zabbix scripts]# netstat -nlput | grep mysql tcp 0 0 :::3306 :::* LISTEN 16454/mysqld
建立zabbix數據庫、並受權html
[root@zabbix scripts]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.32 Source distribution Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbixpass'; Query OK, 0 rows affected (0.03 sec) mysql> exit Bye
安裝PHP&Apache前端
[root@zabbix scripts]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm Retrieving http://repo.webtatic.com/yum/el6/latest.rpm warning: /var/tmp/rpm-tmp.aRTjFj: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY Preparing... ########################################### [100%] 1:webtatic-release ########################################### [100%] [root@zabbix scripts]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap [root@zabbix scripts]# vim /etc/php.ini post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai memory_limit = 128M pload_max_filesize = 2M always_populate_raw_post_data = -1
修改Apache配置java
[root@zabbix scripts]# vim /etc/httpd/conf/httpd.conf ServerName 127.0.0.1 DirectoryIndex index.html index.html.var index.php [root@zabbix scripts]# /etc/init.d/httpd start Starting httpd: [ OK ]
安裝zabbixpython
[root@zabbix scripts]# groupadd zabbix [root@zabbix scripts]# useradd -g zabbix zabbix [root@zabbix scripts]# yum -y install mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel [root@zabbix scripts]# cd /usr/local/src/ [root@zabbix src]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX Latest Stable/3.2.6/zabbix-3.2.6.tar.gz [root@zabbix src]# tar xf zabbix-3.2.6.tar.gz [root@zabbix src]# cd zabbix-3.2.6 [root@zabbix zabbix-3.2.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --enable-java [root@zabbix zabbix-3.2.6]# make install
修改zabbix_server配置文件mysql
[root@zabbix zabbix-3.2.6]# vim /usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=zabbixpass #DBSocket=/var/lib/mysql/mysql.sock #後面會報錯找不到這個文件、能夠保持默認,建立個軟鏈接便可 #DBPort=3306 #能夠保持默認
建立一個軟鏈接把本身mysql數據庫的mysql.sock指向/var/lib/mysql/mysql.sock,而後後面會報錯linux
[root@zabbix zabbix-3.2.6]# mkdir /var/lib/mysqlc++
[root@zabbix zabbix-3.2.6]# ln -s /usr/local/mysql/mysql.sock /var/lib/mysql/mysql.sockweb
建立前端目錄sql
[root@zabbix zabbix-3.2.6]# mkdir /var/www/html/zabbix
拷貝文件到/var/www/html/zabbix
[root@zabbix zabbix-3.2.6]# cd frontends/php/ [root@zabbix php]# cp -a . /var/www/html/zabbix/
賦權
[root@zabbix php]# chown -R apache:apache /var/www/html/zabbix [root@zabbix php]# chmod +x /var/www/html/zabbix/conf/
添加zabbix啓動腳本
[root@zabbix php]# cd /usr/local/src/zabbix-3.2.6 [root@zabbix zabbix-3.2.6]# pwd /usr/local/src/zabbix-3.2.6 [root@zabbix zabbix-3.2.6]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server [root@zabbix zabbix-3.2.6]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_agentd [root@zabbix zabbix-3.2.6]# chkconfig --add /etc/init.d/zabbix_server [root@zabbix zabbix-3.2.6]# chkconfig --add /etc/init.d/zabbix_agentd [root@zabbix zabbix-3.2.6]# chkconfig httpd on [root@zabbix zabbix-3.2.6]# chkconfig mysqld on [root@zabbix zabbix-3.2.6]# chkconfig zabbix_server on [root@zabbix zabbix-3.2.6]# chkconfig zabbix_agentd on [root@zabbix zabbix-3.2.6]# vim /etc/init.d/zabbix_server BASEDIR=/usr/local/zabbix [root@zabbix zabbix-3.2.6]# vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix
初始化數據庫
[root@zabbix zabbix-3.2.6]# cd database/mysql/ [root@zabbix mysql]# ls data.sql p_w_picpaths.sql schema.sql [root@zabbix mysql]# mysql -uroot -hlocalhost -p zabbix <schema.sql Enter password: [root@zabbix mysql]# mysql -uroot -hlocalhost -p zabbix <p_w_picpaths.sql Enter password: [root@zabbix mysql]# mysql -uroot -hlocalhost -p zabbix <data.sql Enter password:
啓動服務
報錯
[root@liveneo-14 ~]# /etc/init.d/zabbix_server start Starting zabbix_server: /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory [FAILED] [root@liveneo-14 ~]# /etc/init.d/zabbix_agentd start Starting zabbix_server: /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory [FAILED]
解決
[root@liveneo-14 ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64
從新啓動服務
[root@liveneo-14 ~]# /etc/init.d/zabbix_server start Starting zabbix_server: [ OK ] [root@liveneo-14 ~]# /etc/init.d/zabbix_agentd start Starting zabbix_server: [ OK ]
瀏覽器訪問:
http://IP/zabbix/setup.php
默認登陸帳號:Admin
默認登陸密碼:zabbix