网站开发软件中文版,公司软件网站建设,江苏弘盛建设工程集团有限公司网站,wordpress主题资源网目录
1、rpm安装zabbix_agentd服务
2、编写zabbix_agentd.conf文件
3、编写模板文件
4、创建mysql用户并赋权限
5、创建.my.cnf文件
6、将规则添加到SELinux策略中
注意#xff1a;
若模板无法读取.my.cnf 信息#xff0c;从而导致监控报错#xff0c;可以尝试修改模…
目录
1、rpm安装zabbix_agentd服务
2、编写zabbix_agentd.conf文件
3、编写模板文件
4、创建mysql用户并赋权限
5、创建.my.cnf文件
6、将规则添加到SELinux策略中
注意
若模板无法读取.my.cnf 信息从而导致监控报错可以尝试修改模板配置配置文件 1、rpm安装zabbix_agentd服务
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/7/x86_64/zabbix-release-6.4-1.el7.noarch.rpm
yum clean all# b. Install Zabbix agent
yum install zabbix-agent
# c. Start Zabbix agent process
# Start Zabbix agent process and make it start at system boot.sudo systemctl stop zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agent
2、编写zabbix_agentd.conf文件
cd /etc/zabbix
vim zabbix_agentd.confPidFile/var/run/zabbix/zabbix_agentd.pid
LogFile/var/log/zabbix/zabbix_agentd_1.log
LogFileSize0
Server192.168.3.246
ServerActive192.168.3.246
Hostname192.168.3.244
Include/etc/zabbix/zabbix_agentd.d/*.conf
UnsafeUserParameters1
3、编写模板文件
vim /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf#template_db_mysql.conf created by Zabbix for Template DB MySQL and Zabbix 4.2
#For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default)
#For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\my.cnf,C:\my.cnf,BASEDIR\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html
#The file must have three strings:
#[client]
#userzbx_monitor
#passwordpassword
#
UserParametermysql.ping[*], mysqladmin -h$1 -P$2 ping
UserParametermysql.get_status_variables[*], mysql -h$1 -P$2 -sNX -e show global status
UserParametermysql.version[*], mysqladmin -s -h$1 -P$2 version
UserParametermysql.db.discovery[*], mysql -h$1 -P$2 -sN -e show databases
UserParametermysql.dbsize[*], mysql -h$1 -P$2 -sN -e SELECT COALESCE(SUM(DATA_LENGTH INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA$3
UserParametermysql.replication.discovery[*], mysql -h$1 -P$2 -sNX -e show slave status
UserParametermysql.slave_status[*], mysql -h$1 -P$2 -sNX -e show slave status
4、创建mysql用户并赋权限
CREATE USER zbx_monitor% IDENTIFIED BY 123456;
GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO zbx_monitor%;
5、创建.my.cnf文件
mkdir -p /var/lib/zabbix
vim /var/lib/zabbix/.my.cnf[client]
userzbx_monitor
password123456
6、将规则添加到SELinux策略中
systemctl edit zabbix-agent.service# cat EOF zabbix_home.te
module zabbix_home 1.0;require {type zabbix_agent_t;type zabbix_var_lib_t;type mysqld_etc_t;type mysqld_port_t;type mysqld_var_run_t;class file { open read };class tcp_socket name_connect;class sock_file write;
}# zabbix_agent_t allow zabbix_agent_t zabbix_var_lib_t:file read;
allow zabbix_agent_t zabbix_var_lib_t:file open;
allow zabbix_agent_t mysqld_etc_t:file read;
allow zabbix_agent_t mysqld_port_t:tcp_socket name_connect;
allow zabbix_agent_t mysqld_var_run_t:sock_file write;
EOF
# checkmodule -M -m -o zabbix_home.mod zabbix_home.te
# semodule_package -o zabbix_home.pp -m zabbix_home.mod
# semodule -i zabbix_home.pp
# restorecon -R /var/lib/zabbix 注意
若模板无法读取.my.cnf 信息从而导致监控报错可以尝试修改模板配置配置文件
#template_db_mysql.conf created by Zabbix for Template DB MySQL and Zabbix 4.2
#For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default)
#For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\\my.cnf,C:\\my.cnf,BASEDIR\\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html
#The file must have three strings:
#[client]
#userzbx_monitor
#passwordpassword
#
UserParametermysql.ping[*], mysqladmin --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 ping
UserParametermysql.get_status_variables[*], mysql --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 -sNX -e show global status
UserParametermysql.version[*], mysqladmin --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 version
UserParametermysql.db.discovery[*], mysql --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 -sN -e show databases
UserParametermysql.dbsize[*], mysql --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 -sN -e SELECT COALESCE(SUM(DATA_LENGTH INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA$3
UserParametermysql.replication.discovery[*], mysql --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 -sNX -e show slave status
UserParametermysql.slave_status[*], mysql --defaults-extra-file/var/lib/zabbix/.my.cnf -h$1 -P$2 -sNX -e show slave status