Keepalived+Haproxy+MySQL(garela)集群配置

积思园 2015-07-28 09:29:59


各位好,目前我正在进行Keepalived+Haproxy+MySQL(garela)集群配置,遇到了两个问题,希望能够得到各位的建议。

架构比较简单,如图所示,设置了一个虚拟IP,

1、Keepalived的配置如下
sm@vip1:~$ cat /etc/keepalived/keepalived.conf
global_defs {
router_id LVS_DEVEL
}
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
vrrp_instance VI_1 {

state MASTER
interface eth0
virtual_router_id 51
priority 101

authentication {
auth_type PASS
auth_pass 1111
}

virtual_ipaddress {
192.168.13.95
}

track_script{
chk_haproxy
}
}


2、Haproxy的配置如下
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
maxconn 40000

defaults
log global
maxconn 80000
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s


listen mysql_cluster
bind 192.168.13.95:3306
option httpchk
balance source
server controller1 192.168.13.97:3306 check port 9200 inter 2000 rise 2 fall 5
server controller2 192.168.13.98:3306 check port 9200 inter 2000 rise 2 fall 5
server controller3 192.168.13.99:3306 check port 9200 inter 2000 rise 2 fall 5


3、MySQL的安装


1、所有机器都安装
libaio1 libssl0.9.8 mysql-client-5.5 python-mysqldb
mysql-server-wsrep-5.5.23-23.6-amd64.deb
galera-23.2.1-amd64.deb




2、所有集群根据自己的IP配置,/etc/mysql/my.cnf文件
bind-address = 192.168.13.97


3、修改 /etc/mysql/conf.d/wsrep.cnf

#mysql1

bind-address=192.168.13.97
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="controller_cluster"
wsrep_cluster_address="gcomm://"
wsrep_sst_method=rsync
wsrep_sst_auth=wsrep_sst:password

#mysql2
bind-address=192.168.13.98
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="controller_cluster"
wsrep_cluster_address="gcomm://192.168.13.97"
wsrep_sst_method=rsync
wsrep_sst_auth=wsrep_sst:password




出现的问题
1、我可以启动mysql1的服务,但是mysql2的服务启动不了,也就是说mysql2添加不了mysql1的集群。
查看/var/log/syslog报如下错误
Jul 28 21:07:48 controller2 mysqld: #011 at galera/src/replicator_str.cpp:prepare_for_IST():439. IST will be unavailable.
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: Node 1 (controller2) requested state transfer from '*any*'. Selected 0 (controller1)(SYNCED) as donor.
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: Shifting PRIMARY -> JOINER (TO: 16)
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: Requesting state transfer: success, donor: 0
Jul 28 21:07:48 controller2 rsyncd[1625]: connect from controller1 (192.168.13.97)
Jul 28 21:07:48 controller2 rsyncd[1625]: rsync: setgroups failed: Operation not permitted (1)
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Warning] WSREP: 0 (controller1): State transfer to 1 (controller2) failed: -1 (Operation not permitted)
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [ERROR] WSREP: gcs/src/gcs_group.c:gcs_group_handle_join_msg():712: Will never receive state. Need to abort.
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: gcomm: terminating thread
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: gcomm: joining thread
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: gcomm: closing backend
Jul 28 21:07:48 controller2 mysqld: 150728 21:07:48 [Note] WSREP: view(view_id(NON_PRIM,6c172cef-3529-11e5-0800-7e16d33603ba,2) memb {
Jul 28 21:07:48 controller2 mysqld: #011a327926e-3529-11e5-0800-7ac52316ca88,


2、我在mysql1机器上创建了一些数据库,用户,我可以通过这些数据库用户、密码以及数据库连接VIP可以连接成功,但是为什么我的root用户无法使用VIP呢?

为什么用用root用户连接VIP,会自动连接到haproxy的主节点上(192.168.13.92)
root@controller1:~# mysql -uroot -p#db4smtest# -h192.168.13.95
ERROR 1045 (28000): Access denied for user 'root'@'192.168.13.92' (using password: YES)
但是我使用已经创建的用户密码和数据库连接VIP确没有问题
root@controller1:~# mysql -unovadbadmin -pnova4smtest -h192.168.13.95 nova
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 72
Server version: 5.5.23 Source distribution, wsrep_23.6.r3755

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


我用的Ubuntu 14.04 ufw已经关闭
希望各位高手给点建议!
...全文
195 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
-无-为- 2015-07-29
  • 打赏
  • 举报
回复
还没有配置过,帮顶。。

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