首页 > Linux 技术 > mysql服务器主从同步配置

mysql服务器主从同步配置

Mysql主从配置

1.         主mysql配置:

grant replication slave on *.* to replication@10.20.137.148 identified by '123456';

vi /usr/local/mysql/my.cnf

log-bin=mysql-bin

同步的数据库

binlog-do-db=star

不同步的数据库

binlog-ignore-db=information_schema

binlog-ignore-db=mysql

binlog-ignore-db=test

2.         从mysql配置

log-bin=mysql-bin

server-id       = 2

master-host     =  10.20.137.150

master-user     =  replication

master-password =  123456

同步的数据库

binlog-do-db=star

不同步的数据库

binlog-ignore-db=information_schema

binlog-ignore-db=mysql

binlog-ignore-db=test

3.         检查

主mysql:

mysql> show master status\G

*************************** 1. row ***************************

            File: mysql-bin.000005

        Position: 106

    Binlog_Do_DB: star

Binlog_Ignore_DB: information_schema,mysql,test

1 row in set (0.00 sec)

从mysql:

mysql> show slave status\G

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 10.20.137.150

                  Master_User: replication

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000005

          Read_Master_Log_Pos: 106

               Relay_Log_File: test02-relay-bin.000012

                Relay_Log_Pos: 251

        Relay_Master_Log_File: mysql-bin.000005

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

              Replicate_Do_DB: star

          Replicate_Ignore_DB: information_schema,mysql,test

           Replicate_Do_Table:

       Replicate_Ignore_Table:

      Replicate_Wild_Do_Table:

  Replicate_Wild_Ignore_Table:

                   Last_Errno: 0

                   Last_Error:

                 Skip_Counter: 0

          Exec_Master_Log_Pos: 106

              Relay_Log_Space: 450

              Until_Condition: None

               Until_Log_File:

                Until_Log_Pos: 0

           Master_SSL_Allowed: No

           Master_SSL_CA_File:

           Master_SSL_CA_Path:

              Master_SSL_Cert:

            Master_SSL_Cipher:

               Master_SSL_Key:

        Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

                Last_IO_Errno: 0

                Last_IO_Error:

               Last_SQL_Errno: 0

               Last_SQL_Error:

1 row in set (0.00 sec)

4.         服务器管理

       3台测试服务器地址:

              test01.fbikey.com

              test02.fbikey.com

              test03.fbikey.com

              root / BqqAuJTmXNUz3LXzJyHQfskB7DjdE99o

       mysql用户和密码:

              sitemanager / UnHGIyDAeID2aVHP6qJv

       进入mysql:

              /usr/local/mysql/bin/mysql –u sitemanager -pUnHGIyDAeID2aVHP6qJv

       启动 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &

       上面3台测试服务器需要从web8.fbikey.com跳转

              root / 23r9&*#hfcnadhb23ad939g0cq2UFH28

5.         参考

http://blog.sina.com.cn/s/blog_474cf12b0100fbp7.html

http://myreligion.javaeye.com/blog/366508

http://kiddymeet.blog.51cto.com/20194/199185

http://www.ai77.org/archives/430

http://hi.chinaunix.net/?uid-227005-action-viewspace-itemid-39545

http://blog.chinaunix.net/u/25969/showart_723396.html

http://www.joinphp.cn/blog/?p=70

http://www.joinphp.cn/blog/?p=75

编者注:如果想让从服务器主动认识主服务器上的新建数据库事件,那么请将binlog-do-db= 的值留空即可!

原创文章,转载请注明: 转载清水的百宝箱

本文链接地址: mysql服务器主从同步配置

Share
分类: Linux 技术 标签: ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.