还没来得及写。我就知道一个月完毕不了,暂时添加的工作总是拖后腿。
。。
MySQL集群 docker下安装MySQL Cluster报错了。是我image的包少了perl。老实装吧。image又小不了了。还须要安装numactl, net-tools
error: Failed dependencies:
/usr/bin/perl is needed by MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64
libnuma.so.1()(64bit) is needed by MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64
-- continue---
192.168.2.54 Management Node
192.168.2.55 Data Node
192.168.2.56 Sql Node
---安装 Data Node----
mysql $ sudo rpm -Uhv MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
成功安装后ndbd和ndbmtd应在已经在/usr/sbin文件夹中
---安装 Sql Node----
mysql $ sudo rpm -Uhv MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
成功安装后mysqld应在已经位于/usr/sbin文件夹中,/usr/share/mysql中有mysql.server
假设要管理Sql Node,须要安装client。安装后/usr/bin/中有mysql
mysql $ sudo rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
假设安装过程报错,则须要安装
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper
mysql $ sudo yum install -y perl-Data-Dumper
---安装Management Node----
mysql $ sudo rpm -Uhv MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
安装后ndb_mgmd已经安装在/usr/sbin中,ndb_mgm管理客户端也已经成功安装
====================================================================
---初始配置cluster----
MySQL Cluster7.3+提供了auto-install的gui安装方式。后面我们会试一下
编辑配置文件,每一个Data Node或sql Node须要编辑my.cnf,提供连接字符信息,告诉节点怎样找到管理节点。另外告诉mysql server提供NDBCluster引擎
管理节点须要配置config.ini文件。说明须要维护多少复制,在每一个数据节点上有多少内存分配给数据和索引,怎样找到数据节点。每一个数据节点的数据保存在磁盘什么位置,怎样查找SQL节点
---配置数据节点和SQL节点----
mysql $ sudo mkdir -p /usr/local/mysql/data
mysql $ sudo chown -R mysq:mysq /usr/local/mysql/
mysql $ sudo vi /etc/my.cnf
[mysqld]
ndbcluster
[mysql_cluster]
ndb-connectstring=192.168.2.54 # 管理节点地址,别忘了防火墙关闭,检測ping通
两个节点都进行配置
注意,假设你启动了配置ndbcluster的mysqld进程,集群没有启动是不能运行create table和alter table语句的,为了保持一致性
---配置管理节点----
mysql $ sudo mkdir /var/lib/mysql-cluster 创建个文件夹保存配置
mysql $ sudo chown -R mysq:mysq /var/lib/mysql-cluster/
mysql $ sudo mkdir /usr/mysql-cluster
mysql $ sudo chown -R mysq:mysq /usr/mysql-cluster
mysql $ sudo vi /var/lib/mysql-cluster/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 Cluster setup. [tcp default] # TCP/IP options: portnumber=2202 # This the default; however, you can use any # port that is free for all the hosts in the cluster # Note: It is recommended that you do not specify the port # number at all and simply allow the default value to be used # instead [ndb_mgmd] # Management process options: hostname=192.168.2.54 # 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.2.55 # Hostname or IP address datadir=/usr/local/mysql/data # Directory for this data node‘s data files #[ndbd] # Options for data node "B": #hostname=192.168.0.40 # Hostname or IP address #datadir=/usr/local/mysql/data # Directory for this data node‘s data files [mysqld] # SQL node options: hostname=192.168.2.56 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore)
================================================
---初始化启动集群----
在管理节点,运行命令启动管理节点进程
mysql $ ndb_mgmd -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql-5.6.28 ndb-7.4.10
假设启动出错在/var/lib/mysql-cluster文件夹中查看日志排除错误
在数据节点。运行命令启动
mysql $ ndbd
[[email protected] ~]$ ndbd
2016-04-21 10:01:37 [ndbd] INFO -- Angel connected to ‘192.168.2.54:1186‘
2016-04-21 10:01:37 [ndbd] INFO -- Angel allocated nodeid: 2
在管理节点上查看状态
mysql $ ndb_mgm
ndb_mgm> SHOW 查看节点状态,假设没有可用节点,则会每五秒尝试一次
[mysql ~]$ ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 1 node(s)
id=2 @192.168.2.55 (mysql-5.6.28 ndb-7.4.10, Nodegroup: 0, *)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.2.54 (mysql-5.6.28 ndb-7.4.10)
[mysqld(API)] 1 node(s)
id=3 (not connected, accepting connect from 192.168.2.56)
启动SQL节点
由于是新安装的,运行mysqld会报错
须要先installdb
mysql $ mysql_install_db --user=mysql
mysql $ mysqld & 使用你习惯的daemon方式运行
============查看状态=============
Cluster Configuration
---------------------
[ndbd(NDB)] 1 node(s)
id=2 @192.168.2.55 (mysql-5.6.28 ndb-7.4.10, Nodegroup: 0, *)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.2.54 (mysql-5.6.28 ndb-7.4.10)
[mysqld(API)] 1 node(s)
id=3 @192.168.2.56 (mysql-5.6.28 ndb-7.4.10)