在后续的安装中出现了很多问题,多为账号,还有字符集导致的。安装zabbix,需要使用之前的密码设置格式,还有最重要的字符集是utf8。 主机配置 [root@zabbix-mysql01 ~]# cat /etc/hosts10.10.
在后续的安装中出现了很多问题,多为账号,还有字符集导致的。安装zabbix,需要使用之前的密码设置格式,还有最重要的字符集是utf8。
主机配置
[root@zabbix-mysql01 ~]# cat /etc/hosts 10.10.10.201 zabbix-mysql01 10.10.10.202 zabbix-mysql02安装mysql
[root@zabbix-mysql01 ~]#rpm -ivh http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql80-community-release-el7-3.noarch.rpm [root@zabbix-mysql01 ~]# yum -y install mysql-community-server配置Mysql
[root@zabbix-mysql01 ~]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 character-set-server=utf8 innodb_file_per_table=1 innodb_data_file_path=ibdata1:10M:autoextend server_id=1 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [root@zabbix-mysql02 ~]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 character-set-server=utf8 innodb_file_per_table=1 innodb_data_file_path=ibdata1:10M:autoextend server_id=2 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid启动数据库
先启动主节点,备节点暂时不启动。 [root@zabbix-mysql01 ~]# systemctl start mysqld [root@zabbix-mysql01 ~]#修改密码
首先查找临时密码 tail -100 /var/log/messages Mar 19 22:30:11 zabbix-mysql01 mysqld_pre_systemd: 2021-03-19T14:30:11.846201Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 3341 Mar 19 22:30:11 zabbix-mysql01 mysqld_pre_systemd: 2021-03-19T14:30:11.847519Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. Mar 19 22:30:11 zabbix-mysql01 mysqld_pre_systemd: 2021-03-19T14:30:11.851720Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. Mar 19 22:30:12 zabbix-mysql01 mysqld_pre_systemd: 2021-03-19T14:30:12.117691Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. Mar 19 22:30:12 zabbix-mysql01 mysqld_pre_systemd: 2021-03-19T14:30:12.680672Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Viop6I6:eWS! [root@zabbix-mysql01 ~]# mysql -uroot -p Enter password: mysql> alter user 'root'@'localhost' identified by 'Root@123456'; mysql> FLUSH PRIVILEGES; 注意zabbix的数据库应该用 utf8,而不应用utf8mb4; 设置密码应该采用 #mysql> create database zabbix character set utf8mb4; mysql> create database zabbix character set utf8; mysql> select host,user from mysql.user; mysql> CREATE USER 'zabbix'@'%' IDENTIFIED BY 'Root@123456'; mysql> grant all privileges on *.* to 'zabbix'@'%' ; mysql> FLUSH PRIVILEGES; mysql> select host,user from mysql.user; mysql> CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'Root@123456'; mysql> CREATE USER 'zabbix'@'127.0.0.1' IDENTIFIED BY 'Root@123456'; mysql> grant all privileges on *.* to 'zabbix'@'localhost' ; mysql> grant all privileges on *.* to 'zabbix'@'127.0.0.1' ; mysql> FLUSH PRIVILEGES; 设置密码应该采用mysql_native_password方式 alter user 'zabbix'@'%' identified with mysql_native_password by 'Root@123456'; alter user 'zabbix'@'127.0.0.1' identified with mysql_native_password by 'Root@123456'; alter user 'zabbix'@'localhost' identified with mysql_native_password by 'Root@123456';导入数据库文件
导入数据库文件,该文件需要安装zabbix插件,可参考之前安装的步骤进行操作 wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm rpm -ivh zabbix-release-4.0-2.el7.noarch.rpm 安装 yum -y install gcc make openldap-devel libssh2-devel net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel net-snmp-devel openldap-devel gnutls-devel sqlite-devel sqlite-devel curl-devel libxml2-devel libevent-devel openssl-devel yum install -y httpd php php-mysql yum -y install zabbix-server-mysql yum -y install zabbix-agent 安装这些以后,就能有create.sql.gz包 cd /usr/share/doc/zabbix-server-mysql-4.0.29 gunzip create.sql.gz mysql -uzabbix -pRoot@123456 -h127.0.0.1 use zabbix source create.sqlMysql数据库主库配置
以下操作在主服务器上进行 停止Mysql主库服务 systemctl stop mysqld同步主库文件到从库
[root@zabbix-mysql01 ~]# rsync -av -e "ssh -p 22" /var/lib/mysql/ root@10.10.10.202:/var/lib/mysql/