MySQL8 innobd cluster 搭建

2020-09-15 壞桃子

利用docker容器,利用mysql-shell 和mysql-router 實現。

setup 1:(建立三個容器)

[root@localhost docker] docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEcentos centos7 7e6257c9f8d8 4 weeks ago 203MBcentos centos8 0d120b6ccaa8 4 weeks ago 215MB docker run -itd --name centos-mysql_s1 --net host centos:centos8 /bin/bash29b2d4ea24663fd984f884bd081c3e5caf53c80c1c2058e2a40a43ee52db9d18[root@localhost docker] docker run -itd --name centos-mysql_s3 --net host centos:centos8 /bin/bash5d4cec7784e33586fa7edfbdab6e854f0f9c938ad611d051dcc5fc2c9dc8dffe[root@localhost docker]34;/bin/bash&34;/bin/bash&34;/bin/bash& lltotal 1421000drwxr-xr-x. 2 root root 136 Sep 14 10:39 docker-rw-r--r--. 1 root root 65413120 Sep 14 11:10 docker.tar-rw-r--r--. 1 root root 694845440 Sep 14 11:34 mysql-8.0.18-linux-glibc2.12-x86_64.tar-rw-r--r--. 1 7155 31415 503854832 Sep 22 2019 mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz-rw-r--r--. 1 7155 31415 40986912 Sep 22 2019 mysql-router-8.0.18-linux-glibc2.12-x86_64.tar.xz-rw-r--r--. 1 7155 31415 149997696 Sep 23 2019 mysql-test-8.0.18-linux-glibc2.12-x86_64.tar.xz[root@localhost dir] docker cp mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz centos-mysql_s2:/root[root@localhost dir]開始進入容器[root@localhost dir] cd /usr/local/[root@localhost local] ln -s mysql-8.0.18-linux-glibc2.12-x86_64/ mysql[root@localhost local] yum install -y libaio numactl[root@localhost mysql] useradd mysql -r -g mysql -s /sbin/nologin[root@localhost mysql] ./bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ./support-files/mysql.server startStarting MySQL.Logging to &39;... SUCCESS![root@localhost mysql] 修改密碼建立一個遠程連接用戶[root@localhost mysql]39;help;&39;\h&39;\c&39;root&39;localhost&39;123456&39;lt&39;%&39;lt123456&39;lt&39;%&39;lt&39;%&39;lt123456&vi /etc/my.cnf[mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data port=2200 ./support-files/mysql.server restart exit netstat -tnlp |grep mysqltcp6 0 0 :::2200 :::* LISTEN 6634/mysqldtcp6 0 0 :::2211 :::* LISTEN 18973/mysqldtcp6 0 0 :::33060 :::* LISTEN 3681/mysqldtcp6 0 0 :::2222 :::* LISTEN 26452/mysqld[root@localhost dir] cd /usr/local/[root@localhost local] ln -s mysql-shell-8.0.21-linux-glibc2.12-x86-64bit/ mysql-shell /usr/local/mysql-shell/bin/mysqlsh lt@192.168.1.13:2200Please provide the password for &39;: ********Save password for &39;? [Y]es/[N]o/Ne[v]er (default No): yMySQL Shell 8.0.21Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates.Other names may be trademarks of their respective owners.Type &39; or &39; for help; &39; to exit.Creating a session to &39;Fetching schema names for autocompletion... Press ^C to stop.Your MySQL connection id is 9Server version: 8.0.18 MySQL Community Server - GPLNo default schema selected; type \use <schema> to set one. MySQL 192.168.1.13:2200 ssl JS > dba.configureInstance();Configuring local MySQL instance listening at port 2200 for use in an InnoDB cluster...This instance reports its own address as localhost.localdomain:2200Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.NOTE: Some configuration options need to be fixed:+--------------------------+---------------+----------------+--------------------------------------------------+| Variable | Current Value | Required Value | Note |+--------------------------+---------------+----------------+--------------------------------------------------+| binlog_checksum | CRC32 | NONE | Update the server variable || enforce_gtid_consistency | OFF | ON | Update read-only variable and restart the server || gtid_mode | OFF | ON | Update read-only variable and restart the server || server_id | 1 | <unique ID> | Update read-only variable and restart the server |+--------------------------+---------------+----------------+--------------------------------------------------+Some variables need to be changed, but cannot be done dynamically on the server.Do you want to perform the required configuration changes? [y/n]: yDo you want to restart the instance after configuring it? [y/n]: yConfiguring instance...The instance &39; was configured to be used in an InnoDB cluster.Restarting MySQL...NOTE: MySQL server at localhost.localdomain:2200 was restarted. MySQL 192.168.1.13:2200 ssl JS > \exit[root@localhost mysql-shell]39;lt@192.168.1.13:2211& /usr/local/mysql-shell/bin/mysqlsh lt@192.168.1.13:2222Please provide the password for &39;: ******** MySQL 192.168.1.13:2222 ssl JS > dba.configureInstance(); MySQL 192.168.1.13:2222 ssl JS > \exit


[root@localhost mysql-shell]39;testCluster&39;lt@192.168.1.13:2211&39;lt@192.168.1.13:2222& tar xvf ~/dir/mysql-router-8.0.18-linux-glibc2.12-x86_64.tar.xz[root@localhost local] cd mysql-router[root@localhost local] /usr/local/mysql-router/bin/mysqlrouter --config /etc/mysqlrouter.cnf &[root@localhost mysql-router]# netstat -tnlp |grep mysqltcp 0 0 0.0.0.0:8001 0.0.0.0:* LISTEN 31818/mysqlroutertcp 0 0 0.0.0.0:8002 0.0.0.0:* LISTEN 31818/mysqlroutertcp6 0 0 :::22001 :::* LISTEN 11404/mysqldtcp6 0 0 :::2200 :::* LISTEN 11404/mysqldtcp6 0 0 :::22111 :::* LISTEN 11880/mysqldtcp6 0 0 :::2211 :::* LISTEN 11880/mysqldtcp6 0 0 :::33060 :::* LISTEN 3681/mysqldtcp6 0 0 :::22221 :::* LISTEN 12244/mysqldtcp6 0 0 :::2222 :::* LISTEN 12244/mysqld

至此:大功告成。

相關焦點

  • 利用docker輕鬆搭建Redis-Cluster集群環境
    在這裡使用docker容器來搭建一套6節點(3主,3從)Redis-Cluster集群環境。Up 7 seconds 0.0.0.0:8002->8002/tcp, 6379/tcp, 0.0.0.0:18002->18002/tcp redis-8002c752fab6c6b8 redis:5.0.9-buster "docker-entrypoint.s鈥 9 seconds ago Up 8 seconds
  • MySQL Cluster 7.2.4 穩定版發布
    【IT168 資訊】MySQL Cluster 7.2.4 穩定版發布了,下載地址:  http://dev.mysql.com/downloads/cluster/7.2.html  改進記錄:  http://dev.mysql.com/doc/refman/5.5/en/
  • MySQL中InnoDB-Cluster 日常運維掃盲-愛可生
    輸出當前 mysql router 路由信息,包含讀寫埠,版本等信息。debian-ytt1", "lastCheckIn": "2020-07-15 11:43:18", "roPort": 6447, "roXPort": 64470, "rwPort": 6446, "rwXPort": 64460, "version": "8.0.21
  • Docker 搭建 Redis Cluster 集群
    使用 Docker 搭建 Redis Cluster,最重要的環節就是容器通信的問題,這一塊我們在之前的文章中已經給大家解決了《 》,本篇文章主要練習使用多個容器完成 Redis Cluster 集群環境的搭建,順便為學習 Docker Compose 鋪鋪路。
  • Docker 搭建 Redis Cluster 集群環境
    使用 Docker 搭建 Redis Cluster,最重要的環節就是容器通信的問題,這一塊我們在之前的文章中已經給大家解決了《 》,本篇文章主要練習使用多個容器完成 Redis Cluster 集群環境的搭建,順便為學習 Docker Compose 鋪鋪路。
  • MySQL資料庫高可用集群搭建-PXC集群部署
    WSRWP API:在DBMS庫和wsrep provider之間提供接口 PXC環境所涉及的埠:#mysql實例埠:3306#PXC cluster相互通訊的埠:4567 #用於SST傳送的埠:4444 #用於IST傳送的埠:4568 1.有3個節點pxc_node0 192.0.0.197 pxc_node1 192.0.0.198
  • redis cluster搭建實踐(非常詳細,值得收藏)
    因為我沒有那麼多伺服器,也啟動不了那麼多虛擬機,所在這裡搭建的是偽分布式集群,即一臺伺服器虛擬運行6個redis實例,修改埠號為(7001-7006),當然實際生產環境的Redis集群搭建和這裡是一樣的。
  • Redis-Window Server快速搭建Redis Cluster集群
    Redis Cluster環境配置Redis Cluster官方提供redis-trib工具進行集群管理,redis-trib工具集採用ruby進行開發,所以集群搭建需要先安裝ruby環境,以下為ruby安裝包地址:
  • Redis的Cluster集群搭建
    以下是最小的Redis集群配置文件:    port 7000    cluster-enabled yes    cluster-config-file nodes.conf    cluster-node-timeout 5000    appendonly yes 正如您所看到的那樣,啟用群集模就是使用 cluster-enabled 這個指令
  • docker如何搭建mysql主從?
    目錄:1 Docker 搭建 mysql 主從1 下載 docker 鏡像2 創建網絡驅動3.1 主伺服器搭建3.1.1 啟動主伺服器3.1.2 修改主伺服器的配置4 從伺服器搭建3.1.1 啟動從伺服器3.1.2 修改從伺服器的配置
  • 基於docker環境搭建redis-cluster集群(單機)
    > 2.創建redis的配置文件redis-cluster.tmpl開啟protected-mode保護模式,需配置bind ip或者設置訪問密碼,關閉protected-mode模式,此時外部網絡可以直接訪問port ${PORT} 節點埠daemonize no 指定redis是否要用守護線程的方式啟動,默認noappendonly yes 持久化模式cluster-enabled yes cluster集群模式cluster-config-file nodes.conf
  • dbdeployer MySQL沙盒部署詳解
    來搭建MySQL8.0新版本時發現用不了,提示需要使用dbdeployer-7.6.10-linux-glibc2.12-x86_64.tar.gz Linux 7.6.10 ndb 916 MB mysql-cluster-8.0.16-dmr-linux-glibc2.12-x86_64.tar.gz Linux 8.0.16 ndb 1.1 GB
  • MySQL系列二 - 搭建MySQL主從集群
    前面一章我們在centos上搭建好了MySQL資料庫,今天我們搭建一個主從同步的MySQL簡單集群。上一章是在虛擬機(192.168.64.123)上搭建的,我用的是vmware15虛擬機搭建的,今天在擴展一臺節點用於搭建主從集群,計劃 IP:192.168.64.123 虛擬機作為主節點,新建的虛擬機 IP:192.168.64.124 做為從節點。124的資料庫搭建什麼的參照上一章步驟執行就行。
  • 零基礎也能快速搭建Python+Mysql開發環境
    不一定說新版本就一定比舊版本好,但是新版本集成的功能肯定是要多於舊版本的,這裡我用最新的Anaconda3-2020.07-Windows-x86_64+Mysql8.022版本來搭建WINDOWS10下的Python基礎開發環境。
  • 資料庫基礎:mysql主從集群搭建
    集群搭建1.集群環境如下:2.mysql數據安裝mysql安裝相對簡單,這裡不做介紹,如果不熟悉的可以查看相關資料。4.測試驗證首先在主庫上創建test庫:create database test character set 'utf8';依次執行:use test;show
  • mysql galera 集群 部署文檔
    -5.7.x86_64 5.7.28-25.20.el7 @galeramysql-wsrep-client-5.7.x86_64 5.7.28-25.20.el7 @galeramysql-wsrep-common
  • MySQL資料庫主從複製搭建
    本文介紹MySQL資料庫主從複製搭建。--datadir=/data/3307/data --basedir=/application/mysql mysqld --initialize-insecure --user=mysql --datadir=/data/3308/data --basedir=/application/mysql mysqld --initialize-insecure --user=mysql --datadir
  • Docker 搭建 nginx + mysql + php 開發環境全方面教學!
    下載頁面我的運行環境:運行環境下載安裝包並安裝後,菜單欄出現 Docker 的標識後,便可以開始搭建我們的環境了~/web/www/phpinfo.php在瀏覽器上訪問:localhost/phpinfo.php進入 php5.4 容器:$ docker exec -it f6f461254df8
  • 秒級搭建MySQL資料庫服務,太香了
    這種方案門檻低,對於非資料庫專業人員也能秒級搭建好一條MySQL服務。搭建步驟拉取MySQL資料庫鏡像docker pull mysql:latest直接執行這個命令,意思是拉取最新的鏡像,但是實際項目可能需要制定的資料庫版本,所以這裡需要制定標籤,拉取需要的鏡像
  • Mysql搭建延遲災備庫
    mysql官方開發了這個特性,那麼就有其適用的場景,下面就列舉2個使用場景當在主庫上刪除了一個不常修改的業務配置表,但是業務又經常訪問,怎麼辦,使用備份恢復出刪除的表,用過這個方式的同學,一定知道,一個上百G或者更大的備份集去恢復數據,真不是兩三個小時就能搞定的事情。