内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

半同步復(fù)制的實(shí)現(xiàn)

1、在主服務(wù)器上的配置

1)安裝mariadb-server
[root@localhost ~]# yum -y install mariadb-server
2)編輯/etc/my.cnf
[root@localhost ~]# vim /etc/my.cnf
    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 1
    log-bin = master-log
3)授權(quán)可以復(fù)制本地?cái)?shù)據(jù)庫(kù)信息的主機(jī)
[root@localhost ~]# systemctl start mariadb.service (啟動(dòng)mariadb server)

[root@localhost ~]# MySQL
    MariaDB [(none)]> grant replication slave,replication client on *.* to 'repluser'@'10.1.51.%' identified by 'replpasswd';
    MariaDB [(none)]> flush privileges;

MariaDB [(none)]> show master status\G (查看主服務(wù)器的狀態(tài)信息,在從服務(wù)器中要用到)
*************************** 1. row ***************************
            File: master-log.000003 (正在使用的二進(jìn)制日志文件)
        Position: 245 (所處的位置)
    Binlog_Do_DB: 
Binlog_Ignore_DB:
4)安裝rplsemisync_master插件,并啟用
[root@localhost ~]# mysql

MariaDB [(none)]> install plugin rpl_semi_sync_master soname 'semisync_master.so';
MariaDB [(none)]> set global rpl_semi_sync_master_enabled = ON; 

補(bǔ)充:
MariaDB [(none)]> show plugins;(可查看插件是否激活)
MariaDB [(none)]> show global variables like 'rpl_semi%';(可查看安裝的插件是否啟用)
MariaDB [(none)]> show global status like '%semi%';(可查看從服務(wù)器的個(gè)數(shù),此時(shí)是0個(gè))

2、從服務(wù)器的配置

1)安裝mariadb-server
[root@localhost ~]# yum -y install mariadb-server
2)編輯/etc/my.cnf文件
[root@localhost ~]# vim /etc/my.cnf
    在[mysqld]段的最后添加以下內(nèi)容
    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 2 (id號(hào)不能跟主服務(wù)器相同)
    relay-log = slave-log (自定義二進(jìn)制日志文件名)
3)設(shè)置要從哪個(gè)主服務(wù)器的那個(gè)位置開始同步
[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# mysql

    MariaDB [(none)]> change master to master_host='10.1.51.60',master_user='repluser',master_password='replpasswd',master_log_file='master-log.000003',master_log_pos=245;
4)安裝rplsemisync_slave插件并啟用
[root@localhost ~]# mysql   

    MariaDB [(none)]> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
    MariaDB [(none)]> set global rpl_semi_sync_slave_enabled = ON;
    MariaDB [(none)]> start slave;

完成上面配置后,可以在主服務(wù)器上查看半同步復(fù)制的相關(guān)信息,命令如下:

創(chuàng)新互聯(lián)是一家專注于網(wǎng)站設(shè)計(jì)制作、網(wǎng)站制作與策劃設(shè)計(jì),陵水黎族網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:陵水黎族等地區(qū)。陵水黎族做網(wǎng)站價(jià)格咨詢:18982081108

MariaDB [(none)]> show global status like '%semi%';
    Rpl_semi_sync_master_clients    1 (從服務(wù)器有一臺(tái))

3、測(cè)試

測(cè)試以個(gè)人實(shí)際情況而定
1)在主服務(wù)器上導(dǎo)入事先準(zhǔn)備好的數(shù)據(jù)庫(kù)hellodb.sql
MariaDB [hellodb]> source /root/hellodb.sql;
2)在主服務(wù)器上查看半同步復(fù)制的狀態(tài)
MariaDB [hellodb]> show master status;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| master-log.000003 |     8102 |              |                  |
+-------------------+----------+--------------+------------------+

MariaDB [hellodb]> show global status like '%semi%';
+--------------------------------------------+-------+
| Variable_name                              | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients               | 1     |
| Rpl_semi_sync_master_net_avg_wait_time     | 1684  |
| Rpl_semi_sync_master_net_wait_time         | 60630 |
| Rpl_semi_sync_master_net_waits             | 36    |
| Rpl_semi_sync_master_no_times              | 1     |
| Rpl_semi_sync_master_no_tx                 | 1     |
| Rpl_semi_sync_master_status                | ON    |
| Rpl_semi_sync_master_timefunc_failures     | 0     |
| Rpl_semi_sync_master_tx_avg_wait_time      | 1884  |
| Rpl_semi_sync_master_tx_wait_time          | 65965 |
| Rpl_semi_sync_master_tx_waits              | 35    |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0     |
| Rpl_semi_sync_master_wait_sessions         | 0     |
| Rpl_semi_sync_master_yes_tx                | 35    |
+--------------------------------------------+-------+
3)在從服務(wù)器上查看是否同步
MariaDB [(none)]> show databases;
MariaDB [(none)]> use hellodb;
MariaDB [hellodb]> select * from students;

