Mysql Master Slave Config,mysqlslave

來源:互聯網
上載者:User

Mysql Master Slave Config,mysqlslave

同一台機器安裝兩個及以上MySQL服務:

下載mysql安裝包,安裝完成以後將安裝資料夾複製多份在磁碟上面;分別進入my.ini修改port(連接埠不能衝突),server_id,basedir(optional),datadir(資料檔案路徑)等參數;

# Path to the database root
datadir="D:/MySQL/MySQL Server 5.7/data/"

# General and Slow logging.
log-output=FILE
general-log=1
general_log_file="VIPSH-20140721I.log"
slow-query-log=1
slow_query_log_file="VIPSH-20140721I-slow.log"
long_query_time=2

# Binary Logging.
# log-bin
server_id           = 54
log_bin             = D:/MySQL/MySQL Server 5.7/data/EricSun-mysql-bin.log
log_bin_index       = D:/MySQL/MySQL Server 5.7/data/EricSun-mysql-bin.index
max_binlog_size     = 256M
expire_logs_days    = 30

#=====從伺服器需要配置=====
relay_log = EricSun-mysql-relay-bin
log_slave_updates = 1
read_only = 1


# Error Logging.
log-error="VIPSH-20140721I.err"

註:複製安裝資料夾時一定要刪除auto.cnf,否則啟動slave的時候會報錯:Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

以上完成以後,cmd輸入命令安裝windows service服務:mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"

安裝成功以後,分別啟動不同的mysql服務;

登陸進入不同的mysql執行個體,輸入show master status\G;查看主伺服器狀態;輸入show slave status\G;查看從伺服器狀態;

然後再從伺服器CMD視窗設定:change master to master_host='localhost',master_user='root',master_password='root',master_log_file='mysql-bin.000001',master_log_pos='0';

然後再次輸入show slave status\G; 查看 

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

後台線程運行YES。

此時在主庫上進行CRUD,從庫會有更新


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.