[freebsd]haproxy實現mysql負載均衡

版主: stnet253

回覆文章
tony
文章: 585
註冊時間: 2012-02-26, 07:04
聯繫:

[freebsd]haproxy實現mysql負載均衡

未閱讀文章 tony »

haproxy支援4層交換,省得freebsd裝ipvs那麼麻煩,性能貌似不錯
# cd /usr/ports/net/haproxy-devel/
# make install clean
# cd /usr/local/etc
# mv haproxy.conf-dist haproxy.conf
隨便改了改conf,有時間研究一下設定檔吧。
global
log 127.0.0.1 local0
log 127.0.0.1 local1notice
#log loghost local0 info
maxconn 4096
chroot /usr/local/etc/haproxy
uid 99
gid 99
daemon
#debug
#quiet

defaults
log global
mode tcp
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000

listen appli1-rewrite 192.0.0.148:3333
balance roundrobin
server app1_1 192.0.0.200:3306
server app1_2 192.0.0.148:3306
server app1_3 192.0.0.148:3307

# /usr/local/etc/rc.d/haproxy forcestart
順利啟動
開始測試,我的兩台機器分別裝著不同版本的mysql
# mysql -h 192.0.0.148 -P 3333 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ;or \g.
Your MySQL connection id is 93
Server version: 5.0.27-log FreeBSD port:mysql-server-5.0.27
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Bye
# mysql -h 192.0.0.148 -P 3333 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ;or \g.
Your MySQL connection id is 2638
Server version: 6.0.8-alpha-log FreeBSDport: mysql-server-6.0.8
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Bye
192# mysql -h 192.0.0.148 -P 3333 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ;or \g.
Your MySQL connection id is 6
Server version: 5.1.30 FreeBSD port:mysql-server-5.1.30
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Bye
仿佛比ipvs還強大一些,不知道和mysql-proxy比誰的性能會更好些。
回覆文章

誰在線上

正在瀏覽這個版面的使用者:Semrush [Bot] 和 1 位訪客