8个节点MySQL-cluster安装和配置,含两个管理节点

换装jdk


[root@clusterdata1 software]# rpm -qa | grep java
java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
tzdata-java-2012j-1.el6.noarch
java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64
[root@clusterdata1 software]# rpm -e --nodeps tzdata-java-2012j-1.el6.noarch
[root@clusterdata1 software]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64
[root@clusterdata1 software]# rpm -qa |grep java
java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
[root@clusterdata1 software]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
[root@clusterdata1 software]# rpm -qa |grep java
[root@clusterdata1 software]# ls
jdk-7u60-linux-x64.rpm  mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64.tar.gz
[root@clusterdata1 software]# rpm -ivh jdk-7u60-linux-x64.rpm
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
    rt.jar...
    jsse.jar...
    charsets.jar...
    tools.jar...
    localedata.jar...
    jfxrt.jar...
[root@clusterdata1 software]# java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

安装datanode,准备工作只要两个执行文件


ndb-connectstring=xxx.xxx.xxx.xx1 
[root@clusterdata1 software]# tar -zxvf mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64.tar.gz
[root@clusterdata1 software]# cd mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64
[root@clusterdata1 mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64]# cp bin/ndbd /usr/local/bin/ndbd
[root@clusterdata1 mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64]# cp bin/ndbmtd /usr/local/bin/ndbmtd
[root@clusterdata1 mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64]# cd /usr/local/bin
[root@clusterdata1 bin]# chmod +x ndb*

创建一个数据存放的目录


ndb-connectstring=xxx.xxx.xxx.xx1 
[root@clusterdata1 bin]# cd /usr/local
[root@clusterdata1 local]# ls
bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@clusterdata1 local]# mkdir -p mysql/data
[root@clusterdata1 local]# cd mysql/data
[root@clusterdata1 data]# pwd
/usr/local/mysql/data

sql节点

创建mysql用户


[root@clustersql2 software]# grep mysql /etc/passwd
[root@clustersql2 software]# grep mysql /etc/group
[root@clustersql2 software]# groupadd mysql
[root@clustersql2 software]# useradd -g mysql mysql

安装


Server version: 5.6.27-ndb-7.4.8-cluster-gpl MySQL Cluster Community Server (GPL)
[root@clustersql2 software]# tar -C /usr/local -xzvf mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64.tar.gz
[root@clustersql2 mysql]# ln -s /usr/local/mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64 /usr/local/mysql
[root@clustersql2 mysql]# cd /usr/local/mysql
[root@clustersql2 mysql]# scripts/mysql_install_db --user=mysql

[root@clustersql2 mysql]# chown -R root .
[root@clustersql2 mysql]# chown -R mysql data
[root@clustersql2 mysql]# chgrp -R mysql .

完成之后启动并设置下root密码


[root@clustersql1 bin]# ./mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 4999
[root@clustersql1 bin]# 151229 08:47:17 mysqld_safe Logging to '/usr/local/mysql/data/clustersql1.err'.
151229 08:47:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

# bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

# bin/mysql -uroot mysql

mysql> update user set password=PASSWORD('tplink') where user='root';

mysql> flush privileges;

# bin/mysqladmin -uroot -p shutdown

# bin/mysql -uroot -p

管理节点安装


[root@clustermgm1 software]# tar -zxvf mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64.tar.gz

[root@clustermgm1 software]# cd mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64
[root@clustermgm1 mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64]# cp bin/ndb_mgm* /usr/local/bin
[root@clustermgm1 mysql-cluster-gpl-7.4.8-linux-glibc2.5-x86_64]# cd /usr/local/bin
[root@clustermgm1 bin]# chmod +x ndb_mgm*
[root@clustermgm1 bin]# ll ndb_mgm*
-rwxr-xr-x 1 root root  7136783 Dec 10 00:19 ndb_mgm
-rwxr-xr-x 1 root root 16368291 Dec 10 00:19 ndb_mgmd

配置

数据节点配置


[root@clusterdata1 data]# vi /etc/my.cnf
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=xxx.xxx.xxx.xx1,xxx.xxx.xxx.xx1 # location of management server

SQL节点配置


[root@clustersql1 bin]# cat /etc/my.cnf
[mysqld]
ndbcluster
character_set_server=utf8

max_connections=2000
connect_timeout=10
wait_timeout=28800
interactive_timeout=28800

[mysql_cluster]
ndb-connectstring=xxx.xxx.xxx.xx1,xxx.xxx.xxx.xx1

管理节点配置


