Mysql cluster 安裝

參考:

http://dev.mysql.com/doc/refman/5.5/en/mysql-cluster-install-configuration.html

http://imysql.cn/node/96


一、前期準備

cp  mysql-cluster-gpl-7.2.12-linux2.6-x86_64.tar.gz  /usr/local/


tar  xvf mysql-cluster-gpl-7.2.12-linux2.6-x86_64.tar.gz


mv mysql-cluster-gpl-7.2.12-linux2.6-x86_64   mysql


更改環境變量 進入家目錄 # vi  ~/.bash_profile  將/usr/local/mysql/bin 添加進去

source ~/.bash_profile


建立mysql的用戶賬戶: #groupadd  mysql     #useradd -g mysql   mysql (-g參數可以不要)


二、配置


(一)、配置data節點和SQL節點

Configuring the data nodes and SQL nodes. The my.cnf file needed for the data nodes is fairly simple. The configuration file should be located in the /etc directory and can be edited using any text editor. (Create the file if it does not exist.) For example:

shell> vi /etc/my.cnf
Note

We show vi being used here to create the file, but any text editor should work just as well.

For each data node and SQL node in our example setup, my.cnf should look like this:

[mysqld]# Options for mysqld process:ndbcluster                      # run NDB storage engine[mysql_cluster]# Options for MySQL Cluster processes:ndb-connectstring=192.168.0.10  # location of management server

After entering the preceding information, save this file and exit the text editor. Do this for the machines hosting data node A, data node B, and the SQL node.

Important

Once you have started a mysqld process with the ndbcluster and ndb-connectstring parameters in the[mysqld] and [mysql_cluster] sections of the my.cnf file as shown previously, you cannot execute anyCREATE TABLE or ALTER TABLE statements without having actually started the cluster. Otherwise, these statements will fail with an error. This is by design.



(二)、配置管理節點

Configuring the management node. The first step in configuring the management node is to create the directory in which the configuration file can be found and then to create the file itself. For example (running asroot):

shell> mkdir /var/lib/mysql-clustershell> cd /var/lib/mysql-clustershell> vi config.ini

For our representative setup, the config.ini file should read as follows:

[ndbd default]# Options affecting ndbd processes on all data nodes:NoOfReplicas=2    # Number of replicas(副本個數)DataMemory=80M    # How much memory to allocate for data storageIndexMemory=18M   # How much memory to allocate for 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.[tcp default]# TCP/IP options:portnumber=2202   # This the default; however, you can use any                  # port that is free for all the hosts in the cluster                  # Note: It is recommended that you do not specify the port                  # number at all and simply allow the default value to be used                  # instead[ndb_mgmd]# Management process options:hostname=192.168.0.10           # Hostname or IP address of MGM nodedatadir=/var/lib/mysql-cluster  # Directory for MGM node log files[ndbd]# Options for data node "A":                                # (one [ndbd] section per data node)hostname=192.168.0.30           # Hostname or IP addressdatadir=/usr/local/mysql/data # Directory for this data node's data files(數據文件存放目錄)[ndbd]# Options for data node "B":hostname=192.168.0.40           # Hostname or IP addressdatadir=/usr/local/mysql/data   # Directory for this data node's data files[mysqld]# SQL node options:hostname=192.168.0.20           # Hostname or IP address                                # (additional mysqld connections can be                                # specified for this node for various# purposes such as running ndb_restore)
Note

The world database can be downloaded from http://dev.mysql.com/doc/, where it can be found listed underExamples.


三、啓動


(一)、初始化時候的啓動:
(1)、管理節點啓動
ndb_mgmd -f /var/lib/mysql-cluster/config.ini


(2)、數據節點啓動

ndbd --initial(第一次啓動時使用,之後可以不使用此參數)

(3)、SQL節點啓動

mkdir  /usr/local/mysql/scripts/bin

cp  /usr/local/mysql/bin/my_print_defaults   /usr/local/mysql/scripts/bin

/usr/local/mysql/scripts/mysql_install_db   --user=mysql  --datadir=/home/mysql

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql


service mysql  start


(二)、正常啓動和關閉


(1)、啓動

To restart the cluster on Unix platforms, run these commands:

  • On the management host (192.168.0.10 in our example setup):

    shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini
  • On each of the data node hosts (192.168.0.30 and 192.168.0.40):

    shell> ndbd
  • Use the ndb_mgm client to verify that both data nodes have started successfully.

  • On the SQL host (192.168.0.20):

    shell> mysqld_safe &


(2)、關閉


ndb_mgm -e shutdown

啓動順序:管理節點——data節點——sql節點,關閉正好相反



四、安裝結束的驗證


shell> ndb_mgm-- NDB Cluster -- Management Client --ndb_mgm> SHOWConnected to Management Server at: localhost:1186Cluster Configuration---------------------[ndbd(NDB)]     2 node(s)id=2    @192.168.0.30  (Version: 5.5.31-ndb-7.2.14, Nodegroup: 0, Master)id=3    @192.168.0.40  (Version: 5.5.31-ndb-7.2.14, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1    @192.168.0.10  (Version: 5.5.31-ndb-7.2.14)[mysqld(API)]   1 node(s)id=4    @192.168.0.20  (Version: 5.5.31-ndb-7.2.14)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章