Cenots 7 安装mysql cluster 通过rpm 包
环境:Cenots 7
MG:192.168.0.105
NDB:192.168.0.108
NDB:192.168.0.109
SQL:192.168.0.111
SQL:192.168.0.107
软件下载说明:
软件下载地址:http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-Cluster-7.5/
MG 管理商:
mysql-cluster-community-client-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-libs-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
NDB 数据节点:
mysql-cluster-community-client-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-libs-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-common-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-libs-compat-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-data-node-7.5.5-1.el7.x86_64.rpm
SQL 查询节点:
mysql-cluster-community-client-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-libs-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-common-7.5.5-1.el7.x86_64.rpm
mysql-cluster-community-server-7.5.5-1.el7.x86_64.rpm
防火墙配置:
MG 管理端配置:
1.禁用firewalld:
systemctl stop firewalld & systemctl disable firewalld
2.安装iptables 防火墙:yum -y install iptables-services
配置重点如下:
在/etc/sysconfig/iptables 添加如下规则
-A INPUT -p tcp -m state --state NEW -m tcp -s 192.168.0.0/24 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp -s 192.168.0.0/24 -j ACCEPT
3.禁用SElinux ,请注意需要重启服务器
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
NDB 数据节点防火墙配置:
1.禁用firewalld:
systemctl stop firewalld & systemctl disable firewalld
2.安装iptables 防火墙:yum -y install iptables-services
配置重点如下:
在/etc/sysconfig/iptables 添加如下规则
-A INPUT -p tcp -m state --state NEW -m tcp -s 192.168.0.0/24 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp -s 192.168.0.0/24 -j ACCEPT
3.禁用SElinux ,请注意需要重启服务器
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
SQL 查询节点防火墙配置:
1.禁用firewalld:
systemctl stop firewalld & systemctl disable firewalld
2.安装iptables 防火墙:yum -y install iptables-services
配置重点如下:
在/etc/sysconfig/iptables 添加如下规则
-A INPUT -p tcp -m state --state NEW -m tcp -s 192.168.0.0/24 -j ACCEPT -A INPUT -p udp -m state --state NEW -m udp -s 192.168.0.0/24 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
3.禁用SElinux ,请注意需要重启服务器
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
Cluster 命令使用:
MG 管理端:
第一次启动命令(修改config.ini配置文件重新初始化):
ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
启动命令:
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
关闭命令:
ndb_mgm -e shutdown
查询状态命令:
ndb_mgm -e show
查询MG是否启动状态:
ps aux | grep ndb | grep -v grep
NDB 数据节点命令:
第一次启动:
ndbd --initial
重启:
ndbd
查询启动状态:
ps aux | grep ndb | grep -v grep
查看端口连接:
netstat -anpt
SQL 查询节点:
第一次启动, 请注意配置好my.cnf 文件之后再启动:
chown mysql:mysql -R /var/lib/mysql mysqld --initialize-insecure
systemctl restart mysqld
安装软件说明:
MGM 管理端,:
安装命令如下,请查收安装时进入到软件所放置的目录下面;
yum -y localinstall mysql-cluster-community-*
NDB 跟MGM 安装一样;
SQL 安装有所不同,是因为安装插件:
yum install prel-Class-MethodMaker perl-libwww-perl perl-DBI perl-GD perl-Data-Dumper yum -y remove mariadb-libs yum -y localinstall mysql-cluster-community-*
配置说明:
MGM 管理端:
配置文件所存放在:/var/lib/mysql-cluster/ 目录下面,所以首先要创建此目录:mkdir /var/lib/mysql-cluster/
配置内容如下:
[ndb_mgmd default] DataDir=/var/lib/mysql-cluster [ndb_mgmd] NodeId=10 HostName=192.168.0.105 #[TCP DEFAULT] #portnumber=2202 [ndbd default] NoOfReplicas=2 DataMemory=10307921510 IndexMemory=5153960755 DataDir=/var/lib/mysql-cluster BackupDataDir=/var/lib/mysql-cluster/backup StringMemory=20 MaxNoOfTables=1024 MaxNoOfOrderedIndexes=2048 MaxNoOfUniqueHashIndexes=512 MaxNoOfAttributes=204800 MaxNoOfTriggers=102400 LockPagesInMainMemory=1 TimeBetweenLocalCheckpoints=20 TimeBetweenGlobalCheckpoints=1000 TimeBetweenEpochs=100 TimeBetweenWatchdogCheckInitial=60000 FragmentLogFileSize=256M NoOfFragmentLogFiles=16 RedoBuffer=64M MaxNoOfConcurrentOperations=500000 TransactionInactiveTimeout=50000 MaxNoOfExecutionThreads=8 BatchSizePerLocalScan=512 SharedGlobalMemory=20M DiskPageBufferMemory=80M [ndbd] NodeId=20 HostName=192.168.0.109 [ndbd] NodeId=21 HostName=192.168.0.108 [mysqld] NodeId=30 HostName=192.168.0.111 [mysqld] NodeId=31 HostName=192.168.0.107 [mysqld] [mysqld] [mysqld] [mysqld] [mysqld] [mysqld] [mysqld] [mysqld]
NDB 数据节点配置:
因在MG 管理里面定义有backup 文件夹,所有首先要创建此文件夹,不然在重启过程中会报错从而不能成功启动节点:mkdir /var/lib/mysql-cluster/backup
配置文件为/etc/my.cnf 配置内容如下:
[mysqld] ndbcluster ndb-connectstring=192.168.0.105 # IP address of Management Node [mysql_cluster] ndb-connectstring=192.168.0.105 # IP address of Management Node
SQL 查询节点配置:
配置文件为/etc/my.cnf 请注意:第一次启动时先配置好此文件再初始化Mysql 再启动;
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] user=mysql # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid ndbcluster ndb-connectstring=192.168.0.105:1186 # IP address for server management node default_storage_engine=ndbcluster # Define default Storage Engine used by MySQL [mysql_cluster] ndb-connectstring=192.168.0.105:1186 # IP address for server management node
启动过程:MG-NDB-SQL
完成!