123456 /"/usr/local/amoeba/conf/amoeba.xmlsed -i "115s/server1/master/"/usr/local/amoeba/conf/amoeba.xmlsed -i "119s/readPool/slave/"/usr/local/amoeba/conf/amoeba.xml mv /usr/local/amoeba/。mysql主从复制及读写分离脚本-亲测可用( 二 )。" />

mysql主从复制及读写分离脚本-亲测可用( 二 )

<< EOFexportJAVA_HOME=/usr/java/jdk1.8.0_20/exportCLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/libexportPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/bin:$PATH:$HOME/binexportAMOEBA_HOME=/usr/local/amoebaexportPATH=$PATH:$AMOEBA_HOME/binEOFsource /etc/profile #重新加载source /etc/profile #重新加载#############安装amoeba#############mkdir /usr/local/amoeba &&chmod -R 755 /usr/local/amoeba #创建目录amoeba及更改权限tar xzf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/amoeba/ #解包到/usr/local/amoeba目录中### /usr/local/amoeba/bin/sed -i "58s/128/256/" /usr/local/amoeba/bin/amoebacd /usr/local/amoeba/bin/&&./amoeba#########进入执行目录安装###################cp/usr/local/amoeba/conf/amoeba.xml/usr/local/amoeba/conf/amoeba.xml.baksed -i "30s/root/amoeba/"/usr/local/amoeba/conf/amoeba.xmlsed -i "32s/"password">/"password">123456/"/usr/local/amoeba/conf/amoeba.xmlsed -i "115s/server1/master/"/usr/local/amoeba/conf/amoeba.xmlsed -i "119s/readPool/slave/"/usr/local/amoeba/conf/amoeba.xml mv /usr/local/amoeba/conf/dbServers.xml/usr/local/amoeba/conf/dbServers.xml.bakread -p "请输入mysql主服务器的IP: "masterIPread -p "请输入mysql从服务器1的IP: "slave1IPread -p "请输入mysql从服务器2的IP: "slave2IPcat >> /usr/local/amoeba/conf/dbServers.xml<< EOF${defaultManager}641283306testmysql password12345650050010600000600000truetruetrue$masterIP【mysql主从复制及读写分离脚本-亲测可用】$slave1IP$slave2IP1slave1, slave2EOF/usr/local/amoeba/bin/amoeba start&###后台启动yum -y install mariadb mariadb-server$$echo"mariadb安装成功"echo "请通过命令mysql -utest -p123 -h $masterIP|$slave1IP|$slave2IP 访问测试"
脚本运行过程中需要输入相关服务器IP 。
代理脚本所需要的安装包请到作者个人网站下载: