第1章 环境准备
1.1 系统环境
[root@zabbix ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@zabbix ~]# uname -r
2.6.32-696.el6.x86_64
[root@zabbix ~]# uname -m
x86_64
1.2 关闭安全机制
[root@zabbix ~]# /etc/init.d/iptables stop
[root@zabbix ~]# setenforce 0
[root@zabbix ~]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/sysconfig/selinux
1.3 注意事项
在安装zabbix3.0以上版本时,php的版本需要大于5.4以上的版本
第2章 yum安装zabbix
2.1 安装的版本及环境
MySQL: MySQL 5.6.40
php: PHP 5.6.35
Apache: httpd-2.2.15
zabbix: 3.2.11
2.2 yum搭建lamp环境
2.2.1 安装Apache+PHP
[root@zabbix ~]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
[root@zabbix ~]# yum install -y httpd libxml2-devel net-snmp-devel libcurl-devel php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
2.2.2 安装Mysql
[root@zabbix ~]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
[root@zabbix ~]# yum -y install mysql-server
2.3 安装zabbix
[root@zabbix ~]# wget http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-
1.el6.noarch.rpm
[root@zabbix ~]# rpm -ivh zabbix-release-3.2-1.el6.noarch.rpm
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
2.4 配置zabbix
2.4.1 创建数据库
[root@zabbix ~]# mysqladmin -uroot password “123456”
[root@zabbix ~]# mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
mysql>quit;
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.11/create.sql.gz |mysql -uroot -p123456 zabbix
2.4.2 修改zabbix配置文件
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
2.4.3 修改php配置文件
[root@zabbix ~]# 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
2.4.4 修改zabbix-agent配置文件
[root@zabbix ~]# sed -i 's#Server=127.0.0.1#Server=61.163.231.195#'
/etc/zabbix/zabbix_agentd.conf
2.4.5 将zabbix配置文件拷贝至相关目录
[root@zabbix ~]# cp -r /usr/share/zabbix/* /var/www/html/zabbix/
[root@zabbix ~]# chown -R apache:apache /var/www/html/zabbix
2.4.6 启动并加入开机自启动
[root@zabbix ~]# /etc/init.d/httpd start
[root@zabbix ~]# /etc/init.d/mysqld start
[root@zabbix ~]# /etc/init.d/ zabbix-agent start
[root@zabbix ~]# /etc/init.d/ zabbix-server start
[root@zabbix ~]# echo “/etc/init.d/httpd start” >>/etc/rc.local
[root@zabbix ~]# echo “/etc/init.d/mysqld start” >>/etc/rc.local
[root@zabbix ~]# echo “/etc/init.d/zabbix-agent start” >>/etc/rc.local
[root@zabbix ~]# echo “/etc/init.d/zabbix-server start” >>/etc/rc.local
2.5 结果展示
输入ip+zabbix
默认的登录用户名:Admin
默认的登录密码:zabbix
第3章 编译安装zabbix
3.1 安装的版本及环境
Zabbix: zabbix-3.2.11.tar.gz
MySQL: MySQL 5.1.73
php: PHP 5.6.35
Apache: httpd-2.2.15
3.2 yum搭建lnmp环境
[root@zabbix ~]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
[root@zabbix ~]# yum -y install httpd httpd-devel mysql mysql-server mysql-devel
[root@zabbix ~]# yum install php56w php56w-mysql php56w-common php56w-gd php56w-mbstring php56w-mcrypt php56w-devel php56w-xml php56w-bcmath -y
3.3 编译zabbix
[root@zabbix ~]# yum install -y gcc-c++ net-snmp net-snmp-devel curl curl-devel libxml2
libxml2-devel
[root@zabbix ~]# mkdir -p /application/tools
[root@zabbix ~]# cd /application/tools
[root@zabbix ~]# rz
[root@zabbix ~]# tar xf zabbix-3.2.11.tar.gz
[root@zabbix ~]# cd zabbix-3.2.11
[root@zabbix ~]# ./configure --prefix=/application/zabbix-3.2.11 --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
[root@zabbix ~]# make && make install
[root@zabbix ~]# ln -s /application/zabbix-3.2.11 /application/zabbix
3.4 创建mysql
[root@zabbix ~]# mysqladmin -uroot password “123456”
[root@zabbix ~]# mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
mysql>quit;
3.5 配置zabbix
3.5.1 导入zabbix数据库
[root@zabbix ~]# cd /application/tools/zabbix-3.0.17/database/mysql/
[root@zabbix mysql]# mysql -uroot -p123456 zabbix [root@zabbix mysql]# mysql -uroot -p123456 zabbix [root@zabbix mysql]# mysql -uroot -p123456 zabbix [root@zabbix ~]# mkdir -p /var/www/html/zabbix [root@zabbix ~]# cp –rf /application/tools/zabbix-3.2.11/frontends/php/* /var/www/html/zabbix/ [root@zabbix ~]# 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@zabbix ~]# vim /application/zabbix/etc/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456 [root@zabbix ~]# vim /application/zabbix/etc/agent_server.conf Server=127.0.0.1 Hostname=Zabbix server [root@zabbix ~]# cd /application/tools/zabbix-3.2.11/misc [root@zabbix ~]# cp init.d/tru64/zabbix_server /etc/init.d/ [root@zabbix ~]# cp init.d/tru64/zabbix_agentd /etc/init.d/ [root@zabbix ~]# chmod +x /etc/init.d/zabbix_* [root@zabbix ~]# sed -i 's#/usr/local#/application/zabbix#g' /etc/init.d/zabbix_server [root@zabbix ~]# sed -i 's#/usr/local#/application/zabbix#g' /etc/init.d/zabbix_agentd [root@zabbix ~]# /etc/init.d/mysqld start [root@zabbix ~]# /etc/init.d/httpd restart [root@zabbix ~]# /etc/init.d/zabbix_server start [root@zabbix ~]# /etc/init.d/zabbix_agentd start [root@zabbix ~]# echo “/etc/init.d/httpd start” >>/etc/rc.local [root@zabbix ~]# echo “/etc/init.d/mysqld start” >>/etc/rc.local [root@zabbix ~]# echo “/etc/init.d/zabbix-agent start” >>/etc/rc.local [root@zabbix ~]# echo “/etc/init.d/zabbix-server start” >>/etc/rc.local 输入ip+zabbix 默认的登录用户名:Admin 默认的登录密码:zabbix3.5.2 拷贝zabbixWEB程序到主站目录下
3.5.3 配置php配置文件
3.5.4 修改zabbix的配置文件
3.5.5 拷贝zabbix启动脚本到/etc/init.d目录下
3.5.6 启动并加入开机自启动
3.6 结果展示