Home > Database > Mysql Tutorial > body text

mysql-cluster 7.3.5-linux 安装_MySQL

WBOY
Release: 2016-06-01 13:06:51
Original
788 people have browsed it

【集群环境】

管理节点    10.0.0.19

数据节点    10.0.0.12

                   10.0.0.17

sql节点       10.0.0.18

                   10.0.0.22

1. 添加mysql用户

# groupadd mysql# useradd mysql -g mysql
Copy after login

2. 安装mysql-cluster 7.3.5-linux

# cd /usr/local/src/(已下载好集群版)# tar -xvf mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64.tar.gz # mv mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64 ../mysql# cd ..# chown -R mysql:mysql mysql/# cd mysql# scripts/mysql_install_db --user=mysql
Copy after login
以上步骤5台机器都要执行

3. 集群配置

(1) 管理节点

# vi/var/lib/mysql-cluster/config.ini (目录和文件没有请新建,添加以下内容)
Copy after login
[NDBD DEFAULT]NoOfReplicas=2[TCP DEFAULT]portnumber=3306[NDB_MGMD]#设置管理节点服务器nodeid=1HostName=10.0.0.19DataDir=/var/mysql/data[NDBD]id=2HostName=10.0.0.12DataDir=/var/mysql/data[NDBD]id=3HostName=10.0.0.17DataDir=/var/mysql/data[MYSQLD]id=4HostName=10.0.0.18[MYSQLD]id=5HostName=10.0.0.22#必须有空的mysqld节点,不然数据节点断开后启动有报错[MYSQLD]id=6[mysqld]id=7
Copy after login

拷贝ndb_mgm、ndb_mgmd到bin目录。

# cd /usr/local/mysql/bin# cp ./ndb_mgm /usr/local/bin/# cp ./ndb_mgmd /usr/local/bin/
Copy after login

备注:    管理节点只要ndb_mgm和ndb_mgmd两个文件和一个配置文件即可。

                因此把这三个文件复制到那里,那里就是管理节点了。

                ndb_mgmd是mysql cluster管理服务器,ndb_mgm是客户端管理工具。

启动管理节点

# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Copy after login

关闭管理节点

# ndb_mgm>shutdown
Copy after login

备注:命令行中的ndb_mgmd是mysql cluster的管理服务器,后面的-f表示后面的参数是启动的参数配置文件。

如果在启动后过了几天又添加了一个数据节点,这时修改了配置文件启动时就必须加上--initial参数,不然添加的节点不会作用在mysql cluster中。

# ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
Copy after login
# ndb_mgm
Copy after login

这时就进入到客户端,可以对mysql cluster进行各项操作。

# ndb_mgm> show 查看各节点情况。# ndb_mgm> all report memory 查看各数据节点使用情况# ndb_mgm>create nodegroup 3;创建数据节点分组# mysql> alter online table data_house reorganize partition; 调整分区数据
Copy after login

(2) 数据节点

# vi /etc/my.cnf (添加以下内容)
Copy after login
Copy after login
[mysqld]datadir=/var/mysql/datasocket=/var/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0#运行NDB存储引擎ndbcluster #指定管理节点ndb-connectstring=10.0.0.19[MYSQL_CLUSTER]ndb-connectstring=10.0.0.19[NDB_MGM]connect-string=10.0.0.19[mysqld_safe]log-error=/var/mysql/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
Copy after login

安装后第一次启动数据节点时要加上--initial参数,其它时候不要加,除非是在备份、恢复或配置变化后重启时

# /usr/local/mysql/bin/ndbd --initial 正常启动# /usr/local/mysql/bin/ndbd
Copy after login

(3) sql节点

# cd /usr/local/mysql/
Copy after login

设置mysql服务为开机自启动

# cp support-files/mysql.server /etc/rc.d/init.d/mysqld# chmod +x /etc/rc.d/init.d/mysqld# chkconfig --add mysqld
Copy after login
# vi /etc/my.cnf (添加以下内容)
Copy after login
Copy after login
[mysqld]server-id=4#每个服务器的id不一样datadir=/var/mysql/datasocket=/var/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0log-bin = /var/mysql/log/mysql-bin.logmax_connections=1000#以下为mysql 主主模式的配置文件# 忽略mysql数据库复制binlog-ignore-db=mysql# 每次增长2auto-increment-increment = 2# 设置自动增长的字段的偏移量,即初始值为2auto-increment-offset = 1[mysqld_safe]log-error=/var/mysql/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid[MYSQLD]ndbclusterndb-connectstring=10.0.0.19[MYSQL_CLUSTER]ndb-connectstring=10.0.0.19[NDB_MGM]connect-string=10.0.0.19
Copy after login
#service mysqld start
Copy after login

错误解决办法:    1. can't connect to local MySQL server through socket '/tmp/mysql.sock'

                               ln -s /var/mysql/mysql.soc /tmp

mysql集群的启动顺序为:管理节点->数据节点->SQL节点

mysql集群的关闭顺序为,管理节点->数据节点->SQL节点

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template