商州網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,商州網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為商州千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的商州做網(wǎng)站的公司定做!
準(zhǔn)備環(huán)境:服務(wù)器操作系統(tǒng)為RHEL6.4 x86_64,為最小化安裝。主機(jī)A和主機(jī)B均關(guān)閉防火墻和SELINUX ,IP地址分別為192.168.131.129和192.168.131.130,MySQL版本為5.6.26,為通用二進(jìn)制包。
1.安裝MySQL
1.主機(jī)A操作
# tar xf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
# mv mysql-5.6.26-linux-glibc2.5-x86_64 /usr/local/mysql
# useradd -M -s /sbin/nologin mysql
# chown -R root:root /usr/local/mysql/*
# chown -R mysql:mysql /usr/local/mysql/data/
# yum -y install libaio
# cd /usr/local/mysql/scripts/
# ./mysql_install_db --datadir=/usr/local/mysql/data/ --user=mysql --basedir=/usr/local/mysql/
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile
# source /etc/profile
# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# service mysqld start
#chkconfig mysqld on
# ss -tunlp | grep 3306
# mysqladmin -uroot password '123456' #設(shè)置數(shù)據(jù)庫(kù)密碼
2.主機(jī)B操作(同上)
二、配置雙主
1、主機(jī)A操作
# vim /etc/my.cnf
server-id=20
log-bin=mysql-bin
log-bin-index=mysql-bin.index
replicate-ignore-db=test
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
auto-increment-increment=2
auto-increment-offset=1
# service mysqld restart
# mysql -uroot -p123456
mysql> flush tables with read lock;
再打開一個(gè)遠(yuǎn)程終端窗口,執(zhí)行以下操作
# mysqldump -uroot -p123456 -B test > test.sql
返回之前的終端窗口,做以下操作
mysql> unlock tables;
mysql> grant replication slave on *.* to 'wdd'@'192.168.131.130' identified by '123456';
mysql> flush privileges;
# scp test.sql 192.168.131.130:/root
2、主機(jī)B操作
# vim /etc/my.cnf
server-id = 21
log-bin=mysql-bin
log-bin-index= mysql-bin.index
replicate-do-db=test
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
auto-increment-increment=2
auto-increment-offset=2
#service mysqld restart
# mysql -uroot -p123456 < test.sql
# mysql -uroot -p123456
mysql> grant replication slave on *.* to 'wdd'@'192.168.131.129' identified by '123456';
mysql> flush privileges;
3.主機(jī)A和主機(jī)B分別作如下操作
主機(jī)A
①# mysql -uroot -p123456
mysql> SHOW MASTER STATUS;
mysql> change master to
master_host='192.168.131.130',
master_user='wdd',
master_password='123456',
master_log_file=' mysql-bin.000002',
master_log_pos=420;
mysql> start slave;
mysql> show slave status\G;
②# mysql -uroot -p123456
mysql> show master status;
mysql> change master to
master_host='192.168.131.129',
master_user='wdd',
master_password='123456',
master_log_file='mysql-bin.000002',
master_log_pos=689;
mysql> start slave;
mysql> show slave status\G;
三、測(cè)試
1、主機(jī)A進(jìn)行一下操作
mysql> use test;
mysql> create table info(
-> id int(10) not null auto_increment primary key,
-> name char(20));
mysql> show tables;
2、主機(jī)B進(jìn)行操作
mysql> use test;
mysql> show tables;
mysql> create table person (
-> id int(20) unsigned not null auto_increment primary key,
-> name char(20));
mysql> show tables;
3.在主機(jī)A進(jìn)行操作檢驗(yàn)
網(wǎng)頁(yè)標(biāo)題:MySQL雙主配置
網(wǎng)頁(yè)地址:http://m.rwnh.cn/article14/gspjde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、搜索引擎優(yōu)化、關(guān)鍵詞優(yōu)化、靜態(tài)網(wǎng)站、App開發(fā)、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)