1、說明
專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)靈武免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了超過千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
主從為rpm包安裝方式,版本為MySQL-5.7.18-1.el7.x86_64.rpm-bundle.tar
配置 /data/mysql_data 為數(shù)據(jù)存放目錄
主從配置文件如下所示:
主服務(wù)器:
# egrep -v "^$|^#" /etc/my.cnf
[mysqld]
socket=/var/lib/mysql/mysql.sock
datadir=/data/mysql_data
character_set_server=utf8
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id=1
log-bin=mysql-bin
binlog_format=mixed
innodb_flush_log_at_trx_commit=1
sync_binlog=1
expire_logs_days=15
relay_log=mysql-realy-bin
從服務(wù)器:
# egrep -v "^$|^#" /etc/my.cnf
[mysqld]
socket=/var/lib/mysql/mysql.sock
datadir=/data/mysql_data
character_set_server=utf8
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id=2
log_bin=mysql-bin
relay_log=mysql-relay-bin
log-slave-updates=on
expire_logs_days=15
replicate-ignore-db=sys
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
2、變更步驟
首先關(guān)閉主從數(shù)據(jù)庫服務(wù)
修改配置文件 /etc/my.cnf ,我這里只修改下面一行
datadir=/data/mysql_data
>>
datadir=data /opt/tmp/mysql_data
然后把數(shù)據(jù)庫數(shù)據(jù)目錄拷貝到目標(biāo)目錄下,這里遷移到 /opt/tmp 目錄下
# cp -a /data/mysql_data /opt/tmp/
最后啟動(dòng)主從mysql服務(wù),并進(jìn)行驗(yàn)證