[root@localhost /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config #重啓生效 [root@localhost /]# setenforce 0 #臨時關閉
zabbix須要mysql5.6以上版本,刪除舊的版本php
[root@localhost /]# rpm -qa mysql* 下載MySQL5.6版本 [root@localhost /]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [root@localhost /]# yum -y install mysql-server [root@localhost /]# yum list installed | grep mysql mysql-community-client.x86_64 5.6.32-2.el6 @mysql56-community mysql-community-common.x86_64 5.6.32-2.el6 @mysql56-community mysql-community-libs.x86_64 5.6.32-2.el6 @mysql56-community mysql-community-release.noarch mysql-community-server.x86_64 5.6.32-2.el6 @mysql56-community 修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1 [root@localhost /]# vim /etc/my.cnf innodb_file_per_table=1 [root@localhost /]# /etc/init.d/mysqld start 這是強烈建議安全數據庫和指定的「根」的賬戶密碼,刪除匿名登陸等。它是按照指令後MySQL安全安裝完成。 root@localhost /]# mysql_secure_installation 登錄數據庫 [root@localhost /]# mysql -u root -p #這裏的root密碼爲123456 mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; Query OK, 1 row affected (0.06 sec) mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbixpass'; Query OK, 0 rows affected (0.02 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | zabbix | +--------------------+ 4 rows in set (0.03 sec) mysql>
Zabbix 3須要PHP是至少5.4或更高版本。咱們的CentOS 6.5庫跟php 5.3.3所以咱們須要安裝一個新的。html
[root@localhost /]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
[root@localhost /]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
修改php配置前端
[root@localhost /]# vim /etc/php.ini post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai always_populate_raw_post_data = -1
[root@localhost /]# vim /etc/httpd/conf/httpd.conf ServerName 127.0.0.1 DirectoryIndex index.html index.html.var index.php 啓動apache [root@localhost /]# /etc/init.d/httpd start Starting httpd: [ OK ] 在iptables上開放80端口 [root@localhost /]# iptables -I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT [root@localhost /]# /etc/init.d/iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] [root@localhost /]# cat /etc/sysconfig/iptables # Generated by iptables-save v1.4.7 on Mon Aug 29 21:58:54 2016 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [67:6921] -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT # Completed on Mon Aug 29 21:58:54 2016 [root@localhost /]#
[root@localhost /]# groupadd zabbix
[root@localhost /]# useradd -g zabbix zabbix
依賴包安裝mysql
[root@localhost mysql]# yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel
用於上傳下載文件(因爲直接在虛擬機裏下載較慢、在此直接下載到本地主機用lrzsz上傳至虛擬機) [root@localhost /]# yum -y install lrzsz zabbix3.0.4下載地址 [root@localhost /]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz 解壓到當前目錄根 [root@localhost /]# tar -zxvf zabbix-3.0.4.tar.gz [root@localhost /]# cd /zabbix-3.0.4/database/mysql/ [root@localhost mysql]# ls data.sql images.sql schema.sql [root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <schema.sql Enter password: #這裏的root密碼爲123456 [root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <images.sql Enter password: [root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <data.sql Enter password:
[root@localhost mysql]# cd /zabbix-3.0.4 編譯 [root@localhost zabbix-3.0.4]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix 安裝 [root@localhost zabbix-3.0.4]# make install [root@localhost zabbix-3.0.4]# echo $? 0
修改zabbix_server的配置linux
[root@localhost etc]# vim /usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=zabbixpass
建立一個新的web前端文件web
[root@localhost conf]# mkdir /var/www/html/zabbix 移動源到剛纔建立目錄下 [root@localhost conf]#cd /zabbix-3.0.4/frontends/php/ [root@localhost php]# cp -a . /var/www/html/zabbix/
設置Apache做爲Web用戶接口文件的全部者sql
[root@localhost php]# chown -R apache:apache /var/www/html/zabbix
添加權限給Zabbix Web界面執行文件數據庫
[root@localhost php]# chmod +x /var/www/html/zabbix/conf/
添加Zabbix服務器和Zabbix代理啓動腳本apache
[root@localhost php]# cp /zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server [root@localhost php]# cp /zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
添加Zabbix服務器和Zabbix代理服務vim
[root@localhost php]# chkconfig --add /etc/init.d/zabbix_server [root@localhost php]# chkconfig --add /etc/init.d/zabbix_agentd [root@localhost php]# chkconfig httpd on [root@localhost php]# chkconfig mysqld on [root@localhost php]# chkconfig zabbix_server on [root@localhost php]# chkconfig zabbix_agentd on
啓動zabbix_server
[root@localhost php]# /etc/init.d/zabbix_server start #報錯 Starting zabbix_server: /etc/init.d/functions: line 546: /usr/local/sbin/zabbix_server: No such file or directory [FAILED] [root@localhost php]# vim /etc/init.d/zabbix_server BASEDIR=/usr/local/zabbix #更改下路徑 [root@localhost php]# /etc/init.d/zabbix_server start Starting zabbix_server: [ OK ] [root@localhost php]# vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix #更改下路徑 [root@localhost php]# /etc/init.d/zabbix_agentd start Starting zabbix_agentd: [ OK ]