2019独角兽企业重金招聘Python工程师标准>>>
一般小公司大多将zabbix web端和zabbix server部署在同一台主机上,其实二者是可以分开的,web GUI配置连接到对应的数据库就行,让zabbix server和MySQL数据库在同一台主机上便于数据快速处理。
这里在centos 7.2 x86_64上依赖LNMP源码编译安装zabbix3.2.7
1安装php7.1
yum install -y epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
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-pear
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.ini
systemctl enable php-fpm
systemctl start php-fpm
systemctl status php-fpm
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 nginx
3,安装mysql5.7.19
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