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

mysql 主从备份

时间:2020-01-16 14:46:03      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:cti   查看   修改   min   yum   serve   set   art   服务器   

1.1、环境准备

两台机器ip分别为

100.100.100.105 (主)
100.100.100.106(从)

安装 mysql

[root@centos ~]# yum install mysql-server mysql-client -y
[root@centos ~]# service mysqld start
[root@centos ~]# /usr/bin/mysqladmin -u root password '123456'
1.2、修改配置文件
100.100.100.105
[root@centos ~]# vim /etc/my.cnf
log-bin=mysql-bin
server-id=105
100.100.100.106
[root@centos ~]# vim /etc/my.cnf
log-bin=mysql-bin
server-id=106
1.3、添加mysql用户
mysql> grant replication slave on *.* to slave@'100.100.100.106' identified by '123456';
1.4、查看主服务器信息
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 |      261 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
1.5、登录从mysql
change master to
master_user='slave',
master_password='123456',
master_host='100.100.100.105',
master_log_file='mysql-bin.000004',
master_log_pos=261;
1.6、开启从mysql
mysql> start slave;
1.7、判断成功,可查看如下参数
mysql> show slave status\G;
            Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

mysql 主从备份

标签:cti   查看   修改   min   yum   serve   set   art   服务器   

原文地址:https://www.cnblogs.com/hjnzs/p/12200670.html

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