相关链接:
在 CentOS 1804 中 使用 yum 安装 MySQL 5.7 最新版
在 CentOS 1804 中 安装 MySQL 5.7.20 (或任意MySQL版本)
在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)
在 Ubuntu 中安装 MySQL5.7.20(任意版本)
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) 下载
- 本文将讲述指定MySQL数据库版本的集群安装:
- 详细的 MySQL 5.7.** 与 MySQL NDB Cluster 7.6.** 对应关系请查看:
MySQL 集群 MySQL NDB Cluster 7.6.** 与 MySQL 5.7.** 对应版本说明 - 详细的 MySQL 5.7.** 与 MySQL NDB Cluster 7.5.** 对应关系请查看:
MySQL 集群 MySQL NDB Cluster 7.5.** 与 MySQL 5.7.** 对应版本说明 - 本文以 MySQL 5.7.20 为例,对应 MySQL NDB Cluster 7.6.4(使用 对应 MySQL NDB Cluster 7.5.8 也可,请自行选择)。
- 所有 MySQL 安装文件均可在Index of /232905中下载:
- yum 安装文件:Index of /232905/yum。
- yum 安装文件MySQL NDB Cluster 7.5.**:Index of /232905/yum/mysql-cluster-7.5-community。
- yum 安装文件MySQL NDB Cluster 7.5.** 的 CentOS版本:Index of /232905/yum/mysql-cluster-7.5-community/el。
- yum 安装文件MySQL NDB Cluster 7.5.** 的 CentOS 7 版本:Index of /232905/yum/mysql-cluster-7.5-community/el/7。
- yum 安装文件MySQL NDB Cluster 7.5.** 的 CentOS 7 64位版本:Index of /232905/yum/mysql-cluster-7.5-community/el/7/x86_64。
- 详细的 MySQL 5.7.** 与 MySQL NDB Cluster 7.6.** 对应关系请查看:
- 一共四台服务器:
- 管理节点:192.168.113.151
- MySQL节点:192.168.113.152
- 数据节点A:192.168.113.153
- 数据节点B:192.168.113.154
- 在管理节点执行操作:
安装管理节点的可执行文件:
管理节点仅需要安装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*
- 在MySQL节点执行操作:
查看是否安装了maria:
卸载maria:rpm -qa | grep maria
手动安装依赖perl-Class-MethodMaker(此依赖CentOS中不存在,无法自动找到,使用的是epel el7 x86_64):yum -y remove mariadb-libs
安装SQL节点的组件: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 ## CentOS 8 ## wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo ## yum makecache ## 下载 https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/ 中的 perl-Class-MethodMaker ## yum -y install perl-Class-MethodMaker # 或 # yum -y install epel-release
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>
打开3306端口:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abc,123.456+';
firewall-cmd --zone=public --add-port=3306/tcp --permanent systemctl restart firewalld.service firewall-cmd --list-ports
- 在数据节点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*
- NDB集群的初始配置:
- 在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
- 在管理节点执行操作:
添加以下内容: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
- 在MySQL节点、数据节点A、数据节点B执行操作:
- NDB集群的初始启动:
- 在管理节点执行操作:
打开端口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
- 在数据节点A、数据节点B执行操作:
创建目录:
在数据节点A执行操作:mkdir -p /usr/local/mysql/data
[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
- 在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版本)
在不打开 MySQL 3306 端口的情况下,使用 Navicat 进项远程连接(使用22端口)
在 Ubuntu 中安装 MySQL5.7.20(任意版本)
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 (或指定版本) 集群