標籤:fps vb6 sni ycm lcs ati rpm noi mac
Windows環境配置MySQL叢集
一、Cluster環境搭建
1、mysql Cluster(MySQL Cluster 7.5.4)檔案:http://dev.mysql.com/downloads/cluster/
2、準備三台伺服器(虛擬機器,本人使用的是Windows Server 2008 R2 enterprise),一台用於組態管理節點,另外兩台每台配置一個資料節點和一個SQL節點:
管理節點:192.168.108.128
資料節點A:192.168.108.129
資料節點B:192.168.108.130
SQL節點A:192.168.108.129
SQL節點B:192.168.108.130
3、將下載壓縮包解壓到每台電腦的C:/mysql目錄下(其他盤也可以)
在管理節點C:\Mysql\Bin目錄下建立cluster-logs和config兩個檔案夾cluster-logs用來儲存記錄檔,在config檔案夾中建立my.ini和config.ini兩個設定檔:
my.ini
[mysql_cluster]
# Options for management node process
config-file=C:/mysql/bin/config/config.ini
config.ini
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataDir=C:/mysql/bin/cluster-data # Directory for each data node‘s data files # Forward slashes used in directory path, # rather than backslashes. This is correct; # see Important note in text
DataMemory=80M # Memory allocated to data storage
IndexMemory=18M # Memory allocated to index storage # For DataMemory and IndexMemory, we have used the # default values. Since the "world" database takes up # only about 500KB, this should be more than enough for # this example Cluster setup.
[ndb_mgmd]
# Management process options:
HostName=192.168.108.128 # Hostname or IP address of management node
DataDir=C:/mysql/bin/cluster-logs # Directory for management node log files
[ndbd]
# Options for data node "A":
HostName=192.168.108.130 # Hostname or IP address
[ndbd]
# Options for data node "B":
HostName=192.168.108.129 # Hostname or IP address
[mysqld]
# SQL node A options:
HostName=192.168.108.130 # Hostname or IP address
[mysqld]
# SQL node B options:
HostName=192.168.108.129 # Hostname or IP address
4、在配置資料節點(192.168.108.129、192.168.108.130)的電腦上的C:\Mysql\Bin目錄下建立cluster-data檔案夾,用來存放資料
5、至此,環境安裝完成
二、Cluster叢集啟動
1、關閉防火牆
2、開啟管理工具
CMD命令:c:\mysql\bin\ndb_mgmd.exe --configdir=c:\mysql\bin\config --config-file=c:\mysql\bin\config\config.ini --ndb-nodeid=1 --reload –initial
3、開啟資料節點(註:必須以管理員運行dos,否則報錯)
CMD命令:c:\mysql\bin\ndbd.exe --ndb-connectstring=192.168.108.128
4、執行命令初始化mysql命令添加data目錄(巨坑)
CMD命令:C:\mysql\bin\mysqld --initialize-insecure --user=mysql
5、開啟sql節點
CMD命令:c:\mysql\bin\mysqld.exe --ndbcluster --ndb-connectstring=192.168.108.128 --console
6、在管理伺服器查看開啟狀態
CMD命令:C:\mysql\bin\ndb_mgm.exe
7、注意,所有命令最好用管理員權限開啟dos環境執行,啟動MySql Cluster叢集的時候裡面有兩大坑,第一大坑是一定得關閉防火牆,第二大坑就是mysql需要初始化。
至此,環境搭建完成,可以進入下一步測試、使用。
三、測試MySql 叢集
1、在sql節點A的電腦上(192.168.108.129)的cmd中運行C:\mysql\bin\mysql.exe -u root -p命令登入mysql,接下來需要輸入密碼時,密碼預設為空白(直接斷行符號)。
建立資料庫並插入資料:
—–建立名為”MySQL_Cluster_Test”的資料庫:
create database MySQL_Cluster_Test;
—–建立表”T_User”:
use MySQL_Cluster_Test;
create table T_User(Name varchar(32),Age int) engine=ndbcluster;
注意建表語句後面一定要加上 engine=ndbcluster
—–插入資料:
insert into T_User values(‘DannyHoo‘,26);
—–查詢資料:
select * from T_User;
2、在sql節點B也可以查詢到資料。
同樣在sql節點B的電腦上(192.168.108.130)的cmd中運行C:\mysql\bin\mysql.exe -u root -p命令登入mysql。
執行 show databases; 命令可以查看到在sql節點A建立的資料庫;
執行use MySQL_Cluster_Test;
select * from T_User;
可以查詢到在sql節點A插入的資料。
到這裡,整個叢集的搭建和測試就完成了。假如一個資料節點宕機,並不會影響整個叢集的運行,任何一個資料節點死掉甚至物理損壞都不用擔心,因為每個資料節點儲存的資料都是完整的一份資料(在你操作資料的時候,它早就自動為你把最新的資料備份到每一個資料節點上啦)。你可以測試一下,這時手動停止某個資料節點和sql節點,另外一個資料節點和sql節點還會正常運行。當你把停止的資料節點和sql節點重新啟動時,會發現又重新串連到叢集裡了,而且每個資料節點的資料都是最新的。
Windows環境配置MySQL叢集