centos6.9 编译安装 zabbix-3.0.15

时间:2023-03-21 22:51:14

本文采用编译安装,请在zabbix官网下载所需版本。此处安装版本是:zabbix-3.0.15.tar.gz
操作系统:centos 6.9

一、安装mysql
mysql-community-libs-5.7.21-1.el6.x86_64.rpm
mysql-community-client-5.7.21-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
mysql-community-common-5.7.21-1.el6.x86_64.rpm
mysql-community-server-5.7.21-1.el6.x86_64.rpm
mysql-community-devel-5.7.21-1.el6.x86_64.rpm
安装步骤此处略。

二、安装php(Zabbix 3.0对PHP的要求最低为5.4,已存在的请将PHP升级到5.4以上,注意,不支持PHP7)
1.获取yum源
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
2.安装下列所有包
yum -y install php56w php56w-gd php56w-mysqlnd php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
....

3.安装完毕后,编辑php的ini文件
---注意date.timezone一定要写对,否则在配置完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

三、安装Apache
1.采用yum在线安装
yum -y install httpd

2.配置httpd.conf
vim /etc/httpd/conf/httpd.conf, 请查找以下内容对应修改:
DocumentRoot "/var/www/html/zabbix"
<Directory "/var/www/html/zabbix">
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.php

四、安装和配置zabbix
1.创建zabbix用户和组:
groupadd zabbix
useradd -g zabbix zabbix

2.安装所需依赖:
yum install gcc* -y
yum install libxml2-devel -y
yum install net-snmp* -y
yum install curl-devel -y
yum -y install unixODBC-devel
rpm -ivh mysql-community-devel-5.7.21-1.el6.x86_64.rpm
yum -y install libssh2-devel
yum -y install openldap openldap-devel
yum -y install OpenIPMI OpenIPMI-devel
yum -y install java*

3.下载zabbix-3.0.15.tar.gz 并解压缩
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX Latest Stable/3.0.15/zabbix-3.0.15.tar.gz
tar -zxvf zabbix-3.0.15.tar.gz
cd zabbix-3.0.15
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --enable-java --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix
make install

五、设置web前端
mkdir /var/www/html/zabbix
cp -r /opt/zabbix-3.0.15/frontends/php/* /var/www/html/zabbix
chown -R apache:apache /var/www/html/zabbix
chmod +x /var/www/html/zabbix/conf/

六、修改配置文件zabbix_server.conf
vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

七、添加Zabbix服务器和Zabbix代理启动脚本
cp /opt/zabbix-3.0.15/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp /opt/zabbix-3.0.15/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

八、创建zabbix数据库并把导入一些sql表
mysql>CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql>GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
mysql>SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+

mysql>use zabbix;
mysql>source /opt/zabbix-3.0.15/database/mysql/schema.sql;
mysql>source /opt/zabbix-3.0.15/database/mysql/images.sql;
mysql>source /opt/zabbix-3.0.15/database/mysql/data.sql;
mysql>show tables;

九、启动服务,并设置开机自启

1.启动Apache\mysql\zabbix_server\zabbix_agentd服务
service httpd start
service mysqld start
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start

如果启动失败,提示比如
[root@localhost mysql]# /etc/init.d/zabbix_server start
Starting zabbix_server: /etc/init.d/functions: line 722: /usr/local/sbin/zabbix_server: No such file or directory [FAILED]
[root@localhost zabbix]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd: /etc/init.d/functions: line 722: /usr/local/sbin/zabbix_agentd: No such file or directory [FAILED]

请修改以下文件:
/etc/rc.d/init.d/zabbix_server
/etc/rc.d/init.d/zabbix_agentd
查看BASEDIR= 修改成正确路径

2.设置开机自启
chkconfig httpd on
chkconfig mysqld on
chkconfig --add /etc/init.d/zabbix_server
chkconfig --add /etc/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on

十、浏览器访问zabbix页面并进行初始化
在浏览器中打开http://192.168.153.166/zabbix

centos6.9 编译安装 zabbix-3.0.15

centos6.9 编译安装 zabbix-3.0.15

centos6.9 编译安装 zabbix-3.0.15

centos6.9 编译安装 zabbix-3.0.15

centos6.9 编译安装 zabbix-3.0.15

centos6.9 编译安装 zabbix-3.0.15

centos6.9 编译安装 zabbix-3.0.15