centos上Mariadb主从复制配置
一、环境
主服务器:
IP:192.168.0.14
OS:cenos7
mariadb version:5.5.56
从服务器:
IP:192.168.3.76
OS:cenos7
mariadb version:5.5.56
二、主服务器配置
#vi /etc/my.cnf.d/server.cnf
####/etc/my.cnf.d/server.cnf文件mysqld节修改#######
server-id=1 log_bin=master-bin binlog-ignore-db=mysql binlog-ignore-db=information_schema binlog-ignore-db=performance_schema binlog_do_db=kovantestdb
重启数据库
#systemctl restart mariadb
增加备份账号
MariaDB [(none)]> grant replication slave,replication client on *.* to 'copy'@'%' identified by 'test123' ;
刷新权限
MariaDB [(none)]> flush privileges ;
显示master状态
MariaDB [(none)]> show master status \G ;
+-------------------+----------+--------------+---------------------------------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +-------------------+----------+--------------+---------------------------------------------+ | master-bin.000001 | 58655043 | kovantestdb | mysql,information_schema,performance_schema | +-------------------+----------+--------------+---------------------------------------------+ 1 row in set (0.00 sec)
三、从服务器配置
####/etc/my.cnf.d/server.cnf文件mysqld节修改#######
server-id=2 log_bin=master-bin
重启数据库
#systemctl restart mariadb
MariaDB [(none)]> stop slave;
MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='192.168.0.14',MASTER_USER='copy',MASTER_PASSWORD='test123',MASTER_LOG_FILE='master-bin.000001',MASTER_LOG_POS=58655043 ;
MariaDB [(none)]> start slave;
MariaDB [(none)]> start slave;
MariaDB [(none)]> show slave status \G ;
*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.14 Master_User: copy Master_Port: 3306 Connect_Retry: 60 Master_Log_File: master-bin.000001 Read_Master_Log_Pos: 59709420 Relay_Log_File: mariadb-relay-bin.000002 Relay_Log_Pos: 17585678 Relay_Master_Log_File: master-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: 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: 59709420 Relay_Log_Space: 17585974 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: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 1 row in set (0.00 sec) ERROR: No query specified
四、测试
在主服务器的kovantestdb里做一些改动,然后去从服务器上查看是否也有相应的更新。
上一篇: C中scanf函数不太明显的易错点
下一篇: 通过数组实现线性表
推荐阅读
-
在CentOS上MySQL数据库服务器配置方法
-
在CentOS上配置Nginx+Gunicorn+Python+Flask环境的教程
-
在阿里云服务器上配置CentOS+Nginx+Python+Flask环境
-
在CentOS上配置Nginx+Gunicorn+Python+Flask环境的教程
-
CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置
-
centos7 mariadb主从复制配置搭建详解步骤
-
CentOS上搭建Nginx+Mono运行asp.net环境的配置方法
-
记录CentOS 7.4 上安装MySQL&MariaDB&Redis&Mongodb
-
Linux(CentOS)上配置 SFTP服务器
-
CentOS6.5平台上rsync服务器安装配置方法简述