Article Directory
Zabbix monitoring experiment deployment
1. Monitoring database
1.2 Type 1: mysql
- Server configuration
mkdir /var/lib/zabbix
vim /var/lib/zabbix/.my.cnf
[mysql]
user=root
password=westos
socket=/var/lib/mysql/mysql.sock
[mysqladmin]
user=root
password=westos
socket=/var/lib/mysql/mysql.sock
- Add template
1.2 Category 2: percona
- Install percona
rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm
- Install php and php-mysql
yum install -y php php-mysql
- Copy key file template
cd /var/lib/zabbix/percona/templates/
cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
- Restart the agent service
systemctl restart zabbix-agent.service
- Add user name and password to percona database script
vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
$mysql_user = 'root';
$mysql_pass = 'westos';
rm -fr /tmp/localhost-mysql_cacti_stats.txt
- Import template zbx_percona_mysql_template.xml
- Add percona database template (cancel the mysql template added before)
2. Monitoring java (using apache-tomcat)
Java monitoring object: server2: 192.168.17.2
2.1 Agent configuration
- Install jdk
yum install -y java-1.8.0-openjdk.x86_64
- Install apache-tomcat, create a soft link,
tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/
cd /usr/local/
ln -s apache-tomcat-7.0.37/ tomcat
- Configure tomcat
cd /usr/local/tomcat/bin/
vim catalina.sh
CATALINA_OPTS='-Dcom.sun.management.jmxremote.port=8888
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false'
./startup.sh
netstat -antlupe | grep 8080
netstat -antlupe | grep :8888
2.2 Server configuration
server1:192.168.17.1
- Install zabbix-java-gateway**
yum install -y zabbix-java-gateway
- Change setting
vim /etc/zabbix/zabbix_java_gateway.conf
(According to your own needs, you can not modify it)
9 LISTEN_IP="0.0.0.0"#默认
17 LISTEN_PORT=10052#默认端口
35 START_POLLERS=10
- Open zabbix-java-gateway service
systemctl enable --now zabbix-java-gateway.service
netstat -antlupe | grep 10052
- Configure java gateway
vim /etc/zabbix/zabbix_server.conf
JavaGateway=192.168.17.1
JavaGatewayPort=10052
StartJavaPollers=10
- Restart zabbix-server service
systemctl restart zabbix-server
2.3 Add JMX interface and template for monitoring
- Add JMX interface
- Add JMX template
- Check whether the monitoring is normal
3. Active monitoring
The client actively sends data
- Full clone template (because new creation is too troublesome)
- Modify the cloned template to be active : select the template Template OS Linux–Active, select all monitoring items of the template, and perform batch updates
- Cancel the template before cloning on the agent side and add the active template
4. Distributed monitoring (proxy)
- Zabbix provides effective and available distributed monitoring for IT infrastructure through Zabbix proxies
- Proxies can be used to collect data locally instead of Zabbix server, and then report the data to the server.
4.1 Experimental environment
Proxy host: proxy:192.168.17.3 (limited hosts, change the agent host into a proxy host)
- Modify the host name as proxy and delete it from the agent host
- Add resolution to all hosts
vim /etc/hosts
192.168.17.3 proxy
4.2 define proxy server
- Create agent
- Set the agent host server2 to be monitored by the agent
4.3 Proxy configuration
- Install database and proxy
yum install -y zabbix-proxy-mysql
yum install -y mariadb-server
- Open and create database
systemctl enable --now mariadb
mysql
create database zabbix_proxy character set utf8 collate utf8_bin;
create user 'zabbix'@'localhost' identified by 'westos';
grant all privileges on zabbix_proxy.* to 'zabbix'@'localhost';
- Change setting
vim /etc/zabbix/zabbix_proxy.conf
30 Server=192.168.17.1
49 Hostname=proxy
173 DBName=zabbix_proxy
188 DBUser=zabbix
196 DBPassword=westos
#由于server2主机配置了java,所以也要修改java网关,否则监测JMX会失败
329 JavaGateway=192.168.17.1
337 JavaGatewayPort=10052
345 StartJavaPollers=10
- Import Data
zcat /usr/share/doc/zabbix-proxy-mysql-4.0.27/schema.sql.gz | mysql -uzabbix -pwestos zabbix_proxy
- Open proxy service
systemctl enable --now zabbix-proxy
4.4 Agent configuration
server2:192.168.17.2
- Modify server to proxy server IP
vim /etc/zabbix/zabbix_agentd.conf
98 Server=192.168.17.3
139 ServerActive=192.168.17.3
- Restart service
systemctl restart zabbix-agent.service
4.5 server configuration
- Re-read zabbix configuration file
zabbix_server -R config_cache_reload
- Restart the service on the proxy side
systemctl restart zabbix-proxy.service
- Server side view log
cat /var/log/zabbix/zabbix_server.log
- Proxy view log
cat /var/log/zabbix/zabbix_proxy.log
4.6 View monitoring results
5. Cloud Alert
Intelligent alarm platform: http://onealert.com/
The intelligent alarm platform CA can quickly access all kinds of alarm information, realize alarm noise reduction through automatic deduplication, rule compression, and algorithm noise reduction, and help the operation and maintenance team reduce alarms and avoid alarm storms; at the same time, through dispatch, scheduling, and notification And other functions, quickly realize the process-based management of alarms, help the operation and maintenance team respond to alarms faster, restore alarms, and improve alarm management capabilities
5.1 Alarm platform configuration
- Create zabbix application, get key
- Create a notification strategy, select the notification method as WeChat (bind WeChat in advance)
5.2 Install CA Probe on Server
- Download package
wget https://download.aiops.com/ca_agent/zabbix/ca_zabbix_release-2.1.0.tar.gz
- Unzip to the specified location
tar zxf ca_zabbix_release-2.1.0.tar.gz -C /usr/lib/zabbix/alertscripts/
- Install to the specified location
cd /usr/lib/zabbix/alertscripts/cloudalert/bin/
./install.sh 获取的key
- It is found that alert media, users, triggers, etc. are automatically added to the front end
5.3 Testing
- Turn off the agent service
- Front end view
- Open the agent service, the front-end view problem is solved
- WeChat display alert
- Alarm platform display