码迷,mamicode.com
首页 > 其他好文 > 详细

msyql 主从备份

时间:2018-08-11 18:14:56      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:RoCE   rar   base   测试   connect   col   pass   cto   src   

环境:server1 rhel6.5
server2 rhel6.5
[root@server1 ~]# cd mysql5.7/
[root@server1 mysql5.7]# ls
mysql-community-client-5.7.17-1.el6.x86_64.rpm
mysql-community-common-5.7.17-1.el6.x86_64.rpm
mysql-community-devel-5.7.17-1.el6.x86_64.rpm
mysql-community-embedded-5.7.17-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm
mysql-community-server-5.7.17-1.el6.x86_64.rpm
mysql-community-test-5.7.17-1.el6.x86_64.rpm
repodata
[root@server1 mysql5.7]# yum install -y mysql-community-client-5.7.17-1.el6.x86_64.rpm mysql-community-common-5.7.17-1.el6.x86_64.rpm mysql-community-libs-5.7.17-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm mysql-community-server-5.7.17-1.el6.x86_64.rpm
[root@server1 mysql5.7]# vim /etc/my.cnf
技术分享图片

[root@server1 mysql5.7]# /etc/init.d/mysqld start
[root@server1 mysql5.7]# grep password /var/log/mysqld.log 查看密码
2018-08-11T01:42:03.837872Z 1 [Note] A temporary password is generated for root@localhost: Et,=8ah+havI
[root@server1 mysql5.7]# mysql_secure_installation ##初始化改密码
[root@server1 mysql5.7]# mysql -p
mysql> grant replication slave on . to cara@‘172.25.135.2‘ identified by ‘Caonimei@478‘;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges; ##刷新策率
Query OK, 0 rows affected (0.01 sec)
[root@server2 ~]# mysql -ucara -p -h 172.25.135.1 ##测试远程登陆
mysql> show master status; ##master上查看
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000007 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

mysql> change master to ##slave上连接 master_host=‘172.25.135.1‘,master_user=‘cara‘,master_password=‘Caonimei@478‘,master_log_file=‘mysql-bin.000007‘,master_log_pos=154;
Query OK, 0 rows affected, 2 warnings (0.11 sec)
mysql> show slave status\G;
1. row
Slave_IO_State:
Master_Host: 172.25.135.1
Master_User: cara
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 154
Relay_Log_File: server2-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: No
Slave_SQL_Running: No
mysql> start slave
mysql> show slave status\G;
主master上添加写数据
mysql> create database westos;
从slave上就可以看到
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| westos |
+--------------------+

msyql 主从备份

标签:RoCE   rar   base   测试   connect   col   pass   cto   src   

原文地址:http://blog.51cto.com/13810716/2158145

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