從零搭建MySQL InnoDB Cluster

2021-03-02 愛可生雲資料庫

mysql-js> \c root@10.186.23.95   #必須連接某個數據節點

Creating a Session to 'root@10.186.23.95'

Enter password:

Classic Session successfully established. No default schema selected.

mysql-js> dba.createCluster('mycluster')

A new InnoDB cluster will be created on instance 'root@10.186.23.95:3306'.

Creating InnoDB cluster 'mycluster' on 'root@10.186.23.95:3306'...

Adding Seed Instance...

Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.

At least 3 instances are needed for the cluster to be able to withstand up to

one server failure.

<Cluster:mycluster>

mysql-js> var cluster=dba.getCluster('mycluster')

mysql-js> cluster.addInstance('root@10.186.23.96:3306')  #添加其他節點

A new instance will be added to the InnoDB cluster. Depending on the amount of

data on the cluster this might take from a few seconds to several hours.

Please provide the password for 'root@10.186.23.96:3306':

Adding instance to the cluster ...

The instance 'root@10.186.23.96:3306' was successfully added to the cluster.

mysql-js> cluster.addInstance('root@10.186.23.94:3306')

A new instance will be added to the InnoDB cluster. Depending on the amount of

data on the cluster this might take from a few seconds to several hours.

Please provide the password for 'root@10.186.23.94:3306':

Adding instance to the cluster ...

The instance 'root@10.186.23.94:3306' was successfully added to the cluster.

mysql-js> cluster.status()

{

    "clusterName": "mycluster",

    "defaultReplicaSet": {

        "name": "default",

        "primary": "10.186.23.95:3306",

        "status": "OK",

        "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",

        "topology": {

            "10.186.23.94:3306": {

                "address": "10.186.23.94:3306",

                "mode": "R/O",

                "readReplicas": {},

                "role": "HA",

                "status": "ONLINE"

            },

            "10.186.23.95:3306": {

                "address": "10.186.23.95:3306",

                "mode": "R/W",

                "readReplicas": {},

                "role": "HA",

                "status": "ONLINE"

            },

            "10.186.23.96:3306": {

                "address": "10.186.23.96:3306",

                "mode": "R/O",

                "readReplicas": {},

                "role": "HA",

                "status": "ONLINE"

            }

        }

    }

}

