使用amoeba配置mysql读写分离

一,背景介绍:

Amoeba(变形虫)项目,专注 分布式数据库 proxy 开发。座落与Client、DB Server(s)之间。对客户端透明。具有负载均衡、高可用性、sql过滤、读写分离、可路由相关的query到目标数据库、可并发请求多台数据库合并结果。要想搭建Amoeba读写分离,首先需要知道MySQL的主从配置。具体的架构图如下图:

wKioL1d6GI2AthQmAAD0JxjjeaQ314.png-wh_50


二,配置所需的环境:

 Amoeba for mysql:192.168.1.28

 Master : 192.168.1.247

 Slave : 192.168.1.245

 database:yazi passwd:root/123456

 JDK1.8.0_51


三,具体的搭建和配置步骤如下:

 1,配置mysql主从复制,具体参照上篇的mysql主从复制的配置

 2,安装配置jdk1.8.0_51以及环境变量

   (1),安装jdk命令: rpm -ivh jdk-8u51-linux-x64.rpm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@localhost  install ] # ll
total 481168
-rw-r--r--. 1 root root   8850470 Nov  2 22:43 apache-tomcat-7.0.63. tar .gz
-rw-r--r--. 1 root root 137808216 Jan 13 15:09 jdk-8u51-linux-x64.rpm
-rw-r--r--. 1 root root  33203321 Nov 20 11:31 mysql-5.6.25. tar .gz
-rw-r--r--. 1 root root 312845162 Nov 13 15:19 mysql-5.6.27-linux-glibc2.5-x86_64. tar .gz
[root@localhost  install ] # rpm -ivh jdk-8u51-linux-x64.rpm 
Preparing...                 ########################################### [100%]
    1:jdk1.8.0_51             ########################################### [100%]
Unpacking JAR files...
         rt.jar...
         jsse.jar...
         charsets.jar...
         tools.jar...
         localedata.jar...
         jfxrt.jar...
         plugin.jar...
         javaws.jar...
         deploy.jar...

   (2)配置环境变量:

[root@localhost install]# vi /etc/profile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
     case  ":${PATH}:"  in
         *: "$1" :*)
             ;;
         *)
             if  "$2"  "after"  ] ;  then
                 PATH=$PATH:$1
             else
                 PATH=$1:$PATH
             fi
     esac
}
if  [ -x  /usr/bin/id  ];  then
     if  [ -z  "$EUID"  ];  then
         # ksh workaround
         EUID=` id  -u`
         UID=` id  -ru`
     fi
     USER= "`id -un`"
     LOGNAME=$USER
     MAIL= "/var/spool/mail/$USER"
fi
# Path manipulation
if  "$EUID"  "0"  ];  then
     pathmunge  /sbin
     pathmunge  /usr/sbin
     pathmunge  /usr/local/sbin
else
     pathmunge  /usr/local/sbin  after
     pathmunge  /usr/sbin  after
     pathmunge  /sbin  after
fi
HOSTNAME=` /bin/hostname  2> /dev/null `
HISTSIZE=1000
if  "$HISTCONTROL"  "ignorespace"  ] ;  then
     export  HISTCONTROL=ignoreboth
else
     export  HISTCONTROL=ignoredups
fi
export  PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if  [ $UID -gt 199 ] && [  "`id -gn`"  "`id -un`"  ];  then
     umask  002
else
     umask  022
fi
for  in  /etc/profile .d/*.sh ;  do
     if  [ -r  "$i"  ];  then
         if  "${-#*i}"  !=  "$-"  ];  then
             "$i"
         else
             "$i"  > /dev/null  2>&1
         fi
     fi
done
unset  i
unset  -f pathmunge
 
export  JAVA_HOME= /usr/java/jdk1 .8.0_51
export  JRE_HOME= /usr/java/jdk1 .8.0_51 /jre
export  PATH=$JAVA_HOME /bin :$PATH
export  CLASSPATH=.:$JAVA_HOME /lib/dt .jar:$JAVA_HOME /lib/tools .jar

    (3)配置生效和验证:

1
2
3
4
5
[root@FileServerA logs] # source /etc/profile
[root@FileServerA logs] # java -version
java version  "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)



 3,安装配置amoeba

   (1)下载amoeba

http://item.taobao.com/item.htm?id=41222768202

   (2)压缩包无需安装,直接解压即可

1
2
3
4
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值