五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

CentOS服務(wù)器環(huán)境下MySQL主從同步配置方法

發(fā)布日期:2022-04-11 19:31 | 文章來源:gibhub

本文實(shí)例講述了CentOS服務(wù)器環(huán)境下MySQL主從同步配置方法。分享給大家供大家參考,具體如下:

一、環(huán)境

主機(jī):

master操作系統(tǒng):centos 5.3
IP:192.168.1.222
MySQL版本:5.0.77

從機(jī):

slave操作系統(tǒng):centos 5.3
IP:192.168.1.220
MySQL版本:5.0.77

二、創(chuàng)建數(shù)據(jù)庫

分別登錄master機(jī)和slave機(jī)的

mysql:mysql –u root –p

創(chuàng)建數(shù)據(jù)庫:

create database repl;

三、master機(jī)和slave機(jī)的相關(guān)配置

1、修改master機(jī)器中mysql配置文件my.cnf,該文件在/etc目錄下

在[mysqld]配置段添加如下字段

server-id=1
log-bin=log
binlog-do-db=repl //需要同步的數(shù)據(jù)庫,如果沒有本行,即表示同步所有的數(shù)據(jù)庫
binlog-ignore-db=mysql //被忽略的數(shù)據(jù)庫

在master機(jī)上為slave機(jī)添加一同步帳號(hào)

grant replication slave on *.* to 'repl'@'192.1681.220' identified by '123456';

重啟master機(jī)的mysql服務(wù):

service mysqld restart

show master status命令看日志情況

mysql>show master status;
+-----------------+------------+-------------------+-----------------------+
| File    | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+-----------------+------------+-------------------+-----------------------+
| log.000003 |   98 | repl     | mysql     |
+-----------------+------------+-------------------+-----------------------+
1 row in set (0.00 sec)

2、修改slave機(jī)中mysql配置文件

同樣在[mysqld]字段下添加如下內(nèi)容

server-id=2
master-host=192.168.1.222
master-user=repl
master-password=123456
master-port=3306
master-connect-retry=60
replicate-do-db=repl //同步的數(shù)據(jù)庫,不寫本行表示同步所有數(shù)據(jù)庫

然后重啟slave機(jī)的mysql

在slave機(jī)中進(jìn)入mysql

mysql>start slave;
mysql>show slave status\G;

如果Slave_IO_Running、Slave_SQL_Running狀態(tài)為Yes則表明設(shè)置成功。

四、出現(xiàn)的問題

當(dāng)我在執(zhí)行start slave這條命令時(shí),系統(tǒng)提示

ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO,

執(zhí)行show slave status;又提示Empty set (0.00 sec),想不通問題在哪里

后來發(fā)現(xiàn),原來slave已經(jīng)默認(rèn)開啟,要先關(guān)閉再開啟

執(zhí)行

slave stop;

再執(zhí)行

復(fù)制代碼 代碼如下:
change master to master_host='192.168.1.222',master_user='repl',master_password='123456', master_log_file='log.000003' ,master_log_pos=98;

然后執(zhí)行

slave start;

這時(shí)再執(zhí)行

show slave status\G

顯示如下:

*************************** 1. row ***************************
   Slave_IO_State: Waiting for master to send event
    Master_Host: 192.168.1.222
    Master_User: repl
    Master_Port: 3306
    Connect_Retry: 60
   Master_Log_File: log.000003
  Read_Master_Log_Pos: 98
   Relay_Log_File: mysqld-relay-bin.000002
    Relay_Log_Pos: 229
  Relay_Master_Log_File: log.000003
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: 98
   Relay_Log_Space: 229
   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
1 row in set (0.00 sec)

至此,說明配置成功。

五、測(cè)試主從服務(wù)器是否能同步

在主服務(wù)器上面新建一個(gè)表,必須在repl數(shù)據(jù)下

mysql> use repl
Database changed
mysql> create table test(id int,name char(10));
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test values(1,'zaq');
Query OK, 1 row affected (0.00 sec)
mysql> insert into test values(1,'xsw');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test;
+------+------+
| id | name |
+-------+------+
| 1 | zaq |
| 1 | xsw |
+-------+------+
2 rows in set (0.00 sec)

在從服務(wù)器查看是否同步過來

mysql> use repl;
Database changed
mysql> select * from test;
+------+------+
| id | name |
+------+------+
|  1 | zaq |
|  1 | xsw |
+------+------+
2 rows in set (0.00 sec)

說明已經(jīng)配置成功。

希望本文所述對(duì)大家CentOS服務(wù)器維護(hù)有所幫助。

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部