赞
踩
MySQL搭建主从、MHA集群、MGR集群等操作所遇到的问题报错。
描述:
密码设置不满足条件
mysql> grant replication slave on *.* to repl@'192.168.111.%' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决方案:
1、查看 mysql 初始的密码策略,
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
2、首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 即可,
set global validate_password_policy=LOW;
3、当前密码长度为 8 ,如果不介意的话就不用修改了,按照通用的来讲,设置为 6 位的密码,设置 validate_password_length 的全局参数为 6 即可,
set global validate_password_length=6;
4、现在可以为 mysql 设置简单密码了,只要满足六位的长度即可。
注:在默认密码的长度最小值为 4 ,由 大/小写字母各一个 + 阿拉伯数字一个 + 特殊字符一个, 只要设置密码的长度小于 3 ,都将自动设值为 4
关于 mysql 密码策略相关参数;
1)、validate_password_length 固定密码的总长度;
2)、validate_password_dictionary_file 指定密码验证的文件路径;
3)、validate_password_mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
4)、validate_password_number_count 整个密码中至少要包含阿拉伯数字的个数;
5)、validate_password_policy 指定密码的强度验证等级,默认为 MEDIUM;
关于 validate_password_policy 的取值:
0/LOW:只验证长度;
1/MEDIUM:验证长度、数字、大小写、特殊字符;
2/STRONG:验证长度、数字、大小写、特殊字符、字典文件;
6)、validate_password_special_char_count 整个密码中至少要包含特殊字符的个数;
描述:
mysql> SHOW VARIABLES LIKE ‘validate_password%’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘validate_password%’' at line 1
翻译:你有一个错误在你的SQL语法;查看MySQL服务器版本对应的手册,在第1行“Continue”附近使用正确的语法
解决方案:
SQL语句中出现特殊字符,检查语句改正即可,或重新手打一遍。
描述:
mysql> stop slave;
ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
翻译:从设备未配置或未能正确初始化。您必须至少设置–server id才能启用master或slave。其他错误消息可以在MySQL错误日志中找到。
解决方案: (目前不靠谱,慎用)
drop 备份的 ibd表:
use mysql
drop table slave_master_info;
drop table slave_relay_log_info;
drop table slave_worker_info;
drop table innodb_index_stats;
drop table innodb_table_stats;
重建:
source /usr/local/mysql/share/mysql_system_tables.sql
再重启数据库
描述1:
Slave_SQL_Running: No
程序可能在slave上进行了写操作,也可能是slave机器重起后,事务回滚造成的,一般是事务回滚造成的。
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.111.143
Master_User: redhat
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin-master.000009
Read_Master_Log_Pos: 154
Relay_Log_File: slave1-relay-bin.000007
Relay_Log_Pos: 1720
Relay_Master_Log_File: mysql-bin-master.000006
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
解决方案:
stop slave ;
set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
start slave ;
描述2:
Slave_IO_Running: No
原因:
1、克隆的机器 两个mysql的uuid很可能相同,# tail /var/log/mysqld.log报错信息为The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work;
2、master上的mysql-bin.xxxxxx文件全错误,报错信息为Error reading packet from server: Could not find first log file name in binary log
解决方案:
1、(1)使用 find / -name “auto.cnf” 命令查找你数据库的auto.cnf 配置文件。
(2)把查询到的文件删除,系统将重新自动分配(或改变/var/lib/mysql/auto.cnf中uuid的值)
(3)重启服务,登录mysql,重启slave,再次验证
mysql -uroot -p1234
stop slave; #停止链路
start slave;
show slave status \G; #查看链路
2、重启master库:
# systemctl restart mysqld
查看状态:
mysql> show master status;
+-------------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------------+----------+--------------+------------------+-------------------+
| mysql-bin-master.000003 | 154 | mha | mysql | |
+-------------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
进入从库:
stop slave;
change master to Master_Log_File='mysql-bin-master.000003',Master_Log_Pos=154;
start slave;
show slave status\G
描述:
显示有HA数据库,但不能切换到HA数据库。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| HA |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql> use HA
ERROR 1049 (42000): Unknown database 'ha'
解决方案:
数据库名不能用大写
mysql> create database MHA; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | HA | | mha | | mysql | | performance_schema | | sys | +--------------------+ 6 rows in set (0.00 sec) mysql> use mha Database changed
描述:
在使用linux系统时,出现下面的提示:
You have new mail in /var/spool/mail/root
原因:Linux系统经常会自动发出一些邮件来提醒用户系统中出了哪些问题(收件箱位置:/var/mail/),比如crontab里面的脚本命令执行错误了(sh文件名,python命令没有使用全路径,没有使用后台运行nohup命令等问题导致无法正常执行的报错)
解决方案:
关闭提示
echo "unset MAILCHECK">> /etc/profile
source /etc/profile
查看
ls -lth /var/spool/mail/
清空
cat /dev/null > /var/spool/mail/root
描述:
启动MGR集群节点时:
mysql> start group_replication;
ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.
翻译:服务器未正确配置为组的活动成员。请查看错误日志中的更多详细信息。
查看错误日志:
(1)发现Server_uuid与group_name匹配。
mysql> show variables like "%log_error%";
+---------------------+---------------------+
| Variable_name | Value |
+---------------------+---------------------+
| binlog_error_action | ABORT_SERVER |
| log_error | /var/log/mysqld.log |
| log_error_verbosity | 3 |
+---------------------+---------------------+
3 rows in set (0.00 sec)
# tail /var/log/mysqld.log
2023-09-08T07:23:11.645915Z 2 [ERROR] Plugin group_replication reported: 'Member server_uuid is incompatible with the group. Server_uuid e72d57ef-262b-11ee-b4dc-000c296a7fb6 matches group_name e72d57ef-262b-11ee-b4dc-000c296a7fb6.'
2023-09-08T07:23:11.645921Z 2 [Note] Plugin group_replication reported: 'Requesting to leave the group despite of not being a member'
2023-09-08T07:23:11.645927Z 2 [ERROR] Plugin group_replication reported: '[GCS] The member is leaving a group without being on one.'
解决方案:
修改配置文件/etc/my.cnf
每个节点的组名要一致,但不能与uuid相同
#加入的组名,命名格式参考cat /var/lib/mysql/auto.cnf
loose-group_replication_group_name='ce9be252-2b71-11e6-b8f4-00212844f856'
(2)发现slave的I/O连接错了用户,这里创建的集群用户是repl,而slave尝试连接的是redhat,与其他主从同步冲突。
# tail /var/log/mysqld.log
2023-09-08T09:26:25.243460Z 4 [ERROR] Plugin group_replication reported: 'Can't start group replication on secondary member with single primary-mode while asynchronous replication channels are running.'
2023-09-08T09:26:25.243464Z 4 [Note] Plugin group_replication reported: 'Requesting to leave the group despite of not being a member'
2023-09-08T09:26:25.243504Z 4 [ERROR] Plugin group_replication reported: '[GCS] The member is leaving a group without being on one.'
2023-09-08T09:27:07.564291Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'redhat@192.168.111.147:3306' - retry-time: 60 retries: 11, Error_code: 2003
2023-09-08T09:28:10.573880Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'redhat@192.168.111.147:3306' - retry-time: 60 retries: 12, Error_code: 2003
解决方案:
停掉其他主从连接(搭建集群时最好用干净的mysql,避免冲突)
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
本文为解决MySQL搭建主从、MHA集群、MGR集群等操作所报错的一些问题,将持续改正和更新。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。