개발/MySql

[MYSQL] REPLICATION

나랑살자 2010. 10. 28. 11:13
REPLICATION
#MASTER
#vi /etc/my.cnf
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id       = 1

#mysql
grant replication slave on *.* to 'backup'@'xxx.xxx.xxx.xxx' identified by 'dnsaud';

#SLAVE
#vi /etc/my.cnf

# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
server-id       = 2
#
# The replication master for this slave - required
master-host     =   db1
#
# The username the slave will use for authentication when connecting
# to the master - required
master-user     =   backup


>master db 를 slave로 복사
#/usr/local/mysql/bin/mysqldump -hxxx.xxx.xxx.xxx -ucutalk -pcutalk cutalkdb | /usr/local/mysql/bin/mysql -uroot -C cutalkdb

#/usr/local/mysql/bin/mysql
CHANGE MASTER TO MASTER_HOST='xxx.xxx.xxx.xxx', MASTER_PORT=3306,
    MASTER_USER='backup', MASTER_PASSWORD='dnsaud', master_log_file='mysql-bin.000007', master_log_pos=659277542;


#master_log_file 및 master_log_pos
show master status;
+------------------+-----------+--------------+------------------+
| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000008 | 121100486 |              |                  |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)