CentOS-7 编译安装zabbix5.0(server端)
1、准备环境
环境:确保已安装LNMP环境(可参考前几条博客文章)
zabbix5.0:https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.2.tar.gz
2、开始安装
添加zabbix用户用于运行zabbix服务
[root@swarm-node1 local]# useradd -s /sbin/nologin zabbix
安装依赖包
yum install unixODBC-devel net-snmp-devel libevent-devel libxml2-devel libcurl-devel -y
解压源码包
[root@swarm-node1 local]# tar -zxf zabbix-5.0.2.tar.gz
编译安装
编译安装参数参考
./configure --prefix=/usr/local/zabbix-server --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc
--prefix=/usr/local/zabbix-server # 编译安装路径
--enable-server # 启动server端
--enable-agent #启动agent端
--with-mysql=/usr/local/mysql/bin/mysql_config #编译连接mysql相关依赖包,并指定mysql_config的路径
--with-net-snmp #启动snmp相关,用于snmp监控设备
--with-libcurl #启动curl相关
--with-libxml2 #启动xml相关
--with-unixodbc #启动odbc相关用于监控数据库
--enable-java #启动java-agent 用于监控java类用于(这里没有监控java类需求,就没有编译进去)
[root@swarm-node1 zabbix-5.0.2]# make && make install
初始化数据库信息
数据库文件在zabbix-5.0.2/database/mysql,分别按顺序导入
schema.sql--images.sql---data.sql
登录数据库创建zabbix-server库
mysql> create database server character set UTF8 collate utf8_bin; Query OK, 1 row affected (0.01 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | server | | sys | +--------------------+ 5 rows in set (0.00 sec)
导入数据
mysql> use server; Database changed mysql> source /usr/local/zabbix-5.0.2/database/mysql/schema.sql;
mysql> source /usr/local/zabbix-5.0.2/database/mysql/images.sql;
mysql> source /usr/local/zabbix-5.0.2/database/mysql/data.sql;
配置zabbix_server.conf配置文件
修改以下信息
DBHost=localhost DBName=server DBUser=root DBPassword=123.com DBSocket=/usr/local/mysql/mysql.sock DBPort=3306
启动zabbix-server
[root@swarm-node1 zabbix-server]# /usr/local/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix-server/etc/zabbix_server.conf
启动报错提示找不到mysql相关lib文件
将mysql lib目录添加到lib环境变量中
[root@swarm-node1 zabbix-server]# echo '/usr/local/mysql/lib/' > /etc/ld.so.conf.d/mysql.conf
[root@swarm-node1 zabbix-server]#ldconfig -v
再次启动zabbix-server
启动成功
配置zabbix-server前端界面
前端界面在zabbix源码包下面的ui文件件中,复制前端文件到nginx的html中
[root@swarm-node1 zabbix-5.0.2]# cd ui/ [root@swarm-node1 ui]# pwd /usr/local/zabbix-5.0.2/ui [root@swarm-node1 ui]# [root@swarm-node1 ui]# [root@swarm-node1 ui]# cp -r * /usr/local/nginx/html/ [root@swarm-node1 ui]#
配置nginx
在nginx server段配置两个location段
上面配置已省略:
location / { root html; index index.php index.htm; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; }
启动ngixn
[root@swarm-node1 nginx]# /usr/local/nginx/sbin/nginx
配置php-fpm
编辑php.ini 文件
[root@swarm-node1 php]# pwd /usr/local/php [root@swarm-node1 php]# [root@swarm-node1 php]# vim etc/php.ini
修改以下参数:
post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone =Asia/Shanghai
mysqli.default_socket = /usr/local/mysql/mysql.sock #此sock文件按mysql实际运行生成的sock文件为准
pdo_mysql.default_socket= /usr/local/mysql/mysql.sock #此sock文件按mysql实际运行生成的sock文件为准
启动php-fpm
[root@swarm-node1 php]# ls bin etc include init.d.php-fpm lib php sbin var [root@swarm-node1 php]# [root@swarm-node1 php]# bash init.d.php-fpm start Starting php-fpm done
打开浏览器,访问zabbix
直接下一步即可
填写数据库相关信息
下载配置文件,放到下面指定目录,这里无法生产配置文件,大部分会是权限的问题