加载中...

MYSQL MIC 集群安装

Linux下安装mysql innoDB cluster

一 准备安装环境: 

1. 准备centos 7 系统.

2. 清空安装环境
[root@localhost ~]# yum list |grep mari
 
[root@localhost ~]# yum remove mariadb-libs.x86_64
 二 安装
1. 下载安装包mysql80-community-release-el7-1.noarch,传入虚拟机
2. Yum安装mysql80-community-release-el7-1.noarch包,yum
[root@localhost /]# yum install mysql80-community-release-el7-1.noarch.rpm
 
2.1  
[root@localhost /]# yum makecache
 
2.2 查看安装包
[root@localhost /]# yum list|grep mysql
 
2.3 安装 mysql-community-server.x86_64
[root@localhost /]# yum install -y mysql-community-server.x86_64
 
2.4 安装 mysql-shell.x86_64 mysql-router.x86_64
[root@localhost /]# yum install -y mysql-shell.x86_64 mysql-router.x86_64
 
3. 进入mysqlsh 初始化mysql实例
[root@localhost /]# mysqlsh
3.1 查看命令
MySQL  JS > \? dba
NAME
      dba - Global variable for InnoDB cluster management.
 
DESCRIPTION
      The global variable dba is used to access the AdminAPI functionality and
      perform DBA operations. It is used for managing MySQL InnoDB clusters.
 
PROPERTIES
      verbose
            Enables verbose mode on the dba operations.
 
FUNCTIONS
      checkInstanceConfiguration(instance[, options])
            Validates an instance for MySQL InnoDB Cluster usage.
 
      configureInstance([instance][, options])
            Validates and configures an instance for MySQL InnoDB Cluster
            usage.
 
      configureLocalInstance(instance[, options])
            Validates and configures a local instance for MySQL InnoDB Cluster
            usage.
 
      createCluster(name[, options])
            Creates a MySQL InnoDB cluster.
 
      deleteSandboxInstance(port[, options])
            Deletes an existing MySQL Server instance on localhost.
 
      deploySandboxInstance(port[, options])
            Creates a new MySQL Server instance on localhost.
 
      dropMetadataSchema(options)
            Drops the Metadata Schema.
 
      getCluster([name][, options])
            Retrieves a cluster from the Metadata Store.
 
      help([member])
            Provides help about this object and it's members
 
      killSandboxInstance(port[, options])
            Kills a running MySQL Server instance on localhost.
 
      rebootClusterFromCompleteOutage([clusterName][, options])
            Brings a cluster back ONLINE when all members are OFFLINE.
 
      startSandboxInstance(port[, options])
            Starts an existing MySQL Server instance on localhost.
 
      stopSandboxInstance(port[, options])
            Stops a running MySQL Server instance on localhost.
 
      For more help on a specific function use: dba.help('<functionName>')
 
      e.g. dba.help('deploySandboxInstance')
3.2 创建端口为331033203330的实例
MySQL  JS > dba.deploySandboxInstance(3310)
 
4. 创建集群
4.1 进入端口3310的实例
MySQL  JS > \connect root@localhost:3310
 
 
4.2 定义集群
 MySQL  localhost:3310 ssl  JS > var cluster=dba.createCluster('test')
 
4.3 集群中加入实例33203330
MySQL  localhost:3310 ssl  JS > cluster.addInstance('root@localhost:3320')
MySQL  localhost:3310 ssl  JS > cluster.addInstance('root@localhost:3330')
 
5. Mysqlrouter 启动
5.1 连接3310
mysqlrouter --bootstrap root@localhost:3310 --user=mysqlrouter
 
5.2 编辑mysqlrouter 配置文件
[root@localhost ~]#  vi /etc/mysqlrouter/mysqlrouter.conf
 
5.3 开启mysqlrouter
[root@localhost ~]#  mysqlrouter &
[1] 11085
6. 通过mysqlrouter连入实例
[root@localhost ~]# mysql -uroot -h 127.0.0.1 -P 6446 -poracle
 
 
[root@localhost ~]# mysql -uroot -h 192.168.80.164 -P 6446 -poracle
 
7. 查看集群状态
7.1 连入实例3310,获取数据
MySQL  JS > \connect root@localhost:3310
MySQL  localhost:3310 ssl  JS > cluster=dba.getCluster()
 
7.2 查看状态
 MySQL  localhost:3310 ssl  JS > cluster.status()
 
MySQL  localhost:3310 ssl  JS > cluster=dba.getCluster()cluster.status()cluster.status()
{
    "clusterName": "test",
    "defaultReplicaSet": {
        "name": "default",
        "primary": "localhost:3310",
        "ssl": "REQUIRED",
        "status": "OK",
        "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
        "topology": {
            "localhost:3310": {
                "address": "localhost:3310",
                "mode": "R/W",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3320": {
                "address": "localhost:3320",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            },
            "localhost:3330": {
                "address": "localhost:3330",
                "mode": "R/O",
                "readReplicas": {},
                "role": "HA",
                "status": "ONLINE"
            }
        }
    },
    "groupInformationSourceMember": "mysql://root@localhost:3310"
}
 
8. 查看mysql进程
[root@localhost ~]# ps -ef |grep mysql
 
9. 通过socket连入3310实例
[root@localhost 3310]# mysql -uroot -poracle -S /root/mysql-sandboxes/3310/sandboxdata/mysqld.sock
 
 
posted @ 2018-08-26 18:26  Chaos_oaa  阅读(747)  评论(0)    收藏  举报