{"id":1313,"date":"2025-03-12T20:29:59","date_gmt":"2025-03-12T12:29:59","guid":{"rendered":"http:\/\/113.45.254.23\/?p=1313"},"modified":"2025-03-14T10:37:11","modified_gmt":"2025-03-14T02:37:11","slug":"mariadb%e6%95%b0%e6%8d%ae%e5%ba%93%e9%9b%86%e7%be%a4","status":"publish","type":"post","link":"http:\/\/113.45.254.23\/?p=1313","title":{"rendered":"mariadb\u6570\u636e\u5e93\u96c6\u7fa4"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">db1 &nbsp;192.168.7.10<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">db2 &nbsp;192.168.7.11<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">db3 &nbsp;192.168.7.12<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u4fee\u6539db1\u3001db2\u3001db3\u6570\u636e\u5e93\u540d\u79f0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# sestatus\nSELinux status:                 disabled\n&#91;root@db1 ~]# systemctl status firewalld\n\u25cb firewalld.service - firewalld - dynamic firewall daemon\n     Loaded: loaded (\/usr\/lib\/systemd\/system\/firewalld.service; disabled; preset: enabled)\n     Active: inactive (dead)\n       Docs: man:firewalld(1)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db2 ~]# sestatus\nSELinux status:                 disabled\n&#91;root@db2 ~]# systemctl status firewalld\n\u25cb firewalld.service - firewalld - dynamic firewall daemon\n     Loaded: loaded (\/usr\/lib\/systemd\/system\/firewalld.service; disabled; preset: enabled)\n     Active: inactive (dead)\n       Docs: man:firewalld(1)\n&#91;root@db3 ~]# sestatus\nSELinux status:                 disabled\n&#91;root@db3 ~]# systemctl status firewalld\n\u25cb firewalld.service - firewalld - dynamic firewall daemon\n     Loaded: loaded (\/usr\/lib\/systemd\/system\/firewalld.service; disabled; preset: enabled)\n     Active: inactive (dead)\n       Docs: man:firewalld(1)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u7f16\u8f91db1\u3001db2\u3001db3\u65f6\u95f4\u540c\u6b65\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# vim \/etc\/chrony.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#pool 2.rocky.pool.ntp.org iburst\npool ntp.aliyun.com iburst#\u540c\u6b65\u963f\u91cc\u4e91\u7684\u65f6\u95f4<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db2 ~]# vim \/etc\/chrony.conf\n\n#pool 2.rocky.pool.ntp.org iburst\npool ntp.aliyun.com iburst#\u540c\u6b65\u963f\u91cc\u4e91\u7684\u65f6\u95f4<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# vim \/etc\/chrony.conf\n\n#pool 2.rocky.pool.ntp.org iburst\npool ntp.aliyun.com iburst#\u540c\u6b65\u963f\u91cc\u4e91\u7684\u65f6\u95f4<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u8bbe\u7f6e\u65f6\u95f4\u540c\u6b65<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# systemctl enable --now chronyd\n&#91;root@db1 ~]# chronyc -v\nchronyc (chrony) version 4.5 (+READLINE +SECHASH +IPV6 +DEBUG)\n&#91;root@db1 ~]# \n&#91;root@db1 ~]# chronyc sources -v\n\n  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.\n \/ .- Source state '*' = current best, '+' = combined, '-' = not combined,\n| \/             'x' = may be in error, '~' = too variable, '?' = unusable.\n||                                                 .- xxxx &#91; yyyy ] +\/- zzzz\n||      Reachability register (octal) -.           |  xxxx = adjusted offset,\n||      Log2(Polling interval) --.      |          |  yyyy = measured offset,\n||                                \\     |          |  zzzz = estimated error.\n||                                 |    |           \\\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample               \n===============================================================================\n^* stratum2-1.ntp.mow01.ru.&gt;     2   6   357     9  -3766us&#91;-4836us] +\/-   61ms\n^+ ntp8.flashdance.cx            2   6   377    11    +14ms&#91;  +13ms] +\/-  113ms\n^+ time.cloudflare.com           3   6   377    12   +285us&#91; -784us] +\/-  115ms\n^+ time.cloudflare.com           3   6   377    10   +699us&#91; -370us] +\/-  116ms\n&#91;root@db1 ~]# date\nWed Mar 12 03:03:14 AM EDT 2025\n&#91;root@db1 ~]# \n&#91;root@db1 ~]# \n&#91;root@db1 ~]# clock -w\n&#91;root@db1 ~]# dnf -y install mariadb-server-galera\t\t\t\u5b89\u88c5\u6570\u636e\u5e93\u96c6\u7fa4<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n&#91;root@db2 ~]# systemctl enable --now chronyd\n&#91;root@db2 ~]# \n&#91;root@db2 ~]# \n&#91;root@db2 ~]# chronyc sources -v\n\n  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.\n \/ .- Source state '*' = current best, '+' = combined, '-' = not combined,\n| \/             'x' = may be in error, '~' = too variable, '?' = unusable.\n||                                                 .- xxxx &#91; yyyy ] +\/- zzzz\n||      Reachability register (octal) -.           |  xxxx = adjusted offset,\n||      Log2(Polling interval) --.      |          |  yyyy = measured offset,\n||                                \\     |          |  zzzz = estimated error.\n||                                 |    |           \\\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample               \n===============================================================================\n^+ time.cloudflare.com           3   6   377   113  -2995us&#91;-2940us] +\/-  114ms\n^+ ntp1.flashdance.cx            2   6   377    50   -337us&#91; -171us] +\/-  100ms\n^* ntp8.flashdance.cx            2   6   377    49    +15ms&#91;  +15ms] +\/-  114ms\n^+ ntp.ams1.nl.leaseweb.net      2   6   377    50    +17ms&#91;  +17ms] +\/-  165ms\n&#91;root@db2 ~]# \n&#91;root@db2 ~]# \n&#91;root@db2 ~]# date\nWed Mar 12 03:05:28 PM CST 2025\n&#91;root@db2 ~]# \n&#91;root@db2 ~]# clock -w\n&#91;root@db2 ~]# \n&#91;root@db2 ~]# dnf -y install mariadb-server-galera\t\u5b89\u88c5\u6570\u636e\u5e93\u96c6\u7fa4<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# systemctl enable --now chronyd\n&#91;root@db3 ~]# \n&#91;root@db3 ~]# \n&#91;root@db3 ~]# chronyc sources -v\n\n  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.\n \/ .- Source state '*' = current best, '+' = combined, '-' = not combined,\n| \/             'x' = may be in error, '~' = too variable, '?' = unusable.\n||                                                 .- xxxx &#91; yyyy ] +\/- zzzz\n||      Reachability register (octal) -.           |  xxxx = adjusted offset,\n||      Log2(Polling interval) --.      |          |  yyyy = measured offset,\n||                                \\     |          |  zzzz = estimated error.\n||                                 |    |           \\\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample               \n===============================================================================\n^- time.cloudflare.com           3   7   377    48  +3053us&#91;+3053us] +\/-  120ms\n^+ ntp1.flashdance.cx            2   6   377    49  +4893us&#91;+4893us] +\/-  125ms\n^* ntp8.flashdance.cx            2   7   377    49   -203us&#91;-1070us] +\/-  116ms\n^- ntp.ams1.nl.leaseweb.net      2   6   377    49    +25ms&#91;  +25ms] +\/-  163ms\n&#91;root@db3 ~]# \n&#91;root@db3 ~]# date\nWed Mar 12 03:07:51 AM EDT 2025\n&#91;root@db3 ~]# \n&#91;root@db3 ~]# \n&#91;root@db3 ~]# clock -w\n&#91;root@db3 ~]# dnf -y install mariadb-server-galera\t\t\u5b89\u88c5\u6570\u636e\u5e93\u96c6\u7fa4<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u542f\u52a8\u9632\u706b\u5899\u5e76\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a0\u7aef\u53e3\u53f7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">4.1db1\u6570\u636e\u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# systemctl enable --now firewalld\nCreated symlink \/etc\/systemd\/system\/dbus-org.fedoraproject.FirewallD1.service \u2192 \/usr\/lib\/systemd\/system\/firewalld.service.\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/firewalld.service \u2192 \/usr\/lib\/systemd\/system\/firewalld.service.\n&#91;root@db1 ~]# firewall-cmd --add-service=mysql\t\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a0Mysql\u670d\u52a1\nsuccess\n&#91;root@db1 ~]# firewall-cmd --add-port={3306\/tcp,4567\/tcp,4568\/tcp,4444\/tcp}\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a03306\/tcp mysql\u7aef\u53e3\u53f7,4567\/tcp,4568\/tcp,4444\/tcp\u7aef\u53e3  \u540e\u4e09\u4e2a\u662f\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u7aef\u53e3\u53f7\n\nsuccess\n&#91;root@db1 ~]# firewall-cmd --runtime-to-permanent\t\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a0\u6c38\u4e45\u8fd0\u884c\u65f6\t\nsuccess<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.2db2\u6570\u636e\u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db2 ~]# systemctl enable --now firewalld\nCreated symlink \/etc\/systemd\/system\/dbus-org.fedoraproject.FirewallD1.service \u2192 \/usr\/lib\/systemd\/system\/firewalld.service.\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/firewalld.service \u2192 \/usr\/lib\/systemd\/system\/firewalld.service.\n&#91;root@db2 ~]# firewall-cmd --add-service=mysql   \u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a0Mysql\u670d\u52a1\nsuccess\n&#91;root@db2 ~]# firewall-cmd --add-port={3306\/tcp,4567\/tcp,4568\/tcp,4444\/tcp}\t\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a03306\/tcp mysql\u7aef\u53e3\u53f7,4567\/tcp,4568\/tcp,4444\/tcp\u7aef\u53e3  \u540e\u4e09\u4e2a\u662f\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u7aef\u53e3\u53f7\n\nsuccess\n&#91;root@db2 ~]# firewall-cmd --runtime-to-permanent\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a0\u6c38\u4e45\u8fd0\u884c\u65f6\nsuccess<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.3 db3\u6570\u636e\u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# systemctl enable --now firewalld\nCreated symlink \/etc\/systemd\/system\/dbus-org.fedoraproject.FirewallD1.service \u2192 \/usr\/lib\/systemd\/system\/firewalld.service.\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/firewalld.service \u2192 \/usr\/lib\/systemd\/system\/firewalld.service.\n&#91;root@db3 ~]# firewall-cmd --add-service=mysql\nsuccess\n&#91;root@db3 ~]# firewall-cmd --add-port={3306\/tcp,4567\/tcp,4568\/tcp,4444\/tcp}\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a03306\/tcp mysql\u7aef\u53e3\u53f7,4567\/tcp,4568\/tcp,4444\/tcp\u7aef\u53e3  \u540e\u4e09\u4e2a\u662f\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u7aef\u53e3\u53f7\n\nsuccess\n&#91;root@db3 ~]# firewall-cmd --runtime-to-permanent\t\t\u5728\u9632\u706b\u5899\u91cc\u6dfb\u52a0\u6c38\u4e45\u8fd0\u884c\u65f6\t<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u7f16\u8f91galera\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# vim \/etc\/my.cnf.d\/galera.cnf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>34 wsrep_on=1\t\t#\u5f00\u542f\u96c6\u7fa4\t\t\n43 wsrep_cluster_name=\"Galera_cluster\"\t\t\t#\u5b9a\u4e49\u96c6\u7fa4\u7684\u540d\u79f0\uff1aGalera_cluster\n46 wsrep_cluster_address=\"gcomm:\/\/\"\t\t\t\t#\u96c6\u7fa4\u7684\u5730\u5740\uff1agcomm:\/\/\n54 wsrep_node_address=\"192.168.7.10\"\t\t\t#\u96c6\u7fa4\u7684\u672c\u673a\u5730\u5740192.168.7.10<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u521b\u5efa\u6570\u636e\u5e93\u96c6\u7fa4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# galera_new_cluster \t\t\u521b\u5efa\u6570\u636e\u5e93\u96c6\u7fa4\n&#91;root@db1 ~]#         \n&#91;root@db1 ~]# systemctl enable mariadb\t\t\u8bbe\u7f6e\u6570\u636e\u5e93\u5f00\u673a\u542f\u52a8\nCreated symlink \/etc\/systemd\/system\/mysql.service \u2192 \/usr\/lib\/systemd\/system\/mariadb.service.\nCreated symlink \/etc\/systemd\/system\/mysqld.service \u2192 <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u7f16\u8f91db1\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# vim \/etc\/my.cnf.d\/galera.cnf\t\t\u7f16\u8f91galera\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u914d\u7f6e\u6587\u4ef6\n\n46 wsrep_cluster_address=\"gcomm:\/\/192.168.7.10,192.168.7.11,192.168.7.12\"\t\t#\u6dfb\u52a0\u96c6\u7fa4\u6240\u6709\u8282\u70b9\u7684IP<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u516b\u3001db1\u6570\u636e\u5e93\u7684\u5b89\u5168\u8bbe\u7f6e<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# mysql_secure_installation\t\t\tdb1\u6570\u636e\u5e93\u7684\u5b89\u5168\u8bbe\u7f6e\n\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\n\nIn order to log into MariaDB to secure it, we'll need the current\npassword for the root user. If you've just installed MariaDB, and\nhaven't set the root password yet, you should just press enter here.\n\nEnter current password for root (enter for none): \nOK, successfully used password, moving on...\n\nSetting the root password or using the unix_socket ensures that nobody\ncan log into the MariaDB root user without the proper authorisation.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nSwitch to unix_socket authentication &#91;Y\/n] n\t\t\u4ea4\u6362\u673a\u5207\u6362\u5230unix\u63a5\u53e3\u8ba4\u8bc1\u5417 n\n ... skipping.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nChange the root password? &#91;Y\/n] y\t\t\t\u66f4\u6539root\u5bc6\u7801\u5417\uff1fy\nNew password: \nRe-enter new password: \nPassword updated successfully!\nReloading privilege tables..\n ... Success!\n\n\nBy default, a MariaDB installation has an anonymous user, allowing anyone\nto log into MariaDB without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? &#91;Y\/n] y\t\t\t\u79fb\u9664\u533f\u540d\u7528\u6237\u5417\uff1fy\n ... Success!Disallow root login remotely? &#91;Y\/n] y\t\t\t\u7981\u6b62root \u8fdc\u7a0b\u767b\u9646\u5417\uff1fy\n ... Success!\n\nBy default, MariaDB comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? &#91;Y\/n] y\t\t\t\u79fb\u9664\u6d4b\u8bd5\u6570\u636e\u5e93\u5417\uff1fy\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? &#91;Y\/n] y\t\t\t\t\t\u91cd\u65b0\u52a0\u8f7d\u6570\u636e\u8868\u5417\uff1fy\n ... Success!\n\nCleaning up...\n\nAll done!  If you've completed all of the above steps, your MariaDB\ninstallation should now be secure.\n\nThanks for using MariaDB!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e5d\u3001\u7f16\u8f91db2\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u914d\u7f6e\u6587\u4ef6\u53ca\u542f\u52a8\u6570\u636e\u5e93<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">[root@db2 ~]# vim \/etc\/my.cnf.d\/galera.cnf&nbsp;&nbsp;\u7f16\u8f91\u6570\u636e\u5e93\u96c6\u7fa4\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>34 wsrep_on=1\t\t\t\t\t\t\t\t#\u5f00\u542f\u96c6\u7fa4\n43 wsrep_cluster_name=\"Galera_cluster\"\t\t\t#\u5b9a\u4e49\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u540d\u79f0\n46 wsrep_cluster_address=\"gcomm:\/\/192.168.7.10,192.168.7.11,192.168.7.12\"\n54 wsrep_node_address=\"192.168.7.11\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db2 ~]# systemctl enable --now mariadb  \u542f\u52a8\u6570\u636e\u5e93\u5e76\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\nCreated symlink \/etc\/systemd\/system\/mysql.service \u2192 \/usr\/lib\/systemd\/system\/mariadb.service.\nCreated symlink \/etc\/systemd\/system\/mysqld.service \u2192 \/usr\/lib\/systemd\/system\/mariadb.service.\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/mariadb.service \u2192 \/usr\/lib\/systemd\/system\/mariadb.se<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u3001db2\u6570\u636e\u5e93\u7684\u5b89\u5168\u8bbe\u7f6e<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db2 ~]# mysql_secure_installation\t\t\tdb2\u6570\u636e\u5e93\u7684\u5b89\u5168\u8bbe\u7f6e\n\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\n\nIn order to log into MariaDB to secure it, we'll need the current\npassword for the root user. If you've just installed MariaDB, and\nhaven't set the root password yet, you should just press enter here.\n\nEnter current password for root (enter for none): \nOK, successfully used password, moving on...\n\nSetting the root password or using the unix_socket ensures that nobody\ncan log into the MariaDB root user without the proper authorisation.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nSwitch to unix_socket authentication &#91;Y\/n] n\t\t\u4ea4\u6362\u673a\u5207\u6362\u5230unix\u63a5\u53e3\u8ba4\u8bc1\u5417 n\n ... skipping.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nChange the root password? &#91;Y\/n] y\nNew password: \nRe-enter new password: \nPassword updated successfully!\nReloading privilege tables..\n ... Success!\n\n\nBy default, a MariaDB installation has an anonymous user, allowing anyone\nto log into MariaDB without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? &#91;Y\/n] y\n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'.  This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? &#91;Y\/n] y\n ... Success!\n\nBy default, MariaDB comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? &#91;Y\/n] y\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? &#91;Y\/n] y\n ... Success!\n\nCleaning up...\n\nAll done!  If you've completed all of the above steps, your MariaDB\ninstallation should now be secure.\n\nThanks for using MariaDB!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u4e00\u3001db2\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u914d\u7f6e\u6587\u4ef6\u8fdc\u7a0b\u590d\u5236<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db2 ~]# scp \/etc\/my.cnf.d\/galera.cnf 192.168.7.12:\/etc\/my.cnf.d\/galera.cnf\t\t\u5c06\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u914d\u7f6e\u6587\u4ef6\u8fdc\u7a0b\u590d\u5236\u5230 192.168.7.12\u96c6\u7fa4\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\u4e0b<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Are you sure you want to continue connecting (yes\/no\/[fingerprint])? yes<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Warning: Permanently added &#8216;192.168.7.12&#8217; (ED25519) to the list of known hosts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">root@192.168.7.12&#8217;s password:                                   \u5bc6\u7801\uff1a123.com<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u4e8c\u3001\u7f16\u8f91db3\u6570\u636e\u5e93\u96c6\u7fa4\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# vim \/etc\/my.cnf.d\/galera.cnf\t\t\u7f16\u8f91db3\u6570\u636e\u5e93\u96c6\u7fa4\u914d\u7f6e\u6587\u4ef6\n54 wsrep_node_address=\"192.168.7.12\"\t\t\u4fee\u6539\u96c6\u7fa4\u8282\u70b9IP\t<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u4e09\u3001\u542f\u52a8db3\u6570\u636e\u5e93\u5e76\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# systemctl enable --now mariadb\t\t\u542f\u52a8db3\u6570\u636e\u5e93\u5e76\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u56db\u3001db3\u6570\u636e\u5e93\u7684\u5b89\u5168\u8bbe\u7f6e<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# mysql_secure_installation \t\t\t\u6570\u636e\u5e93\u7684\u5b89\u5168\u8bbe\u7f6e\n\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\n\nIn order to log into MariaDB to secure it, we'll need the current\npassword for the root user. If you've just installed MariaDB, and\nhaven't set the root password yet, you should just press enter here.\n\nEnter current password for root (enter for none): \nOK, successfully used password, moving on...\n\nSetting the root password or using the unix_socket ensures that nobody\ncan log into the MariaDB root user without the proper authorisation.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nSwitch to unix_socket authentication &#91;Y\/n] n\t\t\u4ea4\u6362\u673a\u5207\u6362\u5230unix\u63a5\u53e3\u8ba4\u8bc1\u5417 n\n ... skipping.\n\nYou already have your root account protected, so you can safely answer 'n'.\n\nChange the root password? &#91;Y\/n] y\nNew password: \nRe-enter new password: \nPassword updated successfully!\nReloading privilege tables..\n ... Success!\n\n\nBy default, a MariaDB installation has an anonymous user, allowing anyone\nto log into MariaDB without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? &#91;Y\/n] y\n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'.  This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? &#91;Y\/n] y\n ... Success!\n\nBy default, MariaDB comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? &#91;Y\/n] y\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? &#91;Y\/n] y\n ... Success!\n\nCleaning up...\n\nAll done!  If you've completed all of the above steps, your MariaDB\ninstallation should now be secure.\n\nThanks for using MariaDB!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u4e94\u3001\u767b\u5f55db2\u6570\u636e\u5e93\u67e5\u770b\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u72b6\u6001<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB &#91;(none)]&gt; show status like 'wsrep_%'; #\u767b\u5f55\u6570\u636e\u5e93 \u67e5\u770b\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u72b6\u6001<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>wsrep_cert_index_size         | 3 \n| wsrep_incoming_addresses      | 192.168.7.11:0,192.168.7.10:0,192.168.7.12:0                                                                                                   |\u767b\u9646\u6210\u529f \u770b\u5230\u4e09\u4e2a\u96c6\u7fa4\u8282\u70b9IP\n\n| wsrep_cluster_weight          | 3 \t\t\u770b\u5230\u96c6\u7fa4\u7684\u6570\u91cf 3<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u516d\u3001\u5728db3\u4e0a\u521b\u5efaclass\u6570\u636e\u5e93,\u521b\u5efa\u5b66\u751f\u8868<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">16.1\u521b\u5efaclass\u6570\u636e\u5e93,\u521b\u5efastudent\u8868<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db3 ~]# mysql\t\t\t\t\u767b\u5f55\u6570\u636e\u5e93\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 8\nServer version: 10.5.27-MariaDB MariaDB Server\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nMariaDB &#91;(none)]&gt; create database class;\nQuery OK, 1 row affected (0.005 sec)\n\nMariaDB &#91;(none)]&gt; use class;\nDatabase changed\nMariaDB &#91;class]&gt;  create table student(   \n    -&gt;     \u5b66\u751f\u7f16\u53f7 int(3) not null,                   \n    -&gt;     \u59d3\u540d nvarchar(50),                          \n    -&gt;     \u8eab\u4efd\u8bc1\u53f7 varchar(18) primary key,           \n    -&gt;     \u6240\u5728\u73ed\u7ea7 int(11),                           \n    -&gt;     \u6210\u7ee9 int(11),                               \n    -&gt;     check(\u6210\u7ee9 &gt;=0 and \u6210\u7ee9 &lt;=100),             \n    -&gt;     \u5907\u6ce8 nvarchar(2000) null                    \n    -&gt;     );\n\n\u521b\u5efastudent\u6570\u636e\u8868<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">16.2\u5411student\u8868\u4e2d\u63d2\u5165\u6570\u636e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB &#91;class]&gt; INSERT INTO student (\u5b66\u751f\u7f16\u53f7,\u59d3\u540d,\u8eab\u4efd\u8bc1\u53f7,\u6240\u5728\u73ed\u7ea7,\u6210\u7ee9,\u5907\u6ce8)\n    -&gt; VALUES (112,'\u897f\u6bd2','223456789123456789',7,95,'\u7231\u597d\u86e4\u87c6\u529f');\nQuery OK, 1 row affected (0.004 sec)\n\nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt; INSERT INTO student (\u5b66\u751f\u7f16\u53f7,\u59d3\u540d,\u8eab\u4efd\u8bc1\u53f7,\u6240\u5728\u73ed\u7ea7,\u6210\u7ee9,\u5907\u6ce8)\n    -&gt; VALUES (113,'\u5357\u5e1d','323456789123456789',2,99,'\u4e00\u9633\u6307');\nQuery OK, 1 row affected (0.002 sec)\n\nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt; INSERT INTO student (\u5b66\u751f\u7f16\u53f7,\u59d3\u540d,\u8eab\u4efd\u8bc1\u53f7,\u6240\u5728\u73ed\u7ea7,\u6210\u7ee9,\u5907\u6ce8)\n    -&gt; VALUES (115,'\u8001\u987d\u7ae5','523456789123456789',1,99,'\u7231\u597d\u5404\u79cd\u6b66\u529f');\nQuery OK, 1 row affected (0.003 sec)\n\nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt; INSERT INTO student (\u5b66\u751f\u7f16\u53f7,\u59d3\u540d,\u8eab\u4efd\u8bc1\u53f7,\u6240\u5728\u73ed\u7ea7,\u6210\u7ee9,\u5907\u6ce8)\n    -&gt; VALUES (116,'\u9ec4\u84c9','623456789123456789',3,88,'\u6253\u72d7\u68d2');\nQuery OK, 1 row affected (0.002 sec)\n\nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt;  \nMariaDB &#91;class]&gt; INSERT INTO student (\u5b66\u751f\u7f16\u53f7,\u59d3\u540d,\u8eab\u4efd\u8bc1\u53f7,\u6240\u5728\u73ed\u7ea7,\u6210\u7ee9,\u5907\u6ce8)\n    -&gt; VALUES (117,'\u90ed\u9756','723456789123456789',1,89,'\u964d\u9f99\u5341\u516b\u638c');\nQuery OK, 1 row affected (0.002 sec)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5341\u4e03\u3001\u5728db1\u6570\u636e\u5e93\u4e0a\u67e5\u770b\u662f\u5426\u6570\u636e\u5df2\u540c\u6b65<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db1 ~]# mysql\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 15\nServer version: 10.5.27-MariaDB MariaDB Server\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nMariaDB &#91;(none)]&gt; show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| class              |\n| information_schema |\n| mysql              |\n| performance_schema |\n+--------------------+\n4 rows in set (0.001 sec)\n\nMariaDB &#91;(none)]&gt; use class;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nMariaDB &#91;class]&gt; show tables;\n+-----------------+\n| Tables_in_class |\n+-----------------+\n| student         |\n+-----------------+\n1 row in set (0.000 sec)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5728db2\u6570\u636e\u5e93\u4e0a\u6d4b\u8bd5\uff0c\u6570\u636e\u662f\u5426\u540c\u6b65\u6210\u529f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB &#91;(none)]&gt; show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| class              |\n| information_schema |\n| mysql              |\n| performance_schema |\n+--------------------+\n4 rows in set (0.001 sec)\n\nMariaDB &#91;(none)]&gt; use class;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nMariaDB &#91;class]&gt; show tables;\n+-----------------+\n| Tables_in_class |\n+-----------------+\n| student         |\n+-----------------+\n1 row in set (0.000 sec)\n\nMariaDB &#91;class]&gt; select * from student;\n+--------------+-----------+--------------------+--------------+--------+--------------------+\n| \u5b66\u751f\u7f16\u53f7     | \u59d3\u540d      | \u8eab\u4efd\u8bc1\u53f7           | \u6240\u5728\u73ed\u7ea7     | \u6210\u7ee9   | \u5907\u6ce8               |\n+--------------+-----------+--------------------+--------------+--------+--------------------+\n|          111 | \u4e1c\u90aa      | 123456789123456789 |            2 |     90 | NULL               |\n|          120 | \u4e18\u5904\u673a    | 213456789123456789 |            5 |     87 | NULL               |\n|          112 | \u897f\u6bd2      | 223456789123456789 |            7 |     95 | \u7231\u597d\u86e4\u87c6\u529f         |\n|          113 | \u5357\u5e1d      | 323456789123456789 |            2 |     99 | \u4e00\u9633\u6307             |\n|          114 | \u5317\u4e10      | 423456789123456789 |            3 |     96 | NULL               |\n|          115 | \u8001\u987d\u7ae5    | 523456789123456789 |            1 |     99 | \u7231\u597d\u5404\u79cd\u6b66\u529f       |\n|          116 | \u9ec4\u84c9      | 623456789123456789 |            3 |     88 | \u6253\u72d7\u68d2             |\n|          117 | \u90ed\u9756      | 723456789123456789 |            1 |     89 | \u964d\u9f99\u5341\u516b\u638c         |\n|          118 | \u6768\u5eb7      | 823456789123456789 |            1 |     80 | \u4e5d\u9634\u767d\u9aa8\u722a         |\n|          119 | \u88d8\u5343\u4ede    | 923456789123456789 |            7 |     77 | \u6c34\u4e0a\u6f02             |\n+--------------+-----------+--------------------+--------------+--------+--------------------+\n10 rows in set (0.001 sec)\n\n\u6570\u636e\u540c\u6b65\u6210\u529f\uff01<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>db1 &nbsp;192.168.7.10 db2 &nbsp;192.168.7.11 db3 &#038;nbsp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[63,62],"class_list":["post-1313","post","type-post","status-publish","format-standard","hentry","category-linux","tag-mariadb","tag-62"],"_links":{"self":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts\/1313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1313"}],"version-history":[{"count":7,"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions"}],"predecessor-version":[{"id":1322,"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions\/1322"}],"wp:attachment":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1313"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}