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

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

MySQL8.0.18配置多主一從

發(fā)布日期:2022-02-10 15:45 | 文章來源:CSDN

1. 現(xiàn)實(shí)背景

現(xiàn)有 4 臺(tái)主機(jī),均能夠自動(dòng)地采集數(shù)據(jù),并存入其 MySQL 數(shù)據(jù)庫中,另有 1 臺(tái)專門用于處理數(shù)據(jù)的高配置主服務(wù)器。這 5 臺(tái)機(jī)器經(jīng)常不在同一個(gè)網(wǎng)段下,但希望,一旦處于同一個(gè)網(wǎng)段下時(shí),4 臺(tái)用于采集數(shù)據(jù)的主機(jī)能夠自動(dòng)地向主服務(wù)器匯集數(shù)據(jù),為此配置環(huán)境。

2. 約定

  • slave,主服務(wù)器
  • master1, 用于采集數(shù)據(jù)的某一臺(tái)主機(jī)
  • master2, 用于采集數(shù)據(jù)的某一臺(tái)主機(jī)
  • master3, 用于采集數(shù)據(jù)的某一臺(tái)主機(jī)
  • master4, 用于采集數(shù)據(jù)的某一臺(tái)主機(jī)

3. 配置 master

3.1. 配置啟動(dòng)參數(shù)

多臺(tái) master 只需確保 server-id 不一致即可,其他根據(jù)自身需求配置。

[mysqld]
# 服務(wù)器標(biāo)識(shí)符, 確保每臺(tái)服務(wù)器標(biāo)識(shí)符都不一樣
server-id = 1000
# master 機(jī)必須開啟 log_bin
# mysql-bin 為自定義名字,會(huì)生成諸如 mysql-bin.index、mysql-bin.000001 等文件
log_bin=mysql-bin
# 二進(jìn)制日志過期時(shí)間(單位:天),默認(rèn)值為 0,即不過期
expire_logs_days = 0
# 錯(cuò)誤日志
log-error=/var/lib/mysql/mysql-error.log
# 單個(gè) log_bin 文件最大值,達(dá)到最大值之后新建文件后綴自增,如 mysql-bin.000002
max_binlog_size = 100M
# mysql 安裝路徑
basedir=/var/lib/mysql
# mysql 數(shù)據(jù)路徑
datadir=/var/lib/mysql
# master 記錄操作的數(shù)據(jù)庫
binlog_do_db=replication
# master 忽略的數(shù)據(jù)庫
binlog_ignore_db=information_schema
binlog_ignore_db=performance_schema
binlog_ignore_db=sys
binlog_ignore_db=mysql
# 二進(jìn)制日志保存模式
binlog_format=MIXED
# blob 類型的最大存儲(chǔ)值(單位:字節(jié)、B)
# 1048576 B = 1MB
max_allowed_packet=1048576

# 密碼復(fù)雜度配置,需要插件
# 密碼長度至少為 0
# validate_password_length=8
# 大小寫同時(shí)存在的最少數(shù)目
# validate_password_mixed_case_count=1
# 密碼至少存在的數(shù)字?jǐn)?shù)目
# validate_password_number_count=1
# 密碼至少存在的特殊字符數(shù)目
# validate_password_special_char_count=1
innodb_flush_log_at_trx_commit=0
[mysql]
default-character-set=utf8mb4
[client]
default-character-set=utf8mb4

3.2. 重啟服務(wù)使參數(shù)生效

3.3. 以 root 身份登錄,創(chuàng)建用戶,賦予密碼,授權(quán),刷新權(quán)限

創(chuàng)建用戶 replication,同時(shí)賦予密碼:

create user 'replication'@'%' identified with mysql_native_password by 'JINGhuaSHUIyue123,.';

如果創(chuàng)建用戶失敗,可能已經(jīng)存在用戶,不緊要的話可以刪除該用戶:

drop user 'replication'@'%';

如果不希望刪除重建用戶,只希望修改密碼:

alter user 'replication'@'%' identified with mysql_native_password by 'JINGhuaSHUIyue123,.';

賦予用戶 replication slave 權(quán)限:

