欢迎光临
我们一直在努力

centos 6.4×64下Mysql-cluster 7.3.4的安装配置

Mysql-cluster 7.3.4的安装配置
OS:Ubuntu
Data1 192.168.10.141 数据节点,SQL节点
Data2 192.168.10.143 数据节点,SQL节点
Ndb 192.168.10.141 管理节点
479-4
1、下载解压到/usr/local/mysql

tar -zxvf mysql-cluster-gpl-7.3.4-linux-glibc2.5-x86_64.tar.gz
mv mysql-cluster-gpl-7.3.4-linux-glibc2.5-x86_64 /usr/local/mysql

2、创建mysql用户
useradd mysql
chown -R mysql:mysql /usr/local/mysql/

3、安装支持库

yum -y  install libaio1 
yum -y install perl #在安装的过程中会出现 mysql cluster ./mysql_install_db: /usr/bin/perl: bad interpreter
yum -y install gcc

4、修改/etc/profile以方便使用

PATH=$PATH:/usr/local/mysql/bin
export PATH

5、安装mysql

cd /usr/local/mysql/ scripts
./mysql_install_db –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data/ --user=mysql

6、配置管理节点ndb
拷贝/usr/local/mysql/bin/ndb_mgm,ndb_mgmd两个文件到/usr/local/bin

cp /usr/local/mysql/bin/ndb_mgm* /usr/local/bin
mkdir /var/lib/mysql-cluster
vim /var/lib/mysql-cluster/config.ini
[NDBD DEFAULT]
NoOfReplicas:2  #定义在Cluster环境中相同数据的份数 最大为4

# Data Memory, Index Memory, and String Memory #
DataMemory: 500M   #分配的数据内存大小
IndexMemory: 250M   #设定用于存放索引(非主键)数据的内存段大小

#一个NDB节点能存放的数据量是会受到DataMemory和IndexMemory两个参数设置的约束,#两者任何一个达到限制数量后,都无法再增加能存储的数据量。如果继续存入数据系统会#报错“table is full”。

MaxNoOfAttributes: 20480   #类似于总体设置,大一些好,不然导入大数据量时容易报错,请参看相关资料
MaxNoOfTables: 1024
MaxNoOfOrderedIndexes: 2048
MaxNoOfUniqueHashIndexes: 512
MaxNoOfTriggers: 10240

[MGM DEFAULT]
PortNumber: 1186  #管理节点端口

[NDB_MGMD]
Nodeid=1
hostname=192.168.10.141
datadir=/var/lib/mysql-cluster/

[NDBD]
Nodeid=2
hostname=192.168.10.141
datadir=/usr/local/mysql/data

[NDBD]
Nodeid=3
hostname=192.168.10.143
datadir=/usr/local/mysql/data

[MYSQLD]
hostname=192.168.10.143

[MYSQLD]

[MYSQLD]

7、配置数据节点和SQL节点
mysql服务启动时会默认加载/etc/my.cnf作为其配置文件,因此

vim /etc/my.cnf
[mysqld]


max_allowed_packet=16M
character_set_server=utf8
ndbcluster
ndb-connectstring=192.168.10.141
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
port=3306
lower_case_table_names=1


# 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

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# 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 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[MYSQL_CLUSTER]
ndb-connectstring=192.168.10.141 

8、启动服务
节点的启动顺序为管理节点- > 数据节点- > SQL节点

启动管理节点:
ndb_mgmd是mysqlcluster的管理服务器,后面的-f表示后面的参数是启动的参数配置文件。如果在启动后过了几天又添加了一个数据节点,这时修改了配置文件启动时就必须加上–initial参数,不然添加的节点不会作用在mysql cluster中

ndb_mgmd -f /var/lib/mysql-cluster/config.ini

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

/usr/local/mysql/bin/ndbd –initial
2012-03-28 02:01:38 [ndbd] INFO -- Angel connected to '10.0.0.102:1186'
2012-03-28 02:01:38 [ndbd] INFO -- Angel allocated nodeid: 2

启动SQL节点

/usr/local/mysql/bin/mysqld_safe --user=mysql &

在启动的过程中会出现
479-1
479-2

请执行

usr/local/mysql/scripts/mysql_install_db --user=mysql 

& 重新注册下

9、客户端查看

[root@mysql2 ~]# /usr/local/mysql/bin/ndb_mgm 
-- NDB Cluster -- Management Client --
ndb_mgm  >  show
Connected to Management Server at: 192.168.10.141:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.10.141  (mysql-5.6.15 ndb-7.3.4, Nodegroup: 0, *)
id=3    @192.168.10.143  (mysql-5.6.15 ndb-7.3.4, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.10.141  (mysql-5.6.15 ndb-7.3.4)

[mysqld(API)]   3 node(s)
id=4    @192.168.10.143  (mysql-5.6.15 ndb-7.3.4)
id=5    @192.168.10.141  (mysql-5.6.15 ndb-7.3.4)
id=6 (not connected, accepting connect from any host)

479-3

10、修改root密码:

#/usr/local/mysql/bin/mysqladmin -u root password 'redhat'

11、测试
A:192.168.10.143

[root@mysql1 mysql]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.15-ndb-7.3.4-cluster-gpl MySQL Cluster Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql  >  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ndb_3_fs           |
| ndbinfo            |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.01 sec)

mysql  >  show test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test' at line 1
mysql  >  use test;
Database changed
mysql  >  show tables;
Empty set (0.01 sec)

mysql  >  create table tt (id int(10)) ENGINE=NDB;
Query OK, 0 rows affected (0.68 sec)

mysql  >  show tables;
+----------------+
| Tables_in_test |
+----------------+
| tt             |
+----------------+
1 row in set (0.00 sec)

mysql  >  select * from tt;
+------+
| id   |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql  > 

B:192.168.10.141

[root@mysql2 mysql-cluster]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.15-ndb-7.3.4-cluster-gpl MySQL Cluster Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql  >  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| ndb_2_fs           |
| ndbinfo            |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)

mysql  >  use test;
Database changed
mysql  >  show tables;
Empty set (0.00 sec)

mysql  >  show tables;
+----------------+
| Tables_in_test |
+----------------+
| tt             |
+----------------+
1 row in set (0.00 sec)
mysql  >  insert into tt (id) values(1);
Query OK, 1 row affected (0.00 sec)

未经允许不得转载:SRE空间 » centos 6.4×64下Mysql-cluster 7.3.4的安装配置

分享到:更多 ()

评论 抢沙发

评论前必须登录!

 

oracle