对大家推荐很好使用的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.
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。