MariaDB Proxy读写分离的实现

MariaDB Proxy读写分离的实现

1.创建用于存储数据目录lvm设备

MariaDB Proxy读写分离的实现

MariaDB Proxy读写分离的实现

MariaDB Proxy读写分离的实现

MariaDB Proxy读写分离的实现

 

安装mysql-proxy-0.8.3

 

MariaDB Proxy读写分离的实现

MariaDB 的详细介绍:请点这里
MariaDB 的下载地址:请点这里

--------------------------------------分割线 --------------------------------------

推荐阅读:

--------------------------------------分割线 --------------------------------------

为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

 

相关推荐