Mycat HA(高可用) 与 LB(负载均衡)19

2021-12-02 09:54:29 浏览数 (1)

切换过程中的影响

切换过程并非完全没有任何影响,一般会产生一次中断,但当再次发起请求时(重试时)就能恢复正常

下面的过程就是在切换中进行操作的

代码语言:javascript复制
mysql> show tables;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> show tables;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    175
Current database: cctest

 ------------------ 
| Tables in cctest |
 ------------------ 
| abc              |
| catworld         |
 ------------------ 
2 rows in set (0.07 sec)

mysql> show databases;
 ---------- 
| DATABASE |
 ---------- 
| cctest   |
 ---------- 
1 row in set (0.00 sec)

mysql> 

命令汇总

  • wget http://www.keepalived.org/software/keepalived-1.2.19.tar.gz
  • tar -zxvf keepalived-1.2.19.tar.gz
  • cd keepalived-1.2.19
  • ./configure --prefix=/usr/local/keepalived
  • make
  • make install
  • tree /usr/local/keepalived/
  • /usr/local/keepalived/sbin/keepalived -v
  • md5sum haproxy-1.6.3.tar.gz
  • tar -zxvf haproxy-1.6.3.tar.gz
  • cd haproxy-1.6.3
  • make TARGET=linux2628 ARCH=x86_64 PREFIX=/usr/local/haproxy
  • make install PREFIX=/usr/local/haproxy
  • tree /usr/local/haproxy/
  • /usr/local/haproxy/sbin/haproxy -v
  • rpm -qa | grep rsyslog
  • grep -v "^#" /etc/rsyslog.conf | grep -v "^$"
  • vim /etc/rsyslog.d/haproxy.conf
  • cat /etc/rsyslog.d/haproxy.conf
  • /etc/init.d/rsyslog restart
  • ll /var/log/ha*
  • netstat -antulp | grep 514
  • logger -it test -p local0.info "test"
  • tail -f /var/log/haproxy.log
  • rsync -av root@192.168.100.102:/usr/local/src/mycat/Mycat-server-1.5-GA-20160217103036-linux.tar.gz .
  • tar -zxvf Mycat-server-1.5-GA-20160217103036-linux.tar.gz
  • java -version
  • cat wrapper.conf | egrep "(Xm|MaxDirectMemorySize)"
  • vim /etc/sysconfig/iptables
  • /etc/init.d/iptables reload
  • iptables -L -nv | grep -E "(8066|9066|8888|9999)"
  • ./mycat start
  • mysql -u cc -p -P 8066 -p -h 192.168.100.101
  • useradd haproxy
  • grep proxy /etc/passwd
  • chown -R haproxy.haproxy /usr/local/haproxy/
  • vim haproxy.cfg
  • grep -v "^#" haproxy.cfg
  • /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
  • ps faux | grep -v grep | grep haproxy
  • netstat -ant | grep -E "(8066|9066|8888|9999|1234)"
  • cat /usr/local/keepalived/script/chk_haproxy.bash
  • chmod x /usr/local/keepalived/script/chk_haproxy.bash
  • ps faux | grep -v grep | grep haproxy
  • /usr/local/keepalived/script/chk_haproxy.bash
  • cat /etc/keepalived/keepalived.conf
  • /usr/local/keepalived/sbin/keepalived -f /etc/keepalived/keepalived.conf
  • kill 12118; watch -n .5 ip a
  • /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg; watch -n .5 ip a
  • mysql -u cc -p -P 8888 -h 192.168.100.222

原文地址

0 人点赞