本次環(huán)境:虛擬機下
服務器:Ubuntu 14.04 LTS
數(shù)據(jù)庫: 5.5.37
端口:3306
主IP:192.168.63.133
從IP:192.168.63.134
授權(quán)賬號:
user:suxh
password:111111
好了交代完環(huán)境:我們直接配置:
第一步:主從兩臺服務器要有同樣的數(shù)據(jù)庫(需要同步的)這里用的是backup 數(shù)據(jù)庫(不多說了,在同步開始前,把主庫的復制一份到從庫就行了)
第二步配置主(master)數(shù)據(jù)庫 編輯/etc/my.cnf 主要是開啟二進制日志 和設置要同步的數(shù)據(jù)庫 等一些參數(shù)
| # binary logging format - mixed recommendedbinlog_format=mixedbinlog-ignore-db=mysqlbinlog-do-db=backup # 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 omittedserver-id = 1 |
參數(shù)解釋下:
server-id 這個是唯一的不能跟從服務器相同。
binlog_format 二進制文件的格式
binlog_ignore-db 忽略的數(shù)據(jù)庫
binlog-do-db 要同步的數(shù)據(jù)庫
設置完了以后 重啟數(shù)據(jù)庫就可以了。
第三步從數(shù)據(jù)庫:
同樣修改/etc/my.cnf 在mysql 版本5.1.7 不支持master-host”類似的參數(shù); 所以這里只要配置server-id=2 就可以了
然后登陸從數(shù)據(jù)庫設置
| change master to master_host='192.168.63.133', master_user='suxh', master_password='111111';slave start; |
基本配置就好了。這是我的簡要筆記。
新聞熱點
疑難解答
圖片精選