×÷ÕߣºmiFor
**********************************************************
µÚÒ»²¿·Ö,¡¡ÔÚһ̨·þÎñÆ÷¹¹½¨¶àmysql ·þÎñ.
**********************************************************
Ò»£¬Ð÷ÑÔ
ÔÚMysqlÖÐÓÐÒ»mysqld_multiÃüÁ¿ÉÓÃÓÚÔÚһ̨ÎïÀí·þÎñÆ÷ÔËÐжà¸öMysql·þÎñ£¬½ñÌì²Î¿¼Ò»Ð©Îĵµ£¬Ç××Ô²âÊÔ²¢Í¨¹ý,Õæ¸ßÐË£¬ÏÖ½«²Ù×÷¹ý³Ì¹²Ïí¸ø´ó¼Ò!
²Ù×÷ϵͳ:Linux 2.6.13 (Slackware),ÆäËü°æµÄLinuxÓ¦¸ÃÒ²²î²»¶à.
Êý¾Ý¿â:Mysql 4.0.17 Ô´³ÌÐò°²×°(ÏàÐÅ×îеÄ5.1.*Ò²²î²»¶à£¬¹ýЩÌìÔÙÊÔÊÔ)
¹æ»®:ÔËÐÐ4¸ömysql·þÎñ:
¼ÙÉè·þÎñÆ÷Ãû:db-app (IPΪ192.168.0.100),
¼ÙÉè·þÎñÆ÷Ãû:db-app2 (IPΪ192.168.0.101),
ÏÂÎÄÖ±µ½µÚ¶þ²¿·Ö,¾ùΪ½²Êödb-appÖеÄmysql,
¶þ,×¼±¸
ÓÃmysqlÔ´³ÌÐò°²×°,¼ÙÉèÔÚ°²×°Ê±ÓõÄconfiguraÑ¡ÔñÏîÂÈ?
./configure --prefix=/usr/local/mysql --datadir=/usr/local/mysql/data1 --sysconfdir=/etc
±¸×¢:--prefix½«MYSQL°²×°µ½/usr/local/mysql,
--datadir½«Êý¾Ý¿âÉú³É/usr/local/mysql/data1
sysconfdirÊÇÖ¸¶¨mysqlʹÓõ½µÄmy.cnfÅäÖÃÎļþµÄËÑË÷·¾¶Îª/etc
ÆäËûmysql°²×°¹ý³ÌÂÔ.
¸ù¾ÝMysql¹ÜÀíÊÖ²áÖÐÌáµ½:ÿ¸öMysqlµÄ·þÎñ¶¼¿ÉΪ¶ÀÁ¢µÄ£¬ËùÒÔËü¶¼µ÷ÓÃÒ»¸ömy.cnfÖи÷×Ô²»Í¬µÄÆô¶¯Ñ¡Ïî--¾ÍÊÇÏÂÎÄÖн«Ìáµ½µÄGNRÖµ,ʹÓò»Í¬µÄ¶Ë¿Ú,Éú³É¸÷×ÔµÄÌ×½ÓÎļþ,·þÎñµÄÊý¾Ý¿â¶¼ÊǶÀÁ¢µÄ(¸ü¶à¿É²éÔÄmysql¹Ù·½ÍøÕ¾µÄÓ¢ÎĹÜÀíÊÖ²á).
mysqld_multiÊǹÜÀí¶à¸ömysqldµÄ·þÎñ½ø³Ì£¬ÕâЩ·þÎñ½ø³Ì³ÌÐò²»Í¬µÄunix socket»òÊǼàÌýÓÚ²»Í¬µÄ¶Ë¿Ú¡£Ëû¿ÉÒÔÆô¶¯¡¢Í£Ö¹ºÍ¼à¿Øµ±Ç°µÄ·þÎñ״̬¡£
----³ÌÐòÔÚmy.cnf(»òÊÇÔÚ--config-file×Ô¶¨ÒåµÄÅäÖÃÎļþ)ÖÐËÑË÷[mysqld#]¶Î£¬"#"¿ÉÒÔÊÇÈÎÒâµÄÕýÕûÊý¡£Õâ¸öÕýÕûÊý¾ÍÊÇÔÚÏÂÃæÌá¼°µÄ¶ÎÐòÁУ¬¼´GNR¡£¶ÎµÄÐòºÅ×öΪmysqld_multiµÄ²ÎÊý£¬À´Çø±ð²»Í¬µÄ¶Î£¬ÕâÑùÄã¾Í¿ÉÒÔ¿ØÖÆÌض¨mysqld½ø³ÌµÄÆô¶¯¡¢Í£Ö¹»òµÃµ½ËûµÄ±¨¸æÐÅÏ¢¡£ÕâЩ×éÀïµÄ²ÎÊý¾ÍÏñÆô¶¯Ò»¸ömysqldËùÐèÒªµÄ×éµÄ²ÎÊýÒ»Ñù¡£µ«ÊÇ£¬Èç¹ûʹÓöà·þÎñ£¬±ØÐëΪÿ¸ö·þÎñÖ¸¶¨Ò»¸öunix socket»ò¶Ë¿Ú(Õª×Ôhttp://mifor.4dian.orgÖеÄʹÓÃmysqld_multi³ÌÐò¹ÜÀí¶à¸öMySQL·þÎñ )¡£
´ÓÉÏÊöÎÄ×Ö¿É¿´µ½¶àMysql·þÎñÖÐ×îÖØÒªµÄ¾ÍÊÇmy.cnfÅäÖÃÎļþÁË.
ÏÖÎÒÌù³öÎÒµÄmy.cnfÎļþ.-----------------------
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = mysql (ÓÃÒ»¸öÕʺÅÀ´Æô¶¯ËùÓеÄmysql·þÎñÆ÷,ÒòΪÊÇÓÃÒ»ÏàͬµÄÕʺš£ÄǸöôÕâÕʺűØÐ붼ÊÇÿ¸ömysql·þÎñ¶¼ÒªÓõÄÕʺÅ,×îºÃÊǹÜÀíÕʺÅ,ÏÂÃæµÄ¿ÚÁîÓëÏàͬ)
password = mypaswd
[mysqld1]
port = 3306
socket = /tmp/mysql.sock1
pid-file=/usr/local/mysql/data1/db-app1.pid
log=/usr/local/mysql/data1/db-app.log
datadir = /usr/local/mysql/data
user = mysql
[mysqld2]
port = 3307
socket = /tmp/mysql.sock2
pid-file = /usr/local/mysql/data2/db-app2.pid
datadir = /usr/local/mysql/data2
log=/usr/local/mysql/data2/db-app.log
user = mysql
[mysqld3]
port = 3308
socket = /tmp/mysql.sock3
pid-file = /usr/local/mysql/data3/db-app3.pid3
datadir = /usr/local/mysql/data3
log=/usr/local/mysql/data3/db-app.log
user = mysql
[mysqld4]
port = 3309
socket = /tmp/mysql.sock4
pid-file = /usr/local/mysql/data3/db-app4.pid
datadir = /usr/local/mysql/data4
log=/usr/local/mysql/data4/db-app.log
user = mysql
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
ÎÒµÄÅäÖÃÎļþÖÐÓÐmysqld1,mysqld2,mysqld3,mysqld4¡£¾ÍÊÇ˵ÎÒ½«Æô¶¯4¸ömysql·þÎñÔÚͬһ·þÎñÆ÷µÄ²»Í¬¶Ë¿Ú----3306-3309£¬Ã¿datadirËùÖ¸¶¨µÄÊý¾Ý¿âÎļþ·¾¶¶¼ÊDz»ÏàͬµÄ£¬¶¼Óи÷×Ô²»Í¬µÄÈÕÖ¾Îļþ¡£ÆäËüһЩÉèÖÿÉÓÃmy.cnf ÔÀ´µÄÄÚÈÝ.
ok, ÖØÒªµÄmy.cnf±àºÃµÄ£¬ÏÖÔÚΪÅäÖÃÖв»Í¬mysql ·þÎñ½¨Á¢¸÷×ÔÎļþ¼ÐºÍ³õʼÊý¾Ý¿âµÈ.
[mysqld1]ÊÇÒ»¸öĬÈϵÄ,ÔÚÎÒÃÇ°²×°mysqlʱÒѾÓÐÁË£¬ËùÒÔ²»ÓùÜËü.
[mysqld2],Ö»Òª¸ù¾ÝÅäÖþ͵Ä·¾¶ÎªËü½¨Á¢Ò»¸öĿ¼¾Í¿ÉÒÔÁË.½«°Ñ¸ÃĿ¼¸ÄΪmysql¹ÜÀíȨ
db-app:/ # mkdir /usr/local/mysql/data2
½¨Êý¾Ý¿â,ÎÒÃÇ¿ÉÒÔ°ÑĬÈϵÄmysqlÊý¾Ý¿â¸´ÖƹýÀ´£¬ÒÔÀûÓÃÆäËüµÄmysqlÕʺÅ,ÆäËüÊý¾Ý¿â¸ù¾ÝÓ¦ÓÃÔÙ½¨Á¢.
db-app:/ # cp /usr/local/mysql/data1/mysql /usr/local/mysql/data2 -R
db-app:/ # chmod mysql.mysql /usr/local/mysql/data2 -R
[mysqld3],[mysqld4], Ïàͬ.
ÎÒÃÇ¿ÉÄÜ¿´¿´ÕâЩĿ¼ÊÇ·ñ¶¼´æÔÚ.
db-app:/ # ls -l /usr/local/mysql/
drwxr-xr-x 6 mysql mysql 4096 Apr 9 17:54 data4
drwxr-x--- 2 mysql mysql 4096 Apr 9 17:14 data1
drwxr-xr-x 3 mysql mysql 4096 Apr 9 17:54 data2
drwxr-xr-x 3 mysql mysql 4096 Apr 9 17:54 data3
ÏÖÔÚ¿ÉÒÔͨ¹ýmysqld_multiÆô¶¯ÁË¡£
Èý,mysqld_multiÃüÁî.
ʹÓÃÈçϲÎÊýÀ´Æô¶¯mysqld_multi: (×¢:¸ÃÃüÁîÔÚmysqlµÄbinĿ¼ÖÐ,¸ù¾ÝÉÏÃæËùÌáµ½./configure --prefix=/usr/local/mysql ,ËùÒÔ¸ÃÎļþÓ¦¸ÃÔÚ /usr/local/mysq/bin, ÕâµÃ¸ù¾ÝÄ㰲װʱËùÖ¸¶¨µÄ·¾¶ )
db-app:/ # mysqld_multi [options] {start|stop|report} [GNR[,GNR]...]
start,stopºÍreportÊÇÖ¸ÄãÏëµ½Ö´ÐеIJÙ×÷¡£Äã¿ÉÒÔÔÚµ¥¶ÀµÄ·þÎñ»òÊǶà·þÎñÉÏÖ¸¶¨Ò»¸ö²Ù×÷£¬Çø±ðÓÚÑ¡ÏîºóÃæµÄGNRÁÐ±í¡£Èç¹ûûÓÐÖ¸¶¨GNRÁÐ±í£¬ÄÇômysqld_multi½«ÔÚËùÓеķþÎñÖиù¾ÝÑ¡ÏîÎļþ½øÐвÙ×÷¡£
ÿһ¸öGNRµÄÖµÊÇ×éµÄÐòÁкŻòÊÇÒ»¸ö×éµÄÐòÁкŷ¶Î§¡£´ËÏîµÄÖµ±ØÐëÊÇ×éÃû×Ö×îºóµÄÊý×Ö£¬±ÈÈç˵Èç¹û×éÃûΪmysqld17£¬ÄÇô´ËÏîµÄÖµÔòΪ17.Èç¹ûÖ¸¶¨Ò»¸ö·¶Î§£¬Ê¹ÓÃ"-"(ÆÆÕÛºÅ)À´Á¬½Ó¶þ¸öÊý×Ö¡£ÈçGNRµÄֵΪ10-13,ÔòÖ¸×émysqld10µ½×émysqld13¡£¶à¸ö×é»òÊÇ×鷶Χ¿ÉÒÔÔÚÃüÁîÐÐÖÐÖ¸¶¨£¬Ê¹ÓÃ","(¶ººÅ)¸ô¿ª¡£²»ÄÜÓпհ׵Ä×Ö·û(Èç¿Õ¸ñ»òtab)£¬ÔÚ¿Õ°××Ö·ûºóÃæµÄ²ÎÊý½«»á±»ºöÂÔ¡£ (×¢:GNRÖµ¾ÍÊÇÎÒÃǶ¨Òåmy.cnfÖÐmysqld#ÖеÄÖµ,ÎÒÕâÀïÖ»ÓÐ1-4).
db-app:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf start 1 Ö»Æô¶¯ µÚÒ»¸ömysql·þÎñ,Ïà¹ØÎļþÓÉmy.cnfÖÐmysql1É趨.
db-app:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf stop 1 ÆôÖ¹ µÚÒ»¸ömysql·þÎñ
db-app:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf start 1-4, Æô¶¯ µÚ1ÖÁ4mysql·þÎñ,Æäʵ¾ÍÊÇÎÒÕâÀïµÄÈ«²¿.
db-app:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf report 1-4
²é¿´Æô¶¯:
db-app:/ # ps aux
root 10467 0.0 0.2 2712 1300 pts/0 S 18:59 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3306 --socket=/tmp/mysql.sock1
root 10475 0.0 0.2 2712 1300 pts/0 S 18:59 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3307 --socket=/tmp/mysql.sock2
root 10482 0.0 0.2 2716 1300 pts/0 S 18:59 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3308 --socket=/tmp/mysql.sock3
root 10487 0.0 0.2 2716 1300 pts/0 S 18:59 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3309 --socket=/tmp/mysql.sock4
.............................................
ËÄ,¿Í»§¶Ë·ÃÎÊ
Èκοͻ§¶Ë·ÃÎʶ¼ÐèÒªÖ¸¶¨·ÃÎʶ˿Ú.·½²ÅÄܽøÈëÖ¸¶¨Êý¾Ý¿â·þÎñ.·ñÔò½«Ê¹Óõ½MysqlĬÈϵĶ˿ڣ¨3306£©Ëù·þÎñµÄMYSQL¡£
**********************************************************
µÚ¶þ²¿·Ö,¡¡ÔÚһ̨·þÎñÆ÷¹¹½¨¶àmysqlÖ÷ ·þÎñ.
**********************************************************
Ìáʾ:½¨Á¢Ò»¸öÕʺÅ,רÃÅÓÃÓÚÏÂÃæÖ÷´Ó¸´ÖÆ,±¾ÀýÓõĵÄÕʺÅrepl, ¿ÚÁîΪ:'1234567890', ¿ÉÈÃÆäÓµÓÐselect_priv, reload_priv,process_priv,grant_priv,super_priv,repl_slave_priv,repl_client_privȨÏÞ£¬²¢ÄÜͨ¹ýÈκοͻ§½øÐзÃÎÊ,¼´·ÃÎÊ¿Í»§Îª'%'¡£
Ö÷ÒªÊÇÐÞ¸Ämy.cnfÖеÄÄÚÈÝ,ÈÃÿ¸ömysqlÉú³É×Ô¼ºµÄbin-logÎļþ¼°¸÷×ÔµÄÔËÐл·¾³£¬ÏÖÌùÉÏÎÒµÄmy.cnfÈ«²¿ÄÚÈÝ,Ïà¹Ø²ÎÊýÓëÇë²Î¿¼mysql ¹ÙÎÄÊÖ²á.
#[client]
#password = your_password
#port = 3306
#socket = /tmp/mysql.sock
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = mysql
password = mypasswd
[mysqld1]
port = 3306
socket = /tmp/mysql.sock1
skip-locking
pid-file=/usr/local/mysql/data/net-app1a.pid
datadir = /usr/local/mysql/data
log=/usr/local/mysql/data/net-app1.log
user = mysql
log-slow-queries=/usr/local/mysql/data/slowquery.log
long_query_time = 2
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
myisam_sort_buffer_size = 64M
thread_cache = 32
query_cache_size = 32M
thread_concurrency = 2
max_connections=500
log-bin
log-bin=/usr/local/mysql/data/app-net1_1-bin
server-id = 1
[mysqld2]
port = 3307
socket = /tmp/mysql.sock2
pid-file = /usr/local/mysql/data2/net-app1b.pid
datadir = /usr/local/mysql/data2
log=/usr/local/mysql/data2/net-app1.log
user = mysql
log-slow-queries=/usr/local/mysql/data2/slowquery.log
long_query_time = 10
key_buffer = 128M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 1M
read_buffer_size = 1M
myisam_sort_buffer_size = 32M
thread_cache = 32
query_cache_size = 16M
thread_concurrency = 2
max_connections=300
log-bin
log-bin=/usr/local/mysql/data2/app-net1_2-bin
server-id = 1
[mysqld3]
port = 3308
socket = /tmp/mysql.sock3
skip-locking
pid-file = /usr/local/mysql/data3/net-app1c.pid
datadir = /usr/local/mysql/data3
log=/usr/local/mysql/data3/net-app1.log
user = mysql
log-bin
log-bin=/usr/local/mysql/data3/app-net1_3-bin
server-id = 1
[mysqld4]
port = 3309
socket = /tmp/mysql.sock4
skip-locking
pid-file = /usr/local/mysql/data1/app-net1d.pid
datadir = /usr/local/mysql/data1
log=/usr/local/mysql/data1/net-app1.log
user = mysql
log-bin
log-bin=/usr/local/mysql/data1/app-net1_4-bin
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
**********************
Æô¶¯¶àmysql·þÎñ¶¼ÊÇÏàͬµÄ,
db-app:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf start 1-4
**********************************************************
µÚÈý²¿·Ö, ÔÚһ̨·þÎñÆ÷¹¹½¨¶àmysql ´Ó·þÎñ.
**********************************************************
¹¹½¨´Ó·þÎñÆ÷µÄԤѡ׼±¸: ½¨ÒéÓÃmysqld_multi °ÑÖ÷·þÎñÆ÷µÄmysqlÈ«²¿Í£µô.ɾ³ýÊý¾ÝĿ¼ÖеÄËùÓгýÊý¾Ý¿âĿ¼ÒÔÍâµÄÈκÎÎļþ(´ËÎÄÖеÄÊý¾ÝĿ¼¿âÓУ´¸ö,datadir = /usr/local/mysql/ÖÐµÄ data1 -- data1)£®½¨Ö÷´Ó¶¼ÓÃÏàͬµÄÊý¾ÝĿ¼·¾¶£®
ÓÃTar ÃüÁî°ÑÿÊý¾Ý¿â·â×°ÆðÀ´£¬²¢Í¨¹ýsftpÃüÁîput/getµ½´Ó·þÎñÆ÷(db-app1 192.168.0.101).
ÏÂÁвÙ×÷¹©²Î¿¼:
ÔÚdb-appÖ÷»úÉϵIJÙ×÷
db-app:/ # tar -cf data1.tar /usr/local/mysql/data1
db-app:/ # tar -cf data2.tar /usr/local/mysql/data2
db-app:/ # tar -cf data3.tar /usr/local/mysql/data3
db-app:/ # tar -cf data4.tar /usr/local/mysql/data4
ÔÚdb-app1Ö÷»úÉϵIJÙ×÷
db-app1:/ # tar xvf data1.tar
db-app1:/ # tar xvf data2.tar
db-app1:/ # tar xvf data3.tar
db-app1:/ # tar xvf data4.tar
ͬʱ£¬ÇëÈ·ÈÏϵͳÕʺÅmysqlÊÇ·ñ¶ÔÖ÷/´Ó·þÎñÆ÷µÄÖеÄmysqlÊý¾ÝĿ¼¶¼ÓвÙ×÷ȨÏÞ£¬Èç¹ûÎÞ·¨È·ÈÏ£¬ÄãÖ±½Ó¸üÐÞ¸ÄÕâЩĿ¼µÄËùÓÐȨ¼´¿É¡£
ÔÚdb-appÖ÷»úÉϵIJÙ×÷
db-app:/ # chown mysql.mysql /usr/local/mysql/data1 -R
db-app:/ # chown mysql.mysql /usr/local/mysql/data2 -R
db-app:/ # chown mysql.mysql /usr/local/mysql/data3 -R
db-app:/ # chown mysql.mysql /usr/local/mysql/data4 -R
ÔÚdb-app1Ö÷»úÉϵIJÙ×÷
db-app1:/ # chown mysql.mysql /usr/local/mysql/data1 -R
db-app2:/ # chown mysql.mysql /usr/local/mysql/data2 -R
db-app3:/ # chown mysql.mysql /usr/local/mysql/data3 -R
db-app4:/ # chown mysql.mysql /usr/local/mysql/data4 -R
ÏÂÃæ¾ÍÊÇ´Ó·þÎñÆ÷ÉÏ/etc/my.cnfµÄÈ«²¿ÄÚÈÝ.
Ìáʾ:ÏÂÃæµÄmy.cnfÖн«»áÌáµ½Ò»¸öÕʺÅ:repl, ¿ÚÁîΪ:'1234567890', Õâ¸öÕʺžÍÊÇÉÏÃæרÃŽ¨Á¢µÄ¡£
Æäʵ¶¼Ò»Ñù,Ö÷ÒªÊÇÐÞ¸Ämy.cnfÖеÄÄÚÈÝ,ÈÃÿ¸ö´Ómysqlͨ¹ýÖ÷mysqlµÄ²»Í¬µÄ¶Ë¿Ú,È¥»ñÈ¡¸÷×Ôbin-logÀ´¸üÐÂ×ÔÉúµÄÊý¾Ý¿âÄÚÈÝ£®ÏÖÌùÉÏÎÒµÄmy.cnfÈ«²¿ÄÚÈÝ(´Ó·þÎñÆ÷),Ïà¹Ø²ÎÊýÓëÇë²Î¿¼mysql ¹ÙÎÄÊÖ²á.
#[client]
#password = your_password
#port = 3306
#socket = /tmp/mysql.sock
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = mysql
password = netmoniit
[mysqld1]
port = 3306
socket = /tmp/mysql.sock1
skip-locking
pid-file=/usr/local/mysql/data/net-app1a.pid
datadir = /usr/local/mysql/data
log=/usr/local/mysql/data/net-app1.log
user = mysql
log-slow-queries=/usr/local/mysql/data/slowquery.log
long_query_time = 2
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
myisam_sort_buffer_size = 64M
thread_cache = 32
query_cache_size = 32M
thread_concurrency = 2
max_connections=500
server-id = 2
master-host = 192.168.0.100
master-user = 'repl'
master-password = '1234567890'
master-port = 3309
report-host = net-app1
master-connect-retry = 30
log-bin
log-slave-updates
[mysqld2]
port = 3307
socket = /tmp/mysql.sock2
pid-file = /usr/local/mysql/data2/net-app1b.pid
datadir = /usr/local/mysql/data2
log=/usr/local/mysql/data2/net-app1.log
user = mysql
log-slow-queries=/usr/local/mysql/data2/slowquery.log
long_query_time = 10
key_buffer = 128M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 1M
read_buffer_size = 1M
myisam_sort_buffer_size = 32M
thread_cache = 32
query_cache_size = 16M
thread_concurrency = 2
max_connections=300
server-id = 2
master-host = 192.168.0.100
master-user = 'repl'
master-password = '1234567890'
master-port = 3309
report-host = net-app1
master-connect-retry = 30
log-bin
log-slave-updates
[mysqld3]
port = 3308
socket = /tmp/mysql.sock3
pid-file = /usr/local/mysql/data3/net-app1c.pid
datadir = /usr/local/mysql/data3
log=/usr/local/mysql/data3/net-app1.log
user = mysql
log-slow-queries=/usr/local/mysql/data3/slowquery.log
long_query_time = 10
key_buffer = 128M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 1M
read_buffer_size = 1M
myisam_sort_buffer_size = 32M
thread_cache = 32
query_cache_size = 16M
thread_concurrency = 2
max_connections=300
server-id = 2
master-host = 192.168.0.100
master-user = 'repl'
master-password = '1234567890'
master-port = 3309
report-host = net-app1
master-connect-retry = 30
log-bin
log-slave-updates
[mysqld3]
port = 3308
socket = /tmp/mysql.sock4
pid-file = /usr/local/mysql/data4/net-app1d.pid
datadir = /usr/local/mysql/data4
log=/usr/local/mysql/data4/net-app1.log
user = mysql
log-slow-queries=/usr/local/mysql/data4/slowquery.log
long_query_time = 10
key_buffer = 128M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 1M
read_buffer_size = 1M
myisam_sort_buffer_size = 32M
thread_cache = 32
query_cache_size = 16M
thread_concurrency = 2
max_connections=300
server-id = 2
master-host = 192.168.0.100
master-user = 'repl'
master-password = '1234567890'
master-port = 3309
report-host = net-app1
master-connect-retry = 30
log-bin
log-slave-updates
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
****************************************
ÔÚ¹¦¸æ³É,ÏÖÔÚ·Ö±ðÆô¶¯Á½Ì¨Ö÷»úÉϵĶàmysql·þÎñ£¬ÕâÑù£¬Ã¿¸öÖ÷·þÎñµÄÿ¸ömysqlÓб仯£¬¶¼»á×Ô¶¯¸´ÖÆ£¯¸üе½´Ó·þÎñÆ÷¶ÔÓ¦µÄÊý¾Ý¿âÖС£
db-app:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf start 1-4
db-app1:/ # /usr/local/mysq/bin/mysqld_multi --config-file=/etc/my.cnf start 1-4
********************
Îå,δÀ´²âÊÔ,
½ÓÏÂÀ´ÎÒÏë×öÒ»¸ö¶àÖ÷Ò»´ÓµÄMysql·þÎñÆ÷¸´Öƽâ¾ö·½°¸!¡¡ÄÇλ¿ÉÒÔ¸øµãÒâ¼û°¡!½á¹¹ÈçÏ£®
¾ÍÊÇÓÐÖ÷·þÎñÆ÷Server A , Server BºÍ´Ó·þÎñÆ÷ Server C, A ºÍ BÔËÐÐ×Ų»Í¬µÄÊý¾Ý¿âÓ¦ÓÃ, ¼ÙÉèÊý¾Ý¿âÃû¶¼²»Í¬¡£Server C£¨¼ÙÉèÕâÈý̨£Ð£ÃÉ϶¼Ö»ÔËÐÐÁËÒ»¸ömysql·þÎñ£©£¬°üÀ¨ÁË£ÁÁˣ·þÎñÆ÷µÄËùÓÐMysql Óû§¼°ÏàͬµÄ·ÃÎÊȨÏÞ, ²¢¼¯³ÉÔÚÒ»¸öMysql·þÎñÖÐ. Cͨ¹ýÖ÷/´Ó·½Ê½¸´ÖÆ£ÁºÍ£ÂµÄÊý¾Ý¿â¡£
¾ÍÊDz¾ÍÊÇ°ÑÁ½¸öÖ÷·þÎñÆ÷µÄmysqlºÏ²¢µ½Ò»¸ö´Ó·þÎñÆ÷ÖÐ.