1. 首先要准备LNMP环境
2. 在mysql中创建zabbix所需要的库和用户
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> flush privileges;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
3. 安装zabbix
groupadd zabbix
useradd -g zabbix -m -s /sbin/nologin
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
tar zxvf zabbix-3.0.3.tar.gz
cd zabbix-3.0.3
./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2
make &&make install
如果发生错误:缺失net-snmp, libxml2
解决办法:
# yum install net-snmp-devel
# yum -y install libxml2-devel
如果mysql报错:指定配置路径 --with-mysql=/usr/local/mysql/bin/mysql_config
即执行此命令: ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql=/usr/local/mysql/bin/mysql_config --with-libxml2
4. 导入zabbix库
cd /root/zabbix-3.0.3/database/mysql
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
5. 配置zabbix_server
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost 数据库ip地址
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
ListenIP=192.168.1.10 zabbix server ip地址
StartIPMIPollers=10
StartPollersUnreachable=10
StartTrappers=10
StartPingers=10
StartDiscoverers=10
CacheSize=256M
StartDBSyncers=40
HistoryCacheSize=128M
TrendCacheSize=128M
HistoryTextCacheSize=128M
ValueCacheSize=128M
Timeout=30
AlertScriptsPath=/etc/zabbix/alertscripts //修改
ExternalScripts=/etc/zabbix/externalscripts //修改
LogSlowQueries=10000
StartProxyPollers=50
创建zabbix所需要的脚本目录
mkdir /etc/zabbix/alertscripts
mkdir /etc/zabbix/externalscripts
ln -s /usr/local/zabbix/sbin/* /usr/sbin/
cp /home/sources/zabbix-3.0.3/misc/init.d/Fedora/core/zabbix_* /etc/init.d/ #复制服务启动脚本
chmod +x /etc/init.d/zabbix_*
sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
6. 配置web
vim /etc/nginx/conf.d/zabbix.conf
cp -r /home/sources/zabbix-3.0.3/frontends/php/* /data/www/zabbix/
chown -R www.www /data/www/zabbix/
chkconfig zabbix_server on
chkconfig nginx on
chkconfig mysqld on
/etc/init.d/zabbix_server start
service nginx restart
chkconfig httpd on
发生以上错误解决办法: ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
7. 在web页面配置zabbixserver
用浏览器访问 http://ip/setup.php
访问首页后无法进行“”下一步“”操作的,要更改session权限组
配置zabbix的时候修改了PHP代码的用户和所属组,但是为修改PHP的session保存路径的用户和所属组没有修改。
解决方法:查找php-fpm 中session存放路径,执行下面命令
chown -R www.www /var/lib/php/session/