MySql節點管理安裝步驟需要在SerA和SerB上各做一次
對大家推薦很好使用的MySql節點系統,像讓大家對MySql節點系統有所了解,然后對MySql節點系統全面講解介紹,希望對大家有用在向大家詳細介紹MySql節點之前,首先讓大家了解下MySql節點,然后全面介紹MySql節點,希望對大家有用。這篇文檔旨在介紹如何安裝配置基于2臺服務器的MySQL集群。并且實現任意一臺服務器出現問題或宕機時MySql集群依然能夠繼續運行。
安裝環境及軟件包:2臺PCmysql-6.0.0-alpha.tar.gzCentos5SerA:192.168.1.50SerB:192.168.1.8
1、在SerA和SerB上安裝MySQL以下步驟需要在SerA和SerB上各做一次
- # mv mysql-6.0.0-alpha.tar.gz /tmp/package
- # cd /tmp/package
- # groupadd mysql
- # useradd -g mysql mysql
- # tar -zxvf mysql-6.0.0-alpha.tar.gz
- # rm -f mysql-6.0.0-alpha.tar.gz
- # mv mysql-6.0.0-alpha mysql
- # cd mysql
- # ./configure --prefix=/usr/local --with-extra-charsets=complex --with-plugin-ndbcluster
- --with-plugin-partition --with-plugin-innobase --with-unix-socket-path=/usr/local/var/mysql.sock
- # make && make install
- #ln -s /usr/local/libexec/ndbd /usr/bin
- #ln -s /usr/local/libexec/ndb_mgmd /usr/bin
- #ln -s /usr/local/libexec/ndb_cpcd /usr/bin
- #ln -s /usr/local/libexec/mysqld /usr/bin
- #ln -s /usr/local/libexec/mysqlmanager /usr/bin
- #mysql_install_db --user=mysql
我用的是:mysql-5.0.85-linux-i686.tar.gz
二、安裝并配置MySql節點
以下步驟需要在SerA和SerB上各做一次
1.配置管理MySql節點配置文件:
- # mkdir /var/lib/mysql-cluster
- # cd /var/lib/mysql-cluster
- # vi config.ini
- 在config.ini中添加如下內容:
- [ndbd default]
- NoOfReplicas= 2
- MaxNoOfConcurrentOperations= 10000
- # Amount of memory required=(SizeofDatabase * NumberOfReplicas * 1.1 ) / NumberOfDataNodes
- DataMemory= 128M
- IndexMemory= 24M
- TimeBetweenWatchDogCheck= 30000
- DataDir=/var/lib/mysql-cluster
- MaxNoOfOrderedIndexes= 512
- StartPartialTimeout=100
- StartPartitionedTimeout=100
- ArbitrationTimeout=5000
- TransactionDeadlockDetectionTimeout=5000
- HeartbeatIntervalDbDb=5000
- StopOnError=0
- [ndb_mgmd default]
- DataDir=/var/lib/mysql-cluster
- [ndb_mgmd]
- Id=1
- HostName= 192.168.1.50
- [ndb_mgmd]
- Id=2
- HostName= 192.168.1.8
- [ndbd]
- Id= 3
- HostName= 192.168.1.50
- [ndbd]
- Id= 4
- HostName= 192.168.1.8
- [mysqld]
- ArbitrationRank=2 (非常重要,全靠有它,才可以形成仲裁競爭,從而當另一個機子當了時,此機還可以有知道partion完整的節點)
- [mysqld]
- ArbitrationRank=2
- [mysqld] (多出的這項是留給恢復時使用的.)
- [mysqld] (多出的這項是留給恢復時使用的.)
- [tcp default]
- PortNumber= 63132
- [separator]
2.配置通用my.cnf文件,mysqld及ndbd,ndb_mgmd均使用此文件.
- # vi /etc/my.cnf
- 在my.cnf中添加如下內容:
- [mysqld]
- datadir=/usr/local/var
- socket=/usr/local/var/mysql.sock
- # Default to using old password format for compatibility with mysql 3.x
- # clients (those using the mysqlclient10 compatibility package).
- old_passwords=1
- default-storage-engine=ndbcluster
- ndbcluster
- ndb-connectstring=192.168.1.50,192.168.1.8
- [ndbd]
- connect-string=192.168.1.50,192.168.1.8
- [ndb_mgm]
- connect-string=192.168.1.50,192.168.1.8
- [ndb_mgmd]
- config-file=/var/lib/mysql-cluster/config.ini
- [mysql_cluster]
- ndb-connectstring=192.168.1.50,192.168.1.8
- [mysql.server]
- user=mysql
- basedir=/usr/local/
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- #pid-file=/var/run/mysqld/mysqld.pid
- [mysql]
- #socket=/usr/local/var/mysql.sock
- [mysqladmin]
- #socket=/usr/local/var/mysql.sock
- [ndb_restore default] 保存退出后.
三.啟動管理MySql節點SerA為:
- [root@SerA ~]# ndb_mgmd --ndb_nodeid=1
- Cluster configuration warning:
- arbitrator with id 1 and db node with id 3 on same host 192.168.1.50
- arbitrator with id 2 and db node with id 4 on same host 192.168.1.8
- arbitrator with id 5 has no hostname specified
- arbitrator with id 6 has no hostname specified
- Running arbitrator on the same host as a database node may
- cause complete cluster shutdown in case of host failure.
注:在啟動時有一個警告提示說MySql節點1和3,2和4的arbitrator一樣,可能引起整個集群失敗。(可以不用放在心上)啟動管理MySql節點SerB為:[root@SerB ~]# ndb_mgmd --ndb_nodeid=2.
【編輯推薦】
























