一、Amoeba介绍
1、优点
1)这个软件致力于MySQL的分布式数据库前端代理层,它主要在应用层访问MySQL的 时候充当SQL路由功能,专注于分布式数据库代理层(Database Proxy)开发。
2)座落与 Client、DB Server(s)之间,对客户端透明。
3)具有负载均衡、高可用性、SQL 过滤、读写分离、可路由相关的到目标数据库、可并发请求多台数据库合并结果。
4)通过Amoeba你能够完成多数据源的高可用、负载均衡、数据切片的功能,目前Amoeba已在很多 企业的生产线上面使用。
5)Amoeba目前不支持事务
2、缺点
1)目前还不支持事务
2)暂时不支持存储过程(近期会支持)
3)不适合从amoeba导数据的场景或者对大数据量查询的query并不合适(比如一次请求返回10w以上甚至更多数据的场合)
4)暂时不支持分库分表,amoeba目前只做到分数据库实例,每个被切分的节点需要保持库表结构一致。
二、mysql5.6给予gtid的复制
1、mysql脚本安装
#!/bin/bash yum -y install make gcc gcc-c++ openssl openssl-devel pcre-devel gd cmake ncurses ncurses-devel id -u mysql if [ `echo $?` -ne 0 ]; then groupadd mysql useradd -M -g mysql -s /sbin/nologin mysql fi if [ ! -d "/usr/local/mysql" ]; then mkdir -p /usr/local/mysql fi mkdir -p /data/mysql chown -R mysql:mysql /data/mysql cd /home/tsbsoft/ tar zxvf mysql-5.6.30.tar.gz #提前下载安装包 cd mysql-5.6.30 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/data/mysql/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 make && make install chown -R mysql:mysql . chmod +x scripts/mysql_install_db ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld chmod 755 /etc/init.d/mysqld chkconfig mysqld on cat> /etc/rc.d/init.d/mysqld <<eof #!/bin/sh # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB # This file is public domain and comes with NO WARRANTY of any kind # MySQL daemon start/stop script. # Usually this is put in /etc/init.d (at least on machines SYSV R4 based # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. # When this is done the mysql server will be started when the machine is # started and shut down when the systems goes down. # Comments to support chkconfig on RedHat Linux # chkconfig: 2345 64 36 # description: A very fast and reliable SQL database engine. # Comments to support LSB init script conventions ### BEGIN INIT INFO # Provides: mysql # Required-Start: $local_fs $network $remote_fs # Should-Start: ypbind nscd ldap ntpd xntpd # Required-Stop: $local_fs $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop MySQL # Description: MySQL is a very fast and reliable SQL database engine. ### END INIT INFO # If you install MySQL on some other places than /usr/local/mysql, then you # have to do one of the following things for this script to work: # # - Run this script from within the MySQL installation directory # - Create a /etc/my.cnf file with the following information: # [mysqld] # basedir=
2、授权
mysql -u root -pmypass grant replication slave,replication client on *.* to repluser@% identified by replpass; show variables like server_id; 查看server-id的值
3、从服务器
修改配置文件/etc/my.cnf server-id = 2 report-host=node3.test.cm change master to master_host=192.168.0.12,master_user=repluser,master_password=replpass,master_auto_position=1; slave start;
三、amoeba安装配置
1、安装jdk
#rmp -ivh jdk-7u9-linux-x64.rpm
# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin:$PATH
#source /etc/profile.d/java.sh
# java -version
2、安装部署amoeba
http://sourceforge.net/projects/amoeba/files/
tar zxvf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/
# ln -sv amoeba-mysql-binary-2.2.0 amoeba
# vim /etc/profile.d/amoeba.sh
export AMOEBA_HOME=/usr/local/amoeba
export PATH=$AMOEBA_HOME/bin:$PATH
#source /etc/profile.d/tomcat.sh
3、配置读写分离
vim /usr/local/amoeba/conf/amoeba.xml
vim dbServers.xml