MySql節(jié)點(diǎn)管理安裝步驟需要在SerA和SerB上各做一次
對(duì)大家推薦很好使用的MySql節(jié)點(diǎn)系統(tǒng),像讓大家對(duì)MySql節(jié)點(diǎn)系統(tǒng)有所了解,然后對(duì)MySql節(jié)點(diǎn)系統(tǒng)全面講解介紹,希望對(duì)大家有用在向大家詳細(xì)介紹MySql節(jié)點(diǎn)之前,首先讓大家了解下MySql節(jié)點(diǎn),然后全面介紹MySql節(jié)點(diǎn),希望對(duì)大家有用。這篇文檔旨在介紹如何安裝配置基于2臺(tái)服務(wù)器的MySQL集群。并且實(shí)現(xiàn)任意一臺(tái)服務(wù)器出現(xiàn)問題或宕機(jī)時(shí)MySql集群依然能夠繼續(xù)運(yùn)行。
安裝環(huán)境及軟件包:2臺(tái)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節(jié)點(diǎn)
以下步驟需要在SerA和SerB上各做一次
1.配置管理MySql節(jié)點(diǎn)配置文件:
- # mkdir /var/lib/mysql-cluster
- # cd /var/lib/mysql-cluster
- # vi config.ini
- 在config.ini中添加如下內(nèi)容:
- [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 (非常重要,全靠有它,才可以形成仲裁競(jìng)爭(zhēng),從而當(dāng)另一個(gè)機(jī)子當(dāng)了時(shí),此機(jī)還可以有知道partion完整的節(jié)點(diǎn))
- [mysqld]
- ArbitrationRank=2
- [mysqld] (多出的這項(xiàng)是留給恢復(fù)時(shí)使用的.)
- [mysqld] (多出的這項(xiàng)是留給恢復(fù)時(shí)使用的.)
- [tcp default]
- PortNumber= 63132
- [separator]
2.配置通用my.cnf文件,mysqld及ndbd,ndb_mgmd均使用此文件.
- # vi /etc/my.cnf
- 在my.cnf中添加如下內(nèi)容:
- [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] 保存退出后.
三.啟動(dòng)管理MySql節(jié)點(diǎn)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.
注:在啟動(dòng)時(shí)有一個(gè)警告提示說MySql節(jié)點(diǎn)1和3,2和4的arbitrator一樣,可能引起整個(gè)集群失敗。(可以不用放在心上)啟動(dòng)管理MySql節(jié)點(diǎn)SerB為:[root@SerB ~]# ndb_mgmd --ndb_nodeid=2.
【編輯推薦】