现在的位置: 首页 > 综合 > 正文

Mysql Cluster单机配置

2013年05月13日 ⁄ 综合 ⁄ 共 2776字 ⁄ 字号 评论关闭

环境: Fedora 17

一、下载安装包:mysql-cluster-gpl-7.2.12-linux2.6-i686.tar.gz


二、安装(参照解压后的INSTALL-BINARY)

1 SQL节点

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd Download
shell> tar -C /usr/local -xzvf mysql-cluster-gpl-7.2.14-linux2.6.tar.gz
shell> ln -s /usr/local/mysql-cluster-gpl-7.2.14-linux2.6-i686 /usr/local/mysql
shell> cd /usr/local/mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> cp support-files/mysql.server /etc/rc.d/init.d/
shell> chmod +x /etc/rc.d/init.d/mysql.server
shell> chkconfig --add mysql.server


2 数据节点

shell> cp bin/ndbd /usr/local/bin/ndbd
shell> cp bin/ndbmtd /usr/local/bin/ndbmtd
shell> chmod +x /usr/local/bin/ndb*

3 管理节点

shell> cp bin/ndb_mgm* /usr/local/bin
shell> chmod +x /usr/local/bin/ndb_mgm*

三、配置

1 配置管理节点

shell> mkdir /var/lib/mysql-cluster
shell> vim config.ini
shell> cat config.ini
[ndbd default]
NoOfReplicas=1
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
hostname=localhost
datadir=/var/lib/mysql-cluster
[ndbd]
hostname=localhost
datadir=/usr/local/mysql/data
[mysqld]
hostname=localhost

2 配置SQL节点

添加如下entries到/etc/my.cnf

[mysqld]
ndbcluster
[mysql_cluster]
ndb-connectstring=localhost

四、启动(必须按此顺序,先启动管理节点,再启动数据节点;都启动成功后,最后启动SQL节点)

1 启动管理节点

shell> ndb_mgmd

2 启动数据节点

shell> ndbd

3 启动SQL节点

/etc/init.d/mysql.server start

五、测试

[root@localhost mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.30-ndb-7.2.12-cluster-gpl-log 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 engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ndbcluster         | YES     | Clustered, fault-tolerant tables                               | YES          | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| ndbinfo            | YES     | MySQL Cluster system information storage engine                | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
11 rows in set (0.04 sec)

mysql> 

抱歉!评论已关闭.