系统环境
Server端:192.168.149.128
Agent端:192.168.149.129
一、lamp环境安装
1、yum安装lamp
yum install -y http http-devel mariadb mariadb-devel mariadb-server php php-devel php-mysql php-gd php-bcmath php-mbstring php-xml
2、修改php配置文件参数
sed -i 's/;always_populate_raw_post_data/always_populate_raw_post_data/g' /etc/php.ini sed -i '/max_execution_time/s/30/600/g;/max_input_time/s/60/600/g;/memory_limit/s/128M/256M/g;/post_max_size/s/8M/32M/g;/upload_max_filesize/s/2M/16M/g;s/;date.timezone.*/date.timezone =Asia/Shanghai/g' /etc/php.ini
二、zabbix_server部署
1、创建数据库并导入数据
create database zabbix charset=utf8; grant all on zabbix.* to zabbix@'localhost' identified by '123456'; flush privileges; cd /usr/local/src wget http://sourceforge.net/projects/zabbix/files/ZABBIX Latest Stable/3.2.6/zabbix-3.2.6.tar.gz/download tar -zxf zabbix-3.2.6.tar.gz cd zabbix-3.2.6/database/mysql/ mysql -uzabbix -p123456 zabbix < schema.sql mysql -uzabbix -p123456 zabbix < images.sql mysql -uzabbix -p123456 zabbix < data.sql
2、下载安装zabbix
yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI mysql-devel groupadd zabbix;useradd -g zabbix zabbix;usermod -s /sbin/nologin zabbix cd /usr/local/src/zabbix-3.2.6 ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl make && make install ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/ cp /usr/local/src/zabbix-3.2.6/misc/init.d/tru64/zabbix_server /etc/init.d/zabbix_server chmod o x /etc/init.d/zabbix_server
3、备份Zabbix server配置文件,将zabbix_server.conf配置文件中代码设置为如下
LogFile=/tmp/zabbix_server.log DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456
4、配置Zabbix interface Web页面,并启动服务
cp -a /usr/local/src/zabbix-3.2.6/frontends/php/* /var/www/html/ /etc/init.d/zabbix_server restart /etc/init.d/httpd restart /etc/init.d/mysqld restart
4、在浏览器访问 http://192.168.149.128/
图1 Zabbix WEB安装界面
图2 Zabbix WEB测试安装环境
1)单击下一步,如图13-7所示,配置数据库连接,输入数据库名、用户、密码,单击Test connection,显示OK,单击下一步即可。
图3 Zabbix WEB数据库配置
2)继续单击下一步出现如图13-8所示,填写Zabbix Title显示,可以为空,可以输入自定义的名称。
图4 Zabbix WEB详细信息
3)需修创建zabbix.conf.php文件,执行如下命令,或者单击“Download the configuration file”下载zabbix.conf.php文件,并将该文件上传至/var/www/html/conf/,并设置可写权限,刷新WEB页面;
图5 Zabbix WEB配置文件测试
4)登录Zabbix WEB界面,默认用户名和密码为:admin/zabbix
三、zabbix_agent部署安装
1、下载编译安装
cd /usr/local/src/ wget http://sourceforge.net/projects/zabbix/files/ZABBIX Latest Stable/3.2.6/zabbix-3.2.6.tar.gz/download ./configure --prefix=/usr/local/zabbix --enable-agent make && make install ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
2、修改zabbix_agentd.conf配置文件如下:
LogFile=/tmp/zabbix_agentd.log Server=192.168.149.128 ServerActive=192.168.149.128 Hostname = 192.168.149.129
3、同时cp zabbix_agentd启动脚本至/etc/init.d/目录,启动zabbix_agentd服务即可, Zabbix_agentd默认监听端口为10050。
cp /usr/local/src/zabbix-3.2.6/misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd chmod o x /etc/init.d/zabbix_agentd /etc/init.d/zabbix_agentd start