[root@zabbix_server zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix-3.0.3 --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-lib
zabbix server 一般充当两个角色:server,agent,所以上面的配置参数也同时加上了--enable-agent. 备注:请安装好MySQL,snmp,curl开发库。
报错:
configure: error: MySQL library not found
[root@zabbix_server zabbix-3.0.3]# yum install mysql-devel
问题解决!
[root@zabbix_server zabbix-3.0.3]# make && make install
创建用户:
安全考虑zabbix只使用普通用户运行,假如你当前用户叫bass,那么你运行他,他便使用bass身份。但是如果你在root环境下运行zabbix,那么zabbix将会主动使用zabbix用户运行。但是如果你的系统没有zabbix用户,这需要新建一个:
[root@zabbix_server ~]# groupadd zabbix[root@zabbix_server ~]# useradd -g zabbix zabbix
初始化数据库:
zabbix server 与proxy需要数据库,angent不需要。尤其要注意的是proxy只需要导入一个sql文件,而server为3个sql文件。
mysql> create database zabbix default charset utf8;Query OK, 1 row affected (0.00 sec)
# mysql -uroot -pttlsapwd zabbix < database/mysql/schema.sql# mysql -uroot -pttlsapwd zabbix < database/mysql/images.sql# mysql -uroot -ppttlsapwd zabbix < database/mysql/data.sql
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test || zabbix |+--------------------+5 rows in set (0.00 sec)
配置zabbix:
[root@zabbix_server etc]# lszabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d
[root@zabbix_server etc]# mkdir /etc/zabbix[root@zabbix_server etc]# cp zabbix_server.conf /etc/zabbix/[root@zabbix_server etc]# vi /etc/zabbix/zabbix_server.conf
# vim /etc/zabbix/zabbix_server.confDBName=zabbixDBUser=zabbixDBPassword=123456DBPort=3306
[root@zabbix_server ~]# ln -s /usr/local/zabbix-3.0.3/sbin/* /usr/local/sbin/[root@zabbix_server ~]# ln -s /usr/local/zabbix-3.0.3/bin/* /usr/local/bin/
[root@zabbix_server ~]# find / -name mysql_config/usr/bin/mysql_config/usr/local/src/mysql-5.5.20/scripts/mysql_config/usr/local/mysql/bin/mysql_config/usr/lib64/mysql/mysql_config
如果没有mysql_config,需要安装 mysql-devel
添加zabbix服务对应的端口:
[root@zabbix_server ~]# vi /etc/services #追加下面代码
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper
修改zabbix配置文件:
[root@zabbix_server ~]# cd /usr/local/zabbix-3.0.3/etc[root@zabbix_server etc]# lszabbix_agentd.conf zabbix_server.confzabbix_agentd.conf.d zabbix_server.conf.d[root@zabbix_server etc]# pwd/usr/local/zabbix-3.0.3/etc[root@zabbix_server etc]# vi zabbix_server.conf
vi /usr/local/zabbix/etc/zabbix_server.confDBName=zabbix #数据库名称DBUser=zabbix #数据库用户名DBPassword=123456 #数据库密码
### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
# If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
DBHost=192.168.1.117#DB数据库的IP
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts #zabbix运行脚本存放目录
[root@zabbix_server etc]# vi /usr/local/zabbix-3.0.3/etc/zabbix_agentd.conf
加上:
Include=/usr/local/zabbix/etc/zabbixagentd.conf.d/
# UnsafeUserParameters=0
UnsafeUserParameters=1
[root@zabbix_server etc]# cp /usr/local/src/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server[root@zabbix_server etc]# cp /usr/local/src/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd[root@zabbix_server etc]# chmod +x /etc/rc.d/init.d/zabbix_server [root@zabbix_server etc]# chmod +x /etc/rc.d/init.d/zabbix_agent [root@zabbix_server etc]# chkconfig zabbix_server on[root@zabbix_server etc]# chkconfig zabbix_agent on
修改zabbix开机启动脚本中的zabbix安装目录:
[root@zabbix_server etc]# vi /etc/rc.d/init.d/zabbix_server # Zabbix-DirectoryBASEDIR=/usr/local/zabbix-3.0.3/ #zabbix安装目录
[root@zabbix_server etc]# vi /etc/rc.d/init.d/zabbix_agentd
# Zabbix-Directory BASEDIR=/usr/local/zabbix-3.0.3/ #编辑客户端配置文件
[root@zabbix_server nginx]# cp -r /usr/local/src/zabbix
/frontends/php /usr/html/
[root@zabbix_server nginx]# cd /usr/html/[root@zabbix_server html]# ls50x.html index.html index.php php[root@zabbix_server html]# mkdir zabbix[root@zabbix_server html]# ls50x.html index.html index.php php zabbix[root@zabbix_server html]# mv php/ zabbix/[root@zabbix_server html]# ls50x.html index.html index.php zabbix[root@zabbix_server html]# chown www.www -R /usr/html/zabbix
[root@zabbix_server etc]# service zabbix_agentd startStarting zabbix_agentd: [ OK ][root@zabbix_server etc]# service zabbix_server startStarting zabbix_server: [ OK ][root@zabbix_server etc]#
先看看php用的是php.ini文件的位置通过<?php phpinfo();
Configuration File (php.ini) Path /usr/local/php/etc
可见是在/usr/local/php/etc/php.ini如果每没有cp /etc/php.ini /usr/local/php/etc/
[root@zabbix_server etc]# vi /etc/php.ini
post_max_size = 16Mmax_execution_time = 300max_input_time = 300
[root@zabbix_server etc]# vi /usr/local/php/etc/php-fpm.conf
request_terminate_timeout = 300
[root@zabbix_server php]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@zabbix_server php]# whereis phpphp: /etc/php.d /etc/php.ini /usr/lib64/php /usr/loca
[root@zabbix_server php]# pwd/usr/html/zabbix/php
http://192.168.1.122/zabbix/php/setup.php
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test || zabbix |+--------------------+5 rows in set (0.07 sec)mysql> grant all privileges on zabbix.* to zabbix@"%" identified by"123456";Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
[root@ok tmp]# scp zabbix.conf.php root@192.168.1.122:/usr/html/zabbix/php/conf/zabbix.conf.phproot@192.168.1.122's password: zabbix.conf.php 100% 423 0.4KB/s 00:00
注意zabbix.conf.php的权限!!(我给的是777)
zabbix默认登录帐户:admin
zabbix默认登录密码:zabbix
注意:selinux一定要关不然会报错!!!
[root@zabbix_server php]# setenforce 0
[root@zabbix_server ~]# netstat -lnutp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2192/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2854/zabbix_server
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1486/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2665/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1924/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1510/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1853/master
tcp 0 0 :::22 :::* LISTEN 1510/sshd
tcp 0 0 ::1:25 :::* LISTEN 1853/master
udp 0 0 0.0.0.0:68 0.0.0.0:* 1244/dhclient
udp 0 0 0.0.0.0:636 0.0.0.0:* 1323/portreserve
注意:看zabbix的日志
[root@zabbix_server ~]# tail -f /tmp/zabbix_server.log
原标题:zabbix (一:zabbix服务端)
关键词: