二、配置管理结点(192.168.124.141)
1. 配置config.ini配置文件
在shell中运行以下命令:
- mkdir /var/lib/mysql-cluster
- cd /var/lib/mysql-cluster
- gedit config.ini
配置文件config.ini内容如下:
- [ndbd default]
- NoOfReplicas=2
- DataMemory=80M
- IndexMemory=18M
- [ndb_mgmd]
- NodeId=1
- hostname=192.168.124.141
- datadir=/var/lib/mysql-cluster
- [ndbd]
- NodeId=2
- hostname=192.168.124.142
- datadir=/usr/local/mysql/data
- [ndbd]
- NodeId=3
- hostname=192.168.124.143
- datadir=/usr/local/mysql/data
- [mysqld]
- NodeId=4
- hostname=192.168.124.144
- [mysqld]
- NodeId=5
- hostname=192.168.124.145
2. 安装管理结点
安装管理节点,不需要mysqld二进制文件,只需要MySQL Cluster服务端程序(ndb_mgmd)和监听客户端程序(ndb_mgm)。在shell中运行以下命令:
- cp /usr/local/mysql/bin/ndb_mgm* /usr/local/bin
- cd /usr/local/bin
- chmod +x ndb_mgm*
三、配置数据结点(192.168.124.142、192.168.124.143)
1. 添加mysql组和用户
在shell中运行以下命令:
- groupadd mysql
- useradd -g mysql mysql
2. 配置my.cnf配置文件
在shell中运行以下命令:
- gedit /etc/my.cnf
配置文件my.cnf的内容如下:
- [mysqld]
- basedir=/usr/local/mysql
- datadir=/usr/local/mysql/data
- socket=/usr/local/mysql/sock/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
- [mysql_cluster]
- ndb-connectstring=192.168.124.141
3. 创建系统数据库
在shell中运行以下命令:
- cd /usr/local/mysql
- mkdir sock
- scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
4. 设置数据目录
在shell中运行以下命令:
- chown -R root .
- chown -R mysql.mysql /usr/local/mysql/data
- chown -R mysql.mysql /usr/local/mysql/sock
- chgrp -R mysql .
5. 配置MySQL服务
在shell中运行以下命令:
- cp support-files/mysql.server /etc/rc.d/init.d/
- chmod +x /etc/rc.d/init.d/mysql.server
- chkconfig --add mysql.server