mysql 主從備份

主服務器:

/etc/my.cnf

-----------------------------------------------------------------

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Default to using old password format for compatibility with mysql 3.x

# clients (those using the mysqlclient10 compatibility package).

old_passwords=1

 

# Disabling symbolic-links is recommended to prevent assorted security risks;

# to do so, uncomment this line:

# symbolic-links=0

server-id=1

log-bin=mysql-bin

binlog-do-db=test

binlog-ignore-db=mysql

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

-----------------------------------------------------------------

重啓mysql服務

GRANT REPLICATION SLAVE ON *.* TO 'gd'@'192.168.128.6' IDENTIFIED BY'gd';

flush privileges;

 

備服務器:

/etc/my.cnf

-----------------------------------------------------------------

[mysqld]

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
 
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
 
server-id=2
log-bin=mysql-bin
master-host=192.168.128.5
master-user=gd
master-password=gd
master-port=3306
replicate-do-db=test
master-connect-retry=60
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
-----------------------------------------------------------------
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章