第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

mysql_主從同步

標(biāo)簽:
MySQL

在这里我就不说怎么搭建 Mysql 数据库了!如果有需要可以参照我前面的博文。

此博文主要说配置 Linux  数据库   主从   下面我们开始进入正题。

master:192.168.31.200

slave:192.168.31.250

主:192.168.31.200   配置如下:

1.修改   /etc/my.cnf    添加以下配置信息

[mysqld]

log-bin = mysql-bin      ##开启 bin  日志
server-id =1         ##指定
innodb-file-per-table =ON   ##开启独立表空间
skip_name_resolve=ON     ##禁止域名解析(优化的一部分_根据需求)

binlog_do_db=web      ##需要同步的数据库
binlog_do_db=mysql
binlog_do_db=webonline
binlog_do_db=hr

保存   wq   

2.重启数据库  

/etc/init.d/mysqld retart

 

3.进入数据库

[root@mysqlmaster ~]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.42-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

4.查看 master 值

mysql> show master status;
+------------------+----------+------------------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB           | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+------------------------+------------------+-------------------+
| mysql-bin.000002 |      120 | web,mysql,webonline,hr |                  |                   |
+------------------+----------+------------------------+------------------+-------------------+
1 row in set (0.01 sec)

 

5.创建一个用户给主从链接

mysql> grant replication slave on *.* to 'lihong'@'192.168.31.250' identified by '123456';

 

从:192.168.31.250   配置如下:

1.修改   /etc/my.cnf    添加以下配置信息

[mysqld]

server-id=2
relay-log=relay-log
relay-log-index=relay-log.index
log-bin = mysql-bin
innodb-file-per-table =ON
skip_name_resolve=ON

binlog_do_db=web
binlog_do_db=mysql
binlog_do_db=webonline
binlog_do_db=hr

保存   wq   

 

2.重启数据库  

/etc/init.d/mysqld retart

 

3.进入数据库

[root@mysqlmaster ~]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.42-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

4.关闭 slave 

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

 

5.创建一个用户给主从链接

mysql> grant replication slave on *.* to 'lihong'@'192.168.31.250' identified by '123456';

 

6.配置关联的信息

mysql> CHANGE MASTER TO
   -> MASTER_HOST='192.168.31.200',
   -> MASTER_USER='lihong',
   -> MASTER_PASSWORD='123456',
   -> MASTER_LOG_FILE='mysql-bin.000002',
   -> MASTER_LOG_POS=120;

 

7.开启 slave 

mysql> START SLAVE;
Query OK, 0 rows affected (0.03 sec)

 

8.查看 slave 是否正常开启了以及是否同步了

mysql> show slave status\G;
*************************** 1. row ***************************
              Slave_IO_State: Waiting for master to send event
                 Master_Host: 192.168.31.200
                 Master_User: lihong
                 Master_Port: 3306
               Connect_Retry: 60
             Master_Log_File: mysql-bin.000002
         Read_Master_Log_Pos: 120
              Relay_Log_File: relay-log.000003
               Relay_Log_Pos: 283
       Relay_Master_Log_File: mysql-bin.000002
            Slave_IO_Running: Yes
           Slave_SQL_Running: Yes
             Replicate_Do_DB:

 

9.是否同步成功,查看这两个状态值

Slave_IO_Running: Yes
           Slave_SQL_Running: Yes

原文出处:https://www.cnblogs.com/lilihong/p/10193428.html  

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報(bào)

0/150
提交
取消