MySQL構成マスター
1925 ワード
の準備をインストールMySQL メインMySQLMySQL構成の変更 同期アカウントの作成 再起動MySQL クエリーmaster状態 MySQLから必要なディレクトリの作成 MySQL構成の変更 再起動MySQL 接続主MySQL レプリケーション機能の起動 レプリケーション機能状態の確認
# vim /etc/my.cnf
[mysqld]
server-id=1
log-bin=/data/mysql/bin-log/bin-log
> GRANT REPLICATION SLAVE ON *.* to 'mysync'@'%' identified by '123456';
# /etc/init.d/mysqld restart
> show master status;
+----------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+----------------+----------+--------------+------------------+-------------------+
| bin-log.000004 | 308 | | | |
+----------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
bin-logファイル名bin-log.000004
とbin-log点308
このときメインMySQLを操作しないで、状態値の変化を防止# mkdir /data/mysql/log-relay
# vi /etc/my.cnf
[mysqld]
server-id=2
read_only=1
relay_log=/data/mysql/log-relay/log-relay
# /etc/init.d/mysqld restart
> change master to master_host='10.10.10.81',master_user='mysync',master_password='123456',master_log_file='mysql-bin.000004',master_log_pos=308;
master_host
主MySQLのIPmaster_user
主MySQLの同期アカウントmaster_password
主MySQLの同期アカウントパスワードmaster_log_file
主MySQLのbin-logファイル名master_log_pos
主MySQLのbin-logポイント> start slave;
> show slave status \G
Slave_IO_Running
およびSlave_SQL_Running
はいずれもYES
正常運転を示す