변군이글루

[MySQL] mysql 리플리케이션(replication) 설정 방법 본문

* 리눅스

[MySQL] mysql 리플리케이션(replication) 설정 방법

변군 변군이글루 2013. 7. 24. 17:02
728x90

mysql 리플리케이션(replication) 설정 방법
1. master 서버 작업
1.1 /etc/mysql.cnf

$ vi /etc/mysql.cnf
…
[mysqld]
server_id = 1
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
log_bin = /var/log/mysql/mysql-bin

//binlog-do-db = 특정디비만

//replicate-ignore-db = 특정db제외

//replicate-wild-ignore-table = 특정 table 제외

1.2 mysql 재시작

$ /bin/sh /usr/local/mysql/bin/mysqld_safe &

 

1.3 slave에서 접속 할 계정 생성

$ mysql –u root –p

mysql> use mysql

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repuser'@10.0.10.101' IDENTIFIED BY '123456';

 

1.4 Slave의 설정을 위한 Master STATUS 정보

(File의 값과 Position의 값 추출)

mysql> FLUSH TABLES WITH READ LOCK;
1 row in set (0.00 sec)
 
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |   198032 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
 
mysql> UNLOCK TABLES;
1 row in set (0.00 sec)

2. slave 서버 작업

2.1 /etc/mysql.cnf

$ vi /etc/my.cnf
...
[mysqld]
server_id = 2
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
log_bin = /var/log/mysql/mysql-bin
relay_log = /var/log/mysql/mysql-relay-bin
expire_logs_days = 7
max_binlog_size = 512M
#binlog_do_db = www
read_only = 1
relay_log_purge = 0

 

 

 

 

 

728x90
0 Comments
댓글쓰기 폼