在我的环境中,会有三台服务器,用以搭建MySQL(Oracle发行的版本) Cluster(ndb)架构。
ndb_manager 10.158.1.98
ndb_node1 10.158.1.148
ndb_node2 10.158.1.173
具体如下:
文件:/etc/hosts
[root@ndb-manager ~]# cat /etc/hosts #127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 # Local 127.0.0.1 localhost # Public 10.158.1.98 ndb-manager 10.158.1.148 ndb-node1 10.158.1.173 ndb-node2 [root@ndb-manager ~]#
操作系统版本:
[root@ndb-manager ~]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (Core) [root@ndb-manager ~]# [root@ndb-manager ~]# uname -a Linux ndb-manager 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@ndb-manager ~]#
关闭防火墙与SELINUX:
[root@ndb-manager ~]# sestatus SELinux status: disabled [root@ndb-manager ~]# [root@ndb-manager ~]# systemctl status firewalld firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled) Active: inactive (dead) [root@ndb-manager ~]#
安装需要的基础目录(个人习惯):
[root@ndb-manager ~]# mkdir /{software,temp_me,backup_me,iso,script_me} [root@ndb-manager ~]#
Oracle官方的MySQL Cluster的下载网址:
https://dev.mysql.com/downloads/cluster/
选择:Red Hat Enterprise Linux / Oracle Linux
下载的安装介质的平台:
Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)
将下载好的安装介质上传服务器【/software】:
[root@ndb-manager ~]# ls -ltr /software total 0 [root@ndb-manager ~]# ls -ltr /software total 4 drwxr-xr-x 2 root root 4096 Feb 15 16:09 MySQL-Oracle-Cluster-ndb [root@ndb-manager ~]# [root@ndb-manager ~]# ls -ltr /software/MySQL-Oracle-Cluster-ndb/ total 622496 -rw-r--r-- 1 root root 1127384 Feb 15 15:47 mysql-cluster-community-java-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 2237932 Feb 15 15:48 mysql-cluster-community-libs-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 3902600 Feb 15 15:49 mysql-cluster-community-devel-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 277864 Feb 15 15:49 mysql-cluster-community-common-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 87678780 Feb 15 15:50 mysql-cluster-community-client-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 127700036 Feb 15 15:50 mysql-cluster-community-test-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 50929432 Feb 15 15:50 mysql-cluster-community-embedded-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 20606120 Feb 15 15:51 mysql-cluster-community-data-node-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 5107196 Feb 15 15:51 mysql-cluster-community-memcached-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 146450524 Feb 15 15:51 mysql-cluster-community-server-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 5527016 Feb 15 15:51 mysql-cluster-community-ndbclient-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 2113208 Feb 15 15:52 mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 6222308 Feb 15 15:52 mysql-cluster-community-auto-installer-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 5926252 Feb 15 15:53 mysql-cluster-community-ndbclient-devel-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 23927784 Feb 15 15:53 mysql-cluster-community-embedded-compat-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 5016432 Feb 15 15:54 mysql-cluster-community-management-server-7.5.5-1.el7.x86_64.rpm -rw-r--r-- 1 root root 142661236 Feb 15 15:54 mysql-cluster-community-embedded-devel-7.5.5-1.el7.x86_64.rpm [root@ndb-manager ~]# [root@ndb-manager ~]#
NFS共享出来:
[root@ndb-manager ~]# cat /etc/exports /software/MySQL-Oracle-Cluster-ndb/ */23(rw) [root@ndb-manager ~]# [root@ndb-manager ~]# systemctl enable nfs-server ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/multi-user.target.wants/nfs-server.service' [root@ndb-manager ~]# [root@ndb-manager ~]# service nfs start Redirecting to /bin/systemctl start nfs.service [root@ndb-manager ~]# [root@ndb-manager ~]# service nfs status Redirecting to /bin/systemctl status nfs.service nfs-server.service - NFS server and services Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled) Active: active (exited) since Wed 2017-02-15 16:26:18 CST; 12s ago Process: 3477 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS) Process: 3476 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Main PID: 3477 (code=exited, status=0/SUCCESS) CGroup: /system.slice/nfs-server.service Feb 15 16:26:18 ndb-manager systemd[1]: Starting NFS server and services... Feb 15 16:26:18 ndb-manager systemd[1]: Started NFS server and services. Feb 15 16:26:26 ndb-manager systemd[1]: Started NFS server and services. [root@ndb-manager ~]# [root@ndb-manager ~]# showmount -e localhost Export list for localhost: /software/MySQL-Oracle-Cluster-ndb * [root@ndb-manager ~]#
其他的两个节点挂载:
[root@ndb-node1 ~]# mkdir /mount_me [root@ndb-node1 ~]# [root@ndb-node1 ~]# mkdir /mount_me/mysql_cluster [root@ndb-node1 ~]# [root@ndb-node1 ~]# [root@ndb-node1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos_rhel7-root 45G 3.6G 42G 8% / devtmpfs 2.4G 0 2.4G 0% /dev tmpfs 2.4G 80K 2.4G 1% /dev/shm tmpfs 2.4G 8.8M 2.4G 1% /run tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup /dev/sda1 497M 124M 374M 25% /boot [root@ndb-node1 ~]# [root@ndb-node1 ~]# mount ndb-manager:/software/MySQL-Oracle-Cluster-ndb /mount_me/mysql_cluster/ [root@ndb-node1 ~]# [root@ndb-node1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos_rhel7-root 45G 3.6G 42G 8% / devtmpfs 2.4G 0 2.4G 0% /dev tmpfs 2.4G 80K 2.4G 1% /dev/shm tmpfs 2.4G 8.8M 2.4G 1% /run tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup /dev/sda1 497M 124M 374M 25% /boot ndb-manager:/software/MySQL-Oracle-Cluster-ndb 45G 4.0G 41G 9% /mount_me/mysql_cluster [root@ndb-node1 ~]#
制作本地YUM源:
[root@ndb-manager ~]# createrepo /software/MySQL-Oracle-Cluster-ndb/ Spawning worker 0 with 17 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@ndb-manager ~]#
添加YUM源配置:
ndb manager:
[root@ndb-manager ~]# cat /etc/yum.repos.d/local_mysql_cluster.repo [local_mysql_cluster] name=local_mysql_cluster_7.5.5 baseurl=file:///software/MySQL-Oracle-Cluster-ndb/ gpgcheck=0 [root@ndb-manager ~]#
ndb node:
[root@ndb-node1 ~]# cat /etc/yum.repos.d/local_mysql_cluster.repo [local_mysql_cluster] name=local_mysql_cluster_7.5.5 baseurl=file:///mount_me/mysql_cluster gpgcheck=0 [root@ndb-node1 ~]#
一、安装
主要涉及两个安装包:
mysql-cluster-xxx-server
mysql-cluster-xxx-client
mysql-cluster-community-management-server
mysql-cluster-community-data-node
mysql-cluster-community-ndbclient
如下:
[root@ndb-node1 ~]# yum list | grep --color local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-client.x86_64 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-common.x86_64 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-devel.x86_64 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-embedded.x86_64 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-java.x86_64 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-libs.x86_64 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-server.x86_64 7.5.5-1.el7 local_mysql_cluster mysql-cluster-community-test.x86_64 7.5.5-1.el7 local_mysql_cluster [root@ndb-node1 ~]#
Client:
mysql-cluster-community-client.x86_64
Server:
mysql-cluster-community-server.x86_64
MySQL Cluster(ndb)中,服务器有这几个角色:
Manager Node
—> mysql-cluster-community-management-server
SQL Node
—> mysql-cluster-community-server
Data Node
—> mysql-cluster-community-server
—> mysql-cluster-community-data-node
官方的说明:
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-install-linux-rpm.html
Management node: management-server
Data node: data-node
SQL node: server and common
在我的环境中:
Manager + SQL Node:
10.158.1.98
Data Node:
10.158.1.148
10.158.1.173
安装详情:
Manager + SQL Node:
yum install -y mysql-cluster-community-server mysql-cluster-community-client –nogpgcheck
[root@ndb-manager ~]# cd /software/ [root@ndb-manager software]# ls MySQL-Oracle-Cluster-ndb [root@ndb-manager software]# [root@ndb-manager software]# cd MySQL-Oracle-Cluster-ndb/ [root@ndb-manager MySQL-Oracle-Cluster-ndb]# ls mysql-cluster-community-auto-installer-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-libs-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-client-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-common-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-management-server-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-data-node-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-memcached-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-devel-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-ndbclient-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-embedded-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-ndbclient-devel-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-embedded-compat-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-server-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-embedded-devel-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-test-7.5.5-1.el7.x86_64.rpm mysql-cluster-community-java-7.5.5-1.el7.x86_64.rpm repodata [root@ndb-manager MySQL-Oracle-Cluster-ndb]# [root@ndb-manager MySQL-Oracle-Cluster-ndb]# [root@ndb-manager MySQL-Oracle-Cluster-ndb]# rpm -ivh mysql-cluster-community-management-server-7.5.5-1.el7.x86_64.rpm warning: mysql-cluster-community-management-server-7.5.5-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-cluster-community-managemen################################# [100%] [root@ndb-manager MySQL-Oracle-Cluster-ndb]# [root@ndb-manager ~]# yum install -y mysql-cluster-community-server mysql-cluster-community-client --nogpgcheck Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn Resolving Dependencies --> Running transaction check ---> Package mysql-cluster-community-client.x86_64 0:7.5.5-1.el7 will be installed --> Processing Dependency: mysql-cluster-community-libs(x86-64) >= 5.7.9 for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 --> Processing Dependency: perl(Data::Dumper) for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 --> Processing Dependency: perl(DBI) for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 --> Processing Dependency: perl(Class::MethodMaker) for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 ---> Package mysql-cluster-community-server.x86_64 0:7.5.5-1.el7 will be installed --> Processing Dependency: mysql-cluster-community-common(x86-64) = 7.5.5-1.el7 for package: mysql-cluster-community-server-7.5.5-1.el7.x86_64 --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.41-2.el7_0 will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 ---> Package mysql-cluster-community-common.x86_64 0:7.5.5-1.el7 will be installed ---> Package mysql-cluster-community-libs.x86_64 0:7.5.5-1.el7 will be obsoleting ---> Package perl-Class-MethodMaker.x86_64 0:2.20-1.el7 will be installed ---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed --> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64 --> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64 ---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed --> Running transaction check ---> Package mysql-cluster-community-libs-compat.x86_64 0:7.5.5-1.el7 will be obsoleting ---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed --> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch --> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch --> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch --> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch --> Running transaction check ---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed --> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch --> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch ---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed --> Running transaction check ---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed ---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================== Installing: mysql-cluster-community-client x86_64 7.5.5-1.el7 local_mysql_cluster 84 M mysql-cluster-community-libs x86_64 7.5.5-1.el7 local_mysql_cluster 2.1 M replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0 mysql-cluster-community-libs-compat x86_64 7.5.5-1.el7 local_mysql_cluster 2.0 M replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0 mysql-cluster-community-server x86_64 7.5.5-1.el7 local_mysql_cluster 140 M Installing for dependencies: mysql-cluster-community-common x86_64 7.5.5-1.el7 local_mysql_cluster 271 k perl-Class-MethodMaker x86_64 2.20-1.el7 epel 334 k perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 ISO 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 ISO 57 k perl-DBI x86_64 1.627-4.el7 ISO 802 k perl-Data-Dumper x86_64 2.145-3.el7 ISO 47 k perl-IO-Compress noarch 2.061-2.el7 ISO 260 k perl-Net-Daemon noarch 0.48-5.el7 ISO 51 k perl-PlRPC noarch 0.2020-14.el7 ISO 36 k Transaction Summary =========================================================================================================================================== Install 4 Packages (+9 Dependent packages) Total size: 229 M Total download size: 228 M Downloading packages: ------------------------------------------------------------------------------------------------------------------------------------------- Total 130 MB/s | 228 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/14 Installing : mysql-cluster-community-common-7.5.5-1.el7.x86_64 2/14 Installing : mysql-cluster-community-libs-7.5.5-1.el7.x86_64 3/14 Installing : perl-Class-MethodMaker-2.20-1.el7.x86_64 4/14 Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/14 Installing : perl-Net-Daemon-0.48-5.el7.noarch 6/14 Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 7/14 Installing : perl-IO-Compress-2.061-2.el7.noarch 8/14 Installing : perl-PlRPC-0.2020-14.el7.noarch 9/14 Installing : perl-DBI-1.627-4.el7.x86_64 10/14 Installing : mysql-cluster-community-client-7.5.5-1.el7.x86_64 11/14 Installing : mysql-cluster-community-server-7.5.5-1.el7.x86_64 12/14 Installing : mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64 13/14 Erasing : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14 Verifying : mysql-cluster-community-client-7.5.5-1.el7.x86_64 1/14 Verifying : mysql-cluster-community-common-7.5.5-1.el7.x86_64 2/14 Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 3/14 Verifying : perl-Net-Daemon-0.48-5.el7.noarch 4/14 Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 5/14 Verifying : perl-Class-MethodMaker-2.20-1.el7.x86_64 6/14 Verifying : mysql-cluster-community-server-7.5.5-1.el7.x86_64 7/14 Verifying : mysql-cluster-community-libs-7.5.5-1.el7.x86_64 8/14 Verifying : mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64 9/14 Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 10/14 Verifying : perl-PlRPC-0.2020-14.el7.noarch 11/14 Verifying : perl-IO-Compress-2.061-2.el7.noarch 12/14 Verifying : perl-DBI-1.627-4.el7.x86_64 13/14 Verifying : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14 Installed: mysql-cluster-community-client.x86_64 0:7.5.5-1.el7 mysql-cluster-community-libs.x86_64 0:7.5.5-1.el7 mysql-cluster-community-libs-compat.x86_64 0:7.5.5-1.el7 mysql-cluster-community-server.x86_64 0:7.5.5-1.el7 Dependency Installed: mysql-cluster-community-common.x86_64 0:7.5.5-1.el7 perl-Class-MethodMaker.x86_64 0:2.20-1.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Replaced: mariadb-libs.x86_64 1:5.5.41-2.el7_0 Complete! [root@ndb-manager ~]#
Data Node:
yum install -y mysql-cluster-community-server –nogpgcheck
[root@ndb-node1 ~]# yum install -y mysql-cluster-community-server --nogpgcheck Loaded plugins: fastestmirror, langpacks epel/x86_64/metalink | 4.5 kB 00:00:00 epel | 4.3 kB 00:00:00 (1/3): epel/x86_64/group_gz | 170 kB 00:00:01 (2/3): epel/x86_64/updateinfo | 734 kB 00:00:38 (3/3): epel/x86_64/primary_db | 4.5 MB 00:01:34 Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn Resolving Dependencies --> Running transaction check ---> Package mysql-cluster-community-server.x86_64 0:7.5.5-1.el7 will be installed --> Processing Dependency: mysql-cluster-community-common(x86-64) = 7.5.5-1.el7 for package: mysql-cluster-community-server-7.5.5-1.el7.x86_64 --> Processing Dependency: mysql-cluster-community-client(x86-64) >= 5.7.9 for package: mysql-cluster-community-server-7.5.5-1.el7.x86_64 --> Running transaction check ---> Package mysql-cluster-community-client.x86_64 0:7.5.5-1.el7 will be installed --> Processing Dependency: mysql-cluster-community-libs(x86-64) >= 5.7.9 for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 --> Processing Dependency: perl(Data::Dumper) for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 --> Processing Dependency: perl(DBI) for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 --> Processing Dependency: perl(Class::MethodMaker) for package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 ---> Package mysql-cluster-community-common.x86_64 0:7.5.5-1.el7 will be installed --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.41-2.el7_0 will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 ---> Package mysql-cluster-community-libs.x86_64 0:7.5.5-1.el7 will be obsoleting ---> Package perl-Class-MethodMaker.x86_64 0:2.20-1.el7 will be installed ---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed --> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64 --> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64 ---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed --> Running transaction check ---> Package mysql-cluster-community-libs-compat.x86_64 0:7.5.5-1.el7 will be obsoleting ---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed --> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch --> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch --> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch --> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch --> Running transaction check ---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed --> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch --> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch ---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed --> Running transaction check ---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed ---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================== Installing: mysql-cluster-community-libs x86_64 7.5.5-1.el7 local_mysql_cluster 2.1 M replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0 mysql-cluster-community-libs-compat x86_64 7.5.5-1.el7 local_mysql_cluster 2.0 M replacing mariadb-libs.x86_64 1:5.5.41-2.el7_0 mysql-cluster-community-server x86_64 7.5.5-1.el7 local_mysql_cluster 140 M Installing for dependencies: mysql-cluster-community-client x86_64 7.5.5-1.el7 local_mysql_cluster 84 M mysql-cluster-community-common x86_64 7.5.5-1.el7 local_mysql_cluster 271 k perl-Class-MethodMaker x86_64 2.20-1.el7 epel 334 k perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 ISO 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 ISO 57 k perl-DBI x86_64 1.627-4.el7 ISO 802 k perl-Data-Dumper x86_64 2.145-3.el7 ISO 47 k perl-IO-Compress noarch 2.061-2.el7 ISO 260 k perl-Net-Daemon noarch 0.48-5.el7 ISO 51 k perl-PlRPC noarch 0.2020-14.el7 ISO 36 k Transaction Summary =========================================================================================================================================== Install 3 Packages (+10 Dependent packages) Total download size: 229 M Downloading packages: (1/8): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00 (2/8): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00 (3/8): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00 (4/8): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00 (5/8): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00 (6/8): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00 (7/8): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00 (8/8): perl-Class-MethodMaker-2.20-1.el7.x86_64.rpm | 334 kB 00:00:01 ------------------------------------------------------------------------------------------------------------------------------------------- Total 49 MB/s | 229 MB 00:00:04 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/14 Installing : mysql-cluster-community-common-7.5.5-1.el7.x86_64 2/14 Installing : mysql-cluster-community-libs-7.5.5-1.el7.x86_64 3/14 Installing : perl-Class-MethodMaker-2.20-1.el7.x86_64 4/14 Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/14 Installing : perl-Net-Daemon-0.48-5.el7.noarch 6/14 Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 7/14 Installing : perl-IO-Compress-2.061-2.el7.noarch 8/14 Installing : perl-PlRPC-0.2020-14.el7.noarch 9/14 Installing : perl-DBI-1.627-4.el7.x86_64 10/14 Installing : mysql-cluster-community-client-7.5.5-1.el7.x86_64 11/14 Installing : mysql-cluster-community-server-7.5.5-1.el7.x86_64 12/14 Installing : mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64 13/14 Erasing : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14 Verifying : mysql-cluster-community-client-7.5.5-1.el7.x86_64 1/14 Verifying : mysql-cluster-community-common-7.5.5-1.el7.x86_64 2/14 Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 3/14 Verifying : perl-Net-Daemon-0.48-5.el7.noarch 4/14 Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 5/14 Verifying : perl-Class-MethodMaker-2.20-1.el7.x86_64 6/14 Verifying : mysql-cluster-community-server-7.5.5-1.el7.x86_64 7/14 Verifying : mysql-cluster-community-libs-7.5.5-1.el7.x86_64 8/14 Verifying : mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64 9/14 Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 10/14 Verifying : perl-PlRPC-0.2020-14.el7.noarch 11/14 Verifying : perl-IO-Compress-2.061-2.el7.noarch 12/14 Verifying : perl-DBI-1.627-4.el7.x86_64 13/14 Verifying : 1:mariadb-libs-5.5.41-2.el7_0.x86_64 14/14 Installed: mysql-cluster-community-libs.x86_64 0:7.5.5-1.el7 mysql-cluster-community-libs-compat.x86_64 0:7.5.5-1.el7 mysql-cluster-community-server.x86_64 0:7.5.5-1.el7 Dependency Installed: mysql-cluster-community-client.x86_64 0:7.5.5-1.el7 mysql-cluster-community-common.x86_64 0:7.5.5-1.el7 perl-Class-MethodMaker.x86_64 0:2.20-1.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Replaced: mariadb-libs.x86_64 1:5.5.41-2.el7_0 Complete! [root@ndb-node1 ~]#
注意,这里,你可能会遇到这样的报错:
--> Finished Dependency Resolution Error: Package: mysql-cluster-community-client-7.5.5-1.el7.x86_64 (local_mysql_cluster) Requires: perl(Class::MethodMaker) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest
这个时候,你可以配置EPEL,然后就能解决这个依赖包关系的问题:
[root@ndb-manager ~]# cat /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [root@ndb-manager ~]# [root@ndb-manager ~]# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.zju.edu.cn * updates: mirrors.zju.edu.cn repo id repo name status ISO ISO 8,652 base/7/x86_64 CentOS-7 - Base 9,363 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 11,172 extras/7/x86_64 CentOS-7 - Extras 263 local_mysql_cluster local_mysql_cluster_7.5.5 17 updates/7/x86_64 CentOS-7 - Updates 814 repolist: 30,281 [root@ndb-manager ~]# [root@ndb-manager ~]# yum list | grep perl-Class-MethodMaker perl-Class-MethodMaker.x86_64 2.20-1.el7 epel [root@ndb-manager ~]#
这样,到这里,MySQL Cluster(ndb)架构的安装就结束了。
二、MySQL Cluster(ndb):配置
文件:/etc/my.cnf
DATA NODE / SQL NODE
[root@ndb-manager ~]# cat /etc/my.cnf [mysqld] ndbcluster datadir=/var/lib/mysql plugin-dir=/usr/lib64/mysql/plugin pid-file=/var/lib/mysql/mysql.pid log-error=/var/lib/mysql/mysql-error.log user=mysql [mysql_cluster] ndb-connectstring=10.158.1.98 [root@ndb-manager ~]#
Manager Node:
创建需要的目录结构:
[root@ndb-manager ~]# mkdir /var/lib/mysql-cluster [root@ndb-manager ~]#
文件:/var/lib/mysql-cluster/config.ini
[root@ndb-manager mysql-cluster]# pwd /var/lib/mysql-cluster [root@ndb-manager mysql-cluster]# [root@ndb-manager mysql-cluster]# cat config.ini [ndb_mgmd default] datadir=/var/lib/mysql-cluster [ndbd default] NoOfReplicas=2 DataMemory=200M IndexMemory=20M datadir=/var/lib/mysql [ndb_mgmd] NodeId=1 HostName=10.158.1.98 datadir=/var/lib/mysql-cluster [ndbd] NodeId=2 HostName=10.158.1.148 datadir=/var/lib/mysql [ndbd] NodeId=3 HostName=10.158.1.173 datadir=/var/lib/mysql [mysqld] NodeId=4 HostName=10.158.1.98 [root@ndb-manager mysql-cluster]#
三、MySQL Cluster(ndb):启动
1. 启动管理节点
[root@ndb-manager mysql-cluster]# ps -ef | grep ndb avahi 614 1 0 15:04 ? 00:00:00 avahi-daemon: running [ndb-manager.local] root 2583 1931 0 20:42 pts/0 00:00:00 grep --color=auto ndb [root@ndb-manager mysql-cluster]# [root@ndb-manager mysql-cluster]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial MySQL Cluster Management Server mysql-5.7.17 ndb-7.5.5 [root@ndb-manager mysql-cluster]# [root@ndb-manager mysql-cluster]# ps -ef | grep ndb avahi 614 1 0 15:04 ? 00:00:00 avahi-daemon: running [ndb-manager.local] root 2593 1 0 20:42 ? 00:00:00 ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial root 2636 1931 0 20:44 pts/0 00:00:00 grep --color=auto ndb [root@ndb-manager mysql-cluster]#
2. 启动数据节点:
[root@ndb-node1 ~]# ps -ef | grep ndbd root 2062 1554 0 20:44 pts/0 00:00:00 grep --color=auto ndbd [root@ndb-node1 ~]# [root@ndb-node1 ~]# ndbd --initial 2017-02-15 20:44:24 [ndbd] INFO -- Angel connected to '10.158.1.98:1186' 2017-02-15 20:44:24 [ndbd] INFO -- Angel allocated nodeid: 2 [root@ndb-node1 ~]# [root@ndb-node1 ~]# ps -ef | grep ndbd root 2067 1 0 20:44 ? 00:00:00 ndbd --initial root 2068 2067 7 20:44 ? 00:00:00 ndbd --initial root 2130 1554 0 20:44 pts/0 00:00:00 grep --color=auto ndbd [root@ndb-node1 ~]# [root@ndb-node1 ~]# netstat -tupln | grep ndbd tcp 0 0 10.158.1.148:39874 0.0.0.0:* LISTEN 2068/ndbd tcp 0 0 10.158.1.148:43306 0.0.0.0:* LISTEN 2068/ndbd [root@ndb-node1 ~]#
3. 启动SQL节点:
启动前,先初始化:
[root@ndb-manager mysql]# mysqld --initialize [root@ndb-manager mysql]#
启动:
[root@ndb-manager ~]# ps -ef | grep mysql root 2593 1 0 20:42 ? 00:01:10 ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial root 5610 5437 0 23:40 pts/0 00:00:00 grep --color=auto mysql [root@ndb-manager ~]# [root@ndb-manager ~]# netstat -tupln | grep ndb tcp 0 0 0.0.0.0:1186 0.0.0.0:* LISTEN 2593/ndb_mgmd [root@ndb-manager ~]# [root@ndb-manager ~]# mysqld --ndbcluster --ndb-connectstring=10.158.1.98:1186 --explicit_defaults_for_timestamp --skip-grant-tables & [1] 5613 [root@ndb-manager ~]# [root@ndb-manager ~]# ps -ef | grep mysql root 2593 1 0 20:42 ? 00:01:11 ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial mysql 5613 5437 8 23:40 pts/0 00:00:00 mysqld --ndbcluster --ndb-connectstring=10.158.1.98:1186 --explicit_defaults_for_timestamp --skip-grant-tables root 5652 5437 0 23:41 pts/0 00:00:00 grep --color=auto mysql [root@ndb-manager ~]# [root@ndb-manager ~]# netstat -tupln | grep ndb tcp 0 0 0.0.0.0:1186 0.0.0.0:* LISTEN 2593/ndb_mgmd [root@ndb-manager ~]# [root@ndb-manager ~]# netstat -tupln | grep mysql tcp6 0 0 :::3306 :::* LISTEN 5613/mysqld [root@ndb-manager ~]#
4. 全部启动后,查看MySQL Cluster的状态:
[root@ndb-manager ~]# ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: 10.158.1.98:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @10.158.1.148 (mysql-5.7.17 ndb-7.5.5, Nodegroup: 0, *) id=3 @10.158.1.173 (mysql-5.7.17 ndb-7.5.5, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @10.158.1.98 (mysql-5.7.17 ndb-7.5.5) [mysqld(API)] 1 node(s) id=4 @10.158.1.98 (mysql-5.7.17 ndb-7.5.5) ndb_mgm> exit [root@ndb-manager ~]# [root@ndb-manager mysql]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.17-ndb-7.5.5-cluster-gpl MySQL Cluster Community Server (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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | ndbinfo | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> exit Bye [root@ndb-manager mysql]#
这样,搭建,就结束了。
——————————————————
Done。