最近在搞mysql 主要就是mha,其实设计到主主复制的部分。就在这里做一下总结,就是简单的记录一下。
下面是情况简单介绍:
首先呢你得有两台服务器,都安装有mysql的数据库服务器,两台数据库之间呢,网络是通畅的,防火墙和selinux 是关闭的。然后就是将mysql 的配置文件做如下的设置。
[mysqld]
server-id=199 (这个地方两个服务器是不同的)
log-bin=mysql-bin
log-bin-index=mysql-bin.index
relay_log=/var/log/mysql-relay-bin.log(这个就是从服务器接受中继日志时使用的)
relay_log_index=/var/log/mysql-relay-bin.index
relay_log_purge=on
#log-bin-index=/data/mysql-bin.index
#expire_logs_days=30
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
以上呢是一份,rpm 版本的mysql 文件的全部内容。
改完之后呢,将两台服务器重新启动,然后分别在服务器上执行
reset slave;
change master to master_host='192.168.198.199',master_port=3306,master_user='c_slave',master_password='!QAZ2wsx',master_log_file='mysql-bin.000010',master_log_pos=154;
上面当中的 mysql_log_file 和 pos
通过下面 看这种情况
mysql> show master status \g
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000012 | 578 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.01 sec)
mysql>
然后就是 start slave; 两台机器互相联通。
然后分别在两台机器上 创建新的数据库和表,来查看同步的情况。
阅读(1631) | 评论(0) | 转发(0) |