| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> mysql >> pei zhi gao ke yong xing de MySQL fu wu qi fu zai yun heng qun ji

pei zhi gao ke yong xing de MySQL fu wu qi fu zai yun heng qun ji

2008-06-01 03:13:59 编辑來源:互联网 评论
 
 
 
本文为【配置高可用性的MySQL服务器负载均衡群集】的拼音翻译版
  zhe pian lun tan wen zhang ( sai di wang ji shu she qu ) zhu yao jie shao le pei zhi yi ge gao ke yong xing de MySQL fu wu qi fu zai yun heng qun ji de ju ti guo cheng , xiang xi nei rong qing shen kao xia wen :
  ben wen jiang gao su ni ru he pei zhi yi ge san ge jie dian de MySQL 5 shu ju ku fu wu qi qun ji : liang ge cun chu jie dian he yi ge
  guan li jie dian 。 zhe ge qun ji shi you yong ti gong “heartbeat xin tiao ”( yong lai jian cha ling wai yi ge jie dian shi fou huo dong ) he
  “ldirectord”( jiang qing qiu fen fa dao MySQL qun ji de jie dian ) de Ultra Monkey an zhuang bao de liang ge jie dian zu cheng de
  yi ge gao ke yong xing fu zai yun heng qi 。
  ben wen wo men de mei ge jie dian shi yong Debian Sarge Linux xi tong 。 qi ta Linux fa xing ban ben de an zhuang ke neng yi dian dian
  qu bie 。MySQL de ban ben wo men shi yong 5.0.19。 ru guo ni bu xiang shi yong MySQL 5, ni ye ke yi shi yong MySQL 4.1, jin
  guan wo huan mei you ce shi guo 。
  ben wen shi yi pian shi jian ying yong zhi dao ; ta mei you she ji tai duo de li lun 。 guan yu qun ji de li lun ni ke yi zai wang shang zhao dao hen duo 。
  yi fu wu qi
  wo shi yong xia mian de Debian fu wu qi , ta men dou zai tong yi ge wang duan ( ben li ru :192.168.0.x):
  sql1.test.com: 192.168.0.101 MySQL qun ji jie dian 1
  sql2.test.com: 192.168.0.102 MySQL qun ji jie dian 2
  loadb1.test.com: 192.168.0.103 fu zai yun heng 1 / MySQL qun ji guan li fu wu qi
  loadb2.test.com: 192.168.0.104 fu zai yun heng 2
  ling wai wo men xu yao yi ge xu ni IP di zhi :192.168.0.105。 ta hui an pai gei zhe ge MySQL qun ji de fu zai yun heng , yi bian yu
  ying yong cheng xu tong guo tong yi dan du de IP di zhi lai fang wen qun ji 。
  jin guan wo men xiang zai MySQL qun ji zhong shi yong liang ge jie dian , dan shi wo men reng ran xu yao di san ge jie dian ,MySQL qun ji guan li fu wu qi
  , zhu yao de yi ge yuan yin shi : ru guo qi zhong yi ge MySQL qun ji jie dian huai le , er MySQL qun ji guan li fu wu qi mei you yun xing , na
  me liang ge qun ji jie dian shang de shu ju jiang hui bu yi zhi (“split brain”)。 wo men xu yao ta lai pei zhi MySQL qun ji .
  yin ci wo men de an zhuang yi ban xu yao wu tai ji qi :
  2 ge MySQL qun ji jie dian + 1 ge qun ji guan li fu wu qi + 2 ge fu zai yun heng = 5
  yin wei qun ji guan li fu wu qi mei you shi yong duo shao zi yuan , xi tong jiang hui kong zhe shen me dou bu zuo , suo yi wo men ke yi ba wo men de di yi
  ge fu zai yun heng he ta yi qi fang zai tong yi tai ji qi shang , zhe yang ke yi jie yue wo men yi tai fu wu qi , suo yi zui hao wo men zhi xu yao si tai
  ji qi 。
  er pei zhi MySQL qun ji guan li fu wu qi
  shou xian wo men yao xia zai MySQL 5.0.19, bing an zhuang qun ji guan li fu wu qi (ndb_mgmd) he qun ji guan li ke hu duan (ndb_mgm - ta
  ke yi yong lai jian kong qun ji de yun xing qing kuang ). xia mian de bu zhou shi zai loadb1.test.com (192.168.0.103) shang jin xing de :
  loadb1.test.com:
  mkdir /usr/src/mysql-mgm
  cd /usr/src/mysql-mgm
  wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-max-5.0.19-linux-i686-\
  glibc23.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
  tar xvfz mysql-max-5.0.19-linux-i686-glibc23.tar.gz
  cd mysql-max-5.0.19-linux-i686-glibc23
  mv bin/ndb_mgm /usr/bin
  mv bin/ndb_mgmd /usr/bin
  chmod 755 /usr/bin/ndb_mg*
  cd /usr/src
  rm -rf /usr/src/mysql-mgm
  xia yi bu , wo men bi xu chuang jian qun ji de pei zhi wen jian ,/var/lib/mysql-cluster/config.ini:
  loadb1.test.com:
  mkdir /var/lib/mysql-cluster
  cd /var/lib/mysql-cluster
  vi config.ini
  ———-
  [NDBD DEFAULT]
  NoOfReplicas=2
  [MYSQLD DEFAULT]
  [NDB_MGMD DEFAULT]
  [TCP DEFAULT]
  # Section for the cluster management node
  [NDB_MGMD]
  # IP address of the management node (this system)
  HostName=192.168.0.103
  # Section for the storage nodes
  [NDBD]
  # IP address of the first storage node
  HostName=192.168.0.101
  DataDir= /var/lib/mysql-cluster
  [NDBD]
  # IP address of the second storage node
  HostName=192.168.0.102
  DataDir=/var/lib/mysql-cluster
  # one [MYSQLD] per storage node
  [MYSQLD]
  [MYSQLD]
  ———-
  shi ji ying yong zhong qing jiang wen jian zhong de IP di zhi huan cheng ni xiang ying de IP。
  
  ran hou wo men qi dong qun ji guan li fu wu qi :
  loadb1.test.com:
  ndb_mgmd -f /var/lib/mysql-cluster/config.ini
  wo men ying gai ye xu yao zai fu wu qi qi dong shi neng gou zi dong qi dong guan li fu wu qi , suo yi wo men chuang jian le yi ge fei chang jian dan de chu shi hua
  jiao ben he xiang ying de qi dong lian jie :
  loadb1.test.com:
  echo ‘ndb_mgmd -f /var/lib/mysql-cluster/config.ini’ > /etc/init.d/ndb_mgmd
  chmod 755 /etc/init.d/ndb_mgmd
  update-rc.d ndb_mgmd defaults
  san pei zhi MySQL qun ji jie dian ( cun chu jie dian )
  xian zai wo men jiang fen bie zai sql1.test.com he sql2.test.com shang an zhuang mysql-max-5.0.19:
  sql1.example.com / sql2.example.com:
  groupadd mysql
  useradd -g mysql mysql
  cd /usr/local/
  wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-max-5.0.19-linux-i686-\
  glibc23.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
  tar xvfz mysql-max-5.0.19-linux-i686-glibc23.tar.gz
  ln -s mysql-max-5.0.19-linux-i686-glibc23 mysql
  cd mysql
  scripts/mysql_install_db –user=mysql
  chown -R root:mysql .
  chown -R mysql data
  cp support-files/mysql.server /etc/init.d/
  chmod 755 /etc/init.d/mysql.server
  update-rc.d mysql.server defaults
  cd /usr/local/mysql/bin
  mv * /usr/bin
  cd ../
  rm -fr /usr/local/mysql/bin
  ln -s /usr/bin /usr/local/mysql/bin
  ran hou wo men zai mei ge jie dian shang chuang jian MySQL pei zhi wen jian /etc/my.cnf :
  vi /etc/my.cnf
  –
  [mysqld]
  ndbcluster
  # IP address of the cluster management node
  ndb-connectstring=192.168.0.103
  [mysql_cluster]
  # IP address of the cluster management node
  ndb-connectstring=192.168.0.103
  –
  que ren ni zai qun ji guan li fu wu qi zhong shu ru de shi zheng que de IP di zhi 。
  xia yi bu wo men fen bie zai mei ge qun ji jie dian shang chuang jian shu ju mu lu he qi dong MySQL fu wu qi :
  sql1.test.com / sql2.test.com:
  mkdir /var/lib/mysql-cluster
  cd /var/lib/mysql-cluster
  ndbd –initial
  /etc/init.d/mysql.server start
  ( qing ji zhu : wo men zhi shi zai di yi ci qi dong MySQL shi huo loadb1.test.com shang mian de
  /var/lib/mysql-cluster/config.ini fa sheng gai bian shi , cai shi yong ndbd –initial)
  xian zai , shi shi hou gei MySQL root zhang hao she zhi mi ma le :
  sql1.test.com / sql2.test.com:
  mysqladmin -u root password yourrootsqlpassword
  wo men xu yao zai fu wu qi qi dong shi , qi dong qun ji jie dian , suo yi wo men chuang jian yi ge ndbd chu shi hua jiao ben he xiang ying de
  xi tong qi dong lian jie :
  sql1.test.com / sql2.test.com:
  echo ‘ndbd’ > /etc/init.d/ndbd
  chmod 755 /etc/init.d/ndbd
  update-rc.d ndbd defaults
  si ce shi MySQL qun ji
  wo men de MySQL qun ji pei zhi gong zuo yi jing wan cheng , xian zai shi ce shi ta de shi jian le 。 zai qun ji guan li fu wu qi
  (loadb1.test.com) shang , yun xing qun ji guan li ke hu duan ndb_mgm lai jian cha qun ji jie dian shi fou lian jie :
  loadb1.test.com:
  ndb_mgm
  ni jiang hui kan dao zhe xie :
  – NDB Cluster — Management Client –
  ndb_mgm>
  zai ming ling xing shu ru show;
  show;
  shu chu de xin xi ying gai shi zhe yang de :
  ndb_mgm> show;
  Connected to Management Server at: localhost:1186
  Cluster Configuration
  ———————
  [ndbd(NDB)] 2 node(s)
  id=2 @192.168.0.101 (Version: 5.0.19, Nodegroup: 0, Master)
  id=3 @192.168.0.102 (Version: 5.0.19, Nodegroup: 0)
  [ndb_mgmd(MGM)] 1 node(s)
  id=1 @192.168.0.103 (Version: 5.0.19)
  [mysqld(API)] 2 node(s)
  id=4 @192.168.0.101 (Version: 5.0.19)
  id=5 @192.168.0.102 (Version: 5.0.19)
  ndb_mgm>
  ru guo ni kan dao ni de jie dian dou yi jing lian jie shang le 。 na me yi qie dou hen shun li !
  shu ru
  quit;
  tui chu ndb_mgm ke hu duan kong zhi tai 。
  xian zai wo men zai sql1.test.com jie dian shang chuang jian yi ge ce shi shu ju ku , bing chuang jian yi ge ce shi biao ,
  tian ru yi xie ce shi shu ju :
  mysql -u root -p
  CREATE DATABASE mysqlclustertest;
  USE mysqlclustertest;
  CREATE TABLE testtable (i INT) ENGINE=NDBCLUSTER;
  INSERT INTO testtable () VALUES (1);
  SELECT * FROM testtable;
  quit;
  ( kan kan shang mian zhe ge CREATE yu ju : wo men xiang qun ji qi lai de suo you shu ju ku de biao , bi xu shi yong ENGINE=NDBCLUSTER!
  ru guo ni shi yong qi ta de ENGINE, na me qun ji jiang bu hui gong zuo !)
  SELECT chu de jie guo ying gai shi :
  mysql> SELECT * FROM testtable;
  +——+
  | i |
  +——+
  | 1 |
  +——+
  1 row in set (0.03 sec)
  xian zai wo men zai sql2.test.com jie dian shang chuang jian xiang tong de shu ju ku ( shi , wo men reng ran yao chuang jian ta , dan shi zai testtable chuang jian zhi hou
  shu ju jiang hui bei fu zhi dao sql2.test.com, yin wei testtable shi shi yong ENGINE=NDBCLUSTER):
  sql2.test.com:
  mysql -u root -p
  CREATE DATABASE mysqlclustertest;
  USE mysqlclustertest;
  SELECT * FROM testtable;
  SELECT chu de jie guo ying gai shi he shang mian de sql1.test.com de jie guo xiang tong :
  mysql> SELECT * FROM testtable;
  +——+
  | i |
  +——+
  | 1 |
  +——+
  1 row in set (0.04 sec)
  wo men kan dao shu ju yi jing cong sql1.test.com jie dian fu zhi dao sql2.example.com jie dian le 。 xian zai wo men
  xiang testtable zhong cha ru ling wai yi xing :
  sql2.test.com:
  INSERT INTO testtable () VALUES (2);
  quit;
  xian zai rang wo men hui dao sql1.example.com jie dian shang , jian cha shi fou neng gou kan jian xin cha ru de na yi xing :
  sql1.example.com:
  mysql -u root -p
  USE mysqlclustertest;
  SELECT * FROM testtable;
  quit;
  
  ni ying gai kan dao xiang zhe yang de shu chu :
  mysql> SELECT * FROM testtable;
  +——+
  | i |
  +——+
  | 1 |
  | 2 |
  +——+
  2 rows in set (0.05 sec)
  suo yi mei ge qun ji jie dian dou you zhe xiang tong de shu ju !
  xian zai rang wo men kan kan ru guo wo men ting zhi jie dian 1(sql1.example.com): yun xing
  sql1.example.com:
  killall ndbd
  bing jian cha
  ps aux | grep ndbd | grep -iv grep
  kan kan suo you de ndbd jin cheng yi jing jie shu le 。 ru guo ni reng ran kan jian ndbd jin cheng , zai yun xing
  killall ndbd
  zhi dao suo you de ndbd jin cheng dou jie shu 。
  xian zai rang zai wo men de guan li fu wu qi shang , jian cha qun ji de zhuang tai (loadb1.example.com):
  loadb1.example.com:
  ndb_mgm
  zai ndb_mgm kong zhi tai shang shu ru
  show;
  ni ying gai kan dao zhe xie :
  ndb_mgm> show;
  Connected to Management Server at: localhost:1186
  Cluster Configuration
  ———————
  [ndbd(NDB)] 2 node(s)
  id=2 (not connected, accepting connect from 192.168.0.101)
  id=3 @192.168.0.102 (Version: 5.0.19, Nodegroup: 0, Master)
  [ndb_mgmd(MGM)] 1 node(s)
  id=1 @192.168.0.103 (Version: 5.0.19)
  [mysqld(API)] 2 node(s)
  id=4 @192.168.0.101 (Version: 5.0.19)
  id=5 @192.168.0.102 (Version: 5.0.19)
  ndb_mgm>
  ni kan jian ,sql1.example.com jie dian mei you lian jie shang le 。
  shu ru :
  quit;
  tui chu ndb_mgm kong zhi tai 。
  rang wo men jian cha sql2.example.com jie dian :
  sql2.example.com:
  mysql -u root -p
  USE mysqlclustertest;
  SELECT * FROM testtable;
  quit;
  SELECT cha xun chu de jie guo ying gai yi ran shi :
  mysql> SELECT * FROM testtable;
  +——+
  | i |
  +——+
  | 1 |
  | 2 |
  +——+
  2 rows in set (0.17 sec)
  Ok, suo you de ce shi dou zheng chang , xian zai rang wo men zai ci qi dong sql1.test.com jie dian :
  sql1.example.com:
  ndbd
  wu ru he chong xin qi dong qun ji
  xian zai rang wo men she xiang ni you yu xiu gai le loadb1.test.com jie dian shang de /var/lib/mysql-cluster/config.ini
  huo zhe qi ta yuan yin , xu yao chong xin qi dong MySQL qun ji 。 wei le zhe yang zuo , ni yao shi yong loadb1.example.com jie dian shang de
  ndb_mgm qun ji guan li ke hu duan :
  loadb1.test.com:
  ndb_mgm
  zai ndb_mgm kong zhi tai shang , ni shu ru
  shutdown;
  ni jiang kan dao xiang zhe yang de xin xi :
  ndb_mgm> shutdown;
  Node 3: Cluster shutdown initiated
  Node 2: Node shutdown completed.
  2 NDB Cluster node(s) have shutdown.
  NDB Cluster management server shutdown.
  ndb_mgm>
  zhe yi wei zhe qun ji jie dian sql1.test.com he sql2.test.com, yi jing qun ji guan li fu wu qi dou yi jing guan bi 。
  yun xing
  quit;
  tui chu ndb_mgm kong zhi tai 。
  wei qi dong qun ji guan li fu wu qi , zai loadb1.test.com shang zhe yang zuo :
  loadb1.test.com:
  ndb_mgmd -f /var/lib/mysql-cluster/config.ini
  bing zai sql1.test.com he sql2.test.com shang yun xing :
  sql1.example.com / sql2.example.com:
  ndbd
  huo zhe , ni gang xiu gai guo loadb1.test.com shang de /var/lib/mysql-cluster/config.ini wen jian :
  ndbd –initial
  zai zhe zhi hou , ni ke yi zai loadb1.test.com shang jian cha kan kan qun ji shi fou yi jing chong qi :
  loadb1.test.com:
  ndb_mgm
  zai ndb_mgm kong zhi tai , shu ru
  show;
  lai cha kan dang qian qun ji de zhuang tai 。 suo you jie dian chong qi hou ke neng xu yao yi dian dian shi jian lai bao gao yi jing lian jie shang 。
  shu ru :
  quit;
  tui chu ndb_mgm kong zhi tai 。
  liu pei zhi fu zai yun heng
  wo men de MySQL qun ji yi jing xian zai wan cheng le , ni xian zai ke yi kai shi shi yong ta le 。 ran er , wo men mei you yi ge fang wen qun ji de
  dan du de IP di zhi , zhe yi wei zhe ni bi xu pei zhi ying yong cheng xu yi bu fen shi yong MySQL qun ji jie dian 1(sql1.test.com), ling
  wai de bu fen shi yong jie dian 2(sql2.test.com). dang ran , suo you de ying yong cheng xu zhi shi xu yao shi yong yi ge jie dian , dan ru guo ni
  bu xiang zai qun ji jie dian zhi jian fen liu fu zai , na ni yong you yi ge qun ji de mu de shi shen me ? ling wai yi ge wen ti shi , ru guo yi ge qun ji
  jie dian huai diao le zen me ban ? na me shi yong zhe ge qun ji jie dian de ying yong cheng xu jiang gen ben bu neng gou gong zuo le 。
  zhe li de jie jue fang an shi zai MySQL qun ji qian duan pei zhi yi ge fu zai yun heng qi lai zai mei ge MySQL qun ji jie dian zhi jian ping heng fu zai 。
  fu zai yun heng qi zai qun ji jie dian zhi jian pei zhi yi ge gong xiang de xu ni IP di zhi , suo you ni de ying yong cheng xu shi yong zhe ge xu ni IP di zhi lai
  fang wen qun ji 。 ru guo qi zhong yi ge jie dian huai diao , na me ni de ying yong cheng xu jiang reng ran ke yi gong zuo , yin wei fu zai yun heng qi jiang qing qiu zhuan yi
  dao le gong zuo zheng chang de ling wai yi ge jie dian 。
  xian zai zai zhe ge li zi zhong fu zai yun heng qi cheng wei le ping jing 。 ru guo zhe ge fu zai yun heng qi huai diao le zen me ban ne ? yin ci wo men jiang yi (active/passive)
  zhu dong / bei dong an zhuang fang shi lai pei zhi liang ge fu zai yun heng qi 。 zhe yi wei zhe wo men you yi ge fu zai yun heng qi shi zhu dong de , ling wai yi ge shi
  re bei de , dang zhu dong de na ge huai diao le , ta jiang hui bian wei zhu dong 。 mei ge fu zai yun heng qi dou shi yong heartbeat( xin tiao ) lai jian cha
  ling wai yi ge fu zai yun heng qi de huo dong qing kuang , tong shi fu zai yun heng qi ye shi yong ldirectord, ta fu ze jiang liu liang fen pei dao qun ji jie dian 。
  heartbeat he ldirectord dou zai wo men jiang yao an zhuang de Ultra Monkey an zhuang bao zhong 。
  loadb1.test.com he loadb2.test.com jie dian de xi tong nei gai zhi chi IPVS(IP xu ni fu wu qi ) fei chang chong yao 。
  IPVS shi zai Linux nei gai de chuan shu ceng zhi xing fu zai yun heng de 。
  6.1 an zhuang Ultra Monkey
  hao , xian zai rang wo men kai shi : shou xian wo men qi yong loadb1.test.com he loadb2.test.com jie dian shang IPVS:
  loadb1.example.com / loadb2.example.com:
  modprobe ip_vs_dh
  modprobe ip_vs_ftp
  modprobe ip_vs
  modprobe ip_vs_lblc
  modprobe ip_vs_lblcr
  modprobe ip_vs_lc
  modprobe ip_vs_nq
  modprobe ip_vs_rr
  modprobe ip_vs_sed
  modprobe ip_vs_sh
  modprobe ip_vs_wlc
  modprobe ip_vs_wrr
  wei le zai qi dong shi IPVS mo kuai , wo men zai /etc/modules lie ju le mo kuai :
  loadb1.test.com / loadb2.test.com:
  vi /etc/modules
  ip_vs_dh
  ip_vs_ftp
  ip_vs
  ip_vs_lblc
  ip_vs_lblcr
  ip_vs_lc
  ip_vs_nq
  ip_vs_rr
  ip_vs_sed
  ip_vs_sh
  ip_vs_wlc
  ip_vs_wrr
  xian zai wo men bian ji /etc/apt/sources.list, tian jia Ultra Monkey de xia zai dian , ran hou wo men an zhuang Ultra Monkey:
  loadb1.test.com / loadb2.test.com:
  vi /etc/apt/sources.list
  deb http://www.ultramonkey.org/download/3/ sarge main
  deb-src http://www.ultramonkey.org/download/3 sarge main
  apt-get update
  apt-get install ultramonkey libdbi-perl libdbd-mysql-perl libmysqlclient14-dev
  xian zai Ultra Monkey yi jing an zhuang le , ru guo ni kan dao xia mian zhe yang de jing gao :
  | libsensors3 not functional
  |
  | It appears that your kernel is not compiled with sensors support. As a
  | result, libsensors3 will not be functional on your system.
  |
  | If you want to enable it, have a look at “I2C Hardware Sensors Chip
  | support” in your kernel configuration.
  ni ke yi hu lue ta 。
  hui da xia mian de wen ti :
  Do you want to automatically load IPVS rules on boot?
  <-- No
  Select a daemon method.
  <-- none
  wo gang an zhuang de libdbd-mysql-perl an zhuang bao bu neng gou zai MySQL 5( wo men zai MySQL qun ji shang shi yong MySQL 5),
  yin ci wo men an zhuang zui xin de DBD::mysql Perl an zhuang bao :
  
  loadb1.test.com / loadb2.test.com:
  cd /tmp
  wget http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-3.0002.tar.gz
  tar xvfz DBD-mysql-3.0002.tar.gz
  cd DBD-mysql-3.0002
  perl Makefile.PL
  make
  make install
  wo men bi xu xian qi yong packet forwarding:
  loadb1.example.com / loadb2.example.com:
  vi /etc/sysctl.conf
  # Enables packet forwardingnet.ipv4.ip_forward = 1
  6.2 pei zhi heartbeat( xin tiao )
  wo men tong guo chuang jian san ge wen jian (loadb1.test.com he loadb2.test.com de wen jian bi xu wan quan yi yang ) lai pei zhi heartbeat:
  loadb1.test.com / loadb2.test.com:
  vi /etc/ha.d/ha.cf
  logfacility local0
  bcast eth0
  mcast eth0 225.0.0.1 694 1 0
  auto_failback off
  node loadb1
  node loadb2
  respawn hacluster /usr/lib/heartbeat/ipfail
  apiauth ipfail gid=haclient uid=hacluster
  qing ji zhu : ni bi xu lie chu jie dian ming cheng ( ben li zhong shi loadb1 he loadb2)
  uname -n
  chu le zhe xie , wo men bu xu yao dui zhe ge wen jian zuo ren he xiu gai 。
  vi /etc/ha.d/haresources
  loadb1 \
  ldirectord::ldirectord.cf \
  LVSSyncDaemonSwap::master \
  IPaddr2::192.168.0.105/24/eth0/192.168.0.255
  ni bi xu lie ju qi zhong yi ge fu zai yun heng jie dian ming cheng ( zhe li shi :loadb1), bing qie lie chu
  xu ni IP di zhi (192.168.0.105) he guang bo di zhi (192.168.0.255).
  vi /etc/ha.d/authkeys
  auth 3
  3 md5 somerandomstring
  somerandomstring shi loadb1 he loadb2 yong lai xiang hu ren zheng de liang ge heartbeat shou hu jin cheng de mi ma 。
  zhe li she zhi cheng ni zi ji de mi ma 。 ni ke yi xuan ze 3 zhong jia mi fang shi 。 wo yi ban shi yong md5 lai jia mi 。
  /etc/ha.d/authkeys ying gai shi root zhang hao zhi du , zhe li wo men zhe yang zuo :
  loadb1.test.com / loadb2.test.com:
  chmod 600 /etc/ha.d/authkeys
  6.3 pei zhi ldirectord
  xian zai wo men wei ldirectord chuang jian pei zhi wen jian , fu zai yun heng qi :
  loadb1.example.com / loadb2.example.com:
  vi /etc/ha.d/ldirectord.cf
  # Global Directives
  checktimeout=10
  checkinterval=2
  autoreload=no
  logfile="local0"
  quiescent=yes
  virtual = 192.168.0.105:3306
  service = mysql
  real = 192.168.0.101:3306 gate
  real = 192.168.0.102:3306 gate
  checktype = negotiate
  login = "ldirector"
  passwd = "ldirectorpassword"
  database = "ldirectordb"
  request = "SELECT * FROM connectioncheck"
  scheduler = wrr
  qing tian ru zheng que de xu ni IP di zhi (192.168.0.105) he zheng que de MySQL qun ji jie dian de IP di zhi (192.168.0.101 he 192.168.0.102)。
  3306 shi MySQL yun xing shi mo ren de duan kou 。 wo men ye zhi ding le yi ge MySQL yong hu (ldirector) he mi ma (ldirectorpassword), yi ge shu ju ku (ldirectordb) he
  yi tiao SQL cha xun 。ldirectord shi yong zhe xie xin xi lai ce shi MySQL qun ji jie dian , yi ci lai jian cha ta men de shi fou yi zhi ke yong 。 xia yi bu wo men jiang yong ldirector yong hu lai
  chuang jian ldirectordb shu ju ku 。
  xian zai wo men wei heartbeat chuang jian xi tong bi xu de qi dong lian jie , bing yi chu ldirectord( yin wei ldirectord jiang you heartbeat lai qi dong ):
  loadb1.test.com / loadb2.test.com:
  update-rc.d -f heartbeat remove
  update-rc.d heartbeat start 75 2 3 4 5 . stop 05 0 1 6 .
  update-rc.d -f ldirectord remove
  6.4 chuang jian shu ju ku ldirector
  xia mian wo men zai MySQL qun ji jie dian sql1.test.com he sql2.test.com shang chuang jian ldirector shu ju ku 。 zhe ge shu ju ku jiang hui yong yu wo men de fu zai yun heng qi lai jian cha
  MySQL qun ji jie dian de ke yong xing 。
  sql1.test.com:
  mysql -u root -p
  GRANT ALL ON ldirectordb.* TO 'ldirector'@'%' IDENTIFIED BY 'ldirectorpassword';
  FLUSH PRIVILEGES;
  CREATE DATABASE ldirectordb;
  USE ldirectordb;
  CREATE TABLE connectioncheck (i INT) ENGINE=NDBCLUSTER;
  INSERT INTO connectioncheck () VALUES (1);
  quit;
  sql2.test.com:
  mysql -u root -p
  GRANT ALL ON ldirectordb.* TO 'ldirector'@'%' IDENTIFIED BY 'ldirectorpassword';
  FLUSH PRIVILEGES;
  CREATE DATABASE ldirectordb;
  quit;
  6.4 wei fu zai yun heng zhun bei MySQL qun ji jie dian
  zui hou wo men bi xu pei zhi MySQL qun ji jie dian sql1.test.com he sql2.test.com lai jie shou xu ni IP di zhi 192.168.0.105。
  sql1.test.com / sql2.test.com:
  apt-get install iproute
  zai /etc/sysctl.conf li mian tian jia xia mian de nei rong :
  vi /etc/sysctl.conf
  # Enable configuration of arp_ignore option
  net.ipv4.conf.all.arp_ignore = 1
  # When an arp request is received on eth0, only respond if that address is
  # configured on eth0. In particular, do not respond if the address is
  # configured on lo
  net.ipv4.conf.eth0.arp_ignore = 1
  # Ditto for eth1, add for all ARPing interfaces
  #net.ipv4.conf.eth1.arp_ignore = 1
  # Enable configuration of arp_announce option
  net.ipv4.conf.all.arp_announce = 2
  # When making an ARP request sent through eth0 Always use an address that
  # is configured on eth0 as the source address of the ARP request. If this
  # is not set, and packets are being sent out eth0 for an address that is on
  # lo, and an arp request is required, then the address on lo will be used.
  # As the source IP address of arp requests is entered into the ARP cache on
  # the destination, it has the effect of announcing this address. This is
  # not desirable in this case as adresses on lo on the real-servers should
  # be announced only by the linux-director.
  net.ipv4.conf.eth0.arp_announce = 2
  # Ditto for eth1, add for all ARPing interfaces
  #net.ipv4.conf.eth1.arp_announce = 2
  sysctl -p
  jiang xia mian zhe duan jia ru dao /etc/network/interfaces:
  sql1.test.com / sql2.test.com:
  vi /etc/network/interfaces
  auto lo:0
  iface lo:0 inet static
  address 192.168.0.105
  netmask 255.255.255.255
  pre-up sysctl -p > /dev/null
  ifup lo:0
  qi . qi dong fu zai yun heng qi bing ce shi
  xian zai wo men qi dong liang ge fu zai yun heng guan li qi :
  loadb1.test.com / loadb2.test.com:
  /etc/init.d/ldirectord stop
  /etc/init.d/heartbeat start
  ru guo ni mei you kan jian cuo wu , ni xu yao xian zai chong qi mei ge fu zai yun heng qi :
  loadb1.test.com / loadb2.test.com:
  shutdown -r now
  chong qi zhi hou wo men ke yi jian cha shi fou liang ge fu zai yun heng qi xiang qi wang yi yang gong zuo :
  loadb1.test.com / loadb2.test.com:
  ip addr sh eth0
  zhu dong de fu zai yun heng qi ying gai lie chu le xu ni IP di zhi (192.168.0.105):
  2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
  link/ether 00:16:3e:45:fc:f8 brd ff:ff:ff:ff:ff:ff
  inet 192.168.0.103/24 brd 192.168.0.255 scope global eth0
  inet 192.168.0.105/24 brd 192.168.0.255 scope global secondary eth0
  bei dong ( re bei ) de fu zai yun heng qi ying gai xian shi ru xia :
  2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
  link/ether 00:16:3e:16:c1:4e brd ff:ff:ff:ff:ff:ff
  inet 192.168.0.104/24 brd 192.168.0.255 scope global eth0
  loadb1.test.com / loadb2.test.com:
  ldirectord ldirectord.cf status
  zhu dong fu zai yun heng qi shang de shu chu :
  ldirectord for /etc/ha.d/ldirectord.cf is running with pid: 1603
  bei dong fu zai yun heng qi shang de shu chu :
  ldirectord is stopped for /etc/ha.d/ldirectord.cf
  loadb1.example.com / loadb2.example.com:
  ipvsadm -L -n
  zhu dong fu zai yun heng qi shang de shu chu :
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port Forward Weight ActiveConn InActConn
  TCP 192.168.0.105:3306 wrr
  -> 192.168.0.101:3306 Route 1 0 0
  -> 192.168.0.102:3306 Route 1 0 0
  bei dong fu zai yun heng qi shang de shu chu :
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port Forward Weight ActiveConn InActConn
  loadb1.test.com / loadb2.test.com:
  /etc/ha.d/resource.d/LVSSyncDaemonSwap master status
  zhu dong fu zai yun heng qi shang de shu chu :
  master running
  (ipvs_syncmaster pid: 1766)
  bei dong fu zai yun heng qi shang de shu chu :
  master stopped
  (ipvs_syncbackup pid: 1440)
  ru guo ni de ce shi dou shi zheng chang de , ni xian zai ke yi cong xiang tong wang luo (192.168.0.x) zhong de qi ta fu wu qi yong xu ni IP di zhi 192.168.0.105 lai fang wen MySQL shu ju ku :
  mysql -h 192.168.0.105 -u ldirector -p
  ( qing ji zhu : ni de MySQL ke hu duan bi xu zhi shao shi 4.1 ban ben de ; jiu de ban ben bu neng yun xing MySQL5。)
  ni xian zai ke yi guan diao yi ge MySQL qun ji jie dian lai ce shi ; ni ying gai reng ran ke yi lian jie dao MySQL shu ju ku 。
  ba zhu jie
  yun xing yi ge MySQL qun ji shi , zhe li you yi xie chong yao de dong xi xu yao ji zhu :
  – suo you de shu ju dou shi cun zai nei cun ! yin ci ni de qun ji jie dian shang xu yao da rong liang de nei cun 。 zhe li you mei ge jie dian xu yao nei cun
  rong liang de ji suan gong shi :
  ( shu ju ku da xiao SizeofDatabase * fu zhi shu liang NumberOfReplicas * 1.1 ) / shu ju jie dian shu liang NumberOfDataNodes
  suo yi ru guo ni you yi ge shu ju ku de da xiao shi 1GB, ni ying gai wei mei ge jie dian pei bei 1.1GB nei cun !
  – qun ji guan li jie dian zai jian ting 1186 duan kou shang de ren yi lian jie 。 suo yi zhe yi wei zhe bu shi hen an quan , suo yi ni ying dang zai yi ge du li de wang luo shang yun xing MySQL qun ji 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
