测试,在主服务器上创建一个空库,看一下从服务器上有木有
在主服务上
mysql> create database ab;
在从服务器1上:
mysql> show databases;
在服务器2上:
mysql> show databases;
如上两幅图所示,表示主从同步成功了。
3、搭建amoeba前端服务器:192.168.80.190
[root@amoeba ~]# yum install -y ntpdate
[root@amoeba ~]# ntpdate 192.168.80.100
[root@amoeba ~]# echo '/30 * /usr/sbin/ntpdate 192.168.80.100' >> /var/spool/cron/root
[root@amoeba ~]# crontab -l
[root@amoeba ~]# tar xf jdk-8u144-linux-x64.tar.gz -C /opt/
[root@amoeba ~]# cd /opt/
[root@amoeba opt]# cp -rv jdk1.8.0_144/ /usr/local/java
[root@amoeba opt]# vi /etc/profile //搭建Java环境
export JAVA_HOME=/usr/local/java
export JRE_HOME=/usr/local/java/jre
export PATH=$PATH:/usr/local/java/bin
export CLASSPATH=./:/usr/local/java/lib:/usr/local/java/jre/lib
[root@amoeba opt]# source /etc/profile
[root@amoeba opt]# java -version
如上图所示,搭建好了Java环境
[root@amoeba ~]# unzip amoeba-mysql-3.0.5-RC-distribution.zip -d /opt/
[root@amoeba ~]# cd /opt/
[root@amoeba opt]# mv amoeba-mysql-3.0.5-RC/ /usr/local/amoeba
[root@amoeba opt]# chmod -R 755 /usr/local/amoeba/
[root@amoeba opt]# vi /usr/local/amoeba/jvm.properties
新增:
JVM_OPTIONS="-server -Xms1024m -Xmx1024m -Xss256k"
[root@amoeba opt]# vi /etc/init.d/amoeba //编辑系统服务脚本
#!/bin/bash
#chkconfig: 35 62 62
export JAVA_HOME=/usr/local/java
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
NAME=Amoeba
AMOEBA_BIN=/usr/local/amoeba/bin/launcher&
SHUTDOWN_BIN=/usr/local/amoeba/bin/shutdown
PIDFILE=/usr/local/amoeba/Amoeba-MySQL.pid
SCRIPTNAME=/etc/init.d/amoeba
case "$1" in
start)
echo -n "Starting $NAME... "
$AMOEBA_BIN
echo " done"
;;
stop)
echo -n "Stoping $NAME... "
$SHUTDOWN_BIN
echo " done"
;;
restart)
$SHUTDOWN_BIN
sleep 1
$AMOEBA_BIN
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}"
exit 1
;;
Esac
[root@amoeba opt]# chmod +x /etc/init.d/amoeba //给予执行权限
[root@amoeba opt]# chkconfig --add amoeba //添加到系统管理中
[root@amoeba opt]# service amoeba start //开启amoeba服务
4、配置读写分离
----在三台mysql数据库中为amoeba授权-------
mysql> GRANT ALL ON . TO test@'192.168.80.%' IDENTIFIED BY '123123';
mysql> FLUSH PRIVILEGES;