先关闭selinux和iptables。
zabbix需要mysql5.6以上版本,如果之前安装过旧版本,则需要先删除,rpm -e xxxx。没有则直接安装。
[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; #创建zabbix数据库 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 | +--------------------+ rows in set (0.03 sec) mysql>
Zabbix 3需要PHP是至少5.4或更高版本,如果低于5.4,需要先卸载PHP,可以先php -v看一下版本。
#rpm -qa|grep php 提示如下 #php-pdo-5.1.6-27.el5_5.3 #php-MySQL-5.1.6-27.el5_5.3 #php-xml-5.1.6-27.el5_5.3 #php-cli-5.1.6-27.el5_5.3 #php-common-5.1.6-27.el5_5.3 #php-gd-5.1.6-27.el5_5.3 注意卸载要先卸载没有依赖的 pdo是mysql的依赖项;common是gd的依赖项; 例如:# rpm -e php-pdo-5.1.6-27.el5_5.3 error: Failed dependencies:php-pdo is needed by (installed) php-mysql-5.1.6-27.el5_5.3.i386 所以正确的卸载顺序是: # rpm -e php-mysql-5.1.6-27.el5_5.3 # rpm -e php-pdo-5.1.6-27.el5_5.3 # rpm -e php-xml-5.1.6-27.el5_5.3 # rpm -e php-cli-5.1.6-27.el5_5.3 # rpm -e php-gd-5.1.6-27.el5_5.3 # rpm -e php-common-5.1.6-27.el5_5.3 再用# php -v 查看版本信息已经没有提示
卸载完成后,先安装新的源,再安装php,apache
[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
修改apache配置
[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 ]
创建zabbix用户和组
[root@localhost /]# groupadd zabbix
[root@localhost /]# useradd -g zabbix zabbix
依赖包安装
[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
下载Zabbix安装包,解压,编译,安装
用于上传下载文件(由于直接在虚拟机里下载较慢、在此直接下载到本地主机用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 -p123456 zabbix <schema.sql #这里的root密码为123456 [root@localhost mysql]# mysql -uroot -hlocalhost -p123456 zabbix <images.sql [root@localhost mysql]# mysql -uroot -hlocalhost -p123456 zabbix <data.sql
[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
修改zabbix_server的配置
[root@localhost etc]# vim /usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=zabbixpass
创建一个新的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用户接口文件的所有者
[root@localhost php]# chown -R apache:apache /var/www/html/zabbix
添加权限给Zabbix Web界面执行文件
[root@localhost php]# chmod -R 777 /var/www/html/zabbix
添加Zabbix服务器和Zabbix代理启动脚本
[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代理服务
[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]# 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 ]
zabbix web安装页面
http://192.168.1.101/zabbix/setup.php
zabbix日志文件默认
/tmp/zabbix_server.log
被监控机只安装zabbix_agentd可以参考以下:
添加zabbix用户群组
#groupadd zabbix
#useradd -g zabbix -m zabbix
下载zabbix安装包,本文用的是3.0.3版本zabbix-3.0.3.tar.gz
解压、编译、安装
#tar -zxvf zabbix-3.0.3.tar.gz #cd zabbix-3.0.3 #./configure --prefix=/usr/local/zabbix --enable-agent #make install
修改agentd配置文件,配置zabbix server地址以及agented自己的Hostname
#vim /usr/local/zabbix/etc/zabbix_agentd.conf Server= ip.ip.ip.ip #服务端ip地址 ServerActive= ip.ip.ip.ip #服务端ip地址(主动模式) Hostname=client01 #该值跟zabbix web上配置的主机名称要一致(配置-》主机-》主机名称)
配置成使用service启动关闭
#cp zabbix-3.0.3/misc/init.d/tru64/zabbix_agentd /etc/init.d/ # chmod +x /etc/init.d/zabbix_ agentd # ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/ # ln -s /usr/local/zabbix/bin/* /usr/local/bin/
启动、检查
#service zabbix_agentd start #ps -ef|grep zabbix_agentd
参考 https://www.cnblogs.com/zzzhfo/p/5820321.html