補(bǔ)充:基于上面的半同步復(fù)制配置復(fù)制的過(guò)濾器,復(fù)制過(guò)濾最好在從服務(wù)器上設(shè)置,步驟如下

1、從服務(wù)器的配置

1)關(guān)閉mariadb server
[root@localhost ~]# systemctl stop mariadb.service
2)編輯/etc/my.cnf文件
[root@localhost ~]# vim /etc/my.cnf
    skip_name_resolve = ON
    innodb_file_per_table = ON
    server-id = 2
    relay-log = slave-log
    replicate-do-db = mydb (只復(fù)制mydb數(shù)據(jù)庫(kù)的內(nèi)容)

補(bǔ)充:常用的過(guò)濾選項(xiàng)如下
    Replicate_Do_DB=
    Replicate_Ignore_DB=
    Replicate_Do_Table=
    Replicate_Ignore_Table=
    Replicate_Wild_Do_Table=
    Replicate_Wild_Ignore_Table=
3)重啟mariadb server
[root@localhost ~]# systemctl start mariadb.service
4)重啟mariadb server后,半同步復(fù)制功能將被關(guān)閉,因此要重新啟動(dòng)
MariaDB [(none)]> show global variables like '%semi%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled     | OFF   |
| rpl_semi_sync_slave_trace_level | 32    |
+---------------------------------+-------+

MariaDB [(none)]> set global rpl_semi_sync_slave_enabled = ON;
MariaDB [(none)]> stop slave;(需先關(guān)閉從服務(wù)器復(fù)制功能再重啟)
MariaDB [(none)]> start slave;

2、測(cè)試

1)主服務(wù)器上的hellodb數(shù)據(jù)庫(kù)創(chuàng)建一個(gè)新表semitable
MariaDB [hellodb]> create table semitable (id int);
2)在從服務(wù)器上查看hellodb數(shù)據(jù)庫(kù)是否有semitable
MariaDB [(none)]> use hellodb
MariaDB [hellodb]> show tables;(并沒(méi)有)
+-------------------+
| Tables_in_hellodb |
+-------------------+
| classes           |
| coc               |
| courses           |
| scores            |
| students          |
| teachers          |
| toc               |
+-------------------+
3)在主服務(wù)器上創(chuàng)建mydb數(shù)據(jù)庫(kù),并為其創(chuàng)建一個(gè)tbl1表
MariaDB [hellodb]> create database mydb;
4)在從服務(wù)器上查看mydb數(shù)據(jù)庫(kù)的是否有tbl1表
MariaDB [hellodb]> use mydb;
MariaDB [mydb]> show tables; (可以查看到)
+----------------+
| Tables_in_mydb |
+----------------+
| tbl1           |
+----------------+

本文名稱:半同步復(fù)制的實(shí)現(xiàn)
網(wǎng)頁(yè)地址:http://www.rwnh.cn/article4/jgjjoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站網(wǎng)站設(shè)計(jì)、面包屑導(dǎo)航服務(wù)器托管、營(yíng)銷型網(wǎng)站建設(shè)、網(wǎng)站收錄

廣告

聲明:本網(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)

成都網(wǎng)站建設(shè)
安康市| 金溪县| 昌江| 新宾| 山东| 吴川市| 梁山县| 宿松县| 奉贤区| 平潭县| 巫溪县| 道真| 唐山市| 霍林郭勒市| 淅川县| 图木舒克市| 新巴尔虎左旗| 内江市| 克什克腾旗| 镇赉县| 雷波县| 福清市| 桃源县| 克东县| 靖边县| 聂荣县| 辉南县| 东山县| 玛沁县| 吉木乃县| 五指山市| 万州区| 仲巴县| 和田县| 天等县| 宣威市| 香河县| 石景山区| 宝山区| 咸阳市| 突泉县|