MySQL搭建集群遇到的报错解决

项目场景

MySQL搭建主从、MHA集群、MGR集群等操作所遇到的问题报错。


问题1:ERROR 1819 (HY000): Your password does not satisfy

描述:
密码设置不满足条件

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 整个密码中至少要包含特殊字符的个数;

问题2:ERROR 1064 (42000): You have an error in your SQL syntax

描述:

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语句中出现特殊字符,检查语句改正即可,或重新手打一遍。

问题3:ERROR 1794 (HY000): Slave is not configured or failed

描述:

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

再重启数据库

问题4:Slave_SQL_Running: No,Slave_IO_Running: No

描述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

问题5:ERROR 1049 (42000): Unknown database ‘ha’

描述:
显示有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

问题6:You have new mail in /var/spool/mail/root

描述:
在使用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

问题7:ERROR 3092 (HY000): The server is not configured properly

描述:
启动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集群等操作所报错的一些问题,将持续改正和更新。

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DVWA(Damn Vulnerable Web Application)是一个漏洞模拟环境,用于进行Web应用程序的安全测试和学习。下面是DVWA靶场搭建的过程及报错解决方法: 1. 首先,下载DVWA。你可以在官方网站上下载DVWA的压缩包。 2. 解压缩下载的压缩包,并将解压后的文件夹放在你的Web服务器的根目录下。 3. 打开DVWA文件夹中的config文件夹,并将config.inc.php.dist文件复制一份,并将复制的文件重命名为config.inc.php。 4. 编辑config.inc.php文件,将其中的数据库参数修改为你的数据库信息。确保将user和password修改为root,并保存文件。 5. 在浏览器中输入你的Web服务器地址,并进入DVWA靶场的安装界面。 6. 点击"Create/Reset Database"按钮,创建或重置数据库。 7. 随后,你将被重定向到DVWA的登录页面。使用默认的用户名和密码(admin/password)进行登录。 8. 完成登录后,你可以选择不同的难度级别(如Low、Medium、High)来进行漏洞测试和学习。 对于报错"Illegal mix of collations for operation 'UNION'"的解决方法: 1. 这个报错通常是由于编码问题引起的。你可以通过下载PhpMyAdmin来修改编码。 2. 首先,在百度上搜索并下载PhpMyAdmin。将下载的压缩包解压缩到你的Web服务器的WWW目录下。 3. 对PhpMyAdmin进行配置。可以参考这篇文章:https://m.php.cn/article/361433.html。按照文章中的步骤进行配置。 4. 配置完成后,在浏览器中输入你的主机IP地址或localhost,然后加上PhpMyAdmin文件夹的名字(根据你的配置进行修改),进入PhpMyAdmin的登录界面。 5. 默认情况下,用户名和密码都是root。登录后,在左边的选项中选择dvwa,在右边的选项中单击"操作",然后往下滑动到"排序规则",将原来的编码改为"utf8_general_ci"。选择好编码后,单击右下角的"执行"。 6. 最后,关闭PhpMyAdmin,并重新启动Apache和MySQL。 现在,你可以重新打开DVWA靶场,将难度级别调至Low,并尝试之前报错的那条操作,应该已经成功了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值