生活随笔
收集整理的這篇文章主要介紹了
MYSQL的集群的安装与配置(mysql-5.1.21)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
具體安裝與配置: 1) 準備工作: 6臺機器,IP地址分別為 192.168.0.(231-236) MGM節點:192.168.0.231(232) SQL 節點:192.168.0.233-234 NDBD 節點:192.168.0.235-236 系統都是REDHAT AS 5.0 裝了基本的部件,具有聯網功能,而且關閉了防火墻。 軟件,版本是: mysql-5.1.21-beta-linux-i686-glibc23.tar.gz 2)管理節點的安裝:(232和231的機器) ??? shell> cd /var/tmp ??? shell> tar -zxvf?? mysql-5.1.21-beta-linux-i686-glibc23.tar.gz ??? shell> cd /var/tmp/mysql-5.1.21-beta-linux-i686-glibc23 ??? shell> mkdir /usr/local/mysql ??? shell> cp bin/ndb_mgm* /usr/local/mysql ??? shell> cd /usr/local/mysql ??? shell> chmod a+x ndb_mgm* ??? shell> mkdir data(用來存放管理節點的數據 )3)SQL節點和NDBD 節點的安裝:(233-236 四臺機器)shell> groupadd mysql shell> useradd -g mysql mysql shell> cd /var/tmp shell> tar -C /usr/local -xzvf mysql-5.1.21-beta-linux-i686-glibc23.tar.gz shell> mv /usr/local/mysql-5.1.21-beta-linux-i686-glibc23 /usr/local/mysql shell> cd mysql shell> scripts/mysql_install_db --user=mysql shell> chown -R mysql:mysql /usr/local/mysql SQL節點還要增加下面的步驟才可以:shell> cp support-files/mysql.server /etc/rc.d/init.d/mysqld shell> chmod a+x /etc/rc.d/init.d/mysqld shell> chkconfig --add mysqld shell> chkconfig mysqld on (注冊MYSQL為系統的服務 ) 4)配置NDBD節點: [root@localhost mysql]# cat /etc/my.cnf [mysqld] ndbcluster#ndb-connectstring=192.168.0.231 #ndb-connectstring=192.168.0.232 這樣寫是可以連接成功。不過我今天來的時候發現全部DOWN掉了。ndb-connectstring=192.168.0.231,192.168.0.232 [mysql_cluster]#ndb-connectstring=192.168.0.231 #ndb-connectstring=192.168.0.232 ndb-connectstring=192.168.0.231,192.168.0.232 [root@localhost mysql]# 5)配置SQL 節點: [root@localhost mysql]# cat /etc/my.cnf [mysqld] basedir=/usr/local/mysql/ datadir=/usr/local/mysql/data/ port=3306 user=nobody socket=/tmp/mysql.sock ndbcluster#ndb-connectstring=192.168.0.231 #ndb-connectstring=192.168.0.232 ndb-connectstring=192.168.0.231,192.168.0.232 [ndbd] connect-string=192.168.0.235 [ndbd] connect-string=192.168.0.236 [ndbd_mgm] connect-string=192.168.0.231 [ndbd_mgm] connect-string=192.168.0.232 [ndbd_mgmd] config-file=/etc/config.ini [mysql_cluster]#ndb-connectstring=192.168.0.231 #ndb-connectstring=192.168.0.232 ndb-connectstring=192.168.0.231,192.168.0.232 [root@localhost mysql]# 6) 配置管理節點: ?? [root@localhost ~]# cat /etc/config.ini [NDBD DEFAULT] NoOfReplicas=2 DataMemory=600M IndexMemory=100M # TCP/IP options: [TCP DEFAULT] portnumber=2202 # Management process options: [NDB_MGMD] id=1 hostname=192.168.0.231 datadir=/usr/local/mysql/data [NDB_MGMD] id=2 hostname=192.168.0.232 datadir=/usr/local/mysql/data # Options for data node A [NDBD] id=5 hostname=192.168.0.235 datadir=/usr/local/mysql/data # Options for data node B [NDBD] id=6 hostname=192.168.0.236 datadir=/usr/local/mysql/data # SQL node options: [MYSQLD] id=3 hostname=192.168.0.233 [MYSQLD] id=4 hostname=192.168.0.234 [MYSQLD] [MYSQLD] [root@localhost ~]# 7)啟動管理節點: [root@localhost mysql]# /usr/local/mysql/ndb_mgmd -f /etc/config.ini [root@localhost mysql]# ps aux | grep ndb | grep -v grep root????? 6230? 0.0? 0.1? 17428? 1780 ???????? Ssl? 22:16?? 0:00 /usr/local/mysql/ndb_mgmd -f /etc/config.ini啟動成功了。 默認MGMD是后臺啟動的。 8)啟動NDBD節點 [root@localhost mysql]# /usr/local/mysql/bin/ndbd --initial(只是第一次啟動還有添加節點而且恢復的時候要加) [root@localhost mysql]# ps aux | grep ndb | grep -v grep root????? 3191? 0.0? 0.2? 17516? 1992 ???????? Ss?? 22:24?? 0:00 /usr/local/mysql/bin/ndbd --initial root????? 3192? 4.2 15.3 911740 149120 ??????? Sl?? 22:24?? 0:00 /usr/local/mysql/bin/ndbd --initial [root@localhost mysql]# 9)啟動SQL 節點: [root@localhost mysql]# service mysqld start Starting MySQL. SUCCESS! 10)查看是否連接成功 [root@localhost ~]# /usr/local/mysql/ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=5 @192.168.0.235 (Version: 5.1.21, Nodegroup: 0, Master) id=6 @192.168.0.236 (Version: 5.1.21, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s) id=1 @192.168.0.231 (Version: 5.1.21) id=2 @192.168.0.232 (Version: 5.1.21) [mysqld(API)] 3 node(s) id=3 @192.168.0.233 (Version: 5.1.21) id=4 @192.168.0.234 (Version: 5.1.21) id=7 (not connected, accepting connect from any host) id=8 (not connected, accepting connect from any host) ndb_mgm> 我這個是配置兩臺管理節點和兩臺SQL節點以及兩臺NDBD節點的。以此類推。 以下是我在使用中遇到的錯誤信息: ?1、 [mysqld(API)]? ?2 node(s) id=4 (not connected, accepting connect from any host) id=5 (not connected, accepting connect from any host)2、 [root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p Enter password: Welcome to the MySQL monitor.??Commands end with ; or /g. Your MySQL connection id is 1 to server version: 5.0.24-max Type 'help;' or '/h' for help. Type '/c' to clear the buffer. mysql> use test Database changed mysql> show tables; Empty set, 1 warning (0.00 sec)mysql> create table t11 (id int) engine=ndb; ERROR 1050 (42S01): Table 't11' already exists解決辦法: 運行setup或者ntsysv命令進入系統啟動設置。 去掉iptables. 關掉防火墻。不過保持sellinux是打開的。 早上還碰到一個錯誤: [root@localhost data]# vi ndb_pid6423_error.log Current byte-offset of file-pointer is: 568 Time: Friday 30 November 2007 - 23:15:28Status: Permanent error, external action needed Message: Invalid configuration received from Management Server (Configuration error) Error: 2350 Error data: Could not connect to ndb_mgmd Error object: Program: /usr/local/mysql/bin/ndbd Pid: 6423 Trace: <no tracefile> Version: Version 5.1.21 (beta) ***EOM***~ 由于我沒有把ndb-connectstring=db1,db2,..dbn 這樣的規律寫導致,已經解決。 PS:集群的數據節點是非常重要的,如果不能保證一個數據節點正常運行的話,集群也就失去了意義。管理節點在啟動了集群后也就沒有了意義。所以我在想多個管理節點是否有必要。
?原文地址 http://blog.chinaunix.net/u/29134/showart_425685.html 摘錄于:http://blog.chinaunix.net/u1/54041/showart_485848.html
總結
以上是生活随笔 為你收集整理的MYSQL的集群的安装与配置(mysql-5.1.21) 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。