創(chuàng)新互聯(lián)建站專注于青銅峽企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站定制開(kāi)發(fā)。青銅峽網(wǎng)站建設(shè)公司,為青銅峽等地區(qū)提供建站服務(wù)。全流程按需策劃設(shè)計(jì),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
如果在生產(chǎn)環(huán)境中可能有一個(gè)主服務(wù)器,也是讀寫服務(wù)器,并可能會(huì)有多個(gè)從服務(wù)器,但這個(gè)主服務(wù)器會(huì)隨之從服務(wù)器的增加而變的性能下降,所以最好主服務(wù)器只有一個(gè)從,其它的從服務(wù)器再?gòu)倪@人從服務(wù)器進(jìn)行復(fù)制,減少主服務(wù)器的壓力,這樣中間服務(wù)器專做復(fù)制從而最小化影響主服務(wù)器的性能
[root@centos7 ~]#yum install mariadb-server
[root@centos7 ~]#mkdir /data/{MySQL,logs}
[root@centos7 ~]#chown mysql:mysql /data/{mysql,logs}
[root@master ~]#vi /etc/my.cnf
[mysqld]
log-bin=/data/logs/bin
datadir=/data/mysql
server-id=17
[root@master ~]#systemctl start mariadb
[root@master ~]#mysql < hellodb_innodb.sql
MariaDB [(none)]> grant replication slave on *.* to repluser@'192.168.205.%' identified by 'centos';
[root@master ~]#mysqldump -A --single-transaction --master-data=1 > /data/all.sql
[root@master ~]#scp /data/all.sql 192.168.205.27:/data
[root@middle ~]#vi /etc/my.cnf
[mysqld]
datadir=/data/mysql
log-bin=/data/logs/bin
server-id=27
read-only
log_slave_updates
[root@middle ~]#vi /data/all.sql
CHANGE MASTER TO
MASTER_HOST='192.168.205.17',
MASTER_USER='repluser',
MASTER_PASSWORD='centos',
MASTER_PORT=3306,
MariaDB [(none)]> source /data/all.sql
MariaDB [(none)]> start slave;
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.205.17
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.000003
Read_Master_Log_Pos: 7973
Relay_Log_File: mariadb-relay-bin.000004
Relay_Log_Pos: 604
Relay_Master_Log_File: bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
[root@middle ~]#mysqldump -A --single-transaction --master-data=1 > /data/middle.sql
[root@middle ~]#scp /data/middle.sql 192.168.205.37:/data
[root@slave ~]#vi /etc/my.cnf
[mysqld]
datadir=/data/mysql
server-id=37
read_only
[root@slave ~]#vi /data/middle.sql
CHANGE MASTER TO
MASTER_HOST='192.168.205.27',
MASTER_USER='repluser',
MASTER_PASSWORD='centos',
MASTER_PORT=3306,
[root@slave ~]#mysql < /data/middle.sql
[root@slave ~]#systemctl start mariadb
MariaDB [(none)]> start salve;
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.205.27
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.000005
Read_Master_Log_Pos: 326
Relay_Log_File: mariadb-relay-bin.000003
Relay_Log_Pos: 604
Relay_Master_Log_File: bin.000005
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
MariaDB [(none)]> create database zhaoli;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1 |
| db2 |
| hellodb |
| mysql |
| performance_schema |
| test |
| zhaoli |
+--------------------+
8 rows in set (0.00 sec)
網(wǎng)站標(biāo)題:數(shù)據(jù)庫(kù)的級(jí)聯(lián)復(fù)制
本文網(wǎng)址:http://www.rwnh.cn/article24/jjeoje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、搜索引擎優(yōu)化、網(wǎng)站維護(hù)、微信小程序、網(wǎng)站收錄、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)