zabbix安装

一.软件版本

ip:
os version: CentOS release 6.5 (Final)
zabbix version: 3.4.6
mysql version: 5.7.11
boost version:boost_1_59
nginx version:1.11.7
php version:5.6.33

二.前期环境准备(LNMP)

1.修改两台机器的主机名,并关闭防火墙及selinux

请按照自己的实际环境修改

2.安装mysql

请参照本人的《Mysql主从复制安装配置》安装单机即可

3.安装ngnix

请参照本人的《nginx安装及配置》安装即可

4.安装php

1)用rz上传php-5.6.33.tar.gz到服务器的/usr/local/src

2)安装依赖包

 yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y

3)解压

tar xvf php-5.6.33.tar.gz

4)编译安装

cd php-5.6.33

 ./configure --prefix=/mnt/php \
 --with-config-file-path=/mnt/php/etc \
 --with-bz2 \
 --with-curl \
 --enable-ftp \
 --enable-sockets \
 --disable-ipv6 \
 --with-gd \
 --with-jpeg-dir=/mnt/phpinstall \
 --with-png-dir=/mnt/phpinstall \
 --with-freetype-dir=/mnt/phpinstall \
 --enable-gd-native-ttf \
 --with-iconv-dir=/mnt/phpinstall \
 --enable-mbstring \
 --enable-calendar \
 --with-gettext \
 --with-libxml-dir=/mnt/phpinstall \
 --with-zlib \
 --with-pdo-mysql=mysqlnd \
 --with-mysqli=mysqlnd \
 --with-mysql=mysqlnd \
 --enable-dom \
 --enable-xml \
 --enable-fpm \
 --with-libdir=lib64 \
 --enable-bcmath

make && make install

5)生成php配置文件

cp php.ini-production /mnt/php/etc/php.ini
cp /mnt/php/etc/php-fpm.conf.default /mnt/php/etc/php-fpm.conf

6)创建php启动脚本

vi /mnt/php/etc/php-fpm.conf
将pid注释取消
pid=run/php-fpm.pid
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
vi /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

7)启动php并验证

(1)启动

/mnt/php/sbin/php-fpm
/etc/init.d/php-fpm start
service php-fpm start

(2)验证

netstat -anlpt|grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 16849/php-fpm

8)停止

/etc/init.d/php-fpm stop
service php-fpm stop

9)设置php开机自启动

chkconfig --add /etc/init.d/php-fpm
chkconfig php-fpm on

5.配置php与nginx

1)配置php

vi /mnt/php/etc/php.ini

更改
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
[Date]
date.timezone = Asia/Shanghai
[filter]
always_populate_raw_post_data = -1

2)用于存放nginx日志

mkdir -p /data/logs/nginx/

三.zabbix server安装

1.利用rz将zabbix-3.4.7.tar.gz上传到/usr/local/src

2.解压并安装依赖

1)解压

[root@www src]# tar xvf zabbix-3.4.7.tar.gz

2)安装依赖

yum install unixODBC-devel net-snmp net-snmp-devel libssh2-devel OpenIPMI-devel libevent-devel java*

3.编译安装

1)编译安装

cd zabbix-3.4.7

./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=/mnt/zabbix

make&&make install

4.创建用户

groupadd zabbix
useradd -g zabbix zabbix

5.修改配置文件

vi /mnt/zabbix/etc/zabbix_server.conf

DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/mnt/mysql/mysql.sock

6.添加启动脚本

cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
vi /etc/init.d/zabbix_server

BASEDIR=/mnt/zabbix

vi /etc/init.d/zabbix_agentd

BASEDIR=/mnt/zabbix

7.初始化数据库

mysql -uroot -p

mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@zabbixip IDENTIFIED BY 'zabbix';
mysql> use zabbix
mysql>source zabbix-3.4.3/database/mysql/schema.sql;
mysql>source zabbix-3.4.3/database/mysql/images.sql;
mysql>source zabbix-3.4.3/database/mysql/data.sql;

注意这三个文件权限(mysql:mysql),否则执行报错

mysql> show tables;(返回140 rows)

8.启动服务并设置开机自启

/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
chkconfig --add /etc/init.d/zabbix_server
chkconfig --add /etc/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on

9.zabbix前端配置

1)为zabbix创建nginx根目录

mkdir -p /data/site/monitor.zabbix.com/zabbix
cp -rp frontends/php/* /data/site/monitor.zabbix.com/zabbix

2) 在nginx配置文件中建立zabbix虚拟机的配置文件

vi /mnt/nginx/conf/nginx.conf

server {
 listen 80;
 server_name monitor.zabbix.com;
 access_log /data/logs/nginx/monitor.zabbix.com.access.log;
 location /
 {
 index index.html index.php index.html;
 root /data/site/monitor.zabbix.com/zabbix;
 }
 location ~ \.php$ {
 root /data/site/monitor.zabbix.com/zabbix;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_param SCRIPT_FILENAME /data/site/monitor.zabbix.com/zabbix$fastcgi_script_name;
 fastcgi_index index.php;
 include fastcgi.conf;
 }
}

/mnt/nginx/sbin/nginx -s reload

四.安装ntp服务器

请自行安装

五.浏览器访问zabbix页面并进行初始化

1.登录网页

http://monitor.zabbix.com/setup.php下一步

zabbix安装_第1张图片
1.png

2.验证php

1)报错为php配置文件缺少相关配置项

zabbix安装_第2张图片
2.png

vi /mnt/php/etc/php.ini
更改:

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
[Date]
date.timezone = Asia/Shanghai
[filter]
always_populate_raw_post_data = -1

2)warning为缺少ldap模块

zabbix安装_第3张图片
3.png

3)编译ldap模块

(1)进入模块所在目录

cd /usr/local/src/php-5.6.33/ext/ldap

(2)编译PHP扩展的工具,主要是根据系统信息生成对应的configure文件

/mnt/php/bin/phpize
安装依赖
yum install openldap openldap-devel -y
cp -frp /usr/lib64/libldap* /usr/lib

(3)编译

./configure --with-php-config=/mnt/php/bin/php-config --with-ldap

make && make install

(5)验证:生成ldap.so

4.png

(6)添加模块到配置文件

vi /mnt/php/etc/php.ini

 862 ; If you wish to have an extension loaded automatically, use the follow ing
 863 ; syntax:
 864 extension=/mnt/php/lib/php/extensions/no-debug-non-zts-20131226/ldap.so
 865 ; extension=modulename.extension
 866 ;
 867 ; For example, on Windows

(7)重启php和nginx

4)连接mysql

zabbix安装_第4张图片
5.png

5)zabbix服务端详细信息

zabbix安装_第5张图片
6.png

6)zabbix安装前信息列表

zabbix安装_第6张图片
7.png

7)安装

zabbix安装_第7张图片
8.png

解决办法:下载文件zabbix.conf.php,上传到服务器上
cp zabbix.conf.php /data/site/monitor.zabbix.com/zabbix/conf


zabbix安装_第8张图片
9.png

8)登录

默认用户名:Admin密码:zabbix


zabbix安装_第9张图片
10.png

zabbix监控报错zabbix server is not running: the information displayed may not be current
解决
vi ****/conf/zabbix.conf.php

$ZBX_SERVER   = 'ip';
$DB['SERVER']    = 'ip';

你可能感兴趣的:(zabbix安装)