[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@clustermgm1 mysql-cluster]# cat config.ini
[ndbd default]
NoOfReplicas= 2
LockPagesInMainMemory=1
DataMemory= 16G
IndexMemory= 4G
#ODirect=1

MaxNoOfOrderedIndexes= 512
MaxNoOfConcurrentOperations= 1000000
MaxNoOfLocalScans= 40000
MaxNoOfConcurrentScans=500
#MaxParallelScansPerFragment=1024

# real-time scheduling
SchedulerSpinTimer=400
SchedulerExecutionTimer=50
RealTimeScheduler=1

#Logging and Checkpointing
NoOfFragmentLogFiles=300
FragmentLogFileSize=16M

TimeBetweenWatchDogCheck= 30000
TimeBetweenLocalCheckpoints= 3
#TimeBetweenGlobalCheckpoints= 1000
TimeBetweenEpochs=200
TimeBetweenWatchdogCheckInitial= 60000

#DiskPageBufferMemory=1024M
TransactionInactiveTimeout= 50000
MaxNoOfExecutionThreads= 8
BatchSizePerLocalScan= 512

TransactionDeadlockDetectionTimeout=10000

[ndb_mgmd]
NodeId=1
HostName= xxx.xxx.xxx.xx1
DataDir= /usr/local/mysql/mysql-cluster

[ndb_mgmd]
NodeId=2
HostName= xxx.xxx.xxx.xx1
DataDir= /usr/local/mysql/mysql-cluster

[ndbd]
NodeId=3
HostName= xxx.xxx.xxx.xx3
DataDir= /usr/local/mysql/data
NodeGroup= 0

[ndbd]
NodeId=4
HostName= xxx.xxx.xxx.xx3
DataDir= /usr/local/mysql/data
NodeGroup= 0

[ndbd]
NodeId=5
HostName= xxx.xxx.xxx.xx4
DataDir= /usr/local/mysql/data
NodeGroup= 1


[ndbd]
NodeId=6
HostName= xxx.xxx.xxx.xx4
DataDir= /usr/local/mysql/data
NodeGroup= 1

[mysqld]
NodeId=7
HostName= xxx.xxx.xxx.xx2
[mysqld]
NodeId=8
HostName= xxx.xxx.xxx.xx2

[mysqld]
[mysqld]

# choose an unused port number
# in this configuration 63132, 63133, and 63134
# will be used
[tcp default]
PortNumber= 63132
SendBufferMemory=2M
ReceiveBufferMemory=2M

首次启动

管理节点


[root@clustermgm1 mysql-cluster]# ndb_mgmd --config-file=/usr/local/mysql/mysql-cluster/config.ini
[root@clustermgm1 mysql-cluster]# ndb_mgm 
-- NDB Cluster -- Management Client --
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 4 node(s)
id=3    @xxx.xxx.xxx.xx3  (mysql-5.6.27 ndb-7.4.8, Nodegroup: 0, *)
id=4    @xxx.xxx.xxx.xx3  (mysql-5.6.27 ndb-7.4.8, Nodegroup: 0)
id=5    @xxx.xxx.xxx.xx4  (mysql-5.6.27 ndb-7.4.8, Nodegroup: 1)
id=6    @xxx.xxx.xxx.xx4  (mysql-5.6.27 ndb-7.4.8, Nodegroup: 1)

[ndb_mgmd(MGM)] 2 node(s)
id=1    @xxx.xxx.xxx.xx1  (mysql-5.6.27 ndb-7.4.8)
id=2    @xxx.xxx.xxx.xx1  (mysql-5.6.27 ndb-7.4.8)

[mysqld(API)]   4 node(s)
id=7    @xxx.xxx.xxx.xx2  (mysql-5.6.27 ndb-7.4.8)
id=8    @xxx.xxx.xxx.xx2  (mysql-5.6.27 ndb-7.4.8)
id=9 (not connected, accepting connect from any host)
id=10 (not connected, accepting connect from any host)

data节点


[root@clusterdata1 ~]# ndbd --initial
2015-12-11 01:05:07 [ndbd] INFO     -- Angel connected to 'xxx.xxx.xxx.xx1:1186'
2015-12-11 01:05:07 [ndbd] INFO     -- Angel allocated nodeid: 1

sql节点


[root@clustersql1 bin]# mysqld_safe --user=mysql &
[1] 3028
[root@clustersql1 bin]# 151229 14:48:20 mysqld_safe Logging to '/usr/local/mysql/data/clustersql1.err'.
151229 14:48:21 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

你可能感兴趣的:(8个节点MySQL-cluster安装和配置,含两个管理节点)