A replication setup of MySQL

1.The snapshot of a master is prepared for the slave side.

The dump file exported from the master is imported to the slave side like the procedure of "Distributed File of MySQL."

2.A setup of a master

The following is added to my.cnf.

server-id = 100 <- Numbers are arbitrary numbers which do not overlap with other MySQL servers.

The user in whom replication is possible is set up from a slave server.

mysql> grant replication slave on *.* to bookmark@192.168.1.50 identified by 'PASSWORD';
Query OK, 0 rows affected (0.01 sec)

The MySQL server by the side of a master is started.

3.A setup of a slave

The following is added to my.cnf.

server-id = 200 <- Numbers are arbitrary numbers which do not overlap with other MySQL servers.
master-host = 192.168.1.40
master-port = 13306 <- A master server port is specified.
master-user = bookmark <- The user who connects from a slave (user who specified by the master side)
master-password = <- The password specified for [ which is connected from a slave ] users
replicate-do-db = SandBox <- The database which performs replication.

The MySQL server by the side of a slave is started.
It is checked whether the error etc. has come out by the error log.

It checks that the following logs are outputted and replication is started in my case.

080218 16:00:29 mysqld started
080218 16:00:29 InnoDB: Started; log sequence number 0 60873317
080218 16:00:29 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
Version: '5.0.24-log' socket: '/tmp/mysql.sock' port: 13306 Source distribution
080218 16:00:29 [Note] Slave SQL thread initialized, starting replication in log 'binlog.000031' at position 351, relay log './c2-relay-bin.000059' position: 232
080218 16:00:29 [Note] Slave I/O thread: connected to master 'bookmark@192.168.1.40:13306', replication started in log 'binlog.000031' at position 351

4.The check of replication

It changes into the database by the side of a master, and checks being satisfactorily reflected in the slave side.

MySQLによる最速RDBMS構築ガイドMySQLによる最速RDBMS構築ガイド
(2005/09/17)
鶴長 鎮一、MCEA DB研究会 他

商品詳細を見る

MySQL逆引きクイックリファレンス―MySQL 4.0/4.1/5.0対応MySQL逆引きクイックリファレンス―MySQL 4.0/4.1/5.0対応
(2006/12)
山田 祥寛

商品詳細を見る