Zabbix deep installation zabbix version (2.4.8) I. Install the server
Official Installation Reference: https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packages
1. Install the zabbix-release package [[email protected] ~] # Mkdir-P/home/oldboy/tools [[email protected] ~] # Cd/home/oldboy/tools [[email protected] tools] # wget-Q http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm [[email protected] tools] # ls-lH zabbix-release-2.4-1.el6.noarch.rpm-RW-r-1 root 12 K September 11 2014 zabbix-release-2.4-1.el6.noarch.rpm [[email protected] tools] # rpm-IVH zabbix-release-2.4-1.el6.noarch.rpm warning: zabbix-release-2.4-1.el6.noarch.rpm: Header V4 DSA/sha1 signature, key ID 79ea5ed4: nokey preparing... (1 ###################################### ##### [100%] 1: zabbix-release (#################################### ####### [100%] ###### zabbix-release package installation result [[email protected] tools] # rpm-QL zabbix-release/etc/pki /rpm-GPG/RPM-GPG-KEY-ZABBIX/etc/yum. repos. d/zabbix. repo/usr/share/doc/zabbix-release-2.4/usr/share/doc/zabbix-release-2.4/GPL [[email protected] tools] # ll/etc/yum. repos. d/zabbix. repo-RW-r-1 Root 401 September 11 2014/etc/yum. repos. d/zabbix. repo 2. Start zabbix Installation
1. Retain the RPM package installed by yum
[[Email protected] tools] # sed-I's # keepcache = 1 # keepcache = 0 # G'/etc/yum. conf [[email protected] tools] # grep keepcache/etc/yum. conf keepcache = 0
2. Install zabbix
Yum-y install zabbix-server-mysql # <= zabbix server-related Yum-y install zabbix-web-mysql # <= Apache, PHP Web interface environment Yum-y install zabbix-Agent # <= zabbix client Yum-y install mysql-server MySQL # <= MYSQL client and server Yum-y install zabbix-Get # <= zabbix command line tool 3. Configure zabbix services
- Configure and start MySQL
[[Email protected] tools] # \ CP/usr/share/MySQL/my-medium.cnf/etc/My. CNF [[email protected] tools] # vi/etc/my.cn
Add the following three lines under the [mysqld] (26th rows) label and save
[Mysqld] character-set-Server = utf8 init-connect = 'set names utf8' collation-Server = utf8_general_ci
- Start the database MySQL that stores data in zabbix
[[Email protected] tools] #/etc/init. d/mysqld start
...... Please report any problems with the/usr/bin/mysqlbug script! [OK] Starting mysqld: [OK]
- Initialize Database
[Root @ linux-node1 ~] # Mysql-e "create database zabbix Character Set utf8 collate utf8_bin;" [root @ linux-node1 ~] # Mysql-e "grant all on zabbix. * to [email protected] identified by 'zabbix';" [root @ linux-node1 ~] # Cd/usr/share/doc/zabbix-server-mysql-2.4.6/create [root @ linux-node1 create] # MySQL zabbix <schema. SQL [root @ linux-node1 create] # MySQL zabbix <images. SQL [root @ linux-node1 create] # MySQL zabbix <data. SQL [root @ linux-node1 create] # mysqladmin-uroot password oldboy
- Initialize apache service
[[Email protected] Create] # sed-I's #\# php_value date. timezone Europe/Riga # php_value date. timezone Asia/Shanghai # G'/etc/httpd/CONF. d/zabbix. conf [[email protected] Create] # grep Shanghai/etc/httpd/CONF. d/zabbix. conf php_value date. timezone Asia/Shanghai
- Comparison before and after modification
[[Email protected] Create] # diff/etc/zabbix/zabbix_server.conf/etc/zabbix/zabbix_server.conf.oldboy.ori
65d64 <### option: dbhost 72, 73c71 <dbhost = localhost <-> # dbhost = localhost 106c104 <dbpassword = zabbix-> # dbpassword =
- Start zabbix server and Web Services
[[Email protected] Create] #/etc/init. d/zabbix-server startstarting zabbix server: [OK] [[email protected] Create] # lsof-I: 10051 | WC-l55 [[email protected] Create] #/etc/init. d/httpd start is starting httpd: apr_sockaddr_info_get () failed for linux-node1.example.com httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for servername [OK] [[email protected] Create] # lsof-I: 80 | WC-L10
At this point, the command line configuration of zabbix server has come to an end, and the next step is to manage it on the web interface. Using Web management is really bad for me, I still like automatic batch script management for Nagios, which is faster and more comfortable.
Ii. Use zabbix to customize monitoring metrics:
1. Add custom Parameters
CAT/etc/zabbix/zabbix_agentd.d/nginx. confuserparameter = nginx. active,/usr/bin/curl-s "http: // 192.168.164.131: 8080/nginx-status" | grep 'active' | awk '{print $ NF }'
2. Restart zabbix-agent.
3. Test and obtain on the server
Zabbix_get-s 192.168.164.131-P 10050-k "nginx. Active"
4. Create an item on the web interface
Custom image: Custom screen: Custom Map
1. Deployment of Network Monitoring smokeping
2. zabbix chaos
3. Next time I will share the piwik Traffic Analysis System
Zabbix production case
1. Project Planning
Host group:
Monitoring recognition object:
-Use an SNMP monitoring Switch
- Use IPMI to monitor server hardware
- Use Agent to monitor servers
- Use JMX to monitor Java
- Monitor MySQL
- Monitor web status
- Monitor nginx status
SNMP monitoring:
1. Enable snmp for the vswitch
1.2 add monitoring on zabbix
1.3 associated monitoring template
IPMI:
Recommended. Use a custom item and run the ipmitool command locally to obtain data.
JMX :( use zabbix Java gateway proxy)
- 1. Install Yum install-y zabbix-Java-Gateway Java-1.8.0
- 2. Configure Vim/etc/zabbix/zabbix_java_gateway.conf
- 3. Start systemctl start zabbix-java-gateway.service
- 4. Port Process
- 5. [[email protected] ~] # Vim/etc/zabbix/zabbix_server.conf
- Set the Java gateway address
- 6. Restart zabbix Server
Three types of JMX: 1. Password-free authentication 2. user name and password authentication 3.ssl
[Root @ linux-node2 ~] # Cd/usr/local/src [root @ linux-node2 SRC] # wget unzip SRC] # tar zxf apache-tomcat-8.0.36.tar.gz ^ C [root @ linux-node2 SRC] # mv APACHE-Tomcat-8.0.36/usr /local/[root @ linux-node2 SRC] # ln-S/usr/local/Apache-Tomcat-8.0.36 // usr/local/tomcat [root @ linux-node2 SRC] #/usr/ local/tomcat/bin/startup. sh
Enable JMX Remote Monitoring
[[Email protected] ~] # Vim/usr/local/tomcat/bin/Catalina. sh catalina_opts = "$ catalina_opts-DCOM. sun. management. jmxremote-DCOM. sun. management. jmxremote. port = 8888-DCOM. sun. management. jmxremote. SSL = false-DCOM. sun. management. jmxremote. authenticate = false-djava. RMI. server. hostname = 192.168.56.12 "[[email protected] ~] #/Usr/local/tomcat/bin/shutdown. Sh [[email protected] ~] #/Usr/local/tomcat/bin/startup. Sh
Manual monitoring status detection
[Root @ linux-node1 ~] # Yum install-y zabbix-Get
1. Enable nginx monitoring
2. Compile scripts for data collection.
3. Set User-Defined parameters
4. Restart zabbix-agent
5. Add item
6. Create a graph
7. Create a trigger
8. Create a template
1. script: 2. upload to/etc/zabbix/zabbix_agentd.d3. modify the agent configuration include =/etc/zabbix/zabbix_agentd.d /*. conf [root @ linux-node1 zabbix_agentd.d] # chmod + x zabbix_linux_plugin.sh [root @ linux-node1 zabbix_agentd.d] #. /zabbix_linux_plugin.sh usage :. /zabbix_linux_plugin.sh {tcp_status key | memcached_status key | redis_status key | nginx_status key} location/nginx_status {stub_status on; access_log off; allow 127.0.0.1; deny All;} [root @ linux-node1 zabbix_agentd.d] # Cat Linux. conf userparameter = linux_status [*], /etc/zabbix/zabbix_agentd.d/zabbix_linux_plugin.sh "$1" "$2" "$3" [root @ linux-node1 zabbix_agentd.d] # systemctl restart zabbix-agent [root @ linux-node1 ~ # Zabbix_get-s 192.168.56.11-K linux_status [nginx_status, 8080, active] 1
Custom alert script:
1. Put it in CD/usr/lib/zabbix/alertscripts 2. Support three parameters: 1. Recipient 2. Topic 3, content 3. Execute Permission 4. Add on the web interface 5. Modify actions
Use the percona monitoring plug-in to monitor MySQL
Yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm https://www.percona.com/doc/percona-monitoring-plugins/1.1/zabbix/index.html#installation-instructions Yum install percona-zabbix-templates PHP-mysql 1. PHP script for data collection 2. shell calls this PHP 3. zabbix configuration file 4. create a zabbix monitoring user in the zabbix template file. Zabbix proxy zabbix-server-> zabbix proxy-> zabbix agent 1.yum install-y zabbix-proxy-mysql mariadb-Server 2. systenctk start nariadb 3. go to the database create database zabbix_proxy Character Set utf8; 4. grant all on zabbix_proxy. * To [email protected] identified by 'zabbix _ proxy'; 5.cd/usr/share/doc/zabbix-proxy-mysql-3.0.22 6. zcat schema. SQL .gz | mysql-uzabbix_proxy-P zabbix_proxy
Automated monitoring
1. Automatic Monitoring
1.1 automatically add zabbix agent
2. Active discovery
2.1 automatic discovery of discover
2.2 zabbix API
Curl-S-X Post-H 'content-type: Application/json'-d' {"jsonrpc": "2.0", "method": "user. login "," Params ": {" user ":" admin "," password ":" zabbix "}," ID ": 1} 'HTTP: // 192.168.164.20./ zabbix/api_jsonrpc.php | Python-m json. tool
Curl-S-X Post-H 'content-type: Application/json'-d'
{
"Jsonrpc": "2.0 ",
"Method": "host. Get ",
"Params ":{
"Output": ["hostid"]
},
"Auth": "c9d7b319e48b6d9ffc2d1f33f9c7c877 ",
"ID": 1
} 'HTTP: // 192.168.164.20./ zabbix/api_jsonrpc.php | Python-m json. Tool
Zabbix deep Installation