MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群

相关链接:

在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版

在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)

在 CentOS 1804 中 修改 MySQL 密码策略

在 CentOS 中 开启 MySQL 的 3306 端口

在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)

在 Ubuntu 中安装 MySQL5.7.20(任意版本)

在 Ubuntu 中安装 MySQL5.7.** 最新版

CentOS 6/7 安装 MySQL 8 最新版

CentOS 6/7 安装 MySQL 8.0.11 (或任意版)

MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群

MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明

MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明

MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群

Windows 安装 MySQL 5.7.20 教程(及常见问题解决)

MySQL 5.7.20 (或任意版本) 的 Windows 版 安装程序 (msi) 下载


  1. 本文将讲述指定MySQL数据库版本的集群安装:
    1. 详细的 MySQL 5.7.** 与 MySQL NDB Cluster 7.6.** 对应关系请查看:
      MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明
    2. 详细的 MySQL 5.7.** 与 MySQL NDB Cluster 7.5.** 对应关系请查看:
      MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明
    3. 本文以 MySQL 5.7.20 为例,对应 MySQL NDB Cluster 7.6.4(使用 对应 MySQL NDB Cluster 7.5.8 也可,请自行选择)。
    4. 所有 MySQL 安装文件均可在http://repo.mysql.com/中下载:
      1. yum 安装文件:http://repo.mysql.com/yum/
      2. yum 安装文件MySQL NDB Cluster 7.5.**:http://repo.mysql.com/yum/mysql-cluster-7.5-community/
      3. yum 安装文件MySQL NDB Cluster 7.5.** 的 CentOS版本:http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/
      4. yum 安装文件MySQL NDB Cluster 7.5.** 的 CentOS 7 版本:http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/7/
      5. yum 安装文件MySQL NDB Cluster 7.5.** 的 CentOS 7 64位版本:http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/7/x86_64/
  2. 一共四台服务器:
    1. 管理节点:192.168.113.151
    2. MySQL节点:192.168.113.152
    3. 数据节点A:192.168.113.153
    4. 数据节点B:192.168.113.154
  3. 管理节点执行操作:
    安装管理节点的可执行文件:
    管理节点仅需要安装mysql-cluster-community-management-server即可:
    mkdir -p /data/mysql
    cd /data/mysql/
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-management-server-7.6.4-1.el7.x86_64.rpm
    yum -y install mysql-cluster-community-management-server*
  4.  在MySQL节点执行操作:
    查看是否安装了maria:
    rpm -qa | grep maria
     卸载maria:
    yum -y remove mariadb-libs
    手动安装依赖perl-Class-MethodMaker(此依赖CentOS中不存在,无法自动找到,使用的是epel el7 x86_64):
    mkdir -p /data/mysql
    cd /data/mysql/
    wget https://mirrors.aliyun.com/epel/7/x86_64/Packages/p/perl-Class-MethodMaker-2.20-1.el7.x86_64.rpm
    yum -y install perl-Class-MethodMaker-2.20-1.el7.x86_64.rpm
    安装SQL节点的组件:
    SLQ节点需要安装注意安装顺序:
    mysql-cluster-community-common
    mysql-cluster-community-libs
    mysql-cluster-community-client
    mysql-cluster-community-server
    mysql-cluster-community-libs-compat
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-common-7.6.4-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-libs-7.6.4-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-client-7.6.4-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-server-7.6.4-1.el7.x86_64.rpm
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-libs-compat-7.6.4-1.el7.x86_64.rpm
    
    yum -y install mysql-cluster-community-common*
    yum -y install mysql-cluster-community-libs*
    yum -y install mysql-cluster-community-client*
    yum -y install mysql-cluster-community-server*
    yum -y install mysql-cluster-community-libs-compat*
    
     开启数据库:
    systemctl start mysqld.service
    
    已默认打开开机自启。
    查看root默认密码:
    [root@CentOS-1804-MySQL-2 mysql]# grep 'temporary password' /var/log/mysqld.log
    2018-10-20T17:20:55.552284Z 1 [Note] A temporary password is generated for root@localhost: JuZUfg+RX8uf
    初次登录修改密码:
    下面已显示 MySQL 版本为 5.7.20,MySQL NDB Cluster版本为7.6.4。
    [root@CentOS-1804-MySQL-2 mysql]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.7.20-ndb-7.6.4-cluster-gpl
    
    Copyright (c) 2000, 2017, 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 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> 
    
    
    设置远程连接密码:
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abc,123.456+';
    打开3306端口:
    firewall-cmd --zone=public --add-port=3306/tcp --permanent
    systemctl restart firewalld.service
    firewall-cmd --list-ports
  5. 数据节点A数据节点B执行操作:
    安装数据节点的可执行文件:
    mkdir -p /data/mysql
    cd /data/mysql/
    wget http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/x86_64/mysql-cluster-community-data-node-7.6.4-1.el7.x86_64.rpm
    yum -y install mysql-cluster-community-data-node*
  6. NDB集群的初始配置:
    1. MySQL节点数据节点A数据节点B执行操作:
      vim /etc/my.cnf
      添加以下内容:
      [mysqld]
      # Options for mysqld process:
      ndbcluster                      # run NDB storage engine
       
      [mysql_cluster]
      # Options for NDB Cluster processes:
      ndb-connectstring=192.168.113.151  # location of management server
    2. 管理节点执行操作:
      mkdir /var/lib/mysql-cluster
      cd /var/lib/mysql-cluster
      vim config.ini
      添加以下内容:
      [ndbd default]
      # Options affecting ndbd processes on all data nodes:
      NoOfReplicas=2    # Number of replicas
      DataMemory=80M    # How much memory to allocate for data storage
      #IndexMemory=18M   # How much memory to allocate for index storage
                        # For DataMemory and IndexMemory, we have used the
                        # default values. Since the "world" database takes up
                        # only about 500KB, this should be more than enough for
                        # this example NDB Cluster setup.
      ServerPort=2202   # This the default value; however, you can use any
                        # port that is free for all the hosts in the cluster
                        # Note1: It is recommended that you do not specify the port
                        # number at all and simply allow the default value to be used
                        # instead
                        # Note2: The port was formerly specified using the PortNumber
                        # TCP parameter; this parameter is no longer available in NDB
                        # Cluster 7.5.
       
      [ndb_mgmd]
      # Management process options:
      HostName=192.168.113.151          # Hostname or IP address of MGM node
      DataDir=/var/lib/mysql-cluster  # Directory for MGM node log files
       
      [ndbd]
      # Options for data node "A":
                                      # (one [ndbd] section per data node)
      HostName=192.168.113.153          # Hostname or IP address
      NodeId=2                        # Node ID for this data node
      DataDir=/usr/local/mysql/data   # Directory for this data node's data files
       
      [ndbd]
      # Options for data node "B":
      HostName=192.168.113.154          # Hostname or IP address
      NodeId=3                        # Node ID for this data node
      DataDir=/usr/local/mysql/data   # Directory for this data node's data files
       
      [mysqld]
      # SQL node options:
      HostName=192.168.113.152          # Hostname or IP address
                                      # (additional mysqld connections can be
                                      # specified for this node for various
                                      # purposes such as running ndb_restore)

      注意
      在MySQL NDB Cluster 7.6中不建议使用IndexMemory,否则会报以下错误:
      WARNING  -- at line 6: [DB] IndexMemory is deprecated, use Number bytes on each ndbd(DB) node allocated for storing indexes instead
  7. NDB集群的初始启动:
    1. 管理节点执行操作:
      打开端口1186:
      firewall-cmd --zone=public --add-port=1186/tcp --permanent
      systemctl restart firewalld.service
      firewall-cmd --list-ports
      首次启动:
      [root@CentOS-1804-MySQL-1 mysql-cluster]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
      MySQL Cluster Management Server mysql-5.7.20 ndb-7.6.4
      2018-10-21 02:14:26 [MgmtSrvr] INFO     -- The default config directory '/usr/mysql-cluster' does not exist. Trying to create it...
      2018-10-21 02:14:26 [MgmtSrvr] INFO     -- Sucessfully created config directory
      
      之后启动:
      ndb_mgmd
    2. 数据节点A数据节点B执行操作:
      创建目录:
      mkdir -p /usr/local/mysql/data
      数据节点A执行操作:
      [root@CentOS-1804-MySQL-3 ~]# ndbd
      2018-10-21 02:18:31 [ndbd] INFO     -- Angel connected to '192.168.113.151:1186'
      2018-10-21 02:18:31 [ndbd] INFO     -- Angel allocated nodeid: 2
      

      数据节点B执行操作:
      [root@CentOS-1804-MySQL-4 ~]# ndbd
      2018-10-21 02:19:15 [ndbd] INFO     -- Angel connected to '192.168.113.151:1186'
      2018-10-21 02:19:15 [ndbd] INFO     -- Angel allocated nodeid: 3
      
    3. MySQL节点执行操作:
      [root@CentOS-1804-MySQL-2 ~]# ndb_mgm
      -- NDB Cluster -- Management Client --
      ndb_mgm> SHOW
      Connected to Management Server at: 192.168.113.151:1186
      Cluster Configuration
      ---------------------
      [ndbd(NDB)]	2 node(s)
      id=2	@192.168.113.153  (mysql-5.7.20 ndb-7.6.4, starting, Nodegroup: 0)
      id=3	@192.168.113.154  (mysql-5.7.20 ndb-7.6.4, starting, Nodegroup: 0)
      
      [ndb_mgmd(MGM)]	1 node(s)
      id=1	@192.168.113.151  (mysql-5.7.20 ndb-7.6.4)
      
      [mysqld(API)]	1 node(s)
      id=4 (not connected, accepting connect from 192.168.113.152)
      
      ndb_mgm> 
      

      上面显示内容已说明配置成功。


相关链接:

在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版

在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)

在 CentOS 1804 中 修改 MySQL 密码策略

在 CentOS 中 开启 MySQL 的 3306 端口

在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)

在 Ubuntu 中安装 MySQL5.7.20(任意版本)

在 Ubuntu 中安装 MySQL5.7.** 最新版

CentOS 6/7 安装 MySQL 8 最新版

CentOS 6/7 安装 MySQL 8.0.11 (或任意版)

MySQL 5.7 最新版 使用 yum 安装 MySQL NDB Cluster 7.5 最新版 集群

MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明

MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明

MySQL 5.7.20 (或指定版本) 与 MySQL NDB Cluster 7.6.4 (或指定版本) 集群

Windows 安装 MySQL 5.7.20 教程(及常见问题解决)

MySQL 5.7.20 (或任意版本) 的 Windows 版 安装程序 (msi) 下载

猜你喜欢

转载自blog.csdn.net/qq_32596527/article/details/83211063
今日推荐