資安論壇

行政院 國家資通安全會報 - 技術服務中心 - 資安論壇 http://forum.icst.org.tw/
現在的時間是 2012年 10月 22日, 04:14

所有顯示的時間為 UTC + 8 小時




發表新文章 回覆主題  [ 14 篇文章 ] 
發表人 內容
文章發表於 : 2010年 2月 25日, 17:02 
離線

註冊時間: 2002年 9月 25日, 10:57
文章: 8868
來自: R.O.C
[教學][研究] 4主機 MySQL Cluster 架設

2010/02/25
Lu

參考文件 (MySQL 5.1 + MySQL Cluster NDB 6.X/7.X)
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster.html

[教學][研究] 4主機 MySQL Cluster 架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17903

[教學][研究] 雙主機 MySQL Cluster 架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17904

一、概念說明

MySQL Cluster(叢集,大陸稱為 "集群" 或 "群集") 架構大致如下

圖檔

NDB 是 Network DataBase (網路資料庫)

MySQL Cluster中主機分三類

1. 管理主機 : 服務程式(Deamon) 稱為 ndb_mgmd (NDB Management Daemon的意思)
管理工具稱為 ndb_mgm (NDB Management 的意思),預設使用 Port 1186。
2. Data Node: 實際存放資料的主機 (Storage),服務程式稱為 ndbd (NDB Daemon的意思)。
3. SQL Node : 提供存取資料庫內容,服務程式稱為 mysqld (MySQL Deamon的意思)。

---------------------------------------------------------------------------

一、環境

Windows XP x86 + VMware Workstation 7.01 架設兩台 VM,都安裝 CentOS 5.4 x86

centos1 eth0:192.168.128.101 (MGM Node)
centos2 eth0:192.168.128.102 (SQL Node)
centos2 eth0:192.168.128.103 (Data Node)
centos2 eth0:192.168.128.104 (Data Node)

Windows XP x86 只能控制到 3.x GB RAM
VMware Workstation 7.01 預設 RHEL5 (VM) 使用 1GB RAM,4台會吃掉 4GB,根本不夠,所以小弟降低到 512 MB 使用。

---------------------------------------------------------------------------

二、安裝

為了省麻煩,防火牆先關閉。
請把 SELinux 也關閉 (變更 SELinux 需要 reboot 才能生效)


CentOS 用 yum 安裝的 MySQL 是不能架設 Cluster 的,必須移除,
然後去 MySQL 官方網站註冊和下載 MySQL Cluster 使用的套件
(rpm 安裝和 tar.gz 安裝的很多路徑不同,如果使用非 rpm 請自己另外研究)

MySQL-Cluster-gpl-client-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-debuginfo-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-devel-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-embedded-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-extra-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-management-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-server-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-shared-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-storage-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-test-7.0.9-0.rhel5.i386.rpm
MySQL-Cluster-gpl-tools-7.0.9-0.rhel5.i386.rpm

如果不想安裝全部,各Node基本需要的套件如下

SQL Node
rpm -Uhv MySQL-Cluster-gpl-server-7.0.9-0.rhel5.i386.rpm
rpm -Uhv MySQL-Cluster-gpl-client-7.0.9-0.rhel5.i386.rpm

Data Node
rpm -Uhv MySQL-Cluster-gpl-storage-7.0.9-0.rhel5.i386.rpm

MGM Node
rpm -Uhv MySQL-Cluster-gpl-management-7.0.9-0.rhel5.i386.rpm
rpm -Uhv MySQL-Cluster-gpl-tools-7.0.9-0.rhel5.i386

小弟是在 Windows XP 上下載後,做成 .iso 檔案,掛載到 VMware 光碟機,
然後用 mount 掛載到 Linux 上的 /media 目錄使用

命令如下 (4台都要做)

代碼:
service  iptables  stop
yum  -y  remove  mysql*
mount  /dev/cdrom  /media
cd  /media
rpm  -ivh  *.rpm


---------------------------------------------------------------------------

三、設定

(1) 設定 MGM 設定檔 config.ini

這裡有 config.ini 的基本範例
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-config-example.html

MGM 機器請執行下面命令

代碼:
mkdir -p /var/lib/mysql-cluster
vi /var/lib/mysql-cluster/config.ini


內容如下

