linux下搭建mysql主從

來源:互聯網
上載者:User

標籤:

在master上建立repl賬戶,用於複製。

grant replication slave on *.* to ‘repl‘@‘%‘ identified by ‘[email protected]$$W0rd‘;

flush privileges;

與windows下搭建mysql主從的區別:

二進位日誌的路徑格式不一樣

master:

my.cnf部分配置(master):
thread_handling = pool-of-threads
thread_pool_oversubscribe = 10
skip-name-resolve
# Replication Master Server (default)
# binary logging is required for replication
#log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id     = 1
expire_logs_days        = 10
max_binlog_size         = 100M
log_bin                 = /var/lib/mysql/mysql-bin.log   #確保此檔案可寫
read-only              =0  #主機,讀寫都可以
binlog-do-db         =yourdb   #需要備份資料,多個寫多行
binlog-ignore-db    =mysql #不需要備份的資料庫,多個寫多行

slave:

master:

show variables like ‘%log_bin%‘;
show master status

slave:

stop slave;
change master to
master_host=‘192.168.103.56‘,
master_user=‘repl‘,
master_password=‘[email protected]$$W0rd‘,
master_log_file=‘mysql-bin.000002‘,
master_log_pos=120;
start slave;
show slave status;

linux下搭建mysql主從

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.