111111

CentOS-6.8 安装zabbix 4.0X

CentOS-6.8 安装zabbix 4.0X

 

1、关闭selinux

[root@localhost /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config  #重启生效
[root@localhost /]# setenforce 0   #临时关闭

2、 zabbix需要mysql5.6以上版本,删除旧的版本

下载MySQL5.6版本
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum -y install mysql-server
yum list installed | grep mysql

3、修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1

[root@localhost /]# vim /etc/my.cnf
innodb_file_per_table=1
[root@localhost /]# /etc/init.d/mysqld start

4、登陆数据库

 
[root@localhost /]# mysql
#创建zabbix库,指定字符集
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.06 sec)
#创建zabbix用户密码:zabbix  授权拥有访问zabbix库的所有权限
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix'; 
Query OK, 0 rows affected (0.02 sec)

#查看数据库是否创建成功
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+
4 rows in set (0.03 sec)
 

5、Zabbix 3需要PHP是至少5.4或更高版本。我们的CentOS 6.5库跟php 5.3.3因此我们需要安装一个新的。

[root@localhost /]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm

 安装所需要的包

yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap

 6、修改php配置

[root@localhost /]# 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

7、 修改apache配置

vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.php

启动httpd服务
/etc/init.d/httpd start

8、 创建zabbix用户

[root@localhost /]# groupadd zabbix
[root@localhost /]# useradd -g zabbix zabbix

9、依赖包安装

yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel

10、下载zabbix安装包、解压、导入sql

 
 
官方源码包下载地址:
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz
tar -zxvf zabbix-4.0.1.tar.gz
cd zabbix-4.0.1/database/mysql/

 [root@slave_217 mysql]# ls 
  data.sql images.sql schema.sql

 
mysql -uzabbix -p zabbix < schema.sql 
mysql -uzabbix -p zabbix < images.sql 
mysql -uzabbix -p zabbix < data.sql 

11、安装zabbix

 
 
[root@localhost mysql]# cd /zabbix-4.0.1
编译
[root@localhost zabbix-4.0.1]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix
安装
[root@localhost zabbix-4.0.1]# make install
[root@localhost zabbix-4.0.1]# echo $?
0
 

12 、修改zabbix_server的配置

[root@localhost etc]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

13、创建一个新的web前端文件

[root@localhost conf]# mkdir /var/www/html/zabbix
移动源到刚才创建目录下
[root@localhost conf]#cd /zabbix-4.0.1/frontends/php/
[root@localhost php]# cp -rf  *  /var/www/html/zabbix/

 设置Apache作为Web用户接口文件的所有者

[root@localhost php]# chown -R apache:apache /var/www/html/zabbix

添加权限给Zabbix Web界面执行文件

[root@localhost php]# chmod +x /var/www/html/zabbix/conf/

 添加Zabbix服务器和Zabbix代理启动脚本

[root@localhost php]# cp /zabbix-4.0.1/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[root@localhost php]# cp /zabbix-4.0.1/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

添加Zabbix服务器和Zabbix代理服务

[root@localhost php]# chkconfig --add /etc/init.d/zabbix_server
[root@localhost php]# chkconfig --add /etc/init.d/zabbix_agentd
[root@localhost php]# chkconfig httpd on
[root@localhost php]# chkconfig mysqld on
[root@localhost php]# chkconfig zabbix_server on
[root@localhost php]# chkconfig zabbix_agentd on

 启动zabbix_server

 
 
[root@localhost php]# /etc/init.d/zabbix_server start    #报错
Starting zabbix_server:  /etc/init.d/functions: line 546: /usr/local/sbin/zabbix_server: No such file or directory
                                                           [FAILED]
 
[root@localhost php]# vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix     #更改下路径

 
[root@localhost php]# /etc/init.d/zabbix_server start
Starting zabbix_server:                                    [  OK  ]
 
[root@localhost php]# vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix    #更改下路径

 
[root@localhost php]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]
 
 

报错提示:

 
 
启动服务时提示:error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory ”

从错误看出是缺少lib文件导致,进一步查看下

ldd $(which /usr/local/zabbix/sbin/zabbix_server)

         linux-vdso.so.1 =>  (0x00007fff2cbff000)

         libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6a5758a000)

         libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f6a57353000)

         libpcre.so.1 => not found  #看到这里没有找到这个文件

         libz.so.1 => /lib64/libz.so.1 (0x00007f6a56f1f000)

         libc.so.6 => /lib64/libc.so.6 (0x00007f6a56b8b000)

         /lib64/ld-linux-x86-64.so.2 (0x00007f6a577af000)

         libfreebl3.so => /lib64/libfreebl3.so (0x00007f6a56928000)

         libdl.so.2 => /lib64/libdl.so.2 (0x00007f6a56724000)   

先查找下系统里面有没有这个文件:

[root@slave_217 ~]# find / -name 'libpcre.so.1' /usr/lib64/libpcre.so.1 /usr/local/zabbix/lib/libpcre.so.1 /usr/local/lib/libpcre.so.1 /usr/lib/libpcre.so.1 /lib64/libpcre.so.1 /root/django/pcre-8.35/.libs/libpcre.so.1

上面看到系统有这个文件,然后把这个文件建立一个软连接,然后就可以正常启动服务
cd /lib64/
ln -s /usr/local/lib/libpcre.so.1 /lib64/ 

 
 

 

14、zabbix  web安装界面
 输入ip地址:127.0.1.1/zabbix
1、进入安装界面:

 

2、检查配置是否ok

3、连接数据库(用户和密码就是你数据库创建的用户名和密码)

4、Enter Zabbix server details.

5、确认设置信息

6、安装完成生成配置文件:/var/www/html/zabbix/zabbix.conf.php

7、登陆zabbix

 

 
登陆用户名:Admin
登陆密码:zabbix
 
centos 7的系统安装部署请参考zabbix官方文档
https://www.zabbix.com/download
 
安装完毕!
 

 

 

posted @ 2019-11-11 10:22  赵SIR  阅读(620)  评论(0编辑  收藏  举报