通常小公司大多將zabbix web端和zabbix server部署在同一臺主機上,其實兩者是能夠分開的,web GUI配置鏈接到對應的數據庫就行,讓zabbix server和MySQL數據庫在同一臺主機上便於數據快速處理。php
這裏在centos 7.2 x86_64上依賴LNMP源碼編譯安裝zabbix3.2.7html
1安裝php7.1前端
yum install -y epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmmysql
yum install -y php71w php71w-bcmath php71w-common php71w-cli php71w-mysql php71w-pdo php71w-gd php71w-fpm php71w-intl php71w-mbstring php71w-mcrypt php71w-xml php71w-xmlrpc php71w-opcache php71w-ldap php71w-pearnginx
sed -i 's/post_max_size = 8M/post_max_size = 16M/g' /etc/php.ini
sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.iniweb
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpmsql
2,安裝nginx1.12.1數據庫
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginxcentos
3,安裝mysql5.7.19php7
rpm -Uvh http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
yum install -y mysql-community-server mysql-community-devel
mysql的基礎配置(根據系統硬件配置)my.cnf
[client]
port = 3306
default-character-set=utf8
[mysqld]
port = 3306
skip-name-resolve
character-set-server=utf8
skip-external-locking
max_connections=1000
max_connect_errors=10
default-storage-engine=INNODB
innodb_buffer_pool_size = 512M
innodb_log_file_size = 128M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
innodb_flush_method=O_DIRECT
default-time-zone = '+8:00'
event_scheduler=ON
open_files_limit=51200
systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
grep 'temporary password' /var/log/mysqld.log 得到臨時密碼
mysql -u root -p輸入密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Uiop@789'; 修改成本身的root密碼
4,nginx和php的融合
mkdir -p /var/www/html/zabbix
chown -R nginx:nginx /var/www/html
vi /etc/nginx/conf.d/default.conf
#location / {
root /var/www/html;
index index.php index.html index.htm;
#}
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcig_read_timeout 120;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
systemctl enable nginx
systemctl start nginx
echo '<?php phpinfo(); ?>' > /var/www/html/index.php
http://IP檢驗lnmp是否安裝成功
5,安裝zabbix server
zabbix只會以普通用戶運行,若是root環境下運行,zabbix會主動嘗試以zabbix身份運行,若系統沒有zabbix用戶需創建
groupadd zabbix
useradd -g zabbix zabbix
yum install -y net-snmp-devel curl curl-devel libxml2-devel
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz
tar zxvf zabbix-3.2.7.tar.gz
cd zabbix-3.2.7
./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make install
導入數據結構:
mysql -u root -p
mysql>create database zabbix character set utf8 collate utf8_bin;
mysql>use zabbix;
mysql>source /root/zabbix-3.2.7/database/mysql/schema.sql
mysql>source /root/zabbix-3.2.7/database/mysql/images.sql
mysql>source /root/zabbix-3.2.7/database/mysql/data.sql
mysql>grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'Uiop!789';
mysql>flush privileges;
mysql>exit
修改zabbix server配置文件
vi /usr/local/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=Uiop!789
DBSocket=/var/lib/mysql/mysql.sock
啓動zabbix_server
cp /root/zabbix-3.2.7/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
chkconfig --add zabbix_server
chkconfig --list zabbix_server
chkconfig --level 35 zabbix_server on
service zabbix_server start/stop/restart
配置客戶端(監控sever自己)
vi /usr/local/etc/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
啓動zabbix agent
cp /root/zabbix-3.2.7/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
chkconfig --add zabbix_agentd
chkconfig --list zabbix_agentd
chkconfig --level 35 zabbix_agentd on
service zbbbix_agentd start/stop/restart
啓動客戶端(客戶端和服務端時間同步,設置crontab:0 0 * * * /usr/sbin/ntpdate -U 210.72.145.44)
客戶端獨立安裝zabbix_agentd(通常都是rpm包安裝)
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.6/zabbix-3.2.6.tar.gz
tar zxvf zabbix-3.2.6.tar.gz
cd zabbix-3.2.6
./configure --enable-agent
make && make install
簡單安裝
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.7-1.el7.x86_64.rpm
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-sender-3.2.7-1.el7.x86_64.rpm
這樣主機端安裝部署就成功了,隨後是zabbix web端的事情了。
在zabbix server主機拷貝前端文件
cd /root/zabbix-3.2.7
cp -rp frontends/php/* /var/www/html/zabbix/
chown nginx.nginx -R /var/www/html/zabbix/
根據以上設置直接http://IP/zabbix,便可看到前端配置提示,若自定義vhost後須重啓nginx