相關焦點

  • MySQL InnoDB Cluster環境搭建和簡單測試
    定義一個Cluster變量,節點1就開啟了Cluster創建之旅,可以從下面的信息看出,至少需要3個節點mysql-js>  var cluster = dba.createCluster('testCluster')A new InnoDB cluster will be created on instance 'root@localhost:3310'.
  • MySQL中InnoDB-Cluster 日常運維掃盲-愛可生
    本篇是《innodb-cluster 掃盲-安裝篇》的續篇。 我們知道,InnoDB Cluster 是 Oralce 官方發布的用來管理 MySQL 組複製的一套工具,有了 InnoDB Cluster,MySQL 原生組複製的部署、運維、開發等將會變得非常簡單。
  • MySQL InnoDB存儲引擎啟動過程源碼分析
    調用 innobase_start_or_create_for_mysql 函數,這個函數非常重要,後面詳細分析這個函數。innobase_start_or_create_for_mysql 函數:這個函數位於源碼文件storage/innobase/srv/srv0start.cc,主要作用是啟動innodb引擎,如果數據目錄為空,則會創建一個新的資料庫所需要的文件。
  • Mysql innodb 存儲引擎的性能優化
    ,但是關於資料庫方面的翻譯的不好,大家就看看吧,翻譯本文只是想更 清楚的了解mysql 優化上的一些基本原則,而國內對於這個沒有完整的資料。InnoDB的的鎖表行為在不同的mysql 版本是不同的,如果你 從MySQL4.0或者更新的版本升級,那你依賴於innodb_table_locks這個選項會導致很多問題。5. 主鍵簇5.1. 主鍵是特殊的5.1.1. 通過主鍵訪問數據比通過其它key訪問更快。無論是在內存還是磁碟通過主鍵查找都是最快的。5.1.2. 數據都由主鍵聚集的。
  • MySQL InnoDB 引擎中的 7 種鎖類型,你都知道嗎?
    前言大概幾個月之前項目中用到事務,需要保證數據的強一致性,期間也用到了mysql的鎖,但當時對mysql的鎖機制只是管中窺豹,所以本文打算總結一下mysql的鎖機制。本文主要論述關於mysql鎖機制,mysql版本為5.7,引擎為innodb,由於實際中關於innodb鎖相關的知識及加鎖方式很多,所以沒有那麼多精力羅列所有場景下的加鎖過程並加以分析,僅根據現在了解的知識,結合官方文檔,說說自己的理解,如果發現有不對的地方,歡迎指正。概述總的來說,InnoDB共有七種類型的鎖:mysql鎖詳解1.
  • InnoDB加鎖實驗
    實驗環境準備mysql版本: 5.6.16-64.2 Percona Server.隔離級別:repeatable read.資料庫引擎設置: InnoDB.https://dev.mysql.com/doc/refman/5.6/en/innodb-enabling-monitors.htmlhttps://www.percona.com/doc/percona-server/5.5/diagnostics/innodb_show_status.htmlIV.
  • MySQL底層存儲結構
    67 Dec 6 14:24 db.opt 12 -rw-r 1 mysql mysql 8674 Dec 24 10:51 t_innodb.frm # 表結構定義文件 96 -rw-r 1 mysql mysql 98304 Dec 24 10:54 t_innodb.ibd # 表空間文件,裡面存放數據和索引 12 -rw-r 1 mysql mysql 8674 Dec
  • 用 Docker 構建 MySQL 主從環境
    MySQL 主從同步分為 5 個步驟:1.master 節點將數據的更新記錄寫到 binary log 中。/mysql/slave/data:/var/lib/mysql restart: always ports: - 3306:3306配置 master 節點的 cluster.cnf 文件以及 Dockerfile 文件[mysqld]server_id=100binlog-ignore-db=mysqllog-bin=replicas-mysql-binbinlog_cache_size
  • Docker 搭建 Redis Cluster 集群環境
    使用 Docker 搭建 Redis Cluster,最重要的環節就是容器通信的問題,這一塊我們在之前的文章中已經給大家解決了《Docker 網絡模式詳解及容器間網絡通信》,本篇文章主要練習使用多個容器完成 Redis Cluster 集群環境的搭建,順便為學習 Docker Compose 鋪鋪路。
  • MySQL innochecksum 工具
    MySQL innochecksum 工具主要用於MySQL innodb表空間文件的校驗,通過讀取表空間文件,計算頁的checksum值,將計算的結果與頁內存儲的checksum值進行對比,檢查對比結果是否一致,如果不一致,說明文件頁可能發生了損壞,innochecksum工具同時提供了checksum校驗值修復功能,能夠將頁checksum值不正確的頁進行修復。
  • MySQL如何計算統計redo log大小
    雖然我在這篇博客「MySQL中Redo Log相關的重要參數總結」中介紹了,MySQL 8.0引入了innodb_dedicated_server自適應參數,可基於伺服器的內存來動態設置innodb_buffer_pool_size,innodb_log_file_size和innodb_flush_method。默認情況下,此參數是關閉的。
  • 淺析 MySQL Replication
    目前很多公司中的生產環境中都使用了MySQL Replication ,也叫 MySQL 複製,搭建配置方便等很多特性讓 MySQL Replication 的應用很廣泛,我們曾經使用過一主拖20多個從庫來分擔業務壓力。
  • MySQL 引擎特性:InnoDB IO 子系統
    innodb_flush_method這個參數比較重要,重點介紹一下:如果innodb_flush_method設置了O_DSYNC,日誌文件(ib_logfileXXX)使用O_SYNC打開,因此寫完數據不需要調用函數fsync刷盤,數據文件(ibd)使用default模式打開,因此寫完數據需要調用fsync刷盤。
  • MySQL慢查詢記錄原理和內容解析
    , value=9503561) at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:1784#2 0x0000000001a4b50f in lock_wait_suspend_thread (thr=0x7fff2c088200) at /root
  • MySQL 表如何計算統計信息-愛可生
    比如對比指定表在系統表 mysql.innodb_index_stats 的數據跟 distinct 查詢的結果,如果相差太大,可以考慮增加這個值。 當 analyze table 變的非常慢時,可能是這個值設置的太大了,此時要考慮減小這個值。
  • MySQL 實戰筆記 第04期:alter table 語句進度評估
    stage/innodb/alter table (merge sort):對 ALTER TABLE  操作添加的每個索引重複此階段。stage/innodb/alter table (insert):對 ALTER TABLE  操作添加的每個索引重複此階段。
  • 解析XtraBackup備份MySQL的原理和過程
    >mysql/3306/dataxtrabackup:   innodb_data_file_path = ibdata1:512M:autoextend>mysql/3306/redologxtrabackup:   innodb_log_files_in_group = 3
  • CUBRID和MySQL使用SSD前後性能測試對比
    /mysql/tmp/mysql.sock[mysqld]user = mysqlport = 3306basedir = /home1/mysql/mysqldatadir = /home1/mysql/mysql/datatmpdir = /home1/mysql/mysql/tmpsocket = /home1/mysql/mysql
  • MySQL 優化案例 - select count-愛可生
    mysql> select * from sys.innodb_buffer_stats_by_table where object_schema = 'test';Empty set (1.92 sec)mysql> select count(*) from test.sbtest1;++| count(*) |++| 5188434 |++1 row in set
  • MySQL- InnoDB之二進位日誌
    2.4 GTID的開啟和配置vim /etc/my.cnfgtid-mode=onenforce-gtid-consistency=true2.5 查看GTID信息mysql> create database gtid charset utf8mb4;mysql> show master status