Zabbix 3.2 编译安装

运行环境

  • 阿里云ECS
  • Centos7.3
  • Zabbix3.2
  • LNMP

解决环境依赖

1
2
3
4
5
6
7
8
9
10
11
yum groupinstall "Development Tools"
yum install nginx php* mariadb* -y
yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin -M
systemctl restart mariadb
systemctl restart php-fpm
systemctl restart nginx
systemctl enable mariadb
systemctl enable nginx
systemctl enable php-fpm

修改php的参数

1
vim /etc/php.ini
1
2
3
4
5
6
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Kolkata

下载解压

1
2
wget -O "zabbix-3.2.6.tar.gz"  "https://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.6/zabbix-3.2.6.tar.gz"
tar zxvf zabbix-3.2.6.tar.gz

编译安装

1
2
3
cd zabbix-3.2.6
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make -j8 && make install

数据库创建

1
2
3
4
5
6
7
8
9
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
shell> cd database/mysql
shell> mysql -uzabbix -p<password> zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -uzabbix -p<password> zabbix < images.sql
shell> mysql -uzabbix -p<password> zabbix < data.sql

服务配置

1
2
3
4
5
6
7
8
9
10
#设置zabbix_server运行级别
sed -i "/^# Zabbix/a# chkconfig: 2345 65 35\n# description: zabbix server" /etc/init.d/zabbix_server
#修改zabbix_server执行程序路径
sed -i '/^DAEMON=/c DAEMON=/usr/local/zabbix/sbin/zabbix_server' /etc/init.d/zabbix_server
#设置zabbix_agentd运行级别
sed -i "/^# Zabbix/i# chkconfig: 2345 66 34\n# description: zabbix agent" /etc/init.d/zabbix_agentd
#修改zabbix_agentd执行程序路径
sed -i '/^DAEMON=/c DAEMON=/usr/local/zabbix/sbin/zabbix_agentd' /etc/init.d/zabbix_agentd
chkconfig --add zabbix_server
chkconfig --add zabbix_agentd

Server配置文件修改

1
2
3
4
5
6
7
8
9
#zabbix_server.conf
vim /usr/local/etc/zabbix_server.conf #这里很诧异我明明编译的时候是--prefix=/usr/local/zabbix,/usr/local/zabbix/etc下面也有配置文件 但是这边默认的配置文件却是这个,害我折腾了一段时间。如果不知道自己默认的配置文件可以执行/usr/local/zabbix/sbin/zabbix_server -h 查看
#以下只列出了我添加或修改的部分
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=4
LogSlowQueries=3000

启动服务

1
2
3
4
5
6
7
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
netstat -ntlp | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 18221/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 17275/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 18221/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 17275/zabbix_server

前端配置

代码拷贝

1
2
3
cp -rf frontends/php/*  /usr/local/nginx/html/
#修改为php运行用户的权限,我这里是www
chown www.www /usr/local/nginx/html/ -R

ngnix配置略

初始化配置

用浏览器访问本地80端口

这里会检查你的环境配置,如果有报错可以按照报错修改即可

填写你的数据库连接信息

填写zabbix server 详细信息

确认预安装信息

安装,这里如果报没有权限写入配置文件那么可以下载下来上传到对应目录即可

默认用户名Admin,密码zabbix

设置默认语言为中文

常见错误

在配置数据库连接信息时报错Unable to select configuration

有可能是你的初始化SQL未执行

参考

https://www.zabbix.com/documentation/3.2/manual/installation/install
http://www.jianshu.com/p/20e4c2a7dfbd
https://www.unixmen.com/how-to-install-zabbix-server-on-centos-7/

坚持原创技术分享,您的支持将鼓励我继续创作!