๋ฐ์ํ
MariaDB Replication ๊ธฐ๋ฅ์ DB ๋ฐ์ดํฐ ๋ฐฑ์ ์ฉ๋๋ก ์ฌ์ฉ (์ด์คํ๊ฐ ์๋)
1. Master ์๋ฒ
1) mariaDB stop & DB ๋ฐฑ์
$ systemctl stop mariadb
$ mysqldump -uroot -p hue > hue.sql
2) server.cnf ์ค์ ์ถ๊ฐ
vi /etc/my.conf.d/server.cnf
-----------------------------
[mysqld]
log_bin=mysql-bin
server-id=1
-----------------------------
3) systemctl start mariadb
4) mysql ์ ์ ํ ์๋ ๋ช ๋ น์ด ์คํ
> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO repl@'%' identified by 'Password'
5) slave ์๋ฒ์ ์ ๋ ฅํ file, position ํ์ธ
- ํด๋น ์ ๋ณด slave ์ค์ ์์ ์ฌ์ฉ
> show master status;
2. Slave ์๋ฒ
1) mariaDB stop & ๋ฐฑ์ DB ์ ๋ก๋
$ systemctl stop mariadb
$ mysql -uroot -p hue < hue.sql
2) server.cnf ์ค์ ์ถ๊ฐ
$ vi /etc/my.conf.d/server.cnf
-------------------------------
[mysqld]
log_bin=mysql-bin
server-id=2
relay_log=mysql-relay-bin
log_slave_updates=1
read_only=1
-------------------------------
3) systemctl start mariadb
4) mysql ์ ์ ํ ์๋ ๋ช ๋ น์ด ์คํ
> CHANGE MASTER TO MASTER_HOST='127.x.x.x', MASTER_USER='repl', MASTER_PASSWORD='Password',
MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=328, MASTER_CONNECT_RETRY=10;
> start slave;
> show slave status;