一、Amoeba介紹
1、優(yōu)點(diǎn)
1)這個(gè)軟件致力于MySQL的分布式數(shù)據(jù)庫(kù)前端代理層,它主要在應(yīng)用層訪問(wèn)MySQL的 時(shí)候充當(dāng)SQL路由功能,專注于分布式數(shù)據(jù)庫(kù)代理層(Database Proxy)開發(fā)。
2)座落與 Client、DB Server(s)之間,對(duì)客戶端透明。
3)具有負(fù)載均衡、高可用性、SQL 過(guò)濾、讀寫分離、可路由相關(guān)的到目標(biāo)數(shù)據(jù)庫(kù)、可并發(fā)請(qǐng)求多臺(tái)數(shù)據(jù)庫(kù)合并結(jié)果。
4)通過(guò)Amoeba你能夠完成多數(shù)據(jù)源的高可用、負(fù)載均衡、數(shù)據(jù)切片的功能,目前Amoeba已在很多 企業(yè)的生產(chǎn)線上面使用。
5)Amoeba目前不支持事務(wù)
2、缺點(diǎn)
1)目前還不支持事務(wù)
2)暫時(shí)不支持存儲(chǔ)過(guò)程(近期會(huì)支持)
3)不適合從amoeba導(dǎo)數(shù)據(jù)的場(chǎng)景或者對(duì)大數(shù)據(jù)量查詢的query并不合適(比如一次請(qǐng)求返回10w以上甚至更多數(shù)據(jù)的場(chǎng)合)
4)暫時(shí)不支持分庫(kù)分表,amoeba目前只做到分?jǐn)?shù)據(jù)庫(kù)實(shí)例,每個(gè)被切分的節(jié)點(diǎn)需要保持庫(kù)表結(jié)構(gòu)一致。
二、mysql5.6給予gtid的復(fù)制
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、授權(quán)
mysql -u root -pmypass grant replication slave,replication client on *.* to repluser@% identified by replpass; show variables like server_id; 查看server-id的值
3、從服務(wù)器
修改配置文件/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