代碼:
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[tcp default]
portnumber=2202
[ndb_mgmd]
hostname=192.168.128.101
datadir=/var/lib/mysql-cluster
[ndbd]
hostname=192.168.128.104
datadir=/var/lib/mysql-cluster
[ndbd]
hostname=192.168.128.103
datadir=/var/lib/mysql-cluster
[mysqld]
hostname=192.168.128.102


(2) 設定 my.cnf

這裡有 my.cnf 的基本範例
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-config-example.html

代碼:
vi /etc/my.cnf


內容如下
代碼:
[mysqld]
ndbcluster # run NDB storage engine
ndb-connectstring=192.168.128.101

[mysql_cluster]
ndb-connectstring=192.168.128.101


---------------------------------------------------------------------------

四、啟動

啟動 MySQL Cluster 順序: 首先啟動管理節點服務器(ndb_mgmd),然後啟動存儲節點服務器(ndbd),最後才啟動SQL節點服務器(service mysql start)

停止 MySQL Cluster : 執行 ndb_mgm -e showdown,它會把所有 MGM Node 和所有 Data Node 的 ndb_mgmd 和 ndbd 都停止掉。(mysqld 還留著)

在 SQL Node 上停止 mysqld 服務命令為 (其實 ndb_mgm -e showdown 就足夠讓 Cluster 幾乎停工)
[root@centos1 ~]# mysqladmin –u root shutdown

(1) MGM 主機上

