您好,登錄后才能下訂單哦!
下面一起來了解下實(shí)現(xiàn)mysql主從復(fù)制方法之加amoeba,相信大家看完肯定會受益匪淺,文字在精不在多,希望實(shí)現(xiàn)mysql主從復(fù)制方法之加amoeba這篇短內(nèi)容是你想要的。
MYSQL主從復(fù)制
yum install ntp -y
時間同步服務(wù)
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主云服務(wù)器配置
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從云服務(wù)器配置
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從云服務(wù)器配置
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\
關(guān)于 Slave_IO_Running: NO 的錯誤其實(shí)有很多原因,在這先說一
環(huán)境:Centos6.7 , MySQL-5.6.25
首先我只安裝了一臺linux 又克隆了兩臺,一主兩從 , 關(guān)鍵點(diǎn)就在于我是克隆的,才導(dǎo)致了報(bào)Slave_IO_Running: NO
原因一:
原因:mysql 有個uuid , 然而uuid 是唯一標(biāo)識的,所以我克隆過來的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服務(wù)
首先安裝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中開放權(quán)限給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>
看完實(shí)現(xiàn)mysql主從復(fù)制方法之加amoeba這篇文章后,很多讀者朋友肯定會想要了解更多的相關(guān)內(nèi)容,如需獲取更多的行業(yè)信息,可以關(guān)注我們的行業(yè)資訊欄目。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。