硬件配置
普通PC server *
模擬環境
red hat linux
MySQL版本
mysql
本方案不涉及從源代碼編譯安裝
主機 IP地址 用途
ndb
ndb
Mgmd:management server
sqld:mysql server
ndb:storaged node (share
安裝
從下載mysql
Storage and SQL Node Installation
在兩台主機上執行如下過程
shell>groupadd mysql
shell>useradd
shell>tar zxfv mysql
shell>cp
shell>cd /usr/local
shell>ln
shell>cd mysql;scripts/mysql_install_db –user=mysql
shell>chown
shell>cp support
shell>chmod +x /etc/rc
shell>chkconfig
shell>chkconfig –level
Management Node Installation
在主機ndb
shell>cd /var/tmp
shell>tar
Configuration
Configuring the Storage and SQL Nodes
在兩台主機上執行如下過程
shell>vi /etc/f
[MYSQLD] # Options for mysqld process:
ndbcluster # run NDB engine
ndb
[MYSQL_CLUSTER] # Options for ndbd process:
ndb
Configuring the Management Node
在主機ndb
shell>mkdir /var/lib/mysql
shell>cd /var/lib/mysql
shell>vi config
[NDBD DEFAULT] # Options affecting ndbd processes on all data nodes:
NoOfReplicas=
DataMemory=
IndexMemory=
# For DataMemory and IndexMemory
# default values
# only about
# this example Cluster setup
[TCP DEFAULT]
[NDB_MGMD] # Management process options:
hostname=
datadir=/var/lib/mysql
[NDBD] # Options for data node
# (one [NDBD] section per data node)
HostName=
DataDir=/usr/local/mysql/data # Directory for this data node
[NDBD] # Options for data node
hostname=
datadir=/usr/local/mysql/data # Directory for this data node
[MYSQLD] # SQL node options:
hostname=
# Directory for SQL node
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
[MYSQLD] # SQL node options:
hostname=
# Directory for SQL node
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
第一次啟動
在主機ndb
shell> ndb_mgmd
在兩台主機上執行如下過程
shell>ndbd –initial (note:
shell>/etc/init
測試
在主機ndb
shell> ndb_mgm
ndb_mgm> show
Connected to Management Server at: localhost:
Cluster Configuration
[ndbd(NDB)]
id=
id=
[ndb_mgmd(MGM)]
id=
[mysqld(SQL)]
id=
出現如上信息則表示mysql群集安裝成功
數據抽樣測試
在主機ndb
shell>/usr/local/mysql/bin/mysql
MySQL>DROP TABLE IF EXISTS City;
CREATE TABLE City (
ID int(
Name char(
CountryCode char(
District char(
Population int(
PRIMARY KEY (ID)
) ENGINE=NDBCLUSTER;
MySQL>INSERT INTO City VALUES (
INSERT INTO City VALUES (
INSERT INTO City VALUES (
在主機ndb
shell>/usr/local/mysql/bin/mysql
MySQSL>select * from City;
如果成功顯示數據信息
Safe Shutdown and Restart
在主機ndb
shell>ndb_mgm
在兩台主機上執行如下過程
shell>/etc/init
重新啟動集群(順序不能弄錯)
在主機ndb
shell> ndb_mgmd
在兩台主機上執行如下過程
shell>/usr/local/mysql/bin/ndbd
啟動完ndbd進程後啟動sqld進程
shell>/etc/init
附
config
[COMPUTER]: 定義群集主機
[NDBD]: 定義群集數據節點
[MYSQLD]: 定義Sql server節點
[MGM|NDB_MGMD]: Defines the management server node in the cluster
[TCP]: Defines TCP/IP connections between nodes in the cluster
[SHM]: Defines shared
From:http://tw.wingwit.com/Article/program/MySQL/201311/29444.html