cd /usr/local
在该网站下载需要的zabbix 版本http://www.zabbix.com/download
上传到/usr/local 目录下
yum install net-snmp-devel -y
tar zxvf zabbix-4.0.7.tar.gz
cd zabbix-4.0.7
./configure --prefix=/usr/local/zabbix_server/ --enable-server --enable-agent --enable-ipv6 --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2
make && make install
添加zabbix 运行用户组
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
注:zabbix-server 共需要导入3个源码包中的sql文件,而搭建proxy 则只需要导入一个sql
#创建zabbix 数据库
mysql -uroot -pxxxx
mysql> create database zabbix default charset utf8;
Query OK, 1 row affected (0.00 sec)
mysql> quit
#mysql -uroot -pxxxx zabbix < /usr/local/zabbix_server/database/mysql/schema.sql
#mysql -uroot -pxxx zabbix < /usr/local/zabbix_server/database/mysql/images.sql
#mysql -uroot -pxxx zabbix < /usr/local/zabbix_server/database/mysql/data.sql
</pre>
#配置zabbix 服务器
vi /usr/local/zabbix_server/etc/zabbix_server.conf
------------------------------------------------------------------------
DBSocket=/tmp/mysql.sock
DBHost=localhost
DBName=zabbix
DBUser=root
DBPassword=XXXXX
DBPort=3306
------------------------------------------------------------------------
echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
ldconfig
/usr/local/zabbix_server/sbin/zabbix_server
/usr/local/zabbix_server/sbin/zabbix_agentd
#自启动
cd /root/zabbix_server/misc/init.d/fedora/core
cp * /etc/init.d/
chmod +x /etc/init.d/zabbix_server
chmod +x /etc/init.d/zabbix_agentd
vi /etc/init.d/zabbix_server
#将BASEDIR=/usr/local/替换为BASEDIR=/usr/local/zabbix_server/(以之前编译的位置为准)
#修改客户器端启动文件:
#vi /etc/init.d/zabbix_agentd
#将BASEDIR=/usr/local/替换为BASEDIR=/usr/local/zabbix_server/(以之前编译的位置为准)
chkconfig --add zabbix_server
chkconfig --add zabbix_agentd
chkconfig --level 35 zabbix_server on
chkconfig --level 35 zabbix_agentd on
#配置zabbix web
mkdir -p /home/data/zabbix/zabbix
cp -rp /root/zabbix-4.0.7/frontends/php/* /home/data/zabbix/zabbix
vim /etc/nginx/conf.d/zabbix.conf
------------------------------------------------------------------------
server {
listen 80;
server_name zabbix.prd.xjh.com;
access_log /var/log/nginx/zabbix.prd.xjh.com.access.log main;
index index.php index.html index.html;
root /home/data/zabbix;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php)?$ {
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
------------------------------------------------------------------------
cp /home/data/zabbix/zabbix/conf/zabbix.conf.php.example /home/data/zabbix/zabbix/conf/zabbix.conf.php
vim /home/data/zabbix/zabbix/conf/zabbix.conf.php
------------------------------------------------------------------------
< ?php
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'root';
$DB['PASSWORD'] = 'xxxxx';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'zabbix-server';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
------------------------------------------------------------------------
#绑定hosts之后,打开浏览器访问