这篇文章是国外一个网友写的,我现在暂时没有条件测试,但觉得写的还不错,就发上来了,给大家提供个参考。配置mysql集群至少需要三台机器,其它信息请参阅mysql的官方文档
Mysql Cluster: Two webserver setup (three servers required for true redundancy)
HOWTO set up a mysql cluster for two servers
Introduction
This HOWTO was designed for a classic setup of two servers behind a loadbalancer. The aim is to have true redundancy - either server can be unplugged and yet the site will remain up.
Notes
You MUST have a third server as a managment node but this can be shut down after the cluster starts. Also note that I do not recommend shutting down the managment server (see the extra notes at the bottom of this document for more information). You can not run a mysql cluster with just two servers And have true redundancy.
Although it is possible to set the cluster up on two physical servers you WILL NOT GET the ability to "kill" one server and for the cluster to continue as normal. For this you need a third server running the managment node.
I am going to talk about three servers,
mysql1.domain.com 192.168.0.1
mysql2.domain.com 192.168.0.2
mysql3.domain.com 192.168.0.3
Servers 1 and 2 will be the two that end up "clustered". This would be perfect for two servers behind a loadbalancer or using round robin DNS and is a good replacement for replication. Server 3 needs to have only minor changes made to it and does NOT require a mysql install. It can be a low-end machine and can be carrying out other tasks.
STAGE 1: Install mysql on the first two servers:
Complete the following steps on both mysql1 and mysql2:
cd /usr/local/
http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz/
from/http://www.signal42.com/mirrors/mysql/
groupadd mysql
useradd -g mysql mysql
tar -zxvf mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
rm mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
ln -s mysql-max-4.1.9-pc-linux-gnu-i686 mysql
cd mysql
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
cp support-files/mysql.server /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/mysql.server
chkconfig --add mysql.server
Do not start mysql yet.
STAGE 2: Install and configure the managment server
You need the following files from the bin/ of the mysql directory: ndb_mgm and ndb_mgmd. Download the whole mysql-max tarball and extract them from the bin/ directory.
mkdir /usr/src/mysql-mgm
cd /usr/src/mysql-mgm
http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz/
from/http://www.signal42.com/mirrors/mysql/
tar -zxvf mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
rm mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
cd mysql-max-4.1.9-pc-linux-gnu-i686
mv bin/ndb_mgm .
mv bin/ndb_mgmd .
chmod +x ndb_mg*
mv ndb_mg* /usr/bin/
cd
rm -rf /usr/src/mysql-mgm
You now need to set up the config file for this managment:
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi [or emacs or any other editor] config.ini
Now, insert the following (changing the bits as indicated):
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=192.168.0.3# the IP of THIS SERVER
# Storage Engines
[NDBD]
HostName=192.168.0.1# the IP of the FIRST SERVER
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=192.168.0.2# the IP of the SECOND SERVER
DataDir=/var/lib/mysql-cluster
# 2 MySQL Clients
# I personally leave this blank to allow rapid changes of the mysql clients;
# you can enter the hostnames of the above two servers here. I suggest you dont.
[MYSQLD]
[MYSQLD]
Now, start the managment server:
ndb_mgmd
This is the mysql managment server, not maganment console. You should therefore not expect any output (we will start the console later).
STAGE 3: Configure the storage/SQL servers and start mysql
On each of the two storage/SQL servers (192.168.0.1 and 192.168.0.2) enter the following (changing the bits as appropriate):
vi /etc/my.cnf
Enter i to go to insert mode again and insert this on both servers (changing the IP address to the IP of the managment server that you set up in stage 2):
[mysqld]
ndbcluster
ndb-connectstring=192.168.0.3# the IP of the MANAGMENT (THIRD) SERVER
[mysql_cluster]
ndb-connectstring=192.168.0.3# the IP of the MANAGMENT (THIRD) SERVER
Now, we make the data directory and start the storage engine:
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
/usr/local/mysql/bin/ndbd --initial
/etc/rc.d/init.d/mysql.server start
If you have done one server now go back to the start of stage 3 and repeat exactly the same procedure on the second server.
NOTE that you should ONLY use --initial if you are either starting from scratch or have changed the config.ini file on the managment.
STAGE 4: Check its working
You can now return to the managment server (mysql3) and enter the managment console:
/usr/local/mysql/bin/ndb_mgm
Enter the command SHOW to see what is going on. A sample output looks like this:
[root@mysql3 mysql-cluster]# /usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm>; show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.0.1 (Version: 4.1.9, Nodegroup: 0, Master)
id=3 @192.168.0.2 (Version: 4.1.9, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.0.3 (Version: 4.1.9)
[mysqld(API)] 2 node(s)
id=4 (Version: 4.1.9)
id=5 (Version: 4.1.9)
ndb_mgm>;
If you see
not connected, accepting connect from 192.168.0.[1/2/3]
in the first or last two lines they you have a problem. Please email me with as much detail as you can give and I can try to find out where you have gone wrong and change this HOWTO to fix it.
If you are OK to here it is time to test mysql. On either server mysql1 or mysql2 enter the following commands: Note that we have no root password yet.
mysql
use test;
CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
INSERT INTO ctest () VALUES (1);
SELECT * FROM ctest;
You should see 1 row returned (with the value 1).
If this works, now go to the other server and run the same SELECT and see what you get. Insert from that host and go back to host 1 and see if it works. If it works then congratulations.
The final test is to kill one server to see what happens. If you have physical access to the machine simply unplug its network cable and see if the other server keeps on going fine (try the SELECT query). If you dont have physical access do the following:
ps aux | grep ndbd
You get an output like this:
root 5578 0.0 0.3 6220 1964 ? S 03:14 0:00 ndbd
root 5579 0.0 20.4 492072 102828 ? R 03:14 0:04 ndbd
root 23532 0.0 0.1 3680 684 pts/1 S 07:59 0:00 grep ndbd
In this case ignore the command "grep ndbd" (the last line) but kill the first two processes by issuing the command kill -9 pid pid:
kill -9 5578 5579
Then try the select on the other server. While you are at it run a SHOW command on the managment node to see that the server has died. To restart it, just issue
ndbd
NOTE no --inital!
Further notes about setup
I strongly recommend that you read all of this (and bookmark this page). It will almost certainly save you a lot of searching.
The Managment Server
I strongly recommend that you do not stop the managment server once it has started. This is for several resons:
The server takes hardly any server resources
If a cluster falls over, you want to be able to just ssh in and type ndbd to stat it. You dont want to have to start messing around with another server
If you want to take backups then you need the managment server up
The cluster log is sent to the management server so to check what is going on in the cluster or has happened since last this is an important tool
All commands from the ndb_mgm client is sent to the management server and thus no management commands without management server.
The managment server is required in case of cluster reconfiguration (crashed server or network split). In the case that it is not running, "split-brain" scenario will occure. The management server arbitration role is required for this type of setup to provide better fault tollerance.
However you are welcome to stop the server if you prefer.
Starting and stopping ndbd automatically on boot
To achieve this, do the following on both mysql1 and mysql2:
echo "ndbd" >; /etc/rc.d/init.d/ndbd
chmod +x /etc/rc.d/init.d/ndbd
chkconfig --add ndbd
Note that this is a really quick script. You ought really to write one that at least checks if ndbd is already started on the machine.
Use of hostnames
You will note that I have used IP addresses exclusively throught this setup. This is because using hostnames simply increases the number of things that can go wrong. Mikael Ronstrm of MySQL AB kindly explains: "Hostnames certainly work with MySQL Cluster. But using hostnames introduces quite a few error sources since a proper DNS lookup system must be set-up, sometimes /etc/hosts must be edited and their might be security blocks ensuring that communication between certain machines is not possible other than on certain ports". I strongly suggest that while testing you use IP addresses if you can, then once it is all working change to hostnames.
RAM
Use the following formula to work out the amount of RAM that you need on each storage node:
(Size of database * NumberofReplicas * 1.1) / Number of storage nodes
NumberofReplicas is set to two by default. You can change it in config.ini if you want. So for example to run a 4GB database you need just under 9GB of RAM on each storage node. For the SQL nodes and managment nodes you dont need much RAM at all.
Note: A lot of people have emailed me querying the maths above! Remember that the cluster is fault tollerant, and each piece of data is stored on at least 2 nodes. (2 by default, as set by NumberOfReplicas). So you need TWICE the space you would need just for one copy, multiplied by 1.1 for overhead.
Adding storage nodes
If you decide to add storage nodes, bear in mind that 3 is not an optimal numbers. If you are going to move from two (above) then move to 4.
Adding SQL nodes
If you want to add another SQL node (i.e. you have another server that you want to add to the cluster but you dont need it to act as a storage node), then just add the following to /etc/my.cnf on the server (it must be a mysql-max server):
[mysqld]
ndbcluster
ndb-connectstring=192.168.0.3# the IP of the MANAGMENT (THIRD) SERVER
[mysql_cluster]
ndb-connectstring=192.168.0.3# the IP of the MANAGMENT (THIRD) SERVER
Then you need to make sure that there is another [MYSQLD] line at the end of config.ini on the managment server. Restart the cluster (see below for an important note) and restart mysql on the new API. It should be connected.
Important note on changing config.ini
If you ever change config.ini you must stop the whole cluster and restart it to re-read the config file. Stop the cluster with a SHUTDOWN command to the ndb_mgm package on the managment server and then restart all the storage nodes.
Some useful configuration options that you will need if you have large tables:
DataMemory: defines the space available to store the actual records in the database. The entire DataMemory will be allocated in memory so it is important that the machine contains enough memory to handle the DataMemory size. Note that DataMemory is also used to store ordered indexes. Ordered indexes uses about 10 bytes per record. Default: 80MB
IndexMemory The IndexMemory is the parameter that controls the amount of storage used for hash indexes in MySQL Cluster. Hash indexes are always used for primary key indexes, unique indexes, and unique constraints. Default: 18MB
MaxNoOfAttributes This parameter defines the number of attributes that can be defined in the cluster. Default: 1000
MaxNoOfTables Obvious (bear in mind that each BLOB field creates another table for various reasons so take this into account). Default: 128
View this page at mysql.com for further information about the things you can put in the [NDBD] section of config.ini
A note about security
MySQL cluster is not secure. By default anyone can connect to your managment server and shut the whole thing down. I suggest the following precautions:
Install APF and block all ports except those you use (do NOT include any MySQL cluster ports). Add the IPs of your cluster machines to the /etc/apf/allow_hosts file.
Run MySQL cluster over a second network card on a second, isolated, network.
Other resources
I found the following resources very useful:
The MySQL cluster documentation. This is gradually being reworked. I would, however, suggest that you at least read these pages:
On-line Backup of MySQL Cluster.
Defining MySQL Cluster Storage Nodes for information that you will need to allow for bigger database memory or a larger number of tables, indexes, unique indexes
MySQL Cluster mailing list.
Google.
MySQL Forums
The #mysql IRC chanel on freenode and EFNet. If you need a free (open source) IRC client I recomment Bersirc.
Thanks
I must thank several others who have contributed to this: Mikael Ronstrm from MySQL AB for helping me to get this to work and spotting my silly mistake right at the end, Lewis Bergman for proof-reading this page and pointing out some improvements, as well as suffering the frustration with me and Martin Pala for explaining the final reason to keep the managment server up as well as a few other minor changes. Thanks also to Terry from Advanced Network Hosts who paid me to set a cluster up and at the same time produce a HOWTO.
[ 本帖最后由 yejr 于 2005-12-12 13:14 编辑 ]
lxw2016 回复于:2005-09-27 09:43:00
写得不错,有时间去试试。感谢楼主!
hardiwang 回复于:2005-09-27 10:35:18
http://mysql.linuxforum.net/tech-resources/articles/mysql-cluster-for-two-servers.html
楼主以后转载的时候要写文章出处哦:)
kingnetwork 回复于:2005-09-27 10:45:05
呵呵!忘了,下次一定记住,另付上这位外国哥们的网址
http://www.davz.net
archangle 回复于:2005-09-27 11:07:00
2台机器也可以跑集群。
阿辉 回复于:2005-09-27 11:17:29
用Mysql跑集群意义不大,因为两三台机器加在一起,可能还没有一台单机快。而且对内存的要求太高。稳定性也差。再没见过这么烂的东西了。
kingnetwork 回复于:2005-09-27 11:44:45
你做过?贴出来大家看看。另外,集群的目的是什么?
leaper 回复于:2005-09-27 11:55:41
引用:原帖由 "阿辉"]用Mysql跑集群意义不大,因为两三台机器加在一起,可能还没有一台单机快。而且对内存的要求太高。稳定性也差。再没见过这么烂的东西了。 发表:
自个脑子有问题的家伙。没作过不要在这里胡扯,搞技术的人实践最重要
我用mysql作DB,数据都几个T了照样跑得很好。
光数据文件就27个G。
阿辉 回复于:2005-09-27 12:11:34
引用:原帖由 "leaper" 发表:
自个脑子有问题的家伙。没作过不要在这里胡扯,搞技术的人实践最重要
我用mysql作DB,数据都几个T了照样跑得很好。
光数据文件就27个G。
就事论事,你说这种话说明没也什么脑子。
用三台机器做mysql集群。和用一台Mysql做的基准测试相比。集群明显慢了很多。有些可能是慢两到三倍。
主要原因我认为是在于数据库引擎的问题。集群必需用NDB,而单机的myisam是非常快的。当然还有其它一些原因,比如集群不支持查询缓存等等。
不过Mysql 5.0对集群有一些改进,但就性能来说依然很烂。
在Mysql的BBS上,有关集群性能的问题是问得最多的,而官方的答复是集群优先注重的是可用性,而不是性能。
yejr 回复于:2005-09-27 12:55:35
萝卜白菜,各有所爱,各取所需,在这里请讨论技术,不要搞人身攻击,请各位自重。
archangle 回复于:2005-09-27 15:14:09
引用:
用Mysql跑集群意义不大,因为两三台机器加在一起,可能还没有一台单机快。而且对内存的要求太高。稳定性也差。再没见过这么烂的东西了。
稳定性差在那里?
阿辉 回复于:2005-09-27 15:37:02
引用:原帖由 "archangle" 发表:
稳定性差在那里?
碰到问题直接死掉,你可以做一个集群,然后再用他自带的基准测试程序测测看,八成是会死的。
阿辉 回复于:2005-09-27 15:39:41
引用:原帖由 "kingnetwork"]你做过?贴出来大家看看。另外,集群的目的是什么? 发表:
很多人可能会说是高可用性,而不是性能,但是用那么大的代价去做集群只是为了高可用性真的值得吗?如果是这样为什么不用主备呢?
我觉得性能应该是集群的一个重要指标。否则意义不大。
北京野狼 回复于:2005-09-27 15:48:08
引用:原帖由 "阿辉" 发表:
很多人可能会说是高可用性,而不是性能,但是用那么大的代价去做集群只是为了高可用性真的值得吗?如果是这样为什么不用主备呢?
我觉得性能应该是集群的一个重要指标。否则意义不大。
我只做主从,而且主从的意义也不很大。
archangle 回复于:2005-09-27 15:59:46
引用:
很多人可能会说是高可用性,而不是性能,但是用那么大的代价去做集群只是为了高可用性真的值得吗?如果是这样为什么不用主备呢?
我觉得性能应该是集群的一个重要指标。否则意义不大。
纵然性能是一大治标,但是可用性也是非常重要的,你是希望性能非常好,但是经常挂掉呢,还是希望性能稍微差点,但是非常稳定呢?
北京野狼 回复于:2005-09-27 16:09:59
引用:原帖由 "archangle" 发表:
纵然性能是一大治标,但是可用性也是非常重要的,你是希望性能非常好,但是经常挂掉呢,还是希望性能稍微差点,但是非常稳定呢?
说的好,有长进
archangle 回复于:2005-09-27 16:21:46
我刚测试了一下,的确会死掉。因为我的内存设置非常小。
原因可能是测试的量太大,超过了cluster设置内存(DataMemory和IndexMemory),所以出错是必然的。
我会去mysql的邮件列表问问是怎么回事。
阿辉 回复于:2005-09-27 16:40:13
引用:原帖由 "archangle" 发表:
纵然性能是一大治标,但是可用性也是非常重要的,你是希望性能非常好,但是经常挂掉呢,还是希望性能稍微差点,但是非常稳定呢?
可用性要看怎么去算了,比如我有三台机器:得到的性能是单机的1.5倍以上。但稳定性有了很大的提高。这我认为是可以接受的。
但如果三台机器的性能还不如单机,稳定性再高,真正的意义大吗?在这种情况下,为什么不用主备。当然主备也是问题多多。不过成本比较低。
archangle 回复于:2005-09-27 16:42:18
具体情况要具体分析,不能一刀切,不同的行业有不同的需要。
我刚才崩溃是因为运行的test-all,所以导致大量数据把内存用完。现在我在测试insert,select等常用操作的性能,并且和非集群做一个对比。
insert
root@dbc6 /usr/local/mysql/sql-bench# ./test-insert
Testing server 'MySQL 4.1.14 max log' at 2005-09-27 16:28:22
Testing the speed of inserting data into 1 table and do some selects on it.
The tests are done with a table that has 100000 rows.
Generating random keys
Creating tables
Inserting 100000 rows in order
Inserting 100000 rows in reverse order
Inserting 100000 rows in random order
Time for insert (300000): 787 wallclock secs ( 5.12 usr 51.42 sys + 0.00 cusr 0.00 csys = 56.54 CPU)
Testing insert of duplicates
Time for insert_duplicates (100000): 126 wallclock secs ( 1.66 usr 13.17 sys + 0.00 cusr 0.00 csys = 14.83 CPU)
阿辉 回复于:2005-09-27 16:43:02
引用:原帖由 "archangle" 发表: 我刚测试了一下,的确会死掉。因为我的内存设置非常小。
原因可能是测试的量太大,超过了cluster设置内存(DataMemory和IndexMemory),所以出错是必然的。
我会去mysql的邮件列表问问是怎么回事。
是的,但不是内存足够的话,出这些问题的机率也是非常高的,我以前在两台DELL的服务器上做过,双至强2.8的CPU,每台4G的内存。数据库大约在2G。发现性能和稳定性都非常差,5.0的性能好一点,但也是不如单机。
阿辉 回复于:2005-09-27 16:47:04
引用:原帖由 "archangle"]具体情况要具体分析,不能一刀切,不同的行业有不同的需要。 发表:
是的,但Mysql的单机稳定性真的很差吗?基本上我现目前为止还很少看到Mysql无故死机的。
我对Mysql集群的基于内存的存储方式真的是很讨厌。用了那很大的内存,性能还不如在单机上给多一点缓存。呵呵!!!你说他们开发这个做什么。
archangle 回复于:2005-09-27 16:52:33
似乎他们对oracle的RAC很不屑,觉得这个share nothing结构很不错。因为成本低,投资也低。
我对这个ndb 不太了解,似乎是需要把所有的数据都放在内存里,如果遇到非常大的数据库就是很麻烦的了。
另外他们也提供SCI方式的联接,这个对性能可能是有帮助的。
反正不管怎么说,够用就行。
阿辉 回复于:2005-09-27 16:54:39
引用:原帖由 "archangle" 发表: 似乎他们对oracle的RAC很不屑,觉得这个share nothing结构很不错。因为成本低,投资也低。
我对这个ndb 不太了解,似乎是需要把所有的数据都放在内存里,如果遇到非常大的数据库就是很麻烦的了。
另外他们也提供SC..........
不要听他们乱吹了,SCI结构我想也不会好到哪去,我用1000M的网卡试的时候,发现1000M的流量它根本就用不完。只用到20%-30%左右。
archangle 回复于:2005-09-27 16:55:42
引用:
是的,但Mysql的单机稳定性真的很差吗?基本上我现目前为止还很少看到Mysql无故死机的。
我对Mysql集群的基于内存的存储方式真的是很讨厌。用了那很大的内存,性能还不如在单机上给多一点缓存。呵呵!!!你说他们开发这个做什么。
的确,我用数据库复制结构提供我们的dns数据源,从来没出错。
稳定性的确很好。不过复制结构决定了只有一个地方可以写,如果写的这个机器挂了,就麻烦了。所以我需要用集群来解决这个问题。
如果集群不用内存来存储,而是存到硬盘再读的话,估计性能会更差。
archangle 回复于:2005-09-27 16:59:19
引用:
不要听他们乱吹了,SCI结构我想也不会好到哪去,我用1000M的网卡试的时候,发现1000M的流量它根本就用不完。只用到20%-30%左右。
反正集群技术他们也才弄出来不久,还是有很多毛病的,我那天想打开他们的 Success story,居然出错。看来是没有 Success story.
先不管那么多,我刚好这两天在测试这个。先测试测试在说,只要能满足我的具体要求就行。
阿辉 回复于:2005-09-27 17:23:29
引用:原帖由 "archangle" 发表:
反正集群技术他们也才弄出来不久,还是有很多毛病的,我那天想打开他们的 Success story,居然出错。看来是没有 Success story.
先不管那么多,我刚好这两天在测试这个。先测试测试在说,只要能满足我的具体要求?.........
我估计他们是碰到很多问题了,Mysql 5.0好像是准备在今年3月份还是6月份出来的,后来又说要到9月份,结果现在也还没见出来。
archangle 回复于:2005-09-28 09:53:15
测试了一下,集群的性能的确比较差。
5.0 rc好象出了。
http://www.mysql.com/news-and-events/news/article_959.html
北京野狼 回复于:2005-09-28 09:58:07
引用:原帖由 "archangle" 发表: 测试了一下,集群的性能的确比较差。
5.0 rc好象出了。
http://www.mysql.com/news-and-events/news/article_959.html
集群的确没有实际意义。
archangle 回复于:2005-09-28 10:33:54
呵呵,正在测试5.0的集群,不知道性能会不会好点。
先用数据库复制凑合着,以后集群的性能应该是有提高的。
北京野狼 回复于:2005-09-28 10:53:27
主从配置有一定的意义所在。
但是所谓集群,至少现在的mysql不适合,甚至其他的所有数据库都
没有完美的解决。
而且b/s结构最适合的是采用简单的方案,不要做过于复杂的配置。
sina,163也没有这些配置。
archangle 回复于:2005-09-28 13:59:11
sina,163是怎么配置的?透露透露,他们用什么数据库?
北京野狼 回复于:2005-09-28 14:02:48
sina就是mysql.
163以前也是mysql,
后来2004改版,我不是很清楚。
macrodba 回复于:2005-09-28 16:45:34
收下
sickcat2004 回复于:2005-09-29 21:25:11
mysql 支持存储过程么?
怎么实际项目中没有人敢用呢?
archangle 回复于:2005-09-30 08:21:13
引用:
mysql 支持存储过程么?
怎么实际项目中没有人敢用呢?
好象 innodb 支持?不太清楚,你去查查。
kingnetwork 回复于:2005-09-30 09:18:55
5.0的好像支持
sickcat2004 回复于:2005-10-07 22:10:32
支持是支持,但是没人敢用,而且也没有合适的开放存贮过程的工具
stonerose 回复于:2005-10-12 16:07:35
等5.0正式版等得不耐烦了。
leaper 回复于:2005-10-12 16:24:25
我作过mysql cluster,数据插入到一定时就会不工作。好像还不稳定
ypch97 回复于:2005-10-12 19:46:22
现在也在研究mysql的集群,目的比较简单,就是要防止单点故障,两台的集群。高手指点一下!
bitbone 回复于:2005-10-12 22:14:51
集群能给我们带来什么?
jjdn519 回复于:2005-10-14 12:00:18
不错,不错!!
flytod 回复于:2005-10-14 18:17:19
这篇文章不错,收藏了。
yanyp 回复于:2005-10-20 21:39:05
mysql的replication也可做互为主的,不一定非得只写一台呀!
看这个:
http://www.linuxeden.com/forum/t130637.html
---
shining0219 回复于:2005-10-21 00:52:21
现在MySQL的集群只能用内存,不能用硬盘,很局限的,离“好用”还差很远。
北京野狼 回复于:2005-10-21 09:25:53
引用:原帖由 "yanyp" 发表: mysql的replication也可做互为主的,不一定非得只写一台呀!
看这个:
http://www.linuxeden.com/forum/t130637.html
---
那文章,完全是放屁
yanyp 回复于:2005-10-21 09:58:06
我试过的,可以做互为主,你有试过么?
yanyp 回复于:2005-10-21 09:59:00
我没试过怎会在这里瞎说,
北京野狼 回复于:2005-10-21 10:10:58
引用:原帖由 "yanyp"]我试过的,可以做互为主,你有试过么? 发表:
你是在做梦
yanyp 回复于:2005-10-21 10:41:56
哎,拉倒,我自己能用就可以,不和你争了
wangyih 回复于:2005-10-21 11:14:09
互备诱人啊,
那些写弱智文章的和宣扬自己能互备的,真是害人!
yanyp 回复于:2005-10-21 17:09:15
不会做或没做过,就不要乱放,难到还要我演示给你看
yanyp 回复于:2005-10-21 17:13:49
10.5.17.101的/etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin
server-id = 2
sql-bin-update-same
binlog-do-db= reptest
master-host = 10.5.17.140
master-user = rep
master-password = eyou
master-port = 3306
master-connect-retry = 60
replicate-do-db = reptest
log-slave-updates
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
yanyp 回复于:2005-10-21 17:15:10
10.5.17.140的/etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin
server-id = 1
sql-bin-update-same
binlog-do-db= reptest
master-host = 10.5.17.101
master-user = rep
master-password = eyou
master-port = 3306
master-connect-retry = 60
replicate-do-db = reptest
log-slave-updates
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
yanyp 回复于:2005-10-21 17:16:12
这是我刚实践过的配置文件
北京野狼 回复于:2005-10-24 09:29:55
这样的配置,不能互备
ginew 回复于:2005-10-27 16:26:03
用好replicate-do-db,replicate-do-table,replicate-ignore-db,replicate-ignore-table等几个参数的话,完全可以实现互相备份的。
楼上那个配置,好像有问题。是否贴错了。
yanyp 回复于:2005-10-27 19:57:38
没错,我做的就是这样的,可能有些参数我还不很熟悉,但可以肯定实现互备
paulgao 回复于:2005-10-29 15:17:51
集群对查询性能要求特别高的情况下,比如每秒上百条数据的插入删除,并不适用。
zmcjs 回复于:2005-10-30 18:09:09
就是就是,在技术上大家一定要谦虚谨慎,不骄不躁,互相学习,共同进步!
yanyp 回复于:2005-10-30 20:47:40
cluster是cluster,互备是互备,不一样的概念
正如oracle的standby和rac一样,概念不一样的
北京野狼 回复于:2005-10-31 09:45:12
引用:原帖由 yanyp 于 2005-10-30 20:47 发表
cluster是cluster,互备是互备,不一样的概念
正如oracle的standby和rac一样,概念不一样的
请把你互备的表结构给大家看看
asus52x 回复于:2005-11-05 00:08:43
萝卜白菜,各有所爱,各取所需,在这里请讨论技术,不要搞人身攻击,请各位自重。
北京野狼 回复于:2005-11-07 09:52:36
引用:原帖由 asus52x 于 2005-11-5 00:08 发表
萝卜白菜,各有所爱,各取所需,在这里请讨论技术,不要搞人身攻击,请各位自重。
那个马甲?
不存在的东西也叫技术?
wuruichang 回复于:2005-11-17 12:41:43
看了上面有人提到互备的事,我可以很肯定的告诉大家,mysql互为备份是可以的。至于是否采用,则看各自需求而定
dadait 回复于:2005-11-17 18:03:40
有没有人可以译成简体中文的呀?
看不懂!~~
eyekllo 回复于:2005-12-01 15:35:05
真不懂里面的冬冬,公司很小!不知道说的对还是不对。
xueyh 回复于:2005-12-07 16:30:14
sina 用的是 mysql??
真的吗?
佛光普照 回复于:2005-12-12 08:43:50
看了这么多,没有哪位能说一说需要采用互备和集群的条件,到底您的数据库达到什么样的要求时需要采用互备,在我看来,一般的数据数量无需动用集群什么的,因为你只需要把数据库文件备份了,MYSQL数据运行停掉或者无故中断的错误较少发生。那么如果想达到某台机的硬件故障而不中断服务的话可以采用备用服务器。共享数据库文件(后端存储)就行了。。这样性格也保证了。。。如果您的数据库很大,建议及时更换大型数据库,哈哈!
gzhuli 回复于:2005-12-12 12:58:39
MySQL确实可以互备,官方的说明书也有说到的。关键是互备是有前提条件的,例如不能用auto_increment的Primary Key,查询的设计也要有特别考虑。光这两点,估计一开始不是专门针对互备而设计的数据库结构,基本上都用不了。
如果实现了互备,再加上一台load balancer,就是群集结构了,可以做到自动failover。
而NDB,是可以允许原有数据库的无缝迁移的,这就是开发它的意义所在。至于效率和稳定性,这是另一方面了,想当初MySQL 3.23用的首选事务表引擎是BDB,经常就莫名其妙崩掉,现在InnoDB不是挺好的?凡事总要有个发展过程的。
|