CentOS 7.2下搭建Zabbix 3.2.6 过程
一、 部署环境
系统:centos7.2最小化安装
Server:192.168.103.180
Client:192.168.103.184
二、 基础软件包安装:
[root@zabbix ~]# yum install gcc* make php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI httpd mariadb* mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel vim –y
1、启动httpd和mariadb,并设成开机启动:
[root@zabbix ~]# systemctl start httpd mariadb
[root@zabbix ~]# chkconfig httpd on
Note: Forwarding request to ‘systemctl enable httpd.service’.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix ~]# chkconfig mariadb on
Note: Forwarding request to ‘systemctl enable mariadb.service’.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
2、关闭selinux:
[root@zabbix ~]# setenforce 0
[root@zabbix ~]# sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config
3、关闭防火墙:
[root@zabbix ~]# systemctl stop firewalld
Failed to stop firewalld.service: Unit firewalld.service not loaded.
4、配置php参数:
[root@zabbix ~]# sed -i ‘s#;date.timezone =#date.timezone = Asihjha/Shanghai#g’ /etc/php.ini
[root@zabbix ~]# sed -i ‘s#max_execution_time = 30#max_execution_time = 300#g’ /etc/php.ini
[root@zabbix ~]# sed -i ‘s#post_max_size = 8M#post_max_size = 32M#g’ /etc/php.ini
[root@zabbix ~]# sed -i ‘s#max_input_time = 60#max_input_time = 300#g’ /etc/php.ini
[root@zabbix ~]# sed -i ‘s#;mbstring.func_overload = 0#mbstring.func_overload = 1#g’ /etc/php.ini
5、修改httpFQDN错误,然后重启httpd服务:
[root@zabbix ~]# echo “ServerName localhost:80” >> /etc/httpd/conf/httpd.conf
[root@zabbix ~]# systemctl restart httpd
6、创建zabbix用户和组:
[root@zabbix opt]# groupadd -g 205 zabbix
[root@zabbix opt]# useradd -g zabbix -u 205 -s /sbin/nologin zabbix
7、导入zabbix-3.2.6.tar.gz至zabbix服务器上,如下:
[root@zabbix opt]# ls
zabbix-3.2.6.tar.gz
8、编译安装
[root@zabbix opt]# tar xf zabbix-3.2.6.tar.gz
[root@zabbix opt]# ls
zabbix-3.2.6 zabbix-3.2.6.tar.gz
[root@zabbix opt]# cd zabbix-3.2.6
[root@zabbix zabbix-3.2.6]# ./config
config.guess config.sub configure
[root@zabbix zabbix-3.2.6]# ./configure –enable-server –enable-agent –with-mysql –with-net-snmp –with-libcurl –with-libxml2 –with-openipmi –with-unixodbc
[root@zabbix zabbix-3.2.6]#make install
9、给数据库设置密码:
10、创建新用户,用户名为:zabbix 密码:zx123456,并把zabbix数据库授权给zabbix用户:
11、导入zabbix相关表:
[root@zabbix zabbix-3.2.6]# mysql -uzabbix -pzx123456 zabbix < database/mysql/schema.sql
[root@zabbix zabbix-3.2.6]# mysql -uzabbix -pzx123456 zabbix < database/mysql/images.sql
[root@zabbix zabbix-3.2.6]# mysql -uzabbix -pzx123456 zabbix < database/mysql/data.sql
12、配置启动文件信息:
[root@zabbix zabbix-3.2.6]# mkdir /var/log/zabbix
[root@zabbix zabbix-3.2.6]# chown zabbix.zabbix /var/log/zabbix/
[root@zabbix zabbix-3.2.6]# ln -s /usr/local/etc/zabbix_
zabbix_agentd.conf zabbix_agentd.conf.d/ zabbix_server.conf zabbix_server.conf.d/
[root@zabbix zabbix-3.2.6]# ln -s /usr/local/etc/zabbix_
zabbix_agentd.conf zabbix_agentd.conf.d/ zabbix_server.conf zabbix_server.conf.d/
[root@zabbix zabbix-3.2.6]# ln -s /usr/local/etc/zabbix_
zabbix_agentd.conf zabbix_agentd.conf.d/ zabbix_server.conf zabbix_server.conf.d/
[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_agentd /etc/init.d/zabbix_agentd
[root@zabbix zabbix-3.2.6]# chmod 755 /etc/init.d/zabbix_*
[root@zabbix zabbix-3.2.6]# chkconfig –add zabbix_server
[root@zabbix zabbix-3.2.6]# chkconfig –add zabbix_agentd
[root@zabbix zabbix-3.2.6]# chkconfig zabbix_agentd on
[root@zabbix zabbix-3.2.6]# chkconfig zabbix_server on
13、复制zabbix站点的文件到/var/www/html目录下
[root@zabbix zabbix-3.2.6]# cp -r ./frontends/php/ /var/www/html/zabbix
[root@zabbix zabbix-3.2.6]# chown -R apache.apache /var/www/html/zabbix/
[root@zabbix zabbix-3.2.6]# systemctl restart httpd
[root@zabbix zabbix-3.2.6]# systemctl restart mariadb
14、修改/usr/local/etc/zabbix_server.conf:
[root@zabbix zabbix-3.2.6]# sed -i “s/DBUser=root/DBUser=zabbix/g” /usr/local/etc/zabbix_server.conf
[root@zabbix zabbix-3.2.6]# sed -i “s/# DBPassword=/DBPassword=zx123456/g” /usr/local/etc/zabbix_server.conf
[root@zabbix zabbix-3.2.6]# systemctl restart zabbix_server
15、修改/usr/local/etc/zabbix_agentd.conf:
[root@zabbix zabbix-3.2.6]# sed -i “s/Server=127.0.0.1/Server=192.168.103.180/g” /usr/local/etc/zabbix_agentd.conf
[root@zabbix zabbix-3.2.6]# sed -i “s/ServerActive=127.0.0.1/ServerActive=192.168.103.180:10051/g” /usr/local/etc/zabbix_agentd.conf
[root@zabbix zabbix-3.2.6]# sed -i “s/# UnsafeUserParameters=0/UnsafeUserParameters=1/g” /usr/local/etc/zabbix_agentd.conf
三、 登录zabbix网页:IP\zabbix
默认用户名:Admin 密码:zabbix
备注:zabbix语言设置成中文后,有乱码解决如下
1.从windows下控制面板->字体->选择一种中文字库例如“楷体”
2.将字体上传至/var/www/html/zabbix/fonts目录下
3.修改zabbix页面管理的中文字体设置
[root@zabbix-server zabbix-2.4.5]# vim /var/www/html/zabbix/include/defines.inc.php
修改如下两行:
define(‘ZBX_FONT_NAME’, ‘simkai’);
define(‘ZBX_GRAPH_FONT_NAME’, ‘simkai’);