zhe pian lun tan wen zhang ( sai di wang ji shu she qu ) zhu yao jie shao le pei zhi yi ge gao ke yong xing de MySQL fu wu qi fu zai yun heng qun ji de ju ti guo cheng , xiang xi nei rong qing shen kao xia wen : ben wen jiang gao su ni ru he pei zhi yi ge san ge jie dian de MySQL 5 shu ju ku fu wu qi qun ji : liang ge cun chu jie dian he yi ge guan li jie dian 。 zhe ge qun ji shi you yong ti gong “heartbeat xin tiao ”( yong lai jian cha ling wai yi ge jie dian shi fou huo dong ) he “ldirectord”( jiang qing qiu fen fa dao MySQL qun ji de jie dian ) de Ultra Monkey an zhuang bao de liang ge jie dian zu cheng de yi ge gao ke yong xing fu zai yun heng qi 。 ben wen wo men de mei ge jie dian shi yong Debian Sarge Linux xi tong 。 qi ta Linux fa xing ban ben de an zhuang ke neng yi dian dian qu bie 。MySQL de ban ben wo men shi yong 5.0.19。 ru guo ni bu xiang shi yong MySQL 5, ni ye ke yi shi yong MySQL 4.1, jin guan wo huan mei you ce shi guo 。 ben wen shi yi pian shi jian ying yong zhi dao ; ta mei you she ji tai duo de li lun 。 guan yu qun ji de li lun ni ke yi zai wang shang zhao dao hen duo 。 yi fu wu qi wo shi yong xia mian de Debian fu wu qi , ta men dou zai tong yi ge wang duan ( ben li ru :192.168.0.x): sql1.test.com: 192.168.0.101 MySQL qun ji jie dian 1 sql2.test.com: 192.168.0.102 MySQL qun ji jie dian 2 loadb1.test.com: 192.168.0.103 fu zai yun heng 1 / MySQL qun ji guan li fu wu qi loadb2.test.com: 192.168.0.104 fu zai yun heng 2 ling wai wo men xu yao yi ge xu ni IP di zhi :192.168.0.105。 ta hui an pai gei zhe ge MySQL qun ji de fu zai yun heng , yi bian yu ying yong cheng xu tong guo tong yi dan du de IP di zhi lai fang wen qun ji 。 jin guan wo men xiang zai MySQL qun ji zhong shi yong liang ge jie dian , dan shi wo men reng ran xu yao di san ge jie dian ,MySQL qun ji guan li fu wu qi , zhu yao de yi ge yuan yin shi : ru guo qi zhong yi ge MySQL qun ji jie dian huai le , er MySQL qun ji guan li fu wu qi mei you yun xing , na me liang ge qun ji jie dian shang de shu ju jiang hui bu yi zhi (“split brain”)。 wo men xu yao ta lai pei zhi MySQL qun ji . yin ci wo men de an zhuang yi ban xu yao wu tai ji qi : 2 ge MySQL qun ji jie dian + 1 ge qun ji guan li fu wu qi + 2 ge fu zai yun heng = 5 yin wei qun ji guan li fu wu qi mei you shi yong duo shao zi yuan , xi tong jiang hui kong zhe shen me dou bu zuo , suo yi wo men ke yi ba wo men de di yi ge fu zai yun heng he ta yi qi fang zai tong yi tai ji qi shang , zhe yang ke yi jie yue wo men yi tai fu wu qi , suo yi zui hao wo men zhi xu yao si tai ji qi 。 er pei zhi MySQL qun ji guan li fu wu qi shou xian wo men yao xia zai MySQL 5.0.19, bing an zhuang qun ji guan li fu wu qi (ndb_mgmd) he qun ji guan li ke hu duan (ndb_mgm - ta ke yi yong lai jian kong qun ji de yun xing qing kuang ). xia mian de bu zhou shi zai loadb1.test.com (192.168.0.103) shang jin xing de : loadb1.test.com: mkdir /usr/src/mysql-mgm cd /usr/src/mysql-mgm wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-max-5.0.19-linux-i686-\ glibc23.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/ tar xvfz mysql-max-5.0.19-linux-i686-glibc23.tar.gz cd mysql-max-5.0.19-linux-i686-glibc23 mv bin/ndb_mgm /usr/bin mv bin/ndb_mgmd /usr/bin chmod 755 /usr/bin/ndb_mg* cd /usr/src rm -rf /usr/src/mysql-mgm xia yi bu , wo men bi xu chuang jian qun ji de pei zhi wen jian ,/var/lib/mysql-cluster/config.ini: loadb1.test.com: mkdir /var/lib/mysql-cluster cd /var/lib/mysql-cluster vi config.ini ———- [NDBD DEFAULT] NoOfReplicas=2 [MYSQLD DEFAULT] [NDB_MGMD DEFAULT] [TCP DEFAULT] # Section for the cluster management node [NDB_MGMD] # IP address of the management node (this system) HostName=192.168.0.103 # Section for the storage nodes [NDBD] # IP address of the first storage node HostName=192.168.0.101 DataDir= /var/lib/mysql-cluster [NDBD] # IP address of the second storage node HostName=192.168.0.102 DataDir=/var/lib/mysql-cluster # one [MYSQLD] per storage node [MYSQLD] [MYSQLD] ———- shi ji ying yong zhong qing jiang wen jian zhong de IP di zhi huan cheng ni xiang ying de IP。 ran hou wo men qi dong qun ji guan li fu wu qi : loadb1.test.com: ndb_mgmd -f /var/lib/mysql-cluster/config.ini wo men ying gai ye xu yao zai fu wu qi qi dong shi neng gou zi dong qi dong guan li fu wu qi , suo yi wo men chuang jian le yi ge fei chang jian dan de chu shi hua jiao ben he xiang ying de qi dong lian jie : loadb1.test.com: echo ‘ndb_mgmd -f /var/lib/mysql-cluster/config.ini’ > /etc/init.d/ndb_mgmd chmod 755 /etc/init.d/ndb_mgmd update-rc.d ndb_mgmd defaults san pei zhi MySQL qun ji jie dian ( cun chu jie dian ) xian zai wo men jiang fen bie zai sql1.test.com he sql2.test.com shang an zhuang mysql-max-5.0.19: sql1.example.com / sql2.example.com: groupadd mysql useradd -g mysql mysql cd /usr/local/ wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-max-5.0.19-linux-i686-\ glibc23.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/ tar xvfz mysql-max-5.0.19-linux-i686-glibc23.tar.gz ln -s mysql-max-5.0.19-linux-i686-glibc23 mysql cd mysql scripts/mysql_install_db –user=mysql chown -R root:mysql . chown -R mysql data cp support-files/mysql.server /etc/init.d/ chmod 755 /etc/init.d/mysql.server update-rc.d mysql.server defaults cd /usr/local/mysql/bin mv * /usr/bin cd ../ rm -fr /usr/local/mysql/bin ln -s /usr/bin /usr/local/mysql/bin ran hou wo men zai mei ge jie dian shang chuang jian MySQL pei zhi wen jian /etc/my.cnf : vi /etc/my.cnf – [mysqld] ndbcluster # IP address of the cluster management node ndb-connectstring=192.168.0.103 [mysql_cluster] # IP address of the cluster management node ndb-connectstring=192.168.0.103 – que ren ni zai qun ji guan li fu wu qi zhong shu ru de shi zheng que de IP di zhi 。 xia yi bu wo men fen bie zai mei ge qun ji jie dian shang chuang jian shu ju mu lu he qi dong MySQL fu wu qi : sql1.test.com / sql2.test.com: mkdir /var/lib/mysql-cluster cd /var/lib/mysql-cluster ndbd –initial /etc/init.d/mysql.server start ( qing ji zhu : wo men zhi shi zai di yi ci qi dong MySQL shi huo loadb1.test.com shang mian de /var/lib/mysql-cluster/config.ini fa sheng gai bian shi , cai shi yong ndbd –initial) xian zai , shi shi hou gei MySQL root zhang hao she zhi mi ma le : sql1.test.com / sql2.test.com: mysqladmin -u root password yourrootsqlpassword wo men xu yao zai fu wu qi qi dong shi , qi dong qun ji jie dian , suo yi wo men chuang jian yi ge ndbd chu shi hua jiao ben he xiang ying de xi tong qi dong lian jie : sql1.test.com / sql2.test.com: echo ‘ndbd’ > /etc/init.d/ndbd chmod 755 /etc/init.d/ndbd update-rc.d ndbd defaults si ce shi MySQL qun ji wo men de MySQL qun ji pei zhi gong zuo yi jing wan cheng , xian zai shi ce shi ta de shi jian le 。 zai qun ji guan li fu wu qi (loadb1.test.com) shang , yun xing qun ji guan li ke hu duan ndb_mgm lai jian cha qun ji jie dian shi fou lian jie : loadb1.test.com: ndb_mgm ni jiang hui kan dao zhe xie : – NDB Cluster — Management Client – ndb_mgm> zai ming ling xing shu ru show; show; shu chu de xin xi ying gai shi zhe yang de : ndb_mgm> show; Connected to Management Server at: localhost:1186 Cluster Configuration ——————— [ndbd(NDB)] 2 node(s) id=2 @192.168.0.101 (Version: 5.0.19, Nodegroup: 0, Master) id=3 @192.168.0.102 (Version: 5.0.19, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.103 (Version: 5.0.19) [mysqld(API)] 2 node(s) id=4 @192.168.0.101 (Version: 5.0.19) id=5 @192.168.0.102 (Version: 5.0.19) ndb_mgm> ru guo ni kan dao ni de jie dian dou yi jing lian jie shang le 。 na me yi qie dou hen shun li ! shu ru quit; tui chu ndb_mgm ke hu duan kong zhi tai 。 xian zai wo men zai sql1.test.com jie dian shang chuang jian yi ge ce shi shu ju ku , bing chuang jian yi ge ce shi biao , tian ru yi xie ce shi shu ju : mysql -u root -p CREATE DATABASE mysqlclustertest; USE mysqlclustertest; CREATE TABLE testtable (i INT) ENGINE=NDBCLUSTER; INSERT INTO testtable () VALUES (1); SELECT * FROM testtable; quit; ( kan kan shang mian zhe ge CREATE yu ju : wo men xiang qun ji qi lai de suo you shu ju ku de biao , bi xu shi yong ENGINE=NDBCLUSTER! ru guo ni shi yong qi ta de ENGINE, na me qun ji jiang bu hui gong zuo !) SELECT chu de jie guo ying gai shi : mysql> SELECT * FROM testtable; +——+ | i | +——+ | 1 | +——+ 1 row in set (0.03 sec) xian zai wo men zai sql2.test.com jie dian shang chuang jian xiang tong de shu ju ku ( shi , wo men reng ran yao chuang jian ta , dan shi zai testtable chuang jian zhi hou shu ju jiang hui bei fu zhi dao sql2.test.com, yin wei testtable shi shi yong ENGINE=NDBCLUSTER): sql2.test.com: mysql -u root -p CREATE DATABASE mysqlclustertest; USE mysqlclustertest; SELECT * FROM testtable; SELECT chu de jie guo ying gai shi he shang mian de sql1.test.com de jie guo xiang tong : mysql> SELECT * FROM testtable; +——+ | i | +——+ | 1 | +——+ 1 row in set (0.04 sec) wo men kan dao shu ju yi jing cong sql1.test.com jie dian fu zhi dao sql2.example.com jie dian le 。 xian zai wo men xiang testtable zhong cha ru ling wai yi xing : sql2.test.com: INSERT INTO testtable () VALUES (2); quit; xian zai rang wo men hui dao sql1.example.com jie dian shang , jian cha shi fou neng gou kan jian xin cha ru de na yi xing : sql1.example.com: mysql -u root -p USE mysqlclustertest; SELECT * FROM testtable; quit; ni ying gai kan dao xiang zhe yang de shu chu : mysql> SELECT * FROM testtable; +——+ | i | +——+ | 1 | | 2 | +——+ 2 rows in set (0.05 sec) suo yi mei ge qun ji jie dian dou you zhe xiang tong de shu ju ! xian zai rang wo men kan kan ru guo wo men ting zhi jie dian 1(sql1.example.com): yun xing sql1.example.com: killall ndbd bing jian cha ps aux | grep ndbd | grep -iv grep kan kan suo you de ndbd jin cheng yi jing jie shu le 。 ru guo ni reng ran kan jian ndbd jin cheng , zai yun xing killall ndbd zhi dao suo you de ndbd jin cheng dou jie shu 。 xian zai rang zai wo men de guan li fu wu qi shang , jian cha qun ji de zhuang tai (loadb1.example.com): loadb1.example.com: ndb_mgm zai ndb_mgm kong zhi tai shang shu ru show; ni ying gai kan dao zhe xie : ndb_mgm> show; Connected to Management Server at: localhost:1186 Cluster Configuration ——————— [ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from 192.168.0.101) id=3 @192.168.0.102 (Version: 5.0.19, Nodegroup: 0, Master) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.103 (Version: 5.0.19) [mysqld(API)] 2 node(s) id=4 @192.168.0.101 (Version: 5.0.19) id=5 @192.168.0.102 (Version: 5.0.19) ndb_mgm> ni kan jian ,sql1.example.com jie dian mei you lian jie shang le 。 shu ru : quit; tui chu ndb_mgm kong zhi tai 。 rang wo men jian cha sql2.example.com jie dian : sql2.example.com: mysql -u root -p USE mysqlclustertest; SELECT * FROM testtable; quit; SELECT cha xun chu de jie guo ying gai yi ran shi : mysql> SELECT * FROM testtable; +——+ | i | +——+ | 1 | | 2 | +——+ 2 rows in set (0.17 sec) Ok, suo you de ce shi dou zheng chang , xian zai rang wo men zai ci qi dong sql1.test.com jie dian : sql1.example.com: ndbd wu ru he chong xin qi dong qun ji xian zai rang wo men she xiang ni you yu xiu gai le loadb1.test.com jie dian shang de /var/lib/mysql-cluster/config.ini huo zhe qi ta yuan yin , xu yao chong xin qi dong MySQL qun ji 。 wei le zhe yang zuo , ni yao shi yong loadb1.example.com jie dian shang de ndb_mgm qun ji guan li ke hu duan : loadb1.test.com: ndb_mgm zai ndb_mgm kong zhi tai shang , ni shu ru shutdown; ni jiang kan dao xiang zhe yang de xin xi : ndb_mgm> shutdown; Node 3: Cluster shutdown initiated Node 2: Node shutdown completed. 2 NDB Cluster node(s) have shutdown. NDB Cluster management server shutdown. ndb_mgm> zhe yi wei zhe qun ji jie dian sql1.test.com he sql2.test.com, yi jing qun ji guan li fu wu qi dou yi jing guan bi 。 yun xing quit; tui chu ndb_mgm kong zhi tai 。 wei qi dong qun ji guan li fu wu qi , zai loadb1.test.com shang zhe yang zuo : loadb1.test.com: ndb_mgmd -f /var/lib/mysql-cluster/config.ini bing zai sql1.test.com he sql2.test.com shang yun xing : sql1.example.com / sql2.example.com: ndbd huo zhe , ni gang xiu gai guo loadb1.test.com shang de /var/lib/mysql-cluster/config.ini wen jian : ndbd –initial zai zhe zhi hou , ni ke yi zai loadb1.test.com shang jian cha kan kan qun ji shi fou yi jing chong qi : loadb1.test.com: ndb_mgm zai ndb_mgm kong zhi tai , shu ru show; lai cha kan dang qian qun ji de zhuang tai 。 suo you jie dian chong qi hou ke neng xu yao yi dian dian shi jian lai bao gao yi jing lian jie shang 。 shu ru : quit; tui chu ndb_mgm kong zhi tai 。 liu pei zhi fu zai yun heng wo men de MySQL qun ji yi jing xian zai wan cheng le , ni xian zai ke yi kai shi shi yong ta le 。 ran er , wo men mei you yi ge fang wen qun ji de dan du de IP di zhi , zhe yi wei zhe ni bi xu pei zhi ying yong cheng xu yi bu fen shi yong MySQL qun ji jie dian 1(sql1.test.com), ling wai de bu fen shi yong jie dian 2(sql2.test.com). dang ran , suo you de ying yong cheng xu zhi shi xu yao shi yong yi ge jie dian , dan ru guo ni bu xiang zai qun ji jie dian zhi jian fen liu fu zai , na ni yong you yi ge qun ji de mu de shi shen me ? ling wai yi ge wen ti shi , ru guo yi ge qun ji jie dian huai diao le zen me ban ? na me shi yong zhe ge qun ji jie dian de ying yong cheng xu jiang gen ben bu neng gou gong zuo le 。 zhe li de jie jue fang an shi zai MySQL qun ji qian duan pei zhi yi ge fu zai yun heng qi lai zai mei ge MySQL qun ji jie dian zhi jian ping heng fu zai 。 fu zai yun heng qi zai qun ji jie dian zhi jian pei zhi yi ge gong xiang de xu ni IP di zhi , suo you ni de ying yong cheng xu shi yong zhe ge xu ni IP di zhi lai fang wen qun ji 。 ru guo qi zhong yi ge jie dian huai diao , na me ni de ying yong cheng xu jiang reng ran ke yi gong zuo , yin wei fu zai yun heng qi jiang qing qiu zhuan yi dao le gong zuo zheng chang de ling wai yi ge jie dian 。 xian zai zai zhe ge li zi zhong fu zai yun heng qi cheng wei le ping jing 。 ru guo zhe ge fu zai yun heng qi huai diao le zen me ban ne ? yin ci wo men jiang yi (active/passive) zhu dong / bei dong an zhuang fang shi lai pei zhi liang ge fu zai yun heng qi 。 zhe yi wei zhe wo men you yi ge fu zai yun heng qi shi zhu dong de , ling wai yi ge shi re bei de , dang zhu dong de na ge huai diao le , ta jiang hui bian wei zhu dong 。 mei ge fu zai yun heng qi dou shi yong heartbeat( xin tiao ) lai jian cha ling wai yi ge fu zai yun heng qi de huo dong qing kuang , tong shi fu zai yun heng qi ye shi yong ldirectord, ta fu ze jiang liu liang fen pei dao qun ji jie dian 。 heartbeat he ldirectord dou zai wo men jiang yao an zhuang de Ultra Monkey an zhuang bao zhong 。 loadb1.test.com he loadb2.test.com jie dian de xi tong nei gai zhi chi IPVS(IP xu ni fu wu qi ) fei chang chong yao 。 IPVS shi zai Linux nei gai de chuan shu ceng zhi xing fu zai yun heng de 。 6.1 an zhuang Ultra Monkey hao , xian zai rang wo men kai shi : shou xian wo men qi yong loadb1.test.com he loadb2.test.com jie dian shang IPVS: loadb1.example.com / loadb2.example.com: modprobe ip_vs_dh modprobe ip_vs_ftp modprobe ip_vs modprobe ip_vs_lblc modprobe ip_vs_lblcr modprobe ip_vs_lc modprobe ip_vs_nq modprobe ip_vs_rr modprobe ip_vs_sed modprobe ip_vs_sh modprobe ip_vs_wlc modprobe ip_vs_wrr wei le zai qi dong shi IPVS mo kuai , wo men zai /etc/modules lie ju le mo kuai : loadb1.test.com / loadb2.test.com: vi /etc/modules ip_vs_dh ip_vs_ftp ip_vs ip_vs_lblc ip_vs_lblcr ip_vs_lc ip_vs_nq ip_vs_rr ip_vs_sed ip_vs_sh ip_vs_wlc ip_vs_wrr xian zai wo men bian ji /etc/apt/sources.list, tian jia Ultra Monkey de xia zai dian , ran hou wo men an zhuang Ultra Monkey: loadb1.test.com / loadb2.test.com: vi /etc/apt/sources.list deb http://www.ultramonkey.org/download/3/ sarge main deb-src http://www.ultramonkey.org/download/3 sarge main apt-get update apt-get install ultramonkey libdbi-perl libdbd-mysql-perl libmysqlclient14-dev xian zai Ultra Monkey yi jing an zhuang le , ru guo ni kan dao xia mian zhe yang de jing gao : | libsensors3 not functional | | It appears that your kernel is not compiled with sensors support. As a | result, libsensors3 will not be functional on your system. | | If you want to enable it, have a look at “I2C Hardware Sensors Chip | support” in your kernel configuration. ni ke yi hu lue ta 。 hui da xia mian de wen ti : Do you want to automatically load IPVS rules on boot? <-- No Select a daemon method. <-- none wo gang an zhuang de libdbd-mysql-perl an zhuang bao bu neng gou zai MySQL 5( wo men zai MySQL qun ji shang shi yong MySQL 5), yin ci wo men an zhuang zui xin de DBD::mysql Perl an zhuang bao : loadb1.test.com / loadb2.test.com: cd /tmp wget http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-3.0002.tar.gz tar xvfz DBD-mysql-3.0002.tar.gz cd DBD-mysql-3.0002 perl Makefile.PL make make install wo men bi xu xian qi yong packet forwarding: loadb1.example.com / loadb2.example.com: vi /etc/sysctl.conf # Enables packet forwardingnet.ipv4.ip_forward = 1 6.2 pei zhi heartbeat( xin tiao ) wo men tong guo chuang jian san ge wen jian (loadb1.test.com he loadb2.test.com de wen jian bi xu wan quan yi yang ) lai pei zhi heartbeat: loadb1.test.com / loadb2.test.com: vi /etc/ha.d/ha.cf logfacility local0 bcast eth0 mcast eth0 225.0.0.1 694 1 0 auto_failback off node loadb1 node loadb2 respawn hacluster /usr/lib/heartbeat/ipfail apiauth ipfail gid=haclient uid=hacluster qing ji zhu : ni bi xu lie chu jie dian ming cheng ( ben li zhong shi loadb1 he loadb2) uname -n chu le zhe xie , wo men bu xu yao dui zhe ge wen jian zuo ren he xiu gai 。 vi /etc/ha.d/haresources loadb1 \ ldirectord::ldirectord.cf \ LVSSyncDaemonSwap::master \ IPaddr2::192.168.0.105/24/eth0/192.168.0.255 ni bi xu lie ju qi zhong yi ge fu zai yun heng jie dian ming cheng ( zhe li shi :loadb1), bing qie lie chu xu ni IP di zhi (192.168.0.105) he guang bo di zhi (192.168.0.255). vi /etc/ha.d/authkeys auth 3 3 md5 somerandomstring somerandomstring shi loadb1 he loadb2 yong lai xiang hu ren zheng de liang ge heartbeat shou hu jin cheng de mi ma 。 zhe li she zhi cheng ni zi ji de mi ma 。 ni ke yi xuan ze 3 zhong jia mi fang shi 。 wo yi ban shi yong md5 lai jia mi 。 /etc/ha.d/authkeys ying gai shi root zhang hao zhi du , zhe li wo men zhe yang zuo : loadb1.test.com / loadb2.test.com: chmod 600 /etc/ha.d/authkeys 6.3 pei zhi ldirectord xian zai wo men wei ldirectord chuang jian pei zhi wen jian , fu zai yun heng qi : loadb1.example.com / loadb2.example.com: vi /etc/ha.d/ldirectord.cf # Global Directives checktimeout=10 checkinterval=2 autoreload=no logfile="local0" quiescent=yes virtual = 192.168.0.105:3306 service = mysql real = 192.168.0.101:3306 gate real = 192.168.0.102:3306 gate checktype = negotiate login = "ldirector" passwd = "ldirectorpassword" database = "ldirectordb" request = "SELECT * FROM connectioncheck" scheduler = wrr qing tian ru zheng que de xu ni IP di zhi (192.168.0.105) he zheng que de MySQL qun ji jie dian de IP di zhi (192.168.0.101 he 192.168.0.102)。 3306 shi MySQL yun xing shi mo ren de duan kou 。 wo men ye zhi ding le yi ge MySQL yong hu (ldirector) he mi ma (ldirectorpassword), yi ge shu ju ku (ldirectordb) he yi tiao SQL cha xun 。ldirectord shi yong zhe xie xin xi lai ce shi MySQL qun ji jie dian , yi ci lai jian cha ta men de shi fou yi zhi ke yong 。 xia yi bu wo men jiang yong ldirector yong hu lai chuang jian ldirectordb shu ju ku 。 xian zai wo men wei heartbeat chuang jian xi tong bi xu de qi dong lian jie , bing yi chu ldirectord( yin wei ldirectord jiang you heartbeat lai qi dong ): loadb1.test.com / loadb2.test.com: update-rc.d -f heartbeat remove update-rc.d heartbeat start 75 2 3 4 5 . stop 05 0 1 6 . update-rc.d -f ldirectord remove 6.4 chuang jian shu ju ku ldirector xia mian wo men zai MySQL qun ji jie dian sql1.test.com he sql2.test.com shang chuang jian ldirector shu ju ku 。 zhe ge shu ju ku jiang hui yong yu wo men de fu zai yun heng qi lai jian cha MySQL qun ji jie dian de ke yong xing 。 sql1.test.com: mysql -u root -p GRANT ALL ON ldirectordb.* TO 'ldirector'@'%' IDENTIFIED BY 'ldirectorpassword'; FLUSH PRIVILEGES; CREATE DATABASE ldirectordb; USE ldirectordb; CREATE TABLE connectioncheck (i INT) ENGINE=NDBCLUSTER; INSERT INTO connectioncheck () VALUES (1); quit; sql2.test.com: mysql -u root -p GRANT ALL ON ldirectordb.* TO 'ldirector'@'%' IDENTIFIED BY 'ldirectorpassword'; FLUSH PRIVILEGES; CREATE DATABASE ldirectordb; quit; 6.4 wei fu zai yun heng zhun bei MySQL qun ji jie dian zui hou wo men bi xu pei zhi MySQL qun ji jie dian sql1.test.com he sql2.test.com lai jie shou xu ni IP di zhi 192.168.0.105。 sql1.test.com / sql2.test.com: apt-get install iproute zai /etc/sysctl.conf li mian tian jia xia mian de nei rong : vi /etc/sysctl.conf # Enable configuration of arp_ignore option net.ipv4.conf.all.arp_ignore = 1 # When an arp request is received on eth0, only respond if that address is # configured on eth0. In particular, do not respond if the address is # configured on lo net.ipv4.conf.eth0.arp_ignore = 1 # Ditto for eth1, add for all ARPing interfaces #net.ipv4.conf.eth1.arp_ignore = 1 # Enable configuration of arp_announce option net.ipv4.conf.all.arp_announce = 2 # When making an ARP request sent through eth0 Always use an address that # is configured on eth0 as the source address of the ARP request. If this # is not set, and packets are being sent out eth0 for an address that is on # lo, and an arp request is required, then the address on lo will be used. # As the source IP address of arp requests is entered into the ARP cache on # the destination, it has the effect of announcing this address. This is # not desirable in this case as adresses on lo on the real-servers should # be announced only by the linux-director. net.ipv4.conf.eth0.arp_announce = 2 # Ditto for eth1, add for all ARPing interfaces #net.ipv4.conf.eth1.arp_announce = 2 sysctl -p jiang xia mian zhe duan jia ru dao /etc/network/interfaces: sql1.test.com / sql2.test.com: vi /etc/network/interfaces auto lo:0 iface lo:0 inet static address 192.168.0.105 netmask 255.255.255.255 pre-up sysctl -p > /dev/null ifup lo:0 qi . qi dong fu zai yun heng qi bing ce shi xian zai wo men qi dong liang ge fu zai yun heng guan li qi : loadb1.test.com / loadb2.test.com: /etc/init.d/ldirectord stop /etc/init.d/heartbeat start ru guo ni mei you kan jian cuo wu , ni xu yao xian zai chong qi mei ge fu zai yun heng qi : loadb1.test.com / loadb2.test.com: shutdown -r now chong qi zhi hou wo men ke yi jian cha shi fou liang ge fu zai yun heng qi xiang qi wang yi yang gong zuo : loadb1.test.com / loadb2.test.com: ip addr sh eth0 zhu dong de fu zai yun heng qi ying gai lie chu le xu ni IP di zhi (192.168.0.105): 2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:16:3e:45:fc:f8 brd ff:ff:ff:ff:ff:ff inet 192.168.0.103/24 brd 192.168.0.255 scope global eth0 inet 192.168.0.105/24 brd 192.168.0.255 scope global secondary eth0 bei dong ( re bei ) de fu zai yun heng qi ying gai xian shi ru xia : 2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:16:3e:16:c1:4e brd ff:ff:ff:ff:ff:ff inet 192.168.0.104/24 brd 192.168.0.255 scope global eth0 loadb1.test.com / loadb2.test.com: ldirectord ldirectord.cf status zhu dong fu zai yun heng qi shang de shu chu : ldirectord for /etc/ha.d/ldirectord.cf is running with pid: 1603 bei dong fu zai yun heng qi shang de shu chu : ldirectord is stopped for /etc/ha.d/ldirectord.cf loadb1.example.com / loadb2.example.com: ipvsadm -L -n zhu dong fu zai yun heng qi shang de shu chu : IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 192.168.0.105:3306 wrr -> 192.168.0.101:3306 Route 1 0 0 -> 192.168.0.102:3306 Route 1 0 0 bei dong fu zai yun heng qi shang de shu chu : IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn loadb1.test.com / loadb2.test.com: /etc/ha.d/resource.d/LVSSyncDaemonSwap master status zhu dong fu zai yun heng qi shang de shu chu : master running (ipvs_syncmaster pid: 1766) bei dong fu zai yun heng qi shang de shu chu : master stopped (ipvs_syncbackup pid: 1440) ru guo ni de ce shi dou shi zheng chang de , ni xian zai ke yi cong xiang tong wang luo (192.168.0.x) zhong de qi ta fu wu qi yong xu ni IP di zhi 192.168.0.105 lai fang wen MySQL shu ju ku : mysql -h 192.168.0.105 -u ldirector -p ( qing ji zhu : ni de MySQL ke hu duan bi xu zhi shao shi 4.1 ban ben de ; jiu de ban ben bu neng yun xing MySQL5。) ni xian zai ke yi guan diao yi ge MySQL qun ji jie dian lai ce shi ; ni ying gai reng ran ke yi lian jie dao MySQL shu ju ku 。 ba zhu jie yun xing yi ge MySQL qun ji shi , zhe li you yi xie chong yao de dong xi xu yao ji zhu : – suo you de shu ju dou shi cun zai nei cun ! yin ci ni de qun ji jie dian shang xu yao da rong liang de nei cun 。 zhe li you mei ge jie dian xu yao nei cun rong liang de ji suan gong shi : ( shu ju ku da xiao SizeofDatabase * fu zhi shu liang NumberOfReplicas * 1.1 ) / shu ju jie dian shu liang NumberOfDataNodes suo yi ru guo ni you yi ge shu ju ku de da xiao shi 1GB, ni ying gai wei mei ge jie dian pei bei 1.1GB nei cun ! – qun ji guan li jie dian zai jian ting 1186 duan kou shang de ren yi lian jie 。 suo yi zhe yi wei zhe bu shi hen an quan , suo yi ni ying dang zai yi ge du li de wang luo shang yun xing MySQL qun ji 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有