"MariaDB 레플리케이션 설정"의 두 판 사이의 차이

68번째 줄: 68번째 줄:
server_id=11
server_id=11
log-basename=master1
log-basename=master1
</source>
<source lang='console'>
root@slave1:~# systemctl restart mariadb
root@slave1:~#
</source>
</source>
<source lang='console'>
<source lang='console'>

2017년 9월 25일 (월) 21:59 판

1 개요

MariaDB 리플레이션 설정
호스트명 역할 IP
master1 마스터 #1 135.79.246.11
slave1 슬레이브 #1 135.79.246.21
slave2 슬레이브 #2 135.79.246.22

2 사전작업

3 DB 구조 이전

root@master1:~# mysqldump -uroot -p패스워드 --all-databases --no-data > structure.sql
root@slave1:~# mysql -uroot -p패스워드 < structure.sql

4 마스터 설정

root@master1:~# vi /etc/mysql/mariadb.conf.d/50-server.cnf
[mariadb]
log-bin
server_id=1
log-basename=master1
→ [mariadb]영역에 기입
root@master1:~# systemctl restart mariadb
root@master1:~#
root@master1:~# mysql -uroot -p
Enter password: P@ssw0rd
MariaDB [(none)]> CREATE USER 'replication_user'@'%' IDENTIFIED BY '패스워드';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> GRANT REPLICATION SLAVE ON *.* TO replication_user;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW MASTER STATUS;
+--------------------+----------+--------------+------------------+
| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| master1-bin.000001 |    42102 |              |                  |
+--------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
→ master1-bin.000001 와 42102 을 기억해두자.

5 슬레이브 설정

root@slave1:~# vi /etc/mysql/mariadb.conf.d/50-server.cnf
[mariadb]
log-bin
server_id=11
log-basename=master1
root@slave1:~# systemctl restart mariadb
root@slave1:~#
root@slave1:~# mysql -uroot -p
Enter password: P@ssw0rd
MariaDB [(none)]> CHANGE MASTER TO
    -> MASTER_HOST='135.79.246.11',
    -> MASTER_USER='replication_user',
    -> MASTER_PASSWORD='패스워드',
    -> MASTER_PORT=3306,
    -> MASTER_LOG_FILE='master1-bin.000001',
    -> MASTER_LOG_POS=42102,
    -> MASTER_CONNECT_RETRY=10;
Query OK, 0 rows affected (0.15 sec)
MariaDB [(none)]> START SLAVE;
Query OK, 0 rows affected (0.00 sec)

6 같이 보기

7 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}