时间:2021-07-01 10:21:17 帮助过:66人阅读
MariaDB Proxy读写分离的实现
1.创建用于存储数据目录lvm设备
安装mysql-proxy-0.8.3
MariaDB 的详细介绍:请点这里
MariaDB 的下载地址:请点这里
--------------------------------------分割线 --------------------------------------
推荐阅读:
在CentOS/RHEL/Scientific Linux 6 下安装 LAMP (Apache with MariaDB and PHP)http://www.linuxidc.com/Linux/2013-07/86755.htm
Haproxy+Keepalived搭建Weblogic高可用负载均衡集群http://www.linuxidc.com/Linux/2013-09/89732.htm
Keepalived+HAProxy配置高可用负载均衡http://www.linuxidc.com/Linux/2012-03/56748.htm
CentOS 6.3下Haproxy+Keepalived+Apache配置笔记http://www.linuxidc.com/Linux/2013-06/85598.htm
Haproxy + KeepAlived 实现WEB群集 on CentOS 6http://www.linuxidc.com/Linux/2012-03/55672.htm
Haproxy+Keepalived构建高可用负载均衡http://www.linuxidc.com/Linux/2012-03/55880.htm
--------------------------------------分割线 --------------------------------------
为mysql-proxy提供SysV服务脚本,内容如下所示
#vim /etc/rc.d/init.d/mysql-proxy
#!/bin/bash
#
# mysql-proxy Thisscript starts and stops the mysql-proxy daemon
#
# chkconfig: - 7830
# processname:mysql-proxy
# description:mysql-proxy is a proxy daemon for mysql
# Source functionlibrary.
./etc/rc.d/init.d/functions
prog="/usr/local/mysql-proxy/bin/mysql-proxy"
# Sourcenetworking configuration.
if [ -f/etc/sysconfig/network ]; then
. /etc/sysconfig/network
fi
# Check thatnetworking is up.
[ ${NETWORKING} = "no"] && exit 0
# Set defaultmysql-proxy configuration.
ADMIN_USER="admin"
ADMIN_PASSWD="admin"
ADMIN_LUA_SCRIPT="/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua"
PROXY_OPTIONS="--daemon"
PROXY_PID=/var/run/mysql-proxy.pid
PROXY_USER="mysql-proxy"
# Sourcemysql-proxy configuration.
if [ -f/etc/sysconfig/mysql-proxy ]; then
. /etc/sysconfig/mysql-proxy
fi
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $prog $PROXY_OPTIONS--pid-file=$PROXY_PID --proxy-address="$PROXY_ADDRESS"--user=$PROXY_USER --admin-username="$ADMIN_USER"--admin-lua-script="$ADMIN_LUA_SCRIPT"--admin-password="$ADMIN_PASSWORD"
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
touch /var/lock/subsys/mysql-proxy
fi
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $PROXY_PID -d 3 $prog
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/mysql-proxy
rm -f $PROXY_PID
fi
}
# See how we werecalled.
case"$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart|try-restart)
if status -p $PROXY_PIDFILE $prog>&/dev/null; then
stop
start
fi
;;
status)
status -p $PROXY_PID $prog
;;
*)
echo "Usage: $0{start|stop|restart|reload|status|condrestart|try-restart}"
RETVAL=1
;;
esac
exit$RETVAL
将上述内容保存为/etc/rc.d/init.d/mysql-proxy,给予执行权限,而后加入到服务列表。
#chmod +x /etc/rc.d/init.d/mysql-proxy
#chkconfig --add mysql-proxy
更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2014-05/101306p2.htm