<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post//</link>
<title><![CDATA[mysql集群技术]]></title> 
<author> &lt;&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Tue, 14 Aug 2007 14:58:08 +0000</pubDate> 
<guid>https://blog.liuts.com/post//</guid> 
<description>
<![CDATA[ 
	1、环境描述<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">Mysql manager 节点：192.168.0.1<br/>MysqlServer节点：192.168.0.100<br/>Mysql 节点：192.168.0.160<br/>Mysql 节点：192.168.0.161</div></div><br/>说明：至少需要四台服务器才可以做mysql的集群。建议5台，再增加一台MysqlServer。<br/>2安装mysql二进制包<br/>2.1 安装之前的准备工作<br/>下载mysql-max-4.1.13-pc-linux-gnu-i686.tar.gz包<br/>（注意：可以做集群的mysql都是mysql-max的,下载地点www.mysql.org）<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#groupadd mysql<br/>#useradd -g mysql mysql<br/>#cd /usr/local<br/>#tar xfz mysql-max-4.1.13-pc-linux-gnu-i686.tar.gz<br/>#ln -s /usr/local/mysql-max-4.1.13-pc-linux-gnu-i686 /opt/mysql4.1.13</div></div><br/>2.2 分别在manager，server，node节点上安装二进制的mysql包<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#cd mysql4.1.13<br/>#scripts/mysql_install_db --user=mysql (必须带目录执行，否则出错)<br/>#chown -R root /opt/mysql4.1.13<br/>#chgrp -R mysql /opt/mysql4.1.13<br/>#chown -R mysql.mysql /opt/mysql4.1.13/data<br/>#cp support-files/mysql.server /etc/rc.d/init.d/ 配置mysql启动设置<br/>#chmod +x /etc/rc.d/init.d/mysql.server <br/>#chkconfig --add mysql.server </div></div><br/>3配置server，note节点<br/>在192.168.0.160和192.168.0.161机器上<br/># ./mysql –help 该命令可以查看mysql启动时是怎么寻找my.cnf文件的顺序。<br/>Default options are read from the following files in the given order:<br/>/etc/my.cnf /usr/local/mysql-max-4.1.13/data/my.cnf ~/.my.cnf <br/># cp support-files/my-medium.cnf data/my.cnf 将mysql的配置文件考到data下<br/>Vi /usr/local/mysql-max-4.1.13-pc-linux-gnu-i686/data/my.cnf<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">[MYSQLD]<br/>ndbcluster<br/>ndb-connectstring=192.168.0.1<br/>[MYSQL_CLUSTER]<br/>ndb-connectstring=192.168.0.1</div></div><br/>4配置Management管理节点<br/>在192.168.0.1机器上<br/>#mkdir /var/lib/mysql-cluster<br/>#cd /var/lib/mysql-cluster<br/>#vi config.ini<br/>[NDBD DEFAULT] # Options affecting ndbd processes on all data nodes:<br/>NoOfReplicas=2 # Number of replicas<br/>DataMemory=80M # How much memory to allocate for data storage<br/>IndexMemory=52M # How much memory to allocate for index storage<br/> # For DataMemory and IndexMemory, we have used the<br/> # default values. Since the "world" database takes up<br/> # only about 500KB, this should be more than enough for<br/> # this example Cluster setup.<br/>[TCP DEFAULT] # TCP/IP options:<br/>portnumber=2202 # This the default; however, you can use any<br/> # port that is free for all the hosts in cluster<br/> # Note: It is recommended beginning with MySQL 5.0 that<br/> # you do not specify the portnumber at all and simply allow<br/> # the default value to be used instead<br/># Management process options（定义管理节点.）<br/>[NDB_MGMD]<br/>hostname=192.168.0.1 # 管理节点Hostname or IP address of MGM node<br/>datadir=/var/lib/mysql-cluster # Directory for MGM node logfiles<br/># Options for data node "A"（定义群集数据节点.）<br/># (one [NDBD] section per data node)<br/>[NDBD]<br/>hostname=192.168.0.160 # 节点Hostname or IP address<br/>datadir=/usr/local/mysql/data # Directory for this data node's datafiles<br/># Options for data node "B"（定义群集数据节点.）<br/>[NDBD]<br/>hostname=192.168.0.161 # 节点Hostname or IP address<br/>datadir=/usr/local/mysql/data # Directory for this data node's datafiles<br/># SQL node options（定义Sql server节点.）<br/>[MYSQLD]<br/>hostname=192.168.0.100 # SQL节点Hostname or IP address<br/>#datadir=/usr/local/mysql/data # Directory for SQL node's datafiles<br/> # (additional mysqld connections can be<br/> # specified for this node for various<br/> # purposes such as running ndb_restore)<br/><br/>[NDB_MGMD]:后面不能有任何注释信息，否则提示：<br/>Error line 17: [TCP] Unknown parameter: [NDB_MGMD] # Management process options<br/>Error line 17: Could not parse name-value pair in config file.<br/>[SHM]: Defines shared-memory connections between nodes. 在MySQL 4.1.9之前，这个功能必须使用--with-ndb-shm option编译进去, 从MySQL 4.1.9-max版本开始, it is enabled by default <br/><br/>5启动mysql集群<br/>5.1 初始化启动mysql集群服务<br/>1）启动MysqlManagement管理节点（192.168.0.1）<br/>#ndb_mgmd -f /var/lib/mysql-cluster/config.ini<br/>2）启动Data Node节点(192.168.0.160,192.168.0.161)<br/>#ndbd --initial<br/>(注意：这个参数只能在第一次启动DataNode节点时使用，因为—initial参数会删除一些ndbd 实例先前创建的所有文件)<br/><br/>3）启动MysqlServer节点(192.168.0.100)<br/># ./mysql.server start<br/>5.2 重启mysql集群服务<br/>1）启动MysqlManagement管理节点（192.168.0.1）<br/>#ndb_mgmd -f /var/lib/mysql-cluster/config.ini<br/>2）启动Data Node节点(192.168.0.160,192.168.0.161)<br/>#ndbd<br/>3）启动MysqlServer节点(192.168.0.100)<br/># ./mysql.server start<br/>(注意：Management管理节点和DataNote节点都不开启mysql服务，只有MysqlServer节点开启。The default port for Cluster management nodes is 1186; the default port for data nodes is 2202.)<br/><br/>6测试集群的效果<br/>6.1 在管理机上查看各节点运行状况<br/>[root@Proxy bin]# ./ndb_mgm<br/>-- NDB Cluster -- Management Client --<br/>ndb_mgm&gt; show<br/>Connected to Management Server at: localhost:1186<br/>Cluster Configuration<br/>[ndbd(NDB)] 2 node(s)<br/>id=2 @192.168.0.160 (Version: 4.1.13, Nodegroup: 0, Master)<br/>id=3 @192.168.0.161 (Version: 4.1.12, Nodegroup: 0)<br/>[ndb_mgmd(MGM)] 1 node(s)<br/>id=1 @192.168.0.1 (Version: 4.1.13)<br/>[mysqld(API)] 1 node(s)<br/>id=4 @192.168.0.100 (Version: 4.1.12)<br/>6.2 模拟写入一个数据库表，各MysqlServer节点是否能够同步<br/>1） 在一个MysqlServer节点上创建数据库world和表，然后看看另一个MysqlServer节点是否也同样可以看到。<br/>答：数据都相同<br/>2） 拔掉一个DataNote节点网线，看看两台MysqlServer节点是否还能正常工作。<br/>答：可以<br/>3） 拔掉两台DataNote节点网线，查看一下MysqlServer节点是否还能正常工作。<br/>答：所有MysqlServer都不能正常工作<br/>Tags - <a href="https://blog.liuts.com/tags/mysql/" rel="tag">mysql</a> , <a href="https://blog.liuts.com/tags/%25E9%259B%2586%25E7%25BE%25A4/" rel="tag">集群</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post//#blogcomment</link>
<title><![CDATA[[评论] mysql集群技术]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://blog.liuts.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>