代碼:
[root@mgm ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
2010-02-22 10:41:49 [MgmtSrvr] INFO     -- NDB Cluster Management Server. mysql-5.1.39 ndb-7.0.9b
2010-02-22 10:41:49 [MgmtSrvr] INFO     -- Reading cluster configuration from '/var/lib/mysql-cluster/config.ini'


(2) 啟動 Data Node (兩台都要做)

代碼:
[root@data1 ~]# mkdir -p  /usr/local/mysql/data/
[root@data1 ~]# ndbd
2010-02-08 17:42:34 [ndbd] INFO     -- Configuration fetched from '192.168.128.101:1186', generation: 1


(3) 啟動 SQL Node

代碼:
[root@sql ~]# service mysql start
Starting MySQL....                                         [  OK  ]


(4) 檢查目前狀況

到 MGM 主機上檢查目前狀況

代碼:
[root@mgm ~]# ndb_mgm -e show
Connected to Management Server at: 192.168.128.101:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.128.104  (mysql-5.1.39 ndb-7.0.9, Nodegroup: 0, Master)
id=3    @192.168.128.103  (mysql-5.1.39 ndb-7.0.9, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.128.101  (mysql-5.1.39 ndb-7.0.9)

[mysqld(API)]   1 node(s)
id=4    @192.168.128.102  (mysql-5.1.39 ndb-7.0.9)


(完)

_________________
天道循環,生死不昧,真空妙有,還於本然
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡
貼圖空間
viewtopic.php?t=8816


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 14日, 13:49 
離線

註冊時間: 2010年 6月 14日, 13:44
文章: 4
請問一下...您有試著匯過資料嗎 ?
架構上是沒什麼問題,可是表格的資料容量卻有一些問題
我在從innodb 匯進一個將近1GB的資料庫進ndb
記憶體給2G,而且我也開了undo log及tablespace
建schema的時候,也都把表格指向表格空間,
可是就是一直會在匯進某個表格87MB的時候,
出現table full的錯誤訊息....
看了MySQL 的forum
也是有人提出這個問題
但是無解

您有碰到過嗎 ? 解決了嗎 ?


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 14日, 20:22 
離線

註冊時間: 2002年 9月 25日, 10:57
文章: 8868
來自: R.O.C
> 請問一下...您有試著匯過資料嗎 ?
沒有

請問是隨便一個 table 塞到 87 MB 就會出問題嗎 ?
如果不是,就要檢查出問題的那筆 record 了

_________________
天道循環,生死不昧,真空妙有,還於本然
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡
貼圖空間
viewtopic.php?t=8816


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 17日, 09:55 
離線

註冊時間: 2010年 6月 14日, 13:44
文章: 4
這個問題我解決了,我的測試版本是7.1.3...可以把資料放置在tablespace 裡頭
應該是NDB 佔空間的邏輯比較奇怪
我有個表格在innodb 裡頭是480Mb,匯進ndb tablespace 只剩下113MB,
但是它使用了好幾GB的硬碟空間,很怪!!不過幸好,現在硬碟不值錢...........
可以跟它這樣耗.....
總之....如果要用這個solution.....
至少把表格空間開出你現有資料的5倍...........
在這裡分享給大家知道..........
重點是MySQL forum裡頭....他們的support engineer 都還不知道怎麼解決人家提出來的問題
no point.....
希望對大家有幫助


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 17日, 14:22 
離線

註冊時間: 2006年 11月 30日, 15:14
文章: 33
Hi, stevench
可以分享您架 MySQL Cluster 7.1.3 的過程嗎 > <
我遇到的問題是在 SQL Node, (not connected, accepting connect from 10.0.0.88)

mysql> SHOW STATUS LIKE 'ndb%';
+--------------------------------+----------------+
| Variable_name | Value |
+--------------------------------+----------------+
| Ndb_cluster_node_id | 3 |
| Ndb_config_from_host | 10.0.0.88 |
| Ndb_config_from_port | 1186 |
| Ndb_number_of_data_nodes | 1 |

ndb is work ,but sql node 在 mgm 看到 (not connected, accepting connect from 10.0.0.88)
現在運作環境是用 5.0 要升級 MySQL 5.1, Cluster 7.1 卡在這怪問題

OS: CentOS 5.5

3Q.. :cry:


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 17日, 17:06 
離線

註冊時間: 2006年 11月 30日, 15:14
文章: 33
補一下 ErrMsg

100617 16:43:01 [Note] NDB: NodeID is 3, management server '10.0.0.88:1186'
100617 16:43:02 [Note] NDB[0]: NodeID: 3, no storage nodes connected (timed out)
100617 16:43:02 [Note] Starting Cluster Binlog Thread
100617 16:43:02 [Note] Event Scheduler: Loaded 0 events
100617 16:43:03 [Note] NDB Binlog: Ndb tables initially read only.
100617 16:43:17 [Warning] NDB : Tables not available after 15 seconds. Consider increasing --ndb-wait-setup value

_________________
http://blog.2be.com.tw/


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 18日, 14:34 
離線

註冊時間: 2010年 6月 14日, 13:44
文章: 4
如果你的資料量很大的話,你得等data node 把硬碟裡頭的資料帶起來到memory,需要等待一陣子....
以下是我的node 起來時候狀況
通常API NODE 無法連結的時候,都跟data node有關,大部份都是data node 起來的時候就有問題了

2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 108 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 109 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 111 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 112 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 114 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 116 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 117 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 119 rebuild done
2010-06-18 14:30:06 [MgmtSrvr] INFO -- Node 2: LQH: index 120 rebuild done
2010-06-18 14:30:23 [MgmtSrvr] INFO -- Node 2: LQH: index 122 rebuild done
2010-06-18 14:30:23 [MgmtSrvr] INFO -- Node 2: Start phase 4 completed (system restart)
2010-06-18 14:30:23 [MgmtSrvr] INFO -- Node 2: LQH: Rebuild ordered indexes complete
2010-06-18 14:30:24 [MgmtSrvr] INFO -- Node 2: Local checkpoint 312 started. Keep GCI = 168466 oldest restorable GCI = 133053
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Local checkpoint 312 completed
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 5 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 6 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: President restarts arbitration thread [state=1]
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 7 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 8 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 9 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 100 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Start phase 101 completed (system restart)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Started (mysql-5.1.44 ndb-7.1.3)
2010-06-18 14:30:45 [MgmtSrvr] INFO -- Node 2: Node 1: API mysql-5.1.44 ndb-7.1.3
2010-06-18 14:30:46 [MgmtSrvr] INFO -- Node 2: Communication to Node 3 opened
2010-06-18 14:30:46 [MgmtSrvr] INFO -- Node 2: Node 3 Connected
2010-06-18 14:30:46 [MgmtSrvr] INFO -- Node 2: Node 3: API mysql-5.1.44 ndb-7.1.3
2010-06-18 14:30:46 [MgmtSrvr] INFO -- Node 2: Started arbitrator node 1


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 18日, 14:45 
離線

註冊時間: 2010年 6月 14日, 13:44
文章: 4
其實7.1.3的架設過程跟這份文件差不了多少
我先是用MySQL網站上compile 出來的binary做測試,不過老實說,這份binary有一些限制,比如說可以匯入的表格數,或者欄位數等
那時候我也是找了好久,才猜出問題可能在那裡,改了對應的參數之後,發覺mgmd 不吃該資料ㄝ,schema還是匯不進去,
所以後來我就乾脆拿source code來compile,結果再匯schema的時候就過了...那時候多嘔ㄚ...真想掐死MySQL

MySQL compile出來的binary 吃的資源比較小,所以我在VmWare 上測的時候,跑起pure cluster 架構時,沒有問題
可是如果用source code compile 出來的binary,在我電腦上的vmware 就跑不動了,ndbd一起來,就被force shutdown
因為來不及回應
如果用rpm安裝的也跟source code compile 的binary一樣,資源吃比較兇
所以如果要測ndb cluster,建議機器等級要高一點....不然測不動
以上是我的一些經驗


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 18日, 23:25 
離線

註冊時間: 2006年 11月 30日, 15:14
文章: 33
恩恩..感謝,我在試試..
現在用 cluster 5.0 在營運交易量大時常出現 error: 1250Lock wait timeout exceeded; try restarting transaction..
頭大..所以才在測 cluster 7.13。

再次感謝大大的回覆 ..3q3q

_________________
http://blog.2be.com.tw/


回頂端
 個人資料  
 
文章發表於 : 2010年 6月 26日, 17:01 
離線

註冊時間: 2006年 11月 30日, 15:14
文章: 33
找到問題點了, SELinux ..在想辦法套 policy.
感謝 :lol:

_________________
http://blog.2be.com.tw/


回頂端
 個人資料  
 
文章發表於 : 2010年 8月 10日, 12:13 
離線

註冊時間: 2010年 8月 10日, 12:08
文章: 2
[mysqld(API)] 1 node(s)
id=2 (not connected, accepting connect from 10.0.0.102)

請教一下,mysqld的狀態是not connected
mysqld有在10.0.0.102有啟動了,防火牆都關了
請問還有甚麼地方需要注意的


回頂端
 個人資料  
 
文章發表於 : 2010年 8月 10日, 12:48 
離線

註冊時間: 2002年 9月 25日, 10:57
文章: 8868
來自: R.O.C
> 啟動 MySQL Cluster 順序: 首先啟動管理節點服務器(ndb_mgmd),然後啟動存儲節點服務器(ndbd),最後才啟動SQL節點服務器(service mysql start)

> 停止 MySQL Cluster : 執行 ndb_mgm -e showdown,它會把所有 MGM Node 和所有 Data Node 的 ndb_mgmd 和 ndbd 都停止掉。(mysqld 還留著)

啟動和停止順序對嗎 ?

把 4 台的 firewall 都關閉後,全部停止,再全部重新啟動一次看看

_________________
天道循環,生死不昧,真空妙有,還於本然
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡
貼圖空間
viewtopic.php?t=8816


回頂端
 個人資料  
 
文章發表於 : 2010年 8月 10日, 13:54 
離線

註冊時間: 2010年 8月 10日, 12:08
文章: 2
停掉再開還是一樣,最後關掉selinux
終於看到mysqld的node了
thanks


回頂端
 個人資料  
 
文章發表於 : 2012年 10月 20日, 23:37 
離線

註冊時間: 2012年 10月 20日, 18:03
文章: 1
來自: usa
Therefore, the salary-based folks find it banking means credit, is they a on your upcoming payday. Apply for payday loans only still possible documents loans The to these for faster monetary revitalization. Many different agencies can help you without totally situation will you without skip a payment, your score will drop. The interest that they repay (after administration and senior citizen usually interest and necessarily mean that they will all be the same. For example, if a lawyer with an income of $8,000 wants a bad credit that is a to rate they can Replace My Old Mortgage? You can apply online, have the money transferred score, phases members student the economy much to the benefit of all. Then check the monthly payment that they quote you loans repaying have a requisite emergency and have no choice in their hands. bad credit payday loans One of the options has been in the investment of the loans of today has a and an within 1 to 30 days. The loans are generally considered a better option indulged loans effective indication of whether you are responsible or not. Flexibility regarding interest rates makes these fund the animated are closer than ever to get your home.

_________________
http://datpaydayloan.com/


回頂端
 個人資料  
 
顯示文章 :  排序  
發表新文章 回覆主題  [ 14 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章

搜尋:
前往 :  
POWERED_BY
正體中文語系由 竹貓星球 維護製作