之前寫過 MariaDB 設定主從式資料庫 (Master Slave Replication) – https://benjr.tw/102278 (Master 的資料庫會透過 Binlog 的機制將資料同步到 Slave)
那如果 Slave 不需要時怎麼把他停掉.
測試環境為 CentOS 8 x86_64 (虛擬機)
先將 MariaDB 的 Slave 停掉.
[root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@localhost ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 17 Server version: 10.3.27-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> STOP SLAVE; MariaDB [(none)]> RESET SLAVE;
修改 MaraiDB 關於 Slave 的設定,並重啟服務.
[root@localhost ~]# vim /etc/my.cnf [mysqld] #server-id = 2 #replicate-do-db=testdb
[root@localhost ~]# systemctl restart mariadb
最後再檢視一下 SLAVE 的狀態是否停掉了.
MariaDB [(none)]> SHOW SLAVE STATUS; Empty set (0.000 sec)
沒有解決問題,試試搜尋本站其他內容