国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MySQL InnoDB Cluster環(huán)境搭建和簡單測驗

2024-07-24 12:31:20
字體:
供稿:網(wǎng)友
       InnoDB Cluster初印象
 
     記得MySQL Group Replicatioin 剛開始的時候,MySQL界很是轟動,等待了多年,終于有了官方的這個高可用解決方案。你要說還有一些方案補充,比如MySQL Cluster,MySQL Proxy,這些的使用率個人感覺還是不高,也就是經(jīng)受的考驗還不夠,原因有很多,就不贅述了。
 
     MySQL DBA:所以說MGR的企業(yè)級應(yīng)用還是需要一些輔助,這樣才算是一個完整的解決方案。
 
    不久,MySQL InnoDB Cluster推出,我覺得這個方案想比原來的MGR更進一步,說實話,我很看好這個方案,盡管目前愿意真正去用的用戶確實不多。
 
    如果你看一下官方的這個架構(gòu)圖,就會發(fā)現(xiàn),MGR本身就是Innodb Cluster的一部分,還有兩個組件,MySQL Shell,MySQL Router,這三板斧就是InnoDB Cluster的一個核心組件,而正如我之前所說,可以看到MySQL的一個格局和定位,他正在很努力去解決以前詬病的問題。
  
    要安裝InnoDB Cluster,環(huán)境的一個基本要求就是Python,我看了下,很多默認的系統(tǒng)版本是2.6,而它的最低要求是2.7及以上,所以還是需要提前準備下這個部分。
 
    如果你的系統(tǒng)是Python 2.6版本的,可以考慮升級到2.7,參考如下的方法。
 
搭建InnoDB Cluster顯而易見需要多臺服務(wù)器,而如果在一臺服務(wù)器上練習測試,也是全然沒有問題,如果想更快更方便的測試模擬,還可以使用sandbox來做,首先你得有sandbox,接著InnoDB Cluster的三大組件是MGR,MySQL Shell,MySQL Router,所以你可以從官網(wǎng)直接下載下來。
 
然后我們開啟安裝之旅。
 
使用MySQL Shell的命令mysqlsh開始部署,創(chuàng)建一個端口為3310的實例
 
mysql-js> dba.deploySandboxInstance(3310)
A new MySQL sandbox instance will be created on this host in
/root/mysql-sandboxes/3310
 
輸入密碼之后,一個3310端口的MySQL服務(wù)就啟動了。
Please enter a MySQL root password for the new instance:
Deploying new MySQL instance...
Instance localhost:3310 successfully deployed and started.
Use shell.connect('root@localhost:3310'); to connect to the instance.
接著創(chuàng)建另外兩個節(jié)點 3320,3330
dba.deploySandboxInstance(3320)
dba.deploySandboxInstance(3330)
我們切換到3310的MySQL實例,準備開始創(chuàng)建Cluster
mysql-js>  /connect root@localhost:3310
Creating a Session to 'root@localhost:3310'
Enter password:
Closing old connection...
Classic Session successfully established. No default schema selected.
 
這個時候,我們再配置一下MySQL Router,創(chuàng)建個軟鏈接,保證能夠正常調(diào)用。
 
# ln -s /home/innodb_cluster/mysql-router-2.1.3-linux-glibc2.12-x86-64bit/bin/mysqlrouter   /usr/bin/mysqlroute
# which mysqlroute
/usr/bin/mysqlroute
配置MySQL Router的啟動節(jié)點為端口3310的實例
# mysqlrouter --bootstrap root@localhost:3310 --user=mysql
 
這個時候還是要輸入密碼,成功之后,這個綁定就打通了。
 
Please enter MySQL password for root:
Bootstrapping system MySQL Router instance...
MySQL Router  has now been configured for the InnoDB cluster 'testCluster'.
The following connection information can be used to connect to the cluster.
Classic MySQL protocol connections to cluster 'testCluster':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
X protocol connections to cluster 'testCluster':
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
可以從上面的日志看出來,分配的讀寫端口是6446,只讀端口是6447,還有x協(xié)議連接的端口為64460,64470
啟動MySQL Router
# mysqlrouter &
[1] 2913
 
如果對MySQL Router還有些疑問,可以看看安裝目錄下,會生成下面的配置文件,我們就看里面的.conf文件,里面的一部分內(nèi)容如下:
[routing:testCluster_default_rw]
bind_address=0.0.0.0
bind_port=6446
destinations=metadata-cache://testCluster/default?role=PRIMARY
mode=read-write
protocol=classic
 
也可以使用describe得到一些基本的信息
mysql-js> cluster.describe();
{
    "clusterName": "testCluster",
    "defaultReplicaSet": {
        "instances": [
            {
                "host": "localhost:3310",
                "label": "localhost:3310",
                "role": "HA"
            },
            {
                "host": "localhost:3320",
                "label": "localhost:3320",
                "role": "HA"
            },
            {
                "host": "localhost:3330",
                "label": "localhost:3330",
                "role": "HA"
            }
        ],
        "name": "default"
    }
}
  
把節(jié)點2納入到Cluster中
 
mysql-js> cluster.rejoinInstance('root@localhost:3310')
Rejoining the instance to the InnoDB cluster. Depending on the original
problem that made the instance unavailable, the rejoin operation might not be
successful and further manual steps will be needed to fix the underlying
problem.
Please monitor the output of the rejoin operation and take necessary action if
the instance cannot rejoin.
Please provide the password for 'root@localhost:3310':
Rejoining instance to the cluster ...
The instance 'root@localhost:3310' was successfully rejoined on the cluster.
The instance 'localhost:3310' was successfully added to the MySQL Cluster.
mysql-js>
 
可以想象如果是一個生產(chǎn)系統(tǒng),這么多的日志,這個過程真是讓人糾結(jié)。
最后來一個切換后的Cluster狀態(tài)
mysql-js> cluster.status()
{
    "clusterName": "testCluster",
    "defaultReplicaSet": {
        "name": "default",
        "primary": "localhost:3320",
        "status": "OK",
        "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
        "topology": {
            "localhost:3310": {
                "address": "localhost:3310",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3320": {
                "address": "localhost:3320",
                "mode": "R/W",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3330": {
                "address": "localhost:3330",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"

(編輯:武林網(wǎng))

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 邯郸市| 平潭县| 奉贤区| 雷山县| 新乐市| 交口县| 岳池县| 德令哈市| 民乐县| 沙河市| 墨江| 康马县| 赣榆县| 两当县| 密云县| 阳江市| 镶黄旗| 咸阳市| 惠东县| 沧源| 齐齐哈尔市| 宜昌市| 富民县| 且末县| 龙门县| 夹江县| 佛冈县| 河南省| 柞水县| 双鸭山市| 马鞍山市| 武安市| 兴山县| 吉安县| 巴中市| 阜宁县| 温州市| 铅山县| 莲花县| 寻甸| 华池县|