码迷,mamicode.com
首页 > 数据库 > 详细

MariaDB主从备份记录

时间:2016-07-19 18:21:43      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

一、预期效果:

  环境: centos 6.5   mariadb 10.0.14 (mysql -V)

  主服务器:192.168.5.206   从服务器:192.168.5.207   主服务器数据库有任何变动,从服务会跟着变动。

二、前期准备:

  确保主从数据库数据一致。

三、配置:

  1??  主服务器:vi /etc/my.cnf.d/server.cnf   添加如下配置,确保log-bin文件存在,并且权限,所属用户组与mysql一致。

# this is only for the mysqld standalone daemon
[mysqld]
log-bin=/var/lib/mysql/log/master-bin
server-id=1

  2??  主服务器增加同步账户,从服务器登录该账号同步主服务器的数据。

MariaDB [(none)]> GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.* TO backup@192.168.5.207 IDENTIFIED BY ‘password;

MariaDB [(none)]> Flush privileges;

注:backup:用户名 192.168.5.207:从服务器的IP(IP限制) password:登录密码

  3??  从服务器:vi /etc/my.cnf.d/server.cnf 添加如下配置,同样保证salve-bin , relay-bin 文件存在,并且权限,所属用户组与mysql一致。

# this is only for the mysqld standalone daemon
[mysqld]
log-bin=/var/lib/mysql/log/salve-bin
server-id=2
relay-log=/var/lib/mysql/log/relay-bin
log-slave-updates=1
read-only=1

重启从服务器 service mysql restart

  4??  主从配置:

主服务器:
MariaDB [(none)]> show master status;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| master-bin.000003 |    17030 |              |                  |
+-------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
从服务器:
MariaDB [(none)]> change master to master_host=192.168.5.206,
    -> master_user=backup,
    -> master_password=password,
    -> master_log_file=master-bin.000003,
    -> master_log_pos=0;
Query OK, 0 rows affected (0.03 sec)

MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.5.206
Master_User: backup1
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: master-bin.000004
Read_Master_Log_Pos: 23773
Relay_Log_File: relay-bin.000004
Relay_Log_Pos: 24061
Relay_Master_Log_File: master-bin.000004
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: 23773
Relay_Log_Space: 24640
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
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
1 row in set (0.00 sec)

ERROR: No query specified   

至此,已经OK了。

 

MariaDB主从备份记录

标签:

原文地址:http://www.cnblogs.com/logo-fox/p/5685544.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!