二,zabbix的安装
目录
二,zabbix的安装
一,环境准备
[root@m01 ~]# cat /etc/redhat-release #查看centos版本
CentOS Linux release 7.4.1708 (Core)
[root@m01 ~]# uname -r #查看内核版本
3.10.0-693.el7.x86_64
[root@m01 ~]# getenforce #查看selinux是否关闭
Disabled
[root@m01 ~]# systemctl status firewalld.service #查看防火墙是否关闭
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
二,部署zabbix服务
1,server端安装zabbix程序
#此处参考官网介绍的安装方法。并基于已经安装了php mysql web程序的前提下
#zabbix官网:
https://www.zabbix.com/download?zabbix=3.4&os_distribution=centos&os_version=6&db=MySQL
#根据需求选择相应的包,然后添加yum源
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4- 1.el6.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
#配置数据库,添加zabbix库及用户授权
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
导入zabbix库中的表
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
#配置 zabbix-server的配置文件
vim /etc/zabbix/zabbix_server.conf
DBPassword=password
#配置php.ini文件
最下方添加
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1
extension_dir="/app/php/lib/php/extensions/no-debug-zts-20131226"
extension=ldap.so
#启动 Zabbix server and agent processest:
systemctl restart zabbix-server zabbix-agent nginx
systemctl enable zabbix-server zabbix-agent nginx
#常见问题:编译安装LNMP的过程中 有可能遇到各种环境缺失,百度即可。再此不一一列举
如调整process触发器规则,则有可能zabbix-server的server进程起不来,此时应注意 ,调大
my.cnf中的max_connections选项
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
tmp_table_size = 32M
max_heap_table_size = 32M
max_connections = 1000
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 4096
port = 3306
socket=/app/mysql/mysql.sock
[mysqld_safe]
err-log=/data/mysql/mysqld.log
2,agent端安装zabbix-agent程序
#zabbix官网:
https://www.zabbix.com/download?zabbix=3.4&os_distribution=centos&os_version=6&db=MySQL
#根据需求选择相应的包,然后添加yum源
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4- 1.el6.noarch.rpm
#安装agent端
yum install zabbix-agent -y
#配置agent,指定zabbix-server地址,而后启动agent服务
sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf
systemctl start zabbix-agent.service
3, 检测连通性
一, 服务端安装zabbix-get检测工具
# 在server端安装zabbix-get检测工具
yum install zabbix-get
#测试agent端的监控项是否正常获取
zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]"
zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"
#测试结果能获取数值,说明连通正常
[root@m01 ~]# zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000
[root@m01 ~]# zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000
至此server端和agent端zabbix安装完成。下一步web界面配置使用zabbix。