CentOS-6.9 安装zabbix 3.4
Posted tang-yuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS-6.9 安装zabbix 3.4相关的知识,希望对你有一定的参考价值。
1、关闭selinux
[[email protected] /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config #重启生效 [[email protected] /]# 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
[[email protected] /]# vim /etc/my.cnf innodb_file_per_table=1 [[email protected] /]# /etc/init.d/mysqld start
4、登陆数据库
[[email protected] /]# 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 [email protected] 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因此我们需要安装一个新的。
[[email protected] /]# 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配置
[[email protected] /]# 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用户
[[email protected] /]# groupadd zabbix [[email protected] /]# 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/3.4.7/zabbix-3.4.7.tar.gz
tar -zxvf zabbix-3.4.7.tar.gz
cd zabbix-3.4.7/database/mysql/
[[email protected]_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
[[email protected] mysql]# cd /zabbix-3.0.4 编译 [[email protected] zabbix-3.0.4]# ./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 安装 [[email protected] zabbix-3.0.4]# make install [[email protected] zabbix-3.0.4]# echo $? 0
12 、修改zabbix_server的配置
[[email protected] etc]# vim /usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=zabbix
13、创建一个新的web前端文件
[[email protected] conf]# mkdir /var/www/html/zabbix 移动源到刚才创建目录下 [[email protected] conf]#cd /zabbix-3.0.4/frontends/php/ [[email protected] php]# cp -rf * /var/www/html/zabbix/
设置Apache作为Web用户接口文件的所有者
[[email protected] php]# chown -R apache:apache /var/www/html/zabbix
添加权限给Zabbix Web界面执行文件
[[email protected] php]# chmod +x /var/www/html/zabbix/conf/
添加Zabbix服务器和Zabbix代理启动脚本
[[email protected] php]# cp /zabbix-3.4.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server [[email protected] php]# cp /zabbix-3.4.7/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
添加Zabbix服务器和Zabbix代理服务
[[email protected] php]# chkconfig --add /etc/init.d/zabbix_server [[email protected] php]# chkconfig --add /etc/init.d/zabbix_agentd [[email protected] php]# chkconfig httpd on [[email protected] php]# chkconfig mysqld on [[email protected] php]# chkconfig zabbix_server on [[email protected] php]# chkconfig zabbix_agentd on
启动zabbix_server
[[email protected] 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] [[email protected] php]# vim /etc/init.d/zabbix_server BASEDIR=/usr/local/zabbix #更改下路径 [[email protected] php]# /etc/init.d/zabbix_server start Starting zabbix_server: [ OK ] [[email protected] php]# vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix #更改下路径 [[email protected] 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)
先查找下系统里面有没有这个文件:
[[email protected]_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/
1、进入安装界面:
2、检查配置是否ok
3、连接数据库(用户和密码就是你数据库创建的用户名和密码)
4、Enter Zabbix server details.
5、确认设置信息
6、安装完成生成配置文件:/var/www/html/zabbix/zabbix.conf.php
7、登陆zabbix
以上是关于CentOS-6.9 安装zabbix 3.4的主要内容,如果未能解决你的问题,请参考以下文章