您好,登录后才能下订单哦!
下面一起来了解下实现mysql主从复制方法之加amoeba,相信大家看完肯定会受益匪浅,文字在精不在多,希望实现mysql主从复制方法之加amoeba这篇短内容是你想要的。
MYSQL主从复制
yum install ntp -y
时间同步服务
master
vim /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 8
systemctl start ntpd
slave
yum install ntp ntpdate -y
systemctl start ntpd
ntpdate 192.168.1.15
yum -y install mariadb mariadb-server
systemctl stop firewall
systemctl start mariadb
mster主云服务器配置
yum -y install libaio-devel #安装liaio 支持I/O
vim /etc/my.cnf
server-id = 1
log-bin=master-bin
log-slave-updates=true
mysql -p1
mysql> grant replication slave on *.* to 'myslave'@'192.168.1.%' identified by '123';
mysql> flush privileges
slave1从云服务器配置
yum -y install libaio-devel
vim /etc/my.cnf
server-id = 2
relay-log=relay-log-bin
relay-log-index=slave-relay-bin.inde
slave1从云服务器配置
yum -y install libaio-devel
vim /etc/my.cnf
server-id = 3
relay-log=relay-log-bin
relay-log-index=slave-relay-bin.inde
mysql> change master to master_host='192.168.1.101',master_user='myslave',
master_password='123',master_log_file='master-bin.000003',master_log_pos=472;
mysql> start slave;
mysql> stop slave;
mysql> show slave status\
关于 Slave_IO_Running: NO 的错误其实有很多原因,在这先说一
环境:Centos6.7 , MySQL-5.6.25
首先我只安装了一台linux 又克隆了两台,一主两从 , 关键点就在于我是克隆的,才导致了报Slave_IO_Running: NO
原因一:
原因:mysql 有个uuid , 然而uuid 是唯一标识的,所以我克隆过来的uuid是一样的,只需要修改一下uuid 就ok了,找到auto.cnf 文件修改uuid
auto.cnf文件一般在 ./var/lib/mysql/auto.cnf , 如果没有那就用linux 查询命令找:find / -name auto.cnf
vim /usr/local/mysql/data/auto.cnf
mv /usr/local/mysql/data/auto.cnf /usr/local/mysql/data/auto.cnf.ba
amoeba服务
首先安装JDK
chmod +x jdk-6u14-linux-x64.bin
./jdk-6u14-linux-x64.bin
mv jdk1.6.0_14/ /usr/local/jdk1.
export JAVA_HOME=/usr/local/jdk1.6
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/bin/:$PATH:$HOME/bin
export AMOEBA_HOME=/usr/local/amoeba
export PATH=$PATH:$AMOEBA_HOME/bi
source /etc/profil
MYSQL读写分离
mkdir /usr/local/amoeba/
tar zxvf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/amoeba/
chmod 755 /usr/local/amoeba
Master Slave1 Slave2中开放权限给amoeba访问
grant all on *.* to test@'192.168.1.%' identified by 'test'
vim /usr/local/amoeba/conf/amoeba.xml
30行 <property name="user">amoeba</property>
<property name="password">123456</property
115行 <property name="defaultPool">master</property>
<property name="writePool">master</property>
<property name="readPool">slaves</propert
vim /usr/local/amoeba/conf/dbServers.xml
26行 <property name="user">test</property>
<property name="password">test</propert
46行开始到最后
<dbServer name="master" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.151</property>
</factoryConfig>
</dbServer
<dbServer name="slave1" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.152</property>
</factoryConfig>
</dbServer
<dbServer name="slave2" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.153</property>
</factoryConfig>
</dbServer>
<dbServer name="slaves" virtual="true">
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<!-- Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA-->
<property name="loadbalance">1</property>
<!-- Separated by commas,such as: server1,server2,server1 -->
<property name="poolNames">slave1,slave2</property>
</poolConfig>
</dbServer
最后客户
/usr/local/amoeba/bin/amoeba start
mysql -u amoeba -p123456 -h 192.168.1.10 -P806
如果是mariadb的情况下要这么改
<property name="defaultPool">slaves</property>
<property name="writePool">master</property>
<property name="readPool">slaves</property>
看完实现mysql主从复制方法之加amoeba这篇文章后,很多读者朋友肯定会想要了解更多的相关内容,如需获取更多的行业信息,可以关注我们的行业资讯栏目。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。