grant replication slave on *.* to 'replication'@'%';

保證 replication slave 權(quán)限立即生效,刷新權(quán)限:

flush privileges;

4. 配置 slave 服務(wù)器

4.1. 配置啟動(dòng)參數(shù)

[mysqld]
# 服務(wù)器標(biāo)識(shí)符, 確保每臺(tái)服務(wù)器標(biāo)識(shí)符都不一樣
server-id = 2000
# mysql 安裝路徑
basedir=D:\mysql
# mysql 數(shù)據(jù)路徑
datadir=D:\mysql\data
# slave 復(fù)制的數(shù)據(jù)庫
replicate_do_db=test
# slave 忽略的數(shù)據(jù)庫
replicate_ignore_db=information_schema
replicate_ignore_db=performance_schema
replicate_ignore_db=mysql
replicate_ignore_db=sys
# slave 網(wǎng)絡(luò)超時(shí)重連間隔(單位:秒)
slave_net_timeout=60
[mysql]
default-character-set=utf8
[client]
default-character-set=utf8

4.2. 重啟服務(wù)使參數(shù)生效

5. 配置多主一從

5.1. 查看 master 狀態(tài)

以 root 身份登陸 master1,需要留意其中的 file、position:

show master status;
+------------------+----------+--------------+-------------------------------------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB    | Executed_Gtid_Set |
+------------------+----------+--------------+-------------------------------------------------+-------------------+
| mysql-bin.000006 |      155 | test         | information_schema,performance_schema,sys,mysql |                   |
+------------------+----------+--------------+-------------------------------------------------+-------------------+

以 root 身份登陸 master1,需要留意其中的 file、position:

show master status;
+------------------+----------+--------------+-------------------------------------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB    | Executed_Gtid_Set |
+------------------+----------+--------------+-------------------------------------------------+-------------------+
| mysql-bin.000005 |      155 | test         | information_schema,performance_schema,sys,mysql |                   |
+------------------+----------+--------------+-------------------------------------------------+-------------------+

說明:啟動(dòng) MySQL 會(huì)強(qiáng)制生成新的 log-bin,因此位置均為 155。

5.2. 配置 slave 與 master 的關(guān)聯(lián)

查看是否有其他殘余的配置:

show slave status\G;

停止 slave,清除殘余配置:

stop slave;
reset slave all;

根據(jù) master1 的 file,position 配置 replication 通道“master1”

change master to
master_host = '112.124.1.100',
master_user = 'replication',
master_port = 3306,
master_password = 'replication',
master_log_file = 'mysql-bin.000006',
master_log_pos = 155,
master_connect_retry = 15,
master_retry_count = 0
for channel 'master1';

根據(jù) master2 的 file,position 配置 replication 通道“master2”

change master to
master_host = '192.168.1.139',
master_user = 'replication',
master_port = 3306,
master_password = 'JINGhuaSHUIyue123,.',
master_log_file = 'mysql-bin.000005',
master_log_pos = 155,
master_connect_retry = 15,
master_retry_count = 0
for channel 'master2';
  • master_connect_retry:連接失敗,重試間隔(單位:秒)
  • master_retry_count:連接失敗重試次數(shù),0 為無限次

5.3. 準(zhǔn)備表

啟動(dòng)前,在三臺(tái)機(jī)器的數(shù)據(jù)庫中使用 DDL 語句定義好表結(jié)構(gòu),且表結(jié)構(gòu)保持一致,確保主從復(fù)制前的一致性,否則會(huì)出錯(cuò)!

5.4. 啟動(dòng) slave,查看 slave 狀態(tài)

start slave for channel 'master1';
start slave for channel 'master2';
show slave status\G;

注意 Slave_IO_Running 和 Slave_Slave_Running 需要均顯示為 Yes,才表示成功,否則留意錯(cuò)誤提示。

到此這篇關(guān)于MySQL8.0.18配置多主一從 的文章就介紹到這了,更多相關(guān)MySQL 多主一從 內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

香港服務(wù)器租用

版權(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í)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

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

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

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

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

在線
客服

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

客服
熱線

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

關(guān)注
微信

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