{"id":57299,"date":"2025-08-15T10:00:48","date_gmt":"2025-08-15T02:00:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/57299.html"},"modified":"2025-08-15T10:00:48","modified_gmt":"2025-08-15T02:00:48","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84mysql-%e9%9b%86%e7%be%a4%e6%8a%80%e6%9c%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/57299.html","title":{"rendered":"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f"},"content":{"rendered":"<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">Mysql \u96c6\u7fa4\u6280\u672f <\/span><\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">Mysql \u5728\u670d\u52a1\u5668\u4e2d\u7684\u90e8\u7f72\u65b9\u6cd5<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5728\u4f01\u4e1a\u4e2d90%\u7684\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u5747\u4e3a<\/span><span style=\"color:#000000\">Linux <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5728\u4f01\u4e1a\u4e2d\u5bf9\u4e8e<\/span><span style=\"color:#000000\">Mysql<\/span><span style=\"color:#000000\">\u7684\u5b89\u88c5\u901a\u5e38\u7528\u6e90\u7801\u7f16\u8bd1\u7684\u65b9\u5f0f\u6765\u8fdb\u884c<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">Rhel<\/span><span style=\"color:#ff0000\">7<\/span><span style=\"color:#ee822f\">\u90e8\u7f72\u6570\u636e\u5e93<\/span>\u00a0<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0<span style=\"color:#000000\">\u3010<\/span><span style=\"color:#ff0000\">\u6ce8\u610f&#xff1a;<\/span><span style=\"color:#000000\">\u7528rhel <\/span><span style=\"color:#ff0000\">7<\/span><span style=\"color:#000000\">\u00a0\u7248\u672c\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">\u6240\u6709mysql ]<\/span><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">yum install -y git bison openssl-devel ncurses-devel -y<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># unzip gcc-11.zip<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd gcc-11\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># yum install *.rpm -y<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># source \/opt\/rh\/devtoolset-11\/enable<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># gcc &#8211;version<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"51\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce309c8.png\" width=\"595\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cat \/opt\/rh\/devtoolset-11\/enable &gt;&gt; ~\/.bash_profile<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># gcc -v<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim \/etc\/yum.repos.d\/rhel7.repo<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"180\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce4182a.png\" width=\"607\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># tar zxf cmake3.tar.gz<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd make3\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># rpm -ivh *.rpm &#8211;nodeps &#8211;force<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cmake3 &#8211;version<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce55037.png\" width=\"462\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5mysql<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd <\/span><span style=\"color:#000000\">\/mnt\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># du -sh mysql-boost-8.0.40.tar.gz<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce669a8.png\" width=\"641\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># tar zxf mysql-boost-8.0.40.tar.gz<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd mysql-8.0.40\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mkdir -p build<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd build\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \u00a0cmake3 \u00a0.. -DCMAKE_INSTALL_PREFIX&#061;\/usr\/local\/mysql -DMYSQL_DATADIR&#061;\/data\/mysql -DMYSQL_UNIX_ADDR&#061;\/data\/mysql\/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE&#061;1 -DWITH_EXTRA_CHARSETS&#061;all -DWITH_SSL&#061;system -DDEFAULT_CHARSET&#061;utf8mb4 -DDEFAULT_COLLATION&#061;utf8mb4_unicode_ci -DWITH_DEBUG&#061;OFF<\/span>\u00a0<span style=\"color:#000000\">\u00a0-DWITH_BOOST&#061;\/<\/span><span style=\"color:#000000\">mnt<\/span><span style=\"color:#000000\">\/mysql-8.0.40\/boost\/boost_1_77_0\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># make -j<\/span><span style=\"color:#000000\">4<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># make install<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">du -sh \/usr\/local\/mysql<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce78b85.png\" width=\"549\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">\u90e8\u7f72mysql<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlA ]<\/span><span style=\"color:#000000\"># cd \/usr\/local\/mysql\/support-files\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cp -p mysql.server \/etc\/init.d\/mysqld<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim ~\/.bash_profile<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"26\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce8b428.png\" width=\"539\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># source ~\/.bash_profile<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql &#8211;version<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"48\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce9b806.png\" width=\"687\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># systemctl disable &#8211;now firewalld.service<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010\u5173\u706b\u5899\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># useradd -M -s \/sbin\/nologin mysql<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mkdir <\/span><span style=\"color:#000000\">-p <\/span><span style=\"color:#000000\">\/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># chown mysql.mysql \/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span>\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">MySQL \u7684\u4e3b\u914d\u7f6e\u6587\u4ef6<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">[mysqld]<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">server-id&#061;10<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#<\/span><span style=\"color:#000000\">\u8bbe\u7f6e\u670d\u52a1\u5668\u552f\u4e00\u6807\u8bc6<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">datadir&#061;\/data\/mysql \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u6307\u5b9a\u6570\u636e\u76ee\u5f55<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">socket&#061;\/data\/mysql\/mysql.sock <\/span>\u00a0<span style=\"color:#000000\">\u00a0\u00a0#\u6307\u5b9a\u5957\u63a5\u5b57<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">default_authentication_plugin&#061;mysql_native_password<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0#<\/span><span style=\"color:#000000\">\u8bbe\u7f6e\u9ed8\u8ba4\u8ba4\u8bc1\u63d2\u4ef6<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6570\u636e\u5e93\u521d\u59cb\u5316\u5efa\u7acbmysql<\/span><span style=\"color:#ee822f\">\u57fa\u672c\u6570\u636e <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysqld &#8211;initialize &#8211;user&#061;mysql <\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">\u521d\u59cb\u5316 MySQL \u6570\u636e\u76ee\u5f55<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ceac5ad.png\" width=\"682\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld start <\/span>\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">\u542f\u52a8 MySQL \u670d\u52a1<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># chkconfig mysqld on<\/span>\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">\u00a0\u8bbe\u7f6e MySQL \u5f00\u673a\u81ea\u542f<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql_secure_installation<\/span>\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010\u6570\u636e\u5e93\u5b89\u5168\u521d\u59cb\u5316\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"128\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94cebdaa9.png\" width=\"382\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">mysql -uroot -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; SHOW DATABASES;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"208\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ced1617.png\" width=\"256\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">mysql\u7f16\u8bd1\u590d\u5236<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlB ]<\/span><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">scp -r root&#064;172.25.254.10:\/usr\/local\/mysql<\/span><span style=\"color:#000000\">\/<\/span><span style=\"color:#000000\">\u00a0\/usr\/local\/<\/span>\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u3010\u590d\u5236\u5185\u5bb9\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># useradd -M -s \/sbin\/nologin mysql<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mkdir <\/span><span style=\"color:#000000\">-p <\/span><span style=\"color:#000000\">\/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># chown mysql.mysql \/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/usr\/local\/mysql\/bin\/mysqld &#8211;initialize &#8211;user&#061;mysql<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span>\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">MySQL \u7684\u4e3b\u914d\u7f6e\u6587\u4ef6<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94cee2ccc.png\" width=\"185\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd \/usr\/local\/mysql\/support-files\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cp -p mysql.server \/etc\/init.d\/mysqld<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">\/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># chkconfig mysqld on<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql_secure_installation<\/span>\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010\u6570\u636e\u5e93\u5b89\u5168\u521d\u59cb\u5316&#xff0c;\u76f8\u540c\u7684\u914d\u7f6e\u3011<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">mysql\u7684\u7ec4\u4ece\u590d\u5236<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlA ]<\/span><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0log-bin<\/span><span style=\"color:#000000\">&#061;mysql-bin<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0#\u6dfb\u52a0\u5185\u5bb9&#xff0c;<\/span><span style=\"color:#000000\">\u542f\u7528binlog<\/span><span style=\"color:#000000\">&#xff0c;\u751f\u6210\u65e5\u5fd7\u6587\u4ef6<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld restart<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; CREATE USER lee&#064;<\/span><span style=\"color:#000000\">&#039;%&#039; IDENTIFIED WITH caching_sha2_password BY &#039;lee&#039;; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; GRANT REPLICATION SLAVE ON *.* TO &#039;<\/span><span style=\"color:#000000\">lee<\/span><span style=\"color:#000000\">&#039;&#064;&#039;%&#039;;<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u5bf9\u8fd9\u4e2a\u7528\u6237\u8fdb\u884c\u6388\u6743 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; show grants for lee&#064;&#039;%&#039;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ceef987.png\" width=\"464\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; SHOW MASTER STATUS;<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u67e5\u770b\u4fe1\u606f<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"128\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf0c3b4.png\" width=\"645\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd \/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysqlbinlog mysql-bin.000001 -vv \u00a0\u00a0<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u3010\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf1e293.png\" width=\"686\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u914d\u7f6esalve1<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlB ]<\/span><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span>\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">MySQL \u7684\u4e3b\u914d\u7f6e\u6587\u4ef6<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf2f8c8.png\" width=\"185\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">\/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt;<\/span><span style=\"color:#000000\">CHANGE MASTER TO MASTER_HOST&#061;&#039;172.25.254.10&#039;, MASTER_USER&#061;&#039;<\/span><span style=\"color:#000000\">lee<\/span><span style=\"color:#000000\">&#039;, MASTER_PASSWORD&#061;&#039;lee&#039;, MASTER_LOG_FILE&#061;&#039;<\/span><span style=\"color:#00b0f0\">mysql-bin.000001<\/span><span style=\"color:#000000\">&#039;, MASTER_LOG_POS&#061;<\/span><span style=\"color:#00b050\">691<\/span><span style=\"color:#000000\">;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; SELECT &#064;&#064;server_uuid;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf3d264.png\" width=\"674\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt;<\/span><span style=\"color:#000000\">start slave;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf4ddad.png\" width=\"444\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">#\u5982\u679c\u4e0a\u8ff0\u5185\u5bb9\u8f93\u5165\u9519\u8bef\u53ef\u4ee5reset<\/span><span style=\"color:#000000\">\u91cd\u65b0\u586b\u5165\u4fe1\u606f\u5373\u53ef <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; RESET SLAVE ALL;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlA ]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; CREATE DATABASE lee;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">CREATE TABLE lee.userlist (<\/span>\u00a0<span style=\"color:#000000\">username varchar(20) not null, password varchar(50) not null );<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">INSERT INTO lee.userlist VALUE (&#039;lee&#039;,&#039;123&#039;);<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">SELECT * FROM lee.userlist;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlB ]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; SELECT * FROM lee.userlist;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"103\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf5e912.png\" width=\"455\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u5f53\u6709\u6570\u636e\u65f6\u6dfb\u52a0slave2<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">scp -r \/usr\/local\/mysql<\/span>\u00a0<span style=\"color:#000000\">root&#064;172.25.254.<\/span><span style=\"color:#000000\">3<\/span><span style=\"color:#000000\">0:\/usr\/local\/mysql <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span>\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010<\/span><span style=\"color:#000000\">MySQL \u7684\u4e3b\u914d\u7f6e\u6587\u4ef6<\/span><span style=\"color:#000000\">\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf732a8.png\" width=\"201\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld restart<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlb ]<\/span><span style=\"color:#000000\"># mysqldump -uroot -plee lee &gt; \/mnt\/lee.sql \u00a0\u00a0\u00a0<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u3010\u6570\u636e\u5907\u4efd\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u751f\u4ea7\u73af\u5883\u4e2d\u5907\u4efd\u65f6\u9700\u8981\u9501\u8868&#xff0c;\u4fdd\u8bc1\u5907\u4efd\u524d\u540e\u7684\u6570\u636e\u4e00\u81f4 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; FLUSH TABLES WITH READ LOCK; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u5907\u4efd\u540e\u518d\u89e3\u9501 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; UNLOCK TABLES; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysqldump<\/span><span style=\"color:#000000\">\u547d\u4ee4\u5907\u4efd\u7684\u6570\u636e\u6587\u4ef6&#xff0c;\u5728\u8fd8\u539f\u65f6\u5148<\/span><span style=\"color:#000000\">DROP TABLE<\/span><span style=\"color:#000000\">&#xff0c;\u9700\u8981\u5408\u5e76\u6570\u636e\u65f6\u8981\u5220\u9664\u6b64\u8bed\u53e5<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlc ]<\/span><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">scp -r root&#064;172.25.254.10:<\/span><span style=\"color:#000000\">\/mnt\/<\/span><span style=\"color:#000000\">lee.sql<\/span>\u00a0<span style=\"color:#000000\">\/mnt\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -uroot -plee -e &#034;create database lee;&#034; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -uroot -p lee &lt;<\/span><span style=\"color:#000000\">\u00a0\/mnt\/<\/span><span style=\"color:#000000\">lee.sql <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -uroot -plee -e &#034;select * from lee.userlist;&#034;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; SELECT * FROM lee.userlist;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020047-689e94cf80488.png\" width=\"333\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u914d\u7f6eslave2\u7684<\/span><span style=\"color:#ee822f\">slave<\/span><span style=\"color:#ee822f\">\u529f\u80fd<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">mysql -uroot -plee -e &#034;SHOW MASTER STATUS;&#034;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"110\" src=\"2025-08-15v0k0mx24rfv.png\" width=\"692\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqlc ]<\/span><span style=\"color:#000000\"># mysql -uroot -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">mysql&gt; CHANGE REPLICATION SOURCE TO SOURCE_HOST&#061;&#039;172.25.254.10&#039;, SOURCE_USER&#061;&#039;lee&#039;, SOURCE_PASSWORD&#061;&#039;lee&#039;,SOURCE_LOG_FILE&#061;&#039;mysql-bin.000002&#039;,SOURCE_LOG_POS&#061;872, SOURCE_SSL&#061;0,GET_SOURCE_PUBLIC_KEY&#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">mysql&gt; start slave; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">mysql&gt; SELECT * FROM lee.userlist;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"90\" src=\"2025-08-15dgfjmrqhhxn.png\" width=\"352\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">mysql&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"123\" src=\"2025-08-15tjsm40n4hlm.png\" width=\"482\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># mysql -uroot -plee -e &#034;INSERT INTO lee.userlist<\/span>\u00a0<span style=\"color:#000000\">VALUES(&#039;user3&#039;,&#039;123&#039;);&#034;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlc ]<\/span><span style=\"color:#000000\"># mysql -uroot -plee -e &#039;select * from lee.userlist;&#039;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"102\" src=\"2025-08-15hp3k4ztaamu.png\" width=\"592\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">\u6162\u67e5\u8be2\u65e5\u5fd7<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u6162\u67e5\u8be2&#xff0c;\u987e\u540d\u601d\u4e49&#xff0c;\u6267\u884c\u5f88\u6162\u7684\u67e5\u8be2 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u5f53\u6267\u884c<\/span><span style=\"color:#000000\">SQL<\/span><span style=\"color:#000000\">\u8d85\u8fc7<\/span><span style=\"color:#000000\">long_query_time<\/span><span style=\"color:#000000\">\u53c2\u6570\u8bbe\u5b9a\u7684\u65f6\u95f4\u9608\u503c&#xff08;\u9ed8\u8ba4<\/span><span style=\"color:#000000\">10s<\/span><span style=\"color:#000000\">&#xff09;\u65f6&#xff0c;\u5c31\u88ab\u8ba4\u4e3a\u662f\u6162\u67e5\u8be2&#xff0c;\u8fd9\u4e2a<\/span><span style=\"color:#000000\">SQL<\/span><span style=\"color:#000000\">\u8bed\u53e5\u5c31\u662f\u9700\u8981\u4f18\u5316\u7684 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u6162\u67e5\u8be2\u88ab\u8bb0\u5f55\u5728\u6162\u67e5\u8be2\u65e5\u5fd7\u91cc <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u6162\u67e5\u8be2\u65e5\u5fd7\u9ed8\u8ba4\u662f\u4e0d\u5f00\u542f\u7684 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u5982\u679c\u9700\u8981\u4f18\u5316<\/span><span style=\"color:#000000\">SQL<\/span><span style=\"color:#000000\">\u8bed\u53e5&#xff0c;\u5f00\u542f\u8fd9\u529f\u80fd&#xff0c;\u5b83\u53ef\u4ee5\u8ba9\u4f60\u5f88\u5bb9\u6613\u5730\u77e5\u9053\u54ea\u4e9b\u8bed\u53e5\u662f\u9700\u8981\u4f18\u5316\u7684\u3002<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW variables like &#034;slow%&#034;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"128\" src=\"2025-08-15eozt3qpfdaa.png\" width=\"481\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u5f00\u542f\u6162\u67e5\u8be2\u65e5\u5fd7<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET GLOBAL slow_query_log&#061;ON;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET long_query_time&#061;4;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW VARIABLES like &#034;long%&#034;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"2025-08-15ehvjavrieiu.png\" width=\"341\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW VARIABLES like &#034;slow%&#034;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-15pg1phqlvcqx.png\" width=\"566\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6d4b\u8bd5\u6162\u67e5\u8be2<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; select sleep (<\/span><span style=\"color:#000000\">6<\/span><span style=\"color:#000000\">);<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># cat \/data\/mysql\/mysqla-slow.log<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u3010\u6162\u67e5\u8be2\u65e5\u5fd7\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-15az3zzks3vuo.png\" width=\"330\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:left\"><span style=\"color:#0070c0\">mysql\u7684\u5e76\u884c\u590d\u5236<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">\u67e5\u770bslave\u4e2d\u7684\u7ebf\u7a0b\u4fe1\u606f<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqlb ~]<\/span>\u00a0\u00a0<span style=\"color:#000000\">&gt; show processlist;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"180\" src=\"2025-08-15xo45t5w4l0u.png\" width=\"218\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">\u9ed8\u8ba4\u60c5\u51b5\u4e0bslave\u4e2d\u4f7f\u7528\u7684\u662f<\/span><span style=\"color:#000000\">sql<\/span><span style=\"color:#000000\">\u5355\u7ebf\u7a0b\u56de\u653e <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">\u5728<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u4e2d\u65f6\u591a\u7528\u6237\u8bfb\u5199&#xff0c;\u5982\u679c\u4f7f\u7528<\/span><span style=\"color:#000000\">sql<\/span><span style=\"color:#000000\">\u5355\u7ebf\u7a0b\u56de\u653e\u90a3\u4e48\u4f1a\u9020\u6210\u7ec4\u4ece\u5ef6\u8fdf\u4e25\u91cd <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">\u5f00\u542f<\/span><span style=\"color:#000000\">MySQL<\/span><span style=\"color:#000000\">\u7684\u591a\u7ebf\u7a0b\u56de\u653e\u53ef\u4ee5\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">slave-parallel-type&#061;LOGICAL_CLOCK <\/span>\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#\u57fa\u4e8e\u7ec4\u63d0\u4ea4&#xff0c; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">slave-parallel-workers&#061;6<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0#<\/span><span style=\"color:#000000\">\u5f00\u542f\u7ebf\u7a0b\u6570\u91cf <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">relay_log_recovery&#061;ON <\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u65e5\u5fd7\u56de\u653e\u6062\u590d\u529f\u80fd\u5f00\u542f<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld restart<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#7030a0\">&gt; show processlist;<\/span><span style=\"color:#7030a0\">\u00a0\u00a0\u00a0## \u67e5\u770b\u7ed3\u679c&#xff1a;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"204\" src=\"2025-08-15j04cdqhnyru.png\" width=\"421\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u4e09\u4e2a\u7ebf\u7a0b <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5b9e\u9645\u4e0a\u4e3b\u4ece\u540c\u6b65\u7684\u539f\u7406\u5c31\u662f\u57fa\u4e8e binlog <\/span><span style=\"color:#000000\">\u8fdb\u884c\u6570\u636e\u540c\u6b65\u7684\u3002\u5728\u4e3b\u4ece\u590d\u5236\u8fc7\u7a0b\u4e2d&#xff0c;\u4f1a\u57fa\u4e8e<\/span><span style=\"color:#000000\">3 <\/span><span style=\"color:#000000\">\u4e2a\u7ebf\u7a0b\u6765\u64cd\u4f5c&#xff0c;\u4e00\u4e2a\u4e3b\u5e93\u7ebf\u7a0b&#xff0c;\u4e24\u4e2a\u4ece\u5e93\u7ebf\u7a0b\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8f6c\u50a8\u7ebf\u7a0b&#xff08;<\/span><span style=\"color:#000000\">Binlog dump thread<\/span><span style=\"color:#000000\">&#xff09;\u662f\u4e00\u4e2a\u4e3b\u5e93\u7ebf\u7a0b\u3002\u5f53\u4ece\u5e93\u7ebf\u7a0b\u8fde\u63a5\u7684\u65f6\u5019&#xff0c; \u4e3b\u5e93\u53ef\u4ee5\u5c06\u4e8c\u8fdb\u5236\u65e5\u5fd7\u53d1\u9001\u7ed9\u4ece\u5e93&#xff0c;\u5f53\u4e3b\u5e93\u8bfb\u53d6\u4e8b\u4ef6&#xff08;<\/span><span style=\"color:#000000\">Event<\/span><span style=\"color:#000000\">&#xff09;\u7684\u65f6\u5019&#xff0c;\u4f1a\u5728<\/span><span style=\"color:#000000\">\u00a0Binlog <\/span><span style=\"color:#000000\">\u4e0a\u52a0\u9501&#xff0c;\u8bfb\u53d6\u5b8c\u6210\u4e4b\u540e&#xff0c;\u518d\u5c06\u9501\u91ca\u653e\u6389\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4ece\u5e93<\/span><span style=\"color:#000000\">\u00a0I\/O <\/span><span style=\"color:#000000\">\u7ebf\u7a0b\u4f1a\u8fde\u63a5\u5230\u4e3b\u5e93&#xff0c;\u5411\u4e3b\u5e93\u53d1\u9001\u8bf7\u6c42\u66f4\u65b0<\/span><span style=\"color:#000000\">\u00a0Binlog<\/span><span style=\"color:#000000\">\u3002\u8fd9\u65f6\u4ece\u5e93\u7684<\/span><span style=\"color:#000000\">\u00a0I\/O <\/span><span style=\"color:#000000\">\u7ebf\u7a0b\u5c31\u53ef\u4ee5\u8bfb\u53d6\u5230\u4e3b\u5e93\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8f6c\u50a8\u7ebf\u7a0b\u53d1\u9001\u7684<\/span><span style=\"color:#000000\">\u00a0Binlog <\/span><span style=\"color:#000000\">\u66f4\u65b0\u90e8\u5206&#xff0c;\u5e76\u4e14\u62f7\u8d1d\u5230\u672c\u5730\u7684\u4e2d\u7ee7\u65e5\u5fd7 &#xff08;<\/span><span style=\"color:#000000\">Relay log<\/span><span style=\"color:#000000\">&#xff09;\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4ece\u5e93<\/span><span style=\"color:#000000\">\u00a0SQL <\/span><span style=\"color:#000000\">\u7ebf\u7a0b\u4f1a\u8bfb\u53d6\u4ece\u5e93\u4e2d\u7684\u4e2d\u7ee7\u65e5\u5fd7&#xff0c;\u5e76\u4e14\u6267\u884c\u65e5\u5fd7\u4e2d\u7684\u4e8b\u4ef6&#xff0c;\u5c06\u4ece\u5e93\u4e2d\u7684\u6570\u636e\u4e0e\u4e3b\u5e93\u4fdd\u6301\u540c\u6b65\u3002 <\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u590d\u5236\u4e09\u6b65\u9aa4<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u6b65\u9aa41<\/span><span style=\"color:#000000\">&#xff1a;<\/span><span style=\"color:#000000\">Master<\/span><span style=\"color:#000000\">\u5c06\u5199\u64cd\u4f5c\u8bb0\u5f55\u5230\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff08;<\/span><span style=\"color:#000000\">binlog<\/span><span style=\"color:#000000\">&#xff09;\u3002<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u6b65\u9aa4<\/span><span style=\"color:#000000\">2<\/span><span style=\"color:#000000\">&#xff1a;<\/span><span style=\"color:#000000\">Slave<\/span><span style=\"color:#000000\">\u5c06<\/span><span style=\"color:#000000\">Master<\/span><span style=\"color:#000000\">\u7684<\/span><span style=\"color:#000000\">binary log events<\/span><span style=\"color:#000000\">\u62f7\u8d1d\u5230\u5b83\u7684\u4e2d\u7ee7\u65e5\u5fd7&#xff08;<\/span><span style=\"color:#000000\">relay log<\/span><span style=\"color:#000000\">&#xff09;&#xff1b; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u6b65\u9aa4<\/span><span style=\"color:#000000\">3<\/span><span style=\"color:#000000\">&#xff1a;<\/span><span style=\"color:#000000\">Slave<\/span><span style=\"color:#000000\">\u91cd\u505a\u4e2d\u7ee7\u65e5\u5fd7\u4e2d\u7684\u4e8b\u4ef6&#xff0c;\u5c06\u6539\u53d8\u5e94\u7528\u5230\u81ea\u5df1\u7684\u6570\u636e\u5e93\u4e2d\u3002<\/span><span style=\"color:#000000\">\u00a0MySQL<\/span><span style=\"color:#000000\">\u590d\u5236\u662f\u5f02\u6b65\u7684\u4e14\u4e32\u884c\u5316\u7684&#xff0c;\u800c\u4e14\u91cd\u542f\u540e\u4ece\u63a5\u5165\u70b9\u5f00\u59cb\u590d\u5236\u3002 <\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u5177\u4f53\u64cd\u4f5c <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">1.slaves<\/span><span style=\"color:#000000\">\u7aef\u4e2d\u8bbe\u7f6e\u4e86<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u7684<\/span><span style=\"color:#000000\">ip<\/span><span style=\"color:#000000\">&#xff0c;\u7528\u6237&#xff0c;\u65e5\u5fd7&#xff0c;\u548c\u65e5\u5fd7\u7684<\/span><span style=\"color:#000000\">Position<\/span><span style=\"color:#000000\">&#xff0c;\u901a\u8fc7\u8fd9\u4e9b\u4fe1\u606f\u53d6\u5f97<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7684\u8ba4\u8bc1\u53ca\u4fe1\u606f <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">2.master<\/span><span style=\"color:#000000\">\u7aef\u5728\u8bbe\u5b9a\u597d<\/span><span style=\"color:#000000\">binlog<\/span><span style=\"color:#000000\">\u542f\u52a8\u540e\u4f1a\u5f00\u542f<\/span><span style=\"color:#000000\">binlog dump<\/span><span style=\"color:#000000\">\u7684\u7ebf\u7a0b <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">3.master<\/span><span style=\"color:#000000\">\u7aef\u7684<\/span><span style=\"color:#000000\">binlog dump<\/span><span style=\"color:#000000\">\u628a\u4e8c\u8fdb\u5236\u7684\u66f4\u65b0\u53d1\u9001\u5230<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef\u7684 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">4.slave<\/span><span style=\"color:#000000\">\u7aef\u5f00\u542f\u4e24\u4e2a\u7ebf\u7a0b&#xff0c;\u4e00\u4e2a\u662f<\/span><span style=\"color:#000000\">I\/O<\/span><span style=\"color:#000000\">\u7ebf\u7a0b&#xff0c;\u4e00\u4e2a\u662f<\/span><span style=\"color:#000000\">sql<\/span><span style=\"color:#000000\">\u7ebf\u7a0b&#xff0c; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">i\/o<\/span><span style=\"color:#000000\">\u7ebf\u7a0b\u7528\u4e8e\u63a5\u6536<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff0c;\u6b64\u7ebf\u7a0b\u4f1a\u5728\u672c\u5730\u6253\u5f00<\/span><span style=\"color:#000000\">relaylog<\/span><span style=\"color:#000000\">\u4e2d\u7ee7\u65e5\u5fd7&#xff0c;\u5e76\u4e14\u4fdd\u5b58\u5230\u672c\u5730\u78c1\u76d8 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">sql<\/span><span style=\"color:#000000\">\u7ebf\u7a0b\u8bfb\u53d6\u672c\u5730<\/span><span style=\"color:#000000\">relog<\/span><span style=\"color:#000000\">\u4e2d\u7ee7\u65e5\u5fd7\u8fdb\u884c\u56de\u653e <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">5.<\/span><span style=\"color:#000000\">\u4ec0\u4e48\u65f6\u5019\u6211\u4eec\u9700\u8981\u591a\u4e2a<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">&#xff1f; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53\u8bfb\u53d6\u7684\u800c\u64cd\u4f5c\u8fdc\u8fdc\u9ad8\u4e0e\u5199\u64cd\u4f5c\u65f6\u3002\u6211\u4eec\u91c7\u7528\u4e00\u4e3b\u591a\u4ece\u67b6\u6784 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6570\u636e\u5e93\u5916\u5c42\u63a5\u5165\u8d1f\u8f7d\u5747\u8861\u5c42\u5e76\u642d\u914d\u9ad8\u53ef\u7528\u673a\u5236<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#4874cb\">\u67b6\u6784\u7f3a\u9677 <\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u4e3b\u4ece\u67b6\u6784\u91c7\u7528\u7684\u662f\u5f02\u6b65\u673a\u5236 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0master\u66f4\u65b0\u5b8c\u6210\u540e\u76f4\u63a5\u53d1\u9001\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5230<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">&#xff0c;\u4f46\u662f<\/span><span style=\"color:#000000\">slaves<\/span><span style=\"color:#000000\">\u662f\u5426\u771f\u6b63\u4fdd\u5b58\u4e86\u6570\u636e<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u4e0d\u4f1a\u68c0\u6d4b<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u76f4\u63a5\u4fdd\u5b58\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5230\u78c1\u76d8 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u5f53<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u5230<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef\u7684\u7f51\u7edc\u51fa\u73b0\u95ee\u9898\u65f6\u6216\u8005<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u76f4\u63a5\u6302\u6389&#xff0c;\u4e8c\u8fdb\u5236\u65e5\u5fd7\u53ef\u80fd\u6839\u672c\u6ca1\u6709\u5230\u8fbe<\/span><span style=\"color:#000000\">slave<\/span>\u00a0<span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u51fa\u73b0\u95ee\u9898<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef\u63a5\u7ba1<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">&#xff0c;\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u6570\u636e\u5c31\u4e22\u5931\u4e86 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u8fd9\u6837\u7684\u95ee\u9898\u51fa\u73b0\u5c31\u65e0\u6cd5\u8fbe\u5230\u6570\u636e\u7684\u5f3a\u4e00\u81f4\u6027&#xff0c;\u96f6\u6570\u636e\u4e22\u5931<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#4874cb\">\u534a\u540c\u6b65\u6a21\u5f0f<\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"312\" src=\"2025-08-15a0ausucg4f4.png\" width=\"513\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">1.\u7528\u6237\u7ebf\u7a0b\u5199\u5165\u5b8c\u6210\u540e<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u4e2d\u7684<\/span><span style=\"color:#000000\">dump<\/span><span style=\"color:#000000\">\u4f1a\u628a\u65e5\u5fd7\u63a8\u9001\u5230<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">2.slave<\/span><span style=\"color:#000000\">\u4e2d\u7684<\/span><span style=\"color:#000000\">io<\/span><span style=\"color:#000000\">\u7ebf\u7a0b\u63a5\u6536\u540e\u4fdd\u5b58\u5230<\/span><span style=\"color:#000000\">relaylog<\/span><span style=\"color:#000000\">\u4e2d\u7ee7\u65e5\u5fd7 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">3.<\/span><span style=\"color:#000000\">\u4fdd\u5b58\u5b8c\u6210\u540e<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u5411<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u8fd4\u56de<\/span><span style=\"color:#000000\">ack <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">4.<\/span><span style=\"color:#000000\">\u5728\u672a\u63a5\u53d7\u5230<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7684<\/span><span style=\"color:#000000\">ack<\/span><span style=\"color:#000000\">\u65f6<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef\u65f6\u4e0d\u505a\u63d0\u4ea4\u7684&#xff0c;\u4e00\u76f4\u5904\u4e8e\u7b49\u5f85\u5f53\u6536\u5230<\/span><span style=\"color:#000000\">ack<\/span><span style=\"color:#000000\">\u540e\u63d0\u4ea4\u5230\u5b58\u50a8\u5f15\u64ce <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">5.<\/span><span style=\"color:#000000\">\u5728<\/span><span style=\"color:#000000\">5.6<\/span><span style=\"color:#000000\">\u7248\u672c\u4e2d\u7528\u5230\u7684<\/span><span style=\"color:#000000\">after_commit<\/span><span style=\"color:#000000\">\u6a21\u5f0f\u65f6\u5148\u63d0\u4ea4\u5728\u7b49\u5f85<\/span><span style=\"color:#000000\">ack<\/span><span style=\"color:#000000\">\u8fd4\u56de\u540e\u8f93\u51fa<\/span><span style=\"color:#000000\">ok<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">gtid\u6a21\u5f0f <\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u5f53\u4e3a\u542f\u7528gtid\u65f6\u6211\u4eec\u8981\u8003\u8651\u7684\u95ee\u9898 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5728master<\/span><span style=\"color:#000000\">\u7aef\u7684\u5199\u5165\u65f6\u591a\u7528\u6237\u8bfb\u5199&#xff0c;\u5728<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef\u7684\u590d\u5236\u65f6\u5355\u7ebf\u7a0b\u65e5\u5fd7\u56de\u653e&#xff0c;\u6240\u4ee5<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef\u4e00\u5b9a\u4f1a\u5ef6\u8fdf\u4e0e<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7aef <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u8fd9\u79cd\u5ef6\u8fdf\u5728<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u7aef\u7684\u5ef6\u8fdf\u53ef\u80fd\u4f1a\u4e0d\u4e00\u81f4&#xff0c;\u5f53<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u6302\u6389\u540e<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u63a5\u7ba1&#xff0c;\u4e00\u822c\u4f1a\u6311\u9009\u4e00\u4e2a\u548c<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u5ef6\u8fdf\u65e5\u5fd7\u6700\u63a5\u8fd1\u7684\u5145\u5f53\u65b0\u7684<\/span><span style=\"color:#000000\">master <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u90a3\u4e48\u4e3a\u63a5\u7ba1<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7684\u4e3b\u673a\u7ee7\u7eed\u5145\u5f53<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u89d2\u8272\u5e76\u4f1a\u6307\u5411\u5230\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u4e0a&#xff0c;\u4f5c\u4e3a\u5176<\/span><span style=\"color:#000000\">slave <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u8fd9\u65f6\u5019\u6309\u7167\u4e4b\u524d\u7684\u914d\u7f6e\u6211\u4eec\u9700\u8981\u77e5\u9053\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u4e0a\u7684<\/span><span style=\"color:#000000\">pos<\/span><span style=\"color:#000000\">\u7684<\/span><span style=\"color:#000000\">id<\/span><span style=\"color:#000000\">&#xff0c;\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u786e\u5b9a\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u548c<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u4e4b\u95f4\u5dee\u591a\u5c11<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">[mysqld] <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">datadir&#061;\/data\/mysql <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">socket&#061;\/data\/mysql\/mysql.sock <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">server-id&#061;1<\/span><span style=\"color:#000000\">0<\/span>\u00a0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">log-bin&#061;mysql-bin <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">gtid_mode&#061;ON <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">enforce-gtid-consistency&#061;ON<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># mysql -uroot -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; SHOW VARIABLES LIKE &#039;%gtid%&#039;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"156\" src=\"2025-08-15r4a3xchvb3u.png\" width=\"361\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">CREATE DATABASE gtid_test;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">USE gtid_test;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">CREATE TABLE test_table(id INT);<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">INSERT INTO test_table VALUES(1);<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">SHOW MASTER STATUS;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">SELECT * FROM mysql.gtid_executed;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-15aeemhvkemgx.png\" width=\"592\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqlb ]<\/span><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">[mysqld] <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">datadir&#061;\/data\/mysql <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">socket&#061;\/data\/mysql\/mysql.sock <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">server-id&#061;<\/span><span style=\"color:#000000\">20<\/span>\u00a0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">log-bin&#061;mysql-bin <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">gtid_mode&#061;ON <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">enforce-gtid-consistency&#061;ON<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># mysql -uroot -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; stop slave;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt;<\/span>\u00a0<span style=\"color:#000000\">RESET SLAVE ALL; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; <\/span><span style=\"color:#000000\">CHANGE MASTER TO MASTER_HOST&#061;&#039;172.25.254.10&#039;, MASTER_USER&#061;&#039;<\/span><span style=\"color:#000000\">lee<\/span><span style=\"color:#000000\">&#039;, MASTER_PASSWORD&#061;&#039;lee&#039;, MASTER_AUTO_POSITION&#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; START SLAVE;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"46\" src=\"2025-08-15wiqbzqo4myl.png\" width=\"370\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">\u542f\u7528\u534a\u540c\u6b65\u6a21\u5f0f <\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u5728master<\/span><span style=\"color:#000000\">\u7aef\u914d\u7f6e\u542f\u7528\u534a\u540c\u6b65\u6a21\u5f0f<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">rpl_semi_sync_master_enabled&#061;1<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0#\u5f00\u542f<\/span><span style=\"color:#ff0000\">\u4e3b\u5e93<\/span><span style=\"color:#000000\">\u534a\u540c\u6b65\u529f\u80fd<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -p lee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; INSTALL PLUGIN rpl_semi_sync_master SONAME &#039;semisync_master.so&#039;;<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0##\u914d\u7f6e\u534a\u540c\u6b65<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; show plugins;<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0##\u67e5\u770b\u534a\u540c\u6b65<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"48\" src=\"2025-08-15nsyipvaggkc.png\" width=\"692\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET GLOBAL rpl_semi_sync_master_enabled &#061; 1; <\/span><span style=\"color:#000000\">\u00a0\u00a0##\u8bbe\u5b9a\u5168\u5c40\u914d\u7f6e<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW VARIABLES LIKE &#039;rpl_semi_sync%&#039;; \u00a0<\/span><span style=\"color:#000000\">\u00a0##\u67e5\u770b\u534a\u540c\u6b65\u72b6\u6001<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"180\" src=\"2025-08-154cm0h3jfrff.png\" width=\"499\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW STATUS LIKE &#039;Rpl_semi_sync%&#039;; <\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0##\u67e5\u770b\u540c\u6b65<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u5728slave\u7aef\u5f00\u542f\u534a\u540c\u6b65\u529f\u80fd<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysql (b\u548cc) ]<\/span><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">rpl_semi_sync_selave_enabled&#061;1 \u00a0\u00a0\u00a0\u00a0\u00a0#\u5f00\u542f<\/span><span style=\"color:#ff0000\">\u4ece\u5e93<\/span><span style=\"color:#000000\">\u534a\u540c\u6b65\u529f\u80fd<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; INSTALL PLUGIN rpl_semi_sync_slave SONAME &#039;semisync_slave.so&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET GLOBAL rpl_semi_sync_slave_enabled &#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW VARIABLES LIKE &#039;rpl_semi_sync%&#039;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"2025-08-1552tm3fn1hfa.png\" width=\"372\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; STOP SLAVE IO_THREAD; <\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#\u91cd\u542fio<\/span><span style=\"color:#000000\">\u7ebf\u7a0b&#xff0c;\u534a\u540c\u6b65\u624d\u80fd\u751f\u6548<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; START SLAVE IO_THREAD;<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0##\u91cd\u542fio<\/span><span style=\"color:#000000\">\u7ebf\u7a0b&#xff0c;\u534a\u540c\u6b65\u624d\u80fd\u751f\u6548<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW STATUS LIKE &#039;Rpl_semi_sync%&#039;;<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0#<\/span><span style=\"color:#000000\">#\u67e5\u770b\u534a\u540c\u6b65\u662f\u5426\u5f00\u542f<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"114\" src=\"2025-08-15n5snjaxcdvi.png\" width=\"465\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">#\u67e5\u770b\u540c\u6b65<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-15nuj21upknek.png\" width=\"417\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6d4b\u8bd5\u5728master\u7aef\u5199\u5165\u6570\u636e<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; insert into lee.userlist values (&#039;user4&#039;,&#039;123&#039;);<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0#<\/span><span style=\"color:#000000\">#\u8f93\u5165\u5185\u5bb9<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW STATUS LIKE &#039;Rpl_semi_sync%&#039;;<\/span>\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0#<\/span><span style=\"color:#000000\">#\u67e5\u770b\u72b6\u6001<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"284\" src=\"2025-08-15srlvtsu1rbb.png\" width=\"403\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6a21\u62df\u6545\u969c<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysql (b\u548cc) ]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; STOP SLAVE IO_THREAD;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; insert into lee.userlist values (&#039;user5&#039;,&#039;555&#039;);<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-15snkkiy4axdk.png\" width=\"627\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW STATUS LIKE &#039;Rpl_semi%&#039;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"156\" src=\"2025-08-15sgt3fqgw5wy.png\" width=\"446\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">mysql\u9ad8\u53ef\u7528\u4e4b\u7ec4\u590d\u5236<\/span><span style=\"color:#0070c0\">\u00a0(MGR) <\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MySQL Group Replication(\u7b80\u79f0<\/span><span style=\"color:#000000\">\u00a0MGR )<\/span><span style=\"color:#000000\">\u662f<\/span><span style=\"color:#000000\">\u00a0MySQL <\/span><span style=\"color:#000000\">\u5b98\u65b9\u4e8e<\/span><span style=\"color:#000000\">\u00a02016 <\/span><span style=\"color:#000000\">\u5e74<\/span><span style=\"color:#000000\">\u00a012 <\/span><span style=\"color:#000000\">\u6708\u63a8\u51fa\u7684\u4e00\u4e2a\u5168\u65b0\u7684\u9ad8\u53ef\u7528\u4e0e\u9ad8\u6269\u5c55\u7684\u89e3\u51b3\u65b9\u6848 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u7ec4\u590d\u5236\u662f<\/span><span style=\"color:#000000\">\u00a0MySQL 5.7.17 <\/span><span style=\"color:#000000\">\u7248\u672c\u51fa\u73b0\u7684\u65b0\u7279\u6027&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u9ad8\u53ef\u7528\u3001\u9ad8\u6269\u5c55\u3001\u9ad8\u53ef\u9760\u7684<\/span><span style=\"color:#000000\">\u00a0MySQL <\/span><span style=\"color:#000000\">\u96c6\u7fa4\u670d\u52a1<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MySQL <\/span><span style=\"color:#000000\">\u7ec4\u590d\u5236\u5206\u5355\u4e3b\u6a21\u5f0f\u548c\u591a\u4e3b\u6a21\u5f0f&#xff0c;\u4f20\u7edf<\/span><span style=\"color:#000000\">mysql<\/span><span style=\"color:#000000\">\u590d\u5236\u6280\u672f\u4ec5\u89e3\u51b3\u4e86\u6570\u636e\u540c\u6b65\u7684\u95ee\u9898 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MGR <\/span><span style=\"color:#000000\">\u5bf9\u5c5e\u4e8e\u540c\u4e00\u7ec4\u7684\u670d\u52a1\u5668\u81ea\u52a8\u8fdb\u884c\u534f\u8c03\u3002\u5bf9\u4e8e\u8981\u63d0\u4ea4\u7684\u4e8b\u52a1&#xff0c;\u7ec4\u6210\u5458\u5fc5\u987b\u5c31\u5168\u5c40\u4e8b\u52a1\u5e8f\u5217\u4e2d\u7ed9\u5b9a\u4e8b\u52a1\u7684\u987a\u5e8f\u8fbe\u6210\u4e00\u81f4 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u7531\u6bcf\u4e2a\u670d\u52a1\u5668\u5355\u72ec\u5b8c\u6210&#xff0c;\u4f46\u6240\u6709\u670d\u52a1\u5668\u90fd\u5fc5\u987b\u505a\u51fa\u76f8\u540c\u7684\u51b3\u5b9a <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5982\u679c\u5b58\u5728\u7f51\u7edc\u5206\u533a&#xff0c;\u5bfc\u81f4\u6210\u5458\u65e0\u6cd5\u8fbe\u6210\u4e8b\u5148\u5b9a\u4e49\u7684\u5206\u5272\u7b56\u7565&#xff0c;\u5219\u5728\u89e3\u51b3\u6b64\u95ee\u9898\u4e4b\u524d\u7cfb\u7edf\u4e0d\u4f1a\u7ee7\u7eed\u8fdb\u884c&#xff0c;\u8fd9\u662f\u4e00\u79cd\u5185\u7f6e\u7684\u81ea\u52a8\u88c2\u8111\u4fdd\u62a4\u673a\u5236 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MGR<\/span><span style=\"color:#000000\">\u7531\u7ec4\u901a\u4fe1\u7cfb\u7edf<\/span><span style=\"color:#000000\">( <\/span><span style=\"color:#000000\">Group Communication System &#xff0c;<\/span><span style=\"color:#000000\">GCS ) <\/span><span style=\"color:#000000\">\u534f\u8bae\u652f\u6301 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u8be5\u7cfb\u7edf\u63d0\u4f9b\u6545\u969c\u68c0\u6d4b\u673a\u5236\u3001\u7ec4\u6210\u5458\u670d\u52a1\u4ee5\u53ca\u5b89\u5168\u4e14\u6709\u5e8f\u7684\u6d88\u606f\u4f20\u9012<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u7ec4\u590d\u5236\u6d41\u7a0b<\/span><\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"232\" src=\"2025-08-15ray1a4uyzs4.png\" width=\"559\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u9996\u5148\u6211\u4eec\u5c06\u591a\u4e2a\u8282\u70b9\u5171\u540c\u7ec4\u6210\u4e00\u4e2a\u590d\u5236\u7ec4&#xff0c;\u5728\u6267\u884c\u8bfb\u5199&#xff08;RW<\/span><span style=\"color:#000000\">&#xff09;\u4e8b\u52a1\u7684\u65f6\u5019&#xff0c;\u9700\u8981\u901a\u8fc7\u4e00\u81f4\u6027\u534f\u8bae\u5c42&#xff08;<\/span><span style=\"color:#000000\">Consensus <\/span><span style=\"color:#000000\">\u5c42&#xff09;\u7684\u540c\u610f&#xff0c;\u4e5f\u5c31\u662f\u8bfb\u5199\u4e8b\u52a1\u60f3\u8981\u8fdb\u884c\u63d0\u4ea4&#xff0c;\u5fc5\u987b\u8981\u7ecf\u8fc7\u7ec4\u91cc<\/span><span style=\"color:#000000\">\u201c<\/span><span style=\"color:#000000\">\u5927\u591a\u6570\u4eba<\/span><span style=\"color:#000000\">\u201d<\/span><span style=\"color:#000000\">&#xff08;\u5bf9\u5e94<\/span><span style=\"color:#000000\">\u00a0Node <\/span><span style=\"color:#000000\">\u8282\u70b9&#xff09;\u7684\u540c\u610f&#xff0c;\u5927\u591a\u6570\u6307\u7684\u662f\u540c\u610f\u7684\u8282\u70b9\u6570\u91cf\u9700\u8981\u5927\u4e8e &#xff08;<\/span><span style=\"color:#000000\">N\/2&#043;1<\/span><span style=\"color:#000000\">&#xff09;&#xff0c;\u8fd9\u6837\u624d\u53ef\u4ee5\u8fdb\u884c\u63d0\u4ea4&#xff0c;\u800c\u4e0d\u662f\u539f\u53d1\u8d77\u65b9\u4e00\u4e2a\u8bf4\u4e86\u7b97\u3002\u800c\u9488\u5bf9\u53ea\u8bfb&#xff08;<\/span><span style=\"color:#000000\">RO<\/span><span style=\"color:#000000\">&#xff09;\u4e8b\u52a1\u5219\u4e0d\u9700\u8981\u7ecf\u8fc7\u7ec4\u5185\u540c\u610f&#xff0c;\u76f4\u63a5 \u63d0\u4ea4 \u5373\u53ef<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">\u7ec4\u590d\u5236\u5355\u4e3b\u548c\u591a\u4e3b\u6a21\u5f0f<\/span><\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">single-primary mode(\u5355\u5199\u6216\u5355\u4e3b\u6a21\u5f0f) <\/span><\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"208\" src=\"2025-08-15bnvi1koguiq.png\" width=\"660\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5355\u5199\u6a21\u5f0f group <\/span><span style=\"color:#000000\">\u5185\u53ea\u6709\u4e00\u53f0\u8282\u70b9\u53ef\u5199\u53ef\u8bfb&#xff0c;\u5176\u4ed6\u8282\u70b9\u53ea\u53ef\u4ee5\u8bfb\u3002\u5f53\u4e3b\u670d\u52a1\u5668\u5931\u8d25\u65f6&#xff0c;\u4f1a\u81ea\u52a8\u9009\u62e9\u65b0\u7684\u4e3b\u670d\u52a1\u5668<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">multi-primary mode(\u591a\u5199\u6216\u591a\u4e3b\u6a21\u5f0f) <\/span><\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"208\" src=\"2025-08-15jycahiyr0nx.png\" width=\"659\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u7ec4\u5185\u7684\u6240\u6709\u673a\u5668\u90fd\u662f primary <\/span><span style=\"color:#000000\">\u8282\u70b9&#xff0c;\u540c\u65f6\u53ef\u4ee5\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c&#xff0c;\u5e76\u4e14\u6570\u636e\u662f\u6700\u7ec8\u4e00\u81f4\u7684\u3002<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">\u5b9e\u73b0mysql\u7ec4<\/span><span style=\"color:#0070c0\">\u590d\u5236<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u4e3a\u4e86\u907f\u514d\u51fa\u9519&#xff0c;\u5728\u6240\u6709\u8282\u70b9\u4e2d\u4ece\u65b0\u751f\u6210\u6570\u636e\u5e93\u6570\u636e<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u7f16\u8f91\u4e3b\u914d\u7f6e\u6587\u4ef6<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">\u6240\u6709mysql ]<\/span><span style=\"color:#000000\"># vim \/etc\/hosts<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-15svdiz44wxlg.png\" width=\"505\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># rm -fr \/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">[mysqld]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">server-id&#061;10<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">datadir&#061;\/data\/mysql<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">socket&#061;\/data\/mysql\/mysql.sock<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">default_authentication_plugin&#061;mysql_native_password<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">log-bin&#061;mysql-bin<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">gtid_mode&#061;ON<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">enforce-gtid-consistency&#061;ON<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">disabled_storage_engines&#061;&#034;MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY&#034; #\u7981\u7528\u6307\u5b9a\u5b58\u50a8\u5f15\u64ce<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">binlog_checksum&#061;NONE \u00a0\u00a0\u00a0#\u7981\u6b62\u5bf9\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6821\u9a8c<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">log_slave_updates&#061;ON \u00a0\u00a0\u00a0#\u6253\u5f00\u6570\u636e\u5e93\u4e2d\u7ee7&#xff0c;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">binlog_format&#061;ROW \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u4f7f\u7528\u884c\u65e5\u5fd7\u683c\u5f0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">transaction_write_set_extraction&#061;XXHASH64\u00a0\u00a0\u00a0\u00a0\u00a0#\u628a\u6bcf\u4e2a\u4e8b\u4ef6\u7f16\u7801\u4e3a\u52a0\u5bc6\u6563\u5217<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysqld &#8211;user&#061;mysql &#8211;initialize <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">##\u6dfb\u52a0\u5185\u5bb9<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">plugin_load_add&#061;&#039;group_replication.so&#039; #\u52a0\u8f7d\u7ec4\u590d\u5236\u63d2\u4ef6<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_group_name&#061;&#034;aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa&#034; #\u901a\u77e5\u63d2\u4ef6\u6b63\u5f0f\u52a0\u5165<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_start_on_boot&#061;off \u00a0\u00a0\u00a0#\u5728server\u542f\u52a8\u65f6\u4e0d\u81ea\u52a8\u542f\u52a8\u7ec4\u590d\u5236<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_local_address&#061;&#034;172.25.254.10:33061&#034; #\u6307\u5b9a\u63d2\u4ef6\u63a5\u53d7\u5176\u4ed6\u6210\u5458\u4fe1\u606f\u7aef\u53e3<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_group_seeds&#061;&#034;172.25.254.10:33061,172.25.254.20:33061,172.25.254.30:33061&#034; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u672c\u5730\u5730\u5740\u5141\u8bb8\u8bbf\u95ee\u6210\u5458\u5217\u8868<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_ip_whitelist&#061;&#034;172.25.254.0\/24,127.0.0.1\/8&#034; \u00a0\u00a0\u00a0#\u4e3b\u673a\u767d\u540d\u5355<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_bootstrap_group&#061;off \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u4e0d\u968f\u7cfb\u7edf\u81ea\u542f\u800c\u542f\u52a8<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_single_primary_mode&#061;OFF \u00a0\u00a0\u00a0#\u4f7f\u7528\u591a\u4e3b\u6a21\u5f0f<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">group_replication_enforce_update_everywhere_checks&#061;ON \u00a0\u00a0#\u7ec4\u540c\u6b65\u4e2d\u6709\u4efb\u4f55\u6539\u53d8\u68c0\u6d4b\u66f4\u65b0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -uroot -p<\/span><span style=\"color:#000000\">&#039;<\/span><span style=\"color:#ff0000\">\u521d\u59cb\u5316\u7684\u5bc6\u7801<\/span><span style=\"color:#000000\">&#039;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt;<\/span><span style=\"color:#000000\">\u00a0ALTER USER &#039;root&#039;&#064;&#039;localhost&#039; IDENTIFIED BY &#039;lee&#039;;<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0##\u66f4\u6539\u5bc6\u7801<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; FLUSH PRIVILEGES;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET SQL_LOG_BIN&#061;0;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CREATE USER rpl_user&#064;&#039;%&#039; IDENTIFIED BY &#039;lee&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT REPLICATION SLAVE ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT CONNECTION_ADMIN ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT BACKUP_ADMIN ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT GROUP_REPLICATION_STREAM ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; FLUSH PRIVILEGES;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET SQL_LOG_BIN&#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; reset master;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CHANGE MASTER TO MASTER_USER&#061;&#039;rpl_user&#039;, MASTER_PASSWORD&#061;&#039;lee&#039; FOR CHANNEL &#039;group_replication_recovery&#039;; \u00a0\u00a0\u00a0<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET GLOBAL group_replication_bootstrap_group&#061;ON;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; START GROUP_REPLICATION USER&#061;&#039;rpl_user&#039;, PASSWORD&#061;&#039;lee&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET GLOBAL group_replication_bootstrap_group&#061;OFF;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SELECT * FROM performance_schema.replication_group_members;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"156\" src=\"2025-08-15dzvoz55bq5q.png\" width=\"624\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysql &#xff08;b\u548cc&#xff09; ]<\/span><span style=\"color:#000000\"># rm -fr \/data\/mysql\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># v<\/span><span style=\"color:#000000\">im \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">##\u548cmysqla\u76f8\u540c\u914d\u7f6e&#xff0c;\u8fd9\u4e2a\u4e5f\u4e00\u6837 <\/span>server-id&#061;10<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysqld &#8211;user&#061;mysql &#8211;initialize <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">vim \/etc\/my.cnf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">\u00a0\u00a0\u00a0\u00a0group_replication_local_address&#061;&#034;172.25.254.<span style=\"color:#ff0000\">2<\/span>0:33061&#034;\u00a0\u00a0\u00a0\u00a0#\u8fd9\u4e2a\u4e0d\u540c\u5176\u4f59\u76f8\u540c&#xff0c;<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -uroot -p<\/span><span style=\"color:#000000\">&#039;<\/span><span style=\"color:#ff0000\">\u521d\u59cb\u5316\u7684\u5bc6\u7801<\/span><span style=\"color:#000000\">&#039;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt;<\/span><span style=\"color:#000000\">\u00a0ALTER USER &#039;root&#039;&#064;&#039;localhost&#039; IDENTIFIED BY &#039;lee&#039;;<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0##\u66f4\u6539\u5bc6\u7801<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; FLUSH PRIVILEGES;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET SQL_LOG_BIN&#061;0;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CREATE USER rpl_user&#064;&#039;%&#039; IDENTIFIED BY &#039;lee&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT REPLICATION SLAVE ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT CONNECTION_ADMIN ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT BACKUP_ADMIN ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; GRANT GROUP_REPLICATION_STREAM ON *.* TO rpl_user&#064;&#039;%&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; FLUSH PRIVILEGES;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SET SQL_LOG_BIN&#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; reset master;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CHANGE MASTER TO MASTER_USER&#061;&#039;rpl_user&#039;, MASTER_PASSWORD&#061;&#039;lee&#039; FOR CHANNEL &#039;group_replication_recovery&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; START GROUP_REPLICATION USER&#061;&#039;rpl_user&#039;, PASSWORD&#061;&#039;lee&#039;;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SELECT * FROM performance_schema.replication_group_members;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CREATE DATABASE lee;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CREATE TABLE lee.userlist( username VARCHAR(10) PRIMARY KEY NOT NULL, password VARCHAR(50) NOT NULL );<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; INSERT INTO lee.userlist VALUES (&#039;user1&#039;,&#039;111&#039;);<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SELECT * FROM lee.userlist;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"90\" src=\"2025-08-15n4welgvhadp.png\" width=\"347\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla ]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; INSERT INTO lee.userlist values (&#039;user2&#039;,&#039;222&#039;);<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; select * from lee.userlist;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"2025-08-15idvi2bab2lp.png\" width=\"385\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">mysql\u9ad8\u53ef\u7528\u4e4bMHA<\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"336\" src=\"2025-08-15xgtt35yqswc.png\" width=\"482\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u4ec0\u4e48\u662f MHA<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA&#xff08;Master High Availability<\/span><span style=\"color:#000000\">&#xff09;\u662f\u4e00\u5957\u4f18\u79c0\u7684<\/span><span style=\"color:#000000\">MySQL<\/span><span style=\"color:#000000\">\u9ad8\u53ef\u7528\u73af\u5883\u4e0b\u6545\u969c\u5207\u6362\u548c\u4e3b\u4ece\u590d\u5236\u7684\u8f6f\u4ef6\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA <\/span><span style=\"color:#000000\">\u7684\u51fa\u73b0\u5c31\u662f\u89e3\u51b3<\/span><span style=\"color:#000000\">MySQL <\/span><span style=\"color:#000000\">\u5355\u70b9\u7684\u95ee\u9898\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MySQL<\/span><span style=\"color:#000000\">\u6545\u969c\u5207\u6362\u8fc7\u7a0b\u4e2d&#xff0c;<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u80fd\u505a\u5230<\/span><span style=\"color:#000000\">0-30<\/span><span style=\"color:#000000\">\u79d2\u5185\u81ea\u52a8\u5b8c\u6210\u6545\u969c\u5207\u6362\u64cd\u4f5c\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u80fd\u5728\u6545\u969c\u5207\u6362\u7684\u8fc7\u7a0b\u4e2d\u6700\u5927\u7a0b\u5ea6\u4e0a\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027&#xff0c;\u4ee5\u8fbe\u5230\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u9ad8\u53ef\u7528\u3002<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">MHA \u7684\u7ec4\u6210 <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA\u7531\u4e24\u90e8\u5206\u7ec4\u6210:MHAManager (<\/span><span style=\"color:#000000\">\u7ba1\u7406\u8282\u70b9<\/span><span style=\"color:#000000\">) MHA Node (<\/span><span style=\"color:#000000\">\u6570\u636e\u5e93\u8282\u70b9<\/span><span style=\"color:#000000\">), <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA Manager <\/span><span style=\"color:#000000\">\u53ef\u4ee5\u5355\u72ec\u90e8\u7f72\u5728\u4e00\u53f0\u72ec\u7acb\u7684\u673a\u5668\u4e0a\u7ba1\u7406\u591a\u4e2a<\/span><span style=\"color:#000000\">master-slave<\/span><span style=\"color:#000000\">\u96c6\u7fa4&#xff0c;\u4e5f\u53ef\u4ee5\u90e8\u7f72\u5728\u4e00\u53f0<\/span><span style=\"color:#000000\">slave <\/span><span style=\"color:#000000\">\u8282\u70b9\u4e0a\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA Manager <\/span><span style=\"color:#000000\">\u4f1a\u5b9a\u65f6\u63a2\u6d4b\u96c6\u7fa4\u4e2d\u7684<\/span><span style=\"color:#000000\">\u00a0master <\/span><span style=\"color:#000000\">\u8282\u70b9\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5f53<\/span><span style=\"color:#000000\">\u00a0master <\/span><span style=\"color:#000000\">\u51fa\u73b0\u6545\u969c\u65f6&#xff0c;\u5b83\u53ef\u4ee5\u81ea\u52a8\u5c06\u6700\u65b0\u6570\u636e\u7684<\/span><span style=\"color:#000000\">\u00a0slave <\/span><span style=\"color:#000000\">\u63d0\u5347\u4e3a\u65b0\u7684<\/span><span style=\"color:#000000\">\u00a0master<\/span><span style=\"color:#000000\">&#xff0c; \u7136\u540e\u5c06\u6240\u6709\u5176\u4ed6\u7684<\/span><span style=\"color:#000000\">slave <\/span><span style=\"color:#000000\">\u91cd\u65b0\u6307\u5411\u65b0\u7684<\/span><span style=\"color:#000000\">\u00a0master<\/span><span style=\"color:#000000\">\u3002 <\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">MHA \u7684\u7279\u70b9 <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u81ea\u52a8\u6545\u969c\u5207\u6362\u8fc7\u7a0b\u4e2d<\/span><span style=\"color:#000000\">&#xff0c;<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u4ece\u4e3b\u673a\u4e3b\u670d\u52a1\u5668\u4fdd\u5b58\u4e8c\u8fdb\u5236\u65e5\u5fd7<\/span><span style=\"color:#000000\">&#xff0c;<\/span><span style=\"color:#000000\">\u6700\u5927\u7a0b\u5ea6\u4fdd\u8bc1\u6570\u636e\u4e0d\u4e22\u5931 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u4f7f\u7528\u534a\u540c\u6b65\u590d\u5236&#xff0c;\u53ef\u4ee5\u5927\u5927\u964d\u4f4e\u6570\u636e\u4e22\u5931\u7684\u98ce\u9669&#xff0c;\u5982\u679c\u53ea\u6709\u4e00\u4e2a<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u5df2\u7ecf\u6536\u5230\u4e86\u6700\u65b0\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7&#xff0c;<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u53ef\u4ee5\u5c06\u6700\u65b0\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5e94\u7528\u4e8e\u5176\u4ed6\u6240\u6709\u7684<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u670d\u52a1\u5668\u4e0a&#xff0c;\u56e0\u6b64\u53ef\u4ee5\u4fdd\u8bc1\u6240\u6709\u8282\u70b9\u7684\u6570\u636e\u4e00\u81f4\u6027 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u76ee\u524d<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u652f\u6301\u4e00\u4e3b\u591a\u4ece\u67b6\u6784&#xff0c;\u6700\u5c11\u4e09\u53f0\u670d\u52a1&#xff0c;\u5373\u4e00\u4e3b\u4e24\u4ece<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6545\u969c\u5207\u6362\u5907\u9009\u4e3b\u5e93\u7684\u7b97\u6cd5 <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">1&#xff0e;\u4e00\u822c\u5224\u65ad\u4ece\u5e93\u7684\u662f\u4ece&#xff08;position\/GTID<\/span><span style=\"color:#000000\">&#xff09;\u5224\u65ad\u4f18\u52a3&#xff0c;\u6570\u636e\u6709\u5dee\u5f02&#xff0c;\u6700\u63a5\u8fd1\u4e8e<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7684<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">&#xff0c;\u6210\u4e3a\u5907\u9009\u4e3b\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">2<\/span><span style=\"color:#000000\">&#xff0e;\u6570\u636e\u4e00\u81f4\u7684\u60c5\u51b5\u4e0b&#xff0c;\u6309\u7167\u914d\u7f6e\u6587\u4ef6\u987a\u5e8f&#xff0c;\u9009\u62e9\u5907\u9009\u4e3b\u5e93\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">3<\/span><span style=\"color:#000000\">&#xff0e;\u8bbe\u5b9a\u6709\u6743\u91cd&#xff08;<\/span><span style=\"color:#000000\">candidate_master&#061;1<\/span><span style=\"color:#000000\">&#xff09;&#xff0c;\u6309\u7167\u6743\u91cd\u5f3a\u5236\u6307\u5b9a\u5907\u9009\u4e3b\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0<span style=\"color:#000000\">&#xff08;<\/span><span style=\"color:#000000\">1<\/span><span style=\"color:#000000\">&#xff09;\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5982\u679c\u4e00\u4e2a<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u843d\u540e<\/span><span style=\"color:#000000\">master 100M<\/span><span style=\"color:#000000\">\u7684<\/span><span style=\"color:#000000\">relay logs<\/span><span style=\"color:#000000\">\u7684\u8bdd&#xff0c;\u5373\u4f7f\u6709\u6743\u91cd\u4e5f\u4f1a\u5931\u6548\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0<span style=\"color:#000000\">&#xff08;<\/span><span style=\"color:#000000\">2<\/span><span style=\"color:#000000\">&#xff09;\u5982\u679c<\/span><span style=\"color:#000000\">check_repl_delay&#061;0<\/span><span style=\"color:#000000\">\u7684\u8bdd&#xff0c;\u5373\u4f7f\u843d\u540e\u5f88\u591a\u65e5\u5fd7&#xff0c;\u4e5f\u5f3a\u5236\u9009\u62e9\u5176\u4e3a\u5907\u9009\u4e3b\u3002<\/span><span style=\"color:#000000\">MHA<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u5de5\u4f5c\u539f\u7406 <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u76ee\u524d<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u4e3b\u8981\u652f\u6301\u4e00\u4e3b\u591a\u4ece\u7684\u67b6\u6784&#xff0c;\u8981\u642d\u5efa<\/span><span style=\"color:#000000\">MHA,<\/span><span style=\"color:#000000\">\u8981\u6c42\u4e00\u4e2a\u590d\u5236\u96c6\u7fa4\u5fc5\u987b\u6700\u5c11\u6709<\/span><span style=\"color:#000000\">3<\/span><span style=\"color:#000000\">\u53f0\u6570\u636e\u5e93\u670d\u52a1\u5668&#xff0c; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u4e00\u4e3b\u4e8c\u4ece&#xff0c;\u5373\u4e00\u53f0\u5145\u5f53<\/span><span style=\"color:#000000\">Master<\/span><span style=\"color:#000000\">&#xff0c;\u53f0\u5145\u5f53\u5907\u7528<\/span><span style=\"color:#000000\">Master<\/span><span style=\"color:#000000\">&#xff0c;\u53e6\u4e00\u53f0\u5145\u5f53\u4ece\u5e93\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHA Node <\/span><span style=\"color:#000000\">\u8fd0\u884c\u5728\u6bcf\u53f0<\/span><span style=\"color:#000000\">\u00a0MySQL <\/span><span style=\"color:#000000\">\u670d\u52a1\u5668\u4e0a <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">MHAManager <\/span><span style=\"color:#000000\">\u4f1a\u5b9a\u65f6\u63a2\u6d4b\u96c6\u7fa4\u4e2d\u7684<\/span><span style=\"color:#000000\">master <\/span><span style=\"color:#000000\">\u8282\u70b9 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5f53<\/span><span style=\"color:#000000\">master <\/span><span style=\"color:#000000\">\u51fa\u73b0\u6545\u969c\u65f6&#xff0c;\u5b83\u53ef\u4ee5\u81ea\u52a8\u5c06\u6700\u65b0\u6570\u636e\u7684<\/span><span style=\"color:#000000\">slave <\/span><span style=\"color:#000000\">\u63d0\u5347\u4e3a\u65b0\u7684<\/span><span style=\"color:#000000\">master <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u7136\u540e\u5c06\u6240\u6709\u5176\u4ed6\u7684<\/span><span style=\"color:#000000\">slave <\/span><span style=\"color:#000000\">\u91cd\u65b0\u6307\u5411\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">&#xff0c;<\/span><span style=\"color:#000000\">VIP<\/span><span style=\"color:#000000\">\u81ea\u52a8\u6f02\u79fb\u5230\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u6574\u4e2a\u6545\u969c\u8f6c\u79fb\u8fc7\u7a0b\u5bf9\u5e94\u7528\u7a0b\u5e8f\u5b8c\u5168\u900f\u660e\u3002 <\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">MHA\u90e8\u7f72\u5b9e\u65bd <\/span><\/h3>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u642d\u5efa\u4e3b\u4e24\u4ece\u67b6\u6784<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">\u6240\u6709\u6570\u636e\u5e93 <\/span><span style=\"color:#ee822f\">~]<\/span><span style=\"color:#000000\"># \/etc\/init.d\/mysqld status<\/span>\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u3010\u67e5\u770b\u6570\u636e\u5e93\u5f00\u542f\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G<\/span><span style=\"color:#000000\">;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-15i4s2gxqqktc.png\" width=\"419\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># unzip MHA-7.zip<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">MHA-7]<\/span><span style=\"color:#000000\"># ls<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-15po5k13ha3bk.png\" width=\"609\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># yum install *.rpm -y<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># scp mha4mysql-node-0.58-0.el7.centos.noarch.rpm <\/span><span style=\"color:#000000\">root&#064;172.25.254.10:\/mnt<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># scp mha4mysql-node-0.58-0.el7.centos.noarch.rpm <\/span><span style=\"color:#000000\">root&#064;172.25.254.<\/span><span style=\"color:#000000\">2<\/span><span style=\"color:#000000\">0:\/mnt<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># scp mha4mysql-node-0.58-0.el7.centos.noarch.rpm <\/span><span style=\"color:#000000\">root&#064;172.25.254.<\/span><span style=\"color:#000000\">3<\/span><span style=\"color:#000000\">0:\/mnt<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u5728\u8f6f\u4ef6\u4e2d\u5305\u542b\u7684\u5de5\u5177\u5305\u4ecb\u7ecd <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">Manager\u5de5\u5177\u5305\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u5de5\u5177&#xff1a; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_check_ssh <\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u68c0\u67e5<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u7684<\/span><span style=\"color:#000000\">SSH<\/span><span style=\"color:#000000\">\u914d\u7f6e\u72b6\u51b5 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_check_repl <\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u68c0\u67e5<\/span><span style=\"color:#000000\">MySQL<\/span><span style=\"color:#000000\">\u590d\u5236\u72b6\u51b5 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_manger<\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u542f\u52a8<\/span><span style=\"color:#000000\">MHA <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_check_status<\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u68c0\u6d4b\u5f53\u524d<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u8fd0\u884c\u72b6\u6001 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_master_monitor <\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u68c0\u6d4b<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u662f\u5426\u5b95\u673a <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_master_switch <\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u63a7\u5236\u6545\u969c\u8f6c\u79fb&#xff08;\u81ea\u52a8\u6216\u8005\u624b\u52a8&#xff09; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">masterha_conf_host <\/span> <span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u6dfb\u52a0\u6216\u5220\u9664\u914d\u7f6e\u7684<\/span><span style=\"color:#000000\">server<\/span><span style=\"color:#000000\">\u4fe1\u606f<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">Node\u5de5\u5177\u5305 <\/span><span style=\"color:#000000\">&#xff08;\u901a\u5e38\u7531<\/span><span style=\"color:#000000\">masterHA<\/span><span style=\"color:#000000\">\u4e3b\u673a\u76f4\u63a5\u8c03\u7528&#xff0c;\u65e0\u9700\u4eba\u4e3a\u6267\u884c&#xff09; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">save_binary_logs <\/span>\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u4fdd\u5b58\u548c\u590d\u5236<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">apply_diff_relay_logs <\/span>\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u8bc6\u522b\u5dee\u5f02\u7684\u4e2d\u7ee7\u65e5\u5fd7\u4e8b\u4ef6\u5e76\u5c06\u5176\u5dee\u5f02\u7684\u4e8b\u4ef6\u5e94\u7528\u4e8e\u5176\u4ed6\u7684<\/span><span style=\"color:#000000\">slave<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">filter_mysqlbinlog <\/span>\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#\u53bb\u9664\u4e0d\u5fc5\u8981\u7684ROLLBACK<\/span><span style=\"color:#000000\">\u4e8b\u4ef6&#xff08;<\/span><span style=\"color:#000000\">MHA<\/span><span style=\"color:#000000\">\u5df2\u4e0d\u518d\u4f7f\u7528\u8fd9\u4e2a\u5de5\u5177&#xff09; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">purge_relay_logs <\/span>\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">#<\/span><span style=\"color:#000000\">\u6e05\u9664\u4e2d\u7ee7\u65e5\u5fd7&#xff08;\u4e0d\u4f1a\u963b\u585e<\/span><span style=\"color:#000000\">SQL<\/span><span style=\"color:#000000\">\u7ebf\u7a0b&#xff09;<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u73af\u5883\u914d\u7f6e<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mha ~]<\/span># ssh-keygen\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u3010\u521b\u5efa\u5bc6\u94a5\u3011<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># ssh-copy-id root&#064;172.25.254.&#xff08; 10 ~ 30 &#xff09;\u00a0\u00a0\u00a0\u00a0\u3010\u514d\u5bc6\u8ba4\u8bc1\u3011<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># scp \/root\/.ssh\/id_rsa root&#064;172.25.254.&#xff08; 10 ~ 30 &#xff09;:\/root\/.ssh\/<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># masterha_manager &#8211;help\u00a0\u00a0\u00a0\u00a0\u3010\u67e5\u770b\u914d\u7f6e\u76ee\u5f55\u548c\u914d\u7f6e\u6587\u4ef6\u3011<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"74\" src=\"2025-08-1510imt3aftgj.png\" width=\"692\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># mkdir \/etc\/masterha<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># tar zxf mha4mysql-manager-0.58.tar.gz<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># cd mha4mysql-manager-0.58\/samples\/conf\/<\/p>\n<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># cat masterha_default.cnf app1.cnf &gt; \/etc\/masterha\/app1.conf<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># vim \/etc\/masterha\/app1.conf<\/p>\n<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">[server default]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">user&#061;root #mysql\u7ba1\u7406\u5458\u7528\u6237&#xff0c;\u56e0\u4e3a\u9700\u8981\u505a\u81ea\u52a8\u5316\u914d\u7f6e<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">password&#061;lee #mysql\u5bc6\u7801<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">ssh_user&#061;root \u00a0#ssh\u8fdc\u7a0b\u767b\u9646\u7528\u6237<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">repl_user&#061;repl #mysql\u4e3b\u4ece\u590d\u5236\u4e2d\u8d1f\u8d23\u8ba4\u8bc1\u7684\u7528\u6237<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">repl_password&#061;lee \u00a0#mysql\u4e3b\u4ece\u590d\u5236\u4e2d\u8d1f\u8d23\u8ba4\u8bc1\u7684\u7528\u6237\u5bc6\u7801<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">master_binlog_dir&#061;\/data\/mysql # mysqla \u4e8c\u8fdb\u5236\u65e5\u5fd7\u76ee\u5f55<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">remote_workdir&#061;\/data\/masterha\/app1 # mha\u7684\u8fdc\u7a0b\u76ee\u5f55<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">manager_workdir&#061;\/etc\/masterha\/app1 # mha\u7684\u5de5\u4f5c\u76ee\u5f55<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">manager_log&#061;\/var\/log\/masterha\/manager.log\u00a0\u00a0\u00a0# mha\u65e5\u5fd7<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">ping_interval&#061;3 #\u6bcf\u96943\u79d2\u68c0\u6d4b\u4e00\u6b21<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">secondary_check_script&#061;masterha_secondary_check -s 172.25.254.10 -s 172.25.254.11<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">[server1]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">hostname&#061;172.25.254.10<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">candidate_master&#061;1\u00a0\u00a0\u00a0\u00a0\u00a0 # \u4e3b\u5e93\u914d\u7f6e<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">check_repl_delay&#061;0 ##\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5982\u679c\u4e00\u4e2aslave\u843d\u540emaster 100M\u7684relay logs\u7684\u8bddMHA\u5c06\u4e0d\u4f1a\u9009\u62e9\u8be5slave\u4f5c\u4e3a\u4e00\u4e2a\u65b0\u7684master&#xff0c;\u56e0\u4e3a\u5bf9\u8fd9\u4e2aslave\u7684\u6062\u590d\u9700\u8981\u82b1\u8d39\u5f88\u957f\u65f6\u95f4<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u901a\u8fc7\u8bbe\u7f6echeck_repl_delay&#061;0&#xff0c;MHA\u89e6\u53d1\u5207\u6362\u5728\u9009\u62e9\u4e00\u4e2a\u65b0\u7684master\u7684\u65f6\u5019\u5c06\u4f1a\u5ffd\u7565\u590d\u5236\u5ef6\u65f6<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u8fd9\u4e2a\u53c2\u6570\u5bf9\u4e8e\u8bbe\u7f6e\u4e86candidate_master&#061;1\u7684\u4e3b\u673a\u975e\u5e38\u6709\u7528&#xff0c;\u56e0\u4e3a\u8fd9\u4e2a\u5019\u9009\u4e3b\u5728\u5207\u6362\u7684\u8fc7\u7a0b\u4e2d\u4e00\u5b9a\u662f\u65b0\u7684master<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">[server2]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">hostname&#061;172.25.254.20<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">candidate_master&#061;1 # \u53ef\u80fd\u4f5c\u4e3a\u4e3b\u5e93master\u7684\u4e3b\u673a<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">check_repl_delay&#061;0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">[server3]<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">hostname&#061;172.25.254.30<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">no_master&#061;1 #\u4e0d\u4f5c\u4e3amaster\u7684\u4e3b\u673a<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">\u6240\u6709\u6570\u636e\u5e93 <\/span><span style=\"color:#ee822f\">~]<\/span><span style=\"color:#000000\"># yum install \/mnt\/mha4mysql-node-0.58-<\/span><span style=\"color:#000000\">0.el7.centos.noarch.rpm -y<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SELECT User, Host FROM mysql.user WHERE User&#061;&#039;lee&#039;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-15ttubjzybd0g.png\" width=\"443\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW GRANTS FOR &#039;lee&#039;&#064;&#039;%&#039;;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-15pa2mes0ghyx.png\" width=\"568\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># masterha_check_ssh &#8211;conf&#061;\/etc\/masterha\/app1.conf<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-153esbcek42b0.png\" width=\"582\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">masterha_check_repl &#8211;conf&#061;\/etc\/masterha\/app1.conf<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-151e4kjwfxgvd.png\" width=\"626\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">\u6240\u6709\u6570\u636e\u5e93 <\/span><span style=\"color:#ee822f\">~]<\/span><span style=\"color:#000000\">&gt; GRANT ALL ON *.* TO root&#064;&#039;%&#039; identified by &#039;lee&#039;; <\/span>\u00a0\u00a0\u00a0\u00a0##\u5141\u8bb8root\u8fdc\u7a0b\u767b\u9646<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># mysql -uroot -plee -h172.25.254.10 -e &#034;SHOW DATABASES&#034;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"128\" src=\"2025-08-15hzpej51doxe.png\" width=\"479\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">MHA\u7684\u6545\u969c\u5207\u6362 <\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">MHA\u7684\u6545\u969c\u5207\u6362\u8fc7\u7a0b\u5171\u5305\u62ec\u4ee5\u4e0b\u7684\u6b65\u9aa4&#xff1a; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">1.<\/span><span style=\"color:#000000\">\u914d\u7f6e\u6587\u4ef6\u68c0\u67e5\u9636\u6bb5&#xff0c;\u8fd9\u4e2a\u9636\u6bb5\u4f1a\u68c0\u67e5\u6574\u4e2a\u96c6\u7fa4\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">2.<\/span><span style=\"color:#000000\">\u5b95\u673a\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u5904\u7406&#xff0c;\u8fd9\u4e2a\u9636\u6bb5\u5305\u62ec\u865a\u62df<\/span><span style=\"color:#000000\">ip<\/span><span style=\"color:#000000\">\u6458\u9664\u64cd\u4f5c&#xff0c;\u4e3b\u673a\u5173\u673a\u64cd\u4f5c <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">3.<\/span><span style=\"color:#000000\">\u590d\u5236<\/span><span style=\"color:#000000\">dead master<\/span><span style=\"color:#000000\">\u548c\u6700\u65b0<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u76f8\u5dee\u7684<\/span><span style=\"color:#000000\">relay log<\/span><span style=\"color:#000000\">&#xff0c;\u5e76\u4fdd\u5b58\u5230<\/span><span style=\"color:#000000\">MHA Manger<\/span><span style=\"color:#000000\">\u5177\u4f53\u7684\u76ee\u5f55\u4e0b <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">4.<\/span><span style=\"color:#000000\">\u8bc6\u522b\u542b\u6709\u6700\u65b0\u66f4\u65b0\u7684<\/span><span style=\"color:#000000\">slave <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">5.<\/span><span style=\"color:#000000\">\u5e94\u7528\u4ece<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u4fdd\u5b58\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4e8b\u4ef6&#xff08;<\/span><span style=\"color:#000000\">binlog events<\/span><span style=\"color:#000000\">&#xff09; <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">6.<\/span><span style=\"color:#000000\">\u63d0\u5347\u4e00\u4e2a<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u4e3a\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u8fdb\u884c\u590d\u5236 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">7.<\/span><span style=\"color:#000000\">\u4f7f\u5176\u4ed6\u7684<\/span><span style=\"color:#000000\">slave<\/span><span style=\"color:#000000\">\u8fde\u63a5\u65b0\u7684<\/span><span style=\"color:#000000\">master<\/span><span style=\"color:#000000\">\u8fdb\u884c\u590d\u5236<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">master\u672a\u51fa\u73b0\u6545\u969c\u624b\u52a8\u5207\u6362<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">masterha_check_repl &#8211;conf&#061;\/etc\/masterha\/app1.conf<\/span><span style=\"color:#000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u3010\u8fd9\u4e2a\u548c\u4e0b\u9762\u7684\u90fd\u4e0d\u80fd\u62a5\u9519\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># masterha_check_ssh &#8211;conf&#061;\/etc\/masterha\/app1.conf<\/span>\u00a0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># masterha_master_switch &#8211;conf&#061;\/etc\/masterha\/app1.conf &#8211;master_state&#061;alive<\/span>\u00a0<span style=\"color:#000000\">&#8211;new_master_host&#061;172.25.254.10 &#8211;new_master_port&#061;3306 &#8211;orig_master_is_new_slave<\/span>\u00a0<span style=\"color:#000000\">&#8211;running_updates_limit&#061;10000<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"44\" src=\"2025-08-15ubhjd4hbx1j.png\" width=\"686\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"166\" src=\"2025-08-15dddk12rbn03.png\" width=\"368\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">master\u6545\u969c\u624b\u52a8\u5207\u6362<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqla<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\"># \/etc\/init.d\/mysqld <\/span><span style=\"color:#000000\">stop<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># masterha_master_switch &#8211;master_state&#061;dead &#8211;conf&#061;\/etc\/masterha\/app1.c<\/span><span style=\"color:#000000\">o<\/span><span style=\"color:#000000\">nf <\/span><span style=\"color:#000000\">&#8211;dead_master_host&#061;<\/span><span style=\"color:#000000\">172.25.254.10<\/span>\u00a0<span style=\"color:#000000\">&#8211;dead_master_port&#061;3306 <\/span><span style=\"color:#000000\">&#8211;new_master_host&#061;<\/span><span style=\"color:#000000\">172.25.254.20<\/span><span style=\"color:#000000\">\u00a0&#8211;new_master_port&#061;3306 &#8211;ignore_last_failover<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"52\" src=\"2025-08-15fwzhhhnztmp.png\" width=\"647\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6062\u590d\u6545\u969cmysql\u8282\u70b9<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -p<\/span><span style=\"color:#000000\">lee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt;<\/span><span style=\"color:#000000\">\u00a0CHANGE MASTER TO MASTER_HOST&#061;&#039;172.25.254.<\/span><span style=\"color:#000000\">2<\/span><span style=\"color:#000000\">0&#039;, MASTER_USER&#061;&#039;lee&#039;, MASTER_PASSWORD&#061;&#039;lee&#039;, MASTER_AUTO_POSITION&#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; start slave;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"156\" src=\"2025-08-15q2ysxjcmuxl.png\" width=\"314\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u81ea\u52a8\u5207\u6362<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cd \/etc\/masterha\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># rm -fr app1.failover.complete<\/span>  <span style=\"color:#000000\">\u3010<\/span><span style=\"color:#000000\">\u5220\u6389\u5207\u6362\u9501\u6587\u4ef6<\/span><span style=\"color:#000000\">\u3011 \u00a0<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u76d1\u63a7\u7a0b\u5e8f\u901a\u8fc7\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\u76d1\u63a7master\u72b6\u6001&#xff0c;\u5f53master\u51fa\u95ee\u9898\u540e\u81ea\u52a8\u5207\u6362\u5e76\u9000\u51fa\u907f\u514d\u91cd\u590d\u505a\u6545\u969c\u5207\u6362<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># masterha_manager &#8211;conf&#061;\/etc\/masterha\/app1.c<\/span><span style=\"color:#000000\">o<\/span><span style=\"color:#000000\">nf <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"50\" src=\"2025-08-15zva3qwrpaec.png\" width=\"679\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlb<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\"># \/etc\/init.d\/mysqld <\/span><span style=\"color:#000000\">stop<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"46\" src=\"2025-08-150xcmq5akgs0.png\" width=\"692\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mysqlc<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"180\" src=\"2025-08-15srxenfc1bhb.png\" width=\"294\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6062\u590d\u6545\u969c\u8282\u70b9<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># \/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; CHANGE MASTER TO MASTER_HOST&#061;&#039;172.25.254.10&#039;, MASTER_USER&#061;&#039;lee&#039;, MASTER_PASSWORD&#061;&#039;lee&#039;, MASTER_AUTO_POSITION&#061;1;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; start slave;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"180\" src=\"2025-08-15lesixsntcij.png\" width=\"276\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6e05\u9664\u9501\u6587\u4ef6<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">rm -rf app1.failover.complete manager.log<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">\u4e3aMHA\u6dfb\u52a0VIP\u529f\u80fd<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># ls ma*<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># cp master_ip_failover master_ip_online_change \/usr\/local\/bin\/<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">chmod &#043;x \/usr\/local\/bin\/master_ip_*<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"># vim \/etc\/masterha\/app1.conf<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"48\" src=\"2025-08-15qqufskp2zai.png\" width=\"675\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># masterha_manager &#8211;conf&#061;\/etc\/masterha\/app1.c<\/span><span style=\"color:#000000\">o<\/span><span style=\"color:#000000\">nf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\"># <\/span><span style=\"color:#000000\">ip a a 172.25.254.<\/span><span style=\"color:#000000\">2<\/span><span style=\"color:#000000\">00\/24 dev eth0<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6a21\u62df\u6545\u969c<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\"># \/etc\/init.d\/mysqld stop<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># cat manager.log<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u6062\u590d\u6545\u969c\u4e3b\u673a<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\"># \/etc\/init.d\/mysqld start<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; CHANGE MASTER TO MASTER_HOST&#061;&#039;172.25.254.10&#039;, MASTER_USER&#061;&#039;<\/span><span style=\"color:#000000\">lee<\/span><span style=\"color:#000000\">&#039;,<\/span>\u00a0<span style=\"color:#000000\">MASTER_PASSWORD&#061;&#039;lee&#039;, MASTER_AUTO_POSITION&#061;1<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; start slave;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"180\" src=\"2025-08-154ulndekb3of.png\" width=\"349\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># rm -rf app1.failover.complete manager.log<\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">\u624b\u52a8\u5207\u6362\u540e\u67e5\u770bvip\u53d8\u5316<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">\u3010\u624b\u52a8\u5207\u6362\u8981\u5148\u5220\u9664\u9501\u6587\u4ef6 <\/span><span style=\"color:#000000\"># rm -rf app1.failover.complete manager.log<\/span>\u00a0<span style=\"color:#000000\">\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># masterha_master_switch &#8211;conf&#061;\/etc\/masterha\/app<\/span><span style=\"color:#000000\">1.conf<\/span><span style=\"color:#000000\">\u00a0&#8211;master_state&#061;alive<\/span>\u00a0<span style=\"color:#000000\">&#8211;new_master_host&#061;172.25.254.10 &#8211;new_master_port&#061;3306 &#8211;orig_master_is_new_slave<\/span>\u00a0<span style=\"color:#000000\">&#8211;running_updates_limit&#061;10000<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"26\" src=\"2025-08-15wdiyfee3a1k.png\" width=\"669\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mysqla<\/span><span style=\"color:#ee822f\">\u00a0~]<\/span><span style=\"color:#000000\"># mysql -plee<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\">&gt; SHOW SLAVE STATUS\\\\G;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#000000\"># ip a<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"2025-08-15hvmxnw3e3xd.png\" width=\"437\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># ping 172.25.254.200<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"89\" src=\"2025-08-15u5ck1kxy45w.png\" width=\"625\" \/><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#0070c0\">mysql-router&#xff08;mysql\u8def\u7531&#xff09;<\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"284\" src=\"2025-08-154ficxeumevc.png\" width=\"417\" \/><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">MySQL Router <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u662f\u4e00\u4e2a\u5bf9\u5e94\u7528\u7a0b\u5e8f\u900f\u660e\u7684InnoDB Cluster<\/span><span style=\"color:#000000\">\u8fde\u63a5\u8def\u7531\u670d\u52a1&#xff0c;\u63d0\u4f9b\u8d1f\u8f7d\u5747\u8861\u3001\u5e94\u7528\u8fde\u63a5\u6545\u969c\u8f6c\u79fb\u548c\u5ba2\u6237\u7aef\u8def\u7531\u3002 <\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u5229\u7528\u8def\u7531\u5668\u7684\u8fde\u63a5\u8def\u7531\u7279\u6027&#xff0c;\u7528\u6237\u53ef\u4ee5\u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u6765\u8fde\u63a5\u5230\u8def\u7531\u5668&#xff0c;\u5e76\u4ee4\u8def\u7531\u5668\u4f7f\u7528\u76f8\u5e94\u7684\u8def\u7531\u7b56\u7565\u6765\u5904\u7406\u8fde\u63a5&#xff0c;\u4f7f\u5176\u8fde\u63a5\u5230\u6b63\u786e\u7684<\/span><span style=\"color:#000000\">MySQL<\/span><span style=\"color:#000000\">\u6570\u636e\u5e93\u670d\u52a1\u5668 <\/span><\/p>\n<h4 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:#ee822f\">Mysql route\u7684\u90e8\u7f72\u65b9\u5f0f <\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u6211\u4eec\u9700\u8981\u5728\u6240\u6709\u7684\u6570\u636e\u5e93\u4e3b\u673a\u4e4b\u5916\u518d\u5f00\u4e00\u53f0\u4e3b\u673a<\/span><span style=\"color:#000000\">mysql-router<\/span><span style=\"color:#000000\">&#xff08;\u53ef\u4ee5\u662fMHA&#xff09;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ee822f\">mha ~]<\/span><span style=\"color:#000000\"># yum install mysql-router-community-8.4.0-1.el7.x86_64.rpm -y<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># vim \/etc\/mysqlrouter\/mysqlrouter.conf<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010\u66f4\u6539\u4e3b\u914d\u7f6e\u6587\u4ef6\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"260\" src=\"2025-08-15nxraoh4lkbm.png\" width=\"536\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># systemctl start mysqlrouter.service<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># netstat -antlupe | grep mysql \u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:#000000\">\u00a0\u00a0\u3010\u67e5\u770b\u7aef\u53e3\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"90\" src=\"2025-08-15attuir0dicf.png\" width=\"498\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -ulee -plee -h 172.25.254.100 -P 7001<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010\u8bbf\u95ee\u8d1f\u8f7d\u8c03\u5ea6\u7684\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; select &#064;&#064;server_id;<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010\u68c0\u6d4b\u67e5\u770b\u3011<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"2025-08-151g2bdadc2zp.png\" width=\"306\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"2025-08-151dol2d0qssn.png\" width=\"374\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\"># mysql -ulee -plee -h 172.25.254.100 -P 7002<\/span>\u00a0\u00a0<span style=\"color:#000000\">\u00a0\u00a0\u3010\u8bbf\u95ee\u8bbf\u95ee\u6307\u5b9a\u7684\u3011<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#000000\">&gt; select &#064;&#064;server_id;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"2025-08-15svwf15ruu2s.png\" width=\"313\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb728\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf21\u6b21\u3002Mysql \u96c6\u7fa4\u6280\u672fMysql \u5728\u670d\u52a1\u5668\u4e2d\u7684\u90e8\u7f72\u65b9\u6cd5\u5728\u4f01\u4e1a\u4e2d90%\u7684\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u5747\u4e3aLinux\u5728\u4f01\u4e1a\u4e2d\u5bf9\u4e8eMysql\u7684\u5b89\u88c5\u901a\u5e38\u7528\u6e90\u7801\u7f16\u8bd1\u7684\u65b9\u5f0f\u6765\u8fdb\u884cRhel7\u90e8\u7f72\u6570\u636e\u5e93\u3002_mysql \u96c6\u7fa4\u63d2\u5165\u8868\u793a\u5177\u4f53\u670d\u52a1\u5668\u6570\u636e<\/p>\n","protected":false},"author":2,"featured_media":57279,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,114,97,100,43,305,44],"topic":[],"class_list":["post-57299","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-mysql","tag-97","tag-100","tag-43","tag-305","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/57299.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb728\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf21\u6b21\u3002Mysql \u96c6\u7fa4\u6280\u672fMysql \u5728\u670d\u52a1\u5668\u4e2d\u7684\u90e8\u7f72\u65b9\u6cd5\u5728\u4f01\u4e1a\u4e2d90%\u7684\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u5747\u4e3aLinux\u5728\u4f01\u4e1a\u4e2d\u5bf9\u4e8eMysql\u7684\u5b89\u88c5\u901a\u5e38\u7528\u6e90\u7801\u7f16\u8bd1\u7684\u65b9\u5f0f\u6765\u8fdb\u884cRhel7\u90e8\u7f72\u6570\u636e\u5e93\u3002_mysql \u96c6\u7fa4\u63d2\u5165\u8868\u793a\u5177\u4f53\u670d\u52a1\u5668\u6570\u636e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/57299.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-15T02:00:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce309c8.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57299.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/57299.html\",\"name\":\"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T02:00:48+00:00\",\"dateModified\":\"2025-08-15T02:00:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/57299.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/57299.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57299.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/57299.html","og_locale":"zh_CN","og_type":"article","og_title":"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb728\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf21\u6b21\u3002Mysql \u96c6\u7fa4\u6280\u672fMysql \u5728\u670d\u52a1\u5668\u4e2d\u7684\u90e8\u7f72\u65b9\u6cd5\u5728\u4f01\u4e1a\u4e2d90%\u7684\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u5747\u4e3aLinux\u5728\u4f01\u4e1a\u4e2d\u5bf9\u4e8eMysql\u7684\u5b89\u88c5\u901a\u5e38\u7528\u6e90\u7801\u7f16\u8bd1\u7684\u65b9\u5f0f\u6765\u8fdb\u884cRhel7\u90e8\u7f72\u6570\u636e\u5e93\u3002_mysql \u96c6\u7fa4\u63d2\u5165\u8868\u793a\u5177\u4f53\u670d\u52a1\u5668\u6570\u636e","og_url":"https:\/\/www.wsisp.com\/helps\/57299.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T02:00:48+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815020046-689e94ce309c8.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"13 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/57299.html","url":"https:\/\/www.wsisp.com\/helps\/57299.html","name":"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T02:00:48+00:00","dateModified":"2025-08-15T02:00:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/57299.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/57299.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/57299.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u670d\u52a1\u5668\u7684Mysql \u96c6\u7fa4\u6280\u672f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=57299"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57299\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/57279"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=57299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=57299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=57299"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=57299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}