- 論壇徽章:
- 0
|
目前還沒有在壇子里找到源代碼安裝MYSQL-CLUSTER 的帖子,自己摸索著搞了一套。
共享給大家討論!
MYSQL-5.1.19-BETA 安裝 mysql-cluster 步驟
1。下載源代碼包, 目前最新包為MYSQL-5.1.23-BETA.TAR.GZ 安裝方式同本文檔。
主機(jī) IP : 192.168.74.4 192.168.74.3
2。檢查系統(tǒng)是否已經(jīng)安裝一下RPM包。 目前OS 為L(zhǎng)INUX AS 4 UPDATE 4
> rpm -qa |grep libstdc++ ## 目前已經(jīng)查明的如果沒有這幾個(gè)RPM包,將無(wú)法把CLUSTER 編譯進(jìn)MYSQLD 中。
compat-libstdc++-33-3.2.3-47.3
libstdc++-devel-3.4.6-3
compat-libstdc++-296-2.96-132.7.2
libstdc++-3.4.6-3
如果沒有安裝以上RPM 請(qǐng)自行安裝。
3.解壓縮
tar -zxvf mysql-5.1.19.tar.gz
4.安裝
cd /data/mysql-5.1.19-beta
./configure \
--with-charset=utf8
--with-collation=utf8_bin
--with-extra-charsets=gbk,gb2312,big5,utf8,binary,ascii
--prefix=/data/mysql
--with-plugins=partition,ndbcluster
--with-ndb-docs
--with-ndb-test
make
make install
5.
groupadd mysql
useradd -g mysql mysql
passwd mysql
cd /data/mysql
chown -R root.mysql .
bin/mysql_install_db --user=mysql ## 在執(zhí)行本步驟時(shí)有可能會(huì)報(bào)錯(cuò)
5.1 錯(cuò)誤信息;
[email=root@localhost]root@localhost[/email] mysql]# bin/mysql_install_db --user=mysql
Installing MySQL system tables...
080226 11:05:30 [ERROR] /data/mysql/libexec/mysqld: unknown option '--~'
080226 11:05:30 [ERROR] Aborting
080226 11:05:30 [Note] /data/mysql/libexec/mysqld: Shutdown complete
Installation of system tables failed!
出現(xiàn)這個(gè)錯(cuò)誤一般情況下是主機(jī)上GCC的相關(guān)的一些開發(fā)包沒有安裝上,本人尚未確認(rèn)具體缺那些包。
5.2 錯(cuò)誤信息:
[root@test232 mysql]# bin/mysql_install_db --user=mysql
Installing MySQL system tables...
080226 11:20:29 [Warning] /data/mysql/libexec/mysqld: unknown option '--loose-skip-innodb'
OK
Filling help tables...
080226 11:20:29 [Warning] /data/mysql/libexec/mysqld: unknown option '--loose-skip-innodb'
OK
出現(xiàn)這個(gè)錯(cuò)誤,尚不明白原因,但不影響數(shù)據(jù)庫(kù)的啟動(dòng)和CLUSETER 的啟用。目前只遇到此兩種情況。
6。構(gòu)建CLUSTER 。
6。1 在兩臺(tái)主機(jī)上分別運(yùn)行1-5步驟,
6。2 在其中一臺(tái)主機(jī)上: (74.4)
cd /data/mysql/libexec
vi config.ini
添加一下內(nèi)容:
[NDBD DEFAULT]
NoOfReplicas= 2
DataDir= /data/mysql/libexec
[NDB_MGMD]
Hostname= 192.168.74.4
DataDir= /data/mysql/var
[NDBD]
HostName= 192.168.74.3
[NDBD]
HostName= 192.168.74.4
[MYSQLD]
HostName=192.168.74.3
[MYSQLD]
HostName=192.168.74.4
6。3 在兩臺(tái)主機(jī)上分別:
su -
vi /etc/my.cnf
增加或修改一下內(nèi)容:
[MYSQLD]
ndbcluster # run NDB engine
ndb-connectstring=192.168.74.4 # location of MGM node
# Options for ndbd process:
[MYSQL_CLUSTER]
ndb-connectstring=192.168.74.4 # location of MGM node
6。4 在74。4上
cd /data/mysql/libexec
./ndb_mgmd -f config.ini
cd /data/mysql-5.1.19-beta/storage/ndb/src/kernel
./ndbd --initial
在74。3 上
cd /data/mysql-5.1.19-beta/storage/ndb/src/kernel
./ndbd --initial
在74。4上
cd /data/mysql
bin/ndb_mgm
show [root@test232 libexec]# ../bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 192.168.74.4:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.74.3 (Version: 5.1.19, Nodegroup: 0, Master)
id=3 @192.168.74.4 (Version: 5.1.19, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.74.4 (Version: 5.1.19)
[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 192.168.74.3)
id=5 @192.168.74.4 (Version: 5.1.19)
6。5 在兩臺(tái)主機(jī)上
cd /data/mysql
bin/mysqld_safe --user=mysql
機(jī)群數(shù)據(jù)庫(kù)啟動(dòng)完成。
7。驗(yàn)證:
SQL> SHOW ENGINES ;
mysql> SHOW ENGINES ;
+------------+---------+-----------------------------------------------------------+--------------+----+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+-----------------------------------------------------------+--------------+----+------------+
| ndbcluster | YES | Clustered, fault-tolerant tables | YES | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+------------+---------+-----------------------------------------------------------+--------------+----+------------+
5 rows in set (0.00 sec)
在其中一臺(tái)主機(jī)上
create database dbtest ;
use dbtest ;
create table abc (id int ) engine=ndbcluster ;
insert into abc values(1) ;
commit;
在另一臺(tái)主機(jī)上
creat database dbtest;
flush tables ;
show tables;
mysql> show tables;
+------------------+
| Tables_in_dbtest |
+------------------+
| ab |
+------------------+
1 row in set (0.00 sec)
8 . oK 到此為止,一個(gè)MYSQL-CLUSTER 就初步完成了。其他的my.cnf參數(shù)請(qǐng)自行修改,添加。 |
|