1) 配置Zabbix Server数据库
[root@node1 ~]# mysql -u root -p
Enter password:
......
......
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@node1 ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.17/
[root@node1 zabbix-server-mysql-4.0.17]# gzip -d create.sql.gz
[root@node1 zabbix-server-mysql-4.0.17]# mysql -u root -p zabbix < create.sql
Enter password:
# 如果出现
"ERROR 1118 (42000) at line 1278: Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline."
错误,请按以下步骤解决此错误
[root@node1 zabbix-server-mysql-4.0.17]# vim /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf
# 在[mysqld]区段最后追加如下内容
max_allowed_packet = 256M
innodb_buffer_pool_size = 512M
innodb_log_file_size = 30M
innodb_log_buffer_size = 32M
innodb_file_per_table = 1
innodb_large_prefix=1
innodb_file_format = Barracuda
# innodb_strict_mode设置影响CREATE TABLE,ALTER TABLE和CREATE INDEX语句的语法错误的处理。innodb_strict_mode还启用了记录大小检查,因此INSERT或UPDATE永远不会失败,因为记录对于所选页面大小而言太大。
innodb_strict_mode = 0
[root@node1 zabbix-server-mysql-4.0.17]# systemctl restart rh-mariadb102-mariadb
# 错误解决完成之后,进入MariaDB使用drop database zabbix;指令删除数据库。并根据1.5小节中的第一步重新创建数据库及授权
[root@node1 zabbix-server-mysql-4.0.17]# cd
[root@node1 ~]#
[root@node1 ~]# vim /etc/zabbix/zabbix_server.conf
# 更改91行,设定DB Server所在位置
DBHost=localhost
# 更改100行,设定zabbix的DB名称
DBName=zabbix
# 更改116行,设定zabbix数据的的连接账户
DBUser=zabbix
# 更改124行,设定zabbix数据的的连接账户的密码
DBPassword=password
# 为zabbix-server.service文件增加MariaDB信息
[root@node1 ~]# systemctl cat zabbix-server.service
# /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=mysql.service
After=mysqld.service
After=mariadb.service
After=postgresql.service
.....
.....
[root@node1 ~]# systemctl edit zabbix-server.service
# 添加如下内容
[Unit]
......
......
......
After=rh-mariadb102-mariadb.service
[root@node1 ~]# systemctl daemon-reload
[root@node1 ~]# systemctl enable --now zabbix-server
2) 设置SELinux
[root@node1 ~]# setsebool -P zabbix_can_network on
[root@node1 ~]# setsebool -P httpd_can_connect_zabbix on
[root@node1 ~]# setsebool -P daemons_enable_cluster_mode on
[root@node1 ~]# vim zabbix_server.te
# create new
module zabbix_server 1.0;
require {
type zabbix_var_run_t;
type zabbix_t;
class sock_file { create unlink };
class unix_stream_socket connectto;
}
#============= zabbix_t ==============
allow zabbix_t self:unix_stream_socket connectto;
allow zabbix_t zabbix_var_run_t:sock_file { create unlink };
[root@node1 ~]# checkmodule -m -M -o zabbix_server.mod zabbix_server.te
checkmodule: loading policy configuration from zabbix_server.te
checkmodule: policy configuration loaded
checkmodule: writing binary representation (version 17) to zabbix_server.mod
[root@node1 ~]# semodule_package --outfile zabbix_server.pp --module zabbix_server.mod
[root@node1 ~]# semodule -i zabbix_server.pp
3) Firewalld设置
[root@node1 ~]# firewall-cmd --add-service={http,https} --permanent
success
[root@node1 ~]# firewall-cmd --add-port={10051/tcp,10050/tcp} --permanent
success
[root@node1 ~]# firewall-cmd --reload
success
4) 设置Zabbix Agent以监测Zabbix Server
[root@node1 ~]# vim /etc/zabbix/zabbix_agentd.conf
# 更改98行,设定zabbix Server的位置
Server=127.0.0.1
# 更改139行,设定zabbix Server的位置
ServerActive=127.0.0.1
# 更改150行,设定zabbix Server的FQDN的位置
Hostname=node1.1000cc.net
[root@node1 ~]# systemctl enable --now zabbix-agent
5) 为Zabbix Server配置httpd服务
[root@node1 ~]# vim /etc/httpd/conf.d/zabbix.conf
# 注释9行,不允许所有网络连接Zabbix平台
# 添加第10行内容,仅允许指定网络访问Zabbix Server。
#Require all granted
Require ip 127.0.0.1 192.168.10.0/24
# 注释12行,21行两行。取消20行注释,并修改本地的时区.
#<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
#</IfModule>
# 移除旧有的5.x版本的php相关文件
[root@node1 ~]# mv /etc/httpd/conf.modules.d/10-php.conf /etc/httpd/conf.modules.d/10-php.conf.bak
[root@node1 ~]# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bak
[root@node1 ~]# systemctl restart httpd
|