資料庫主從伺服器搭建
配置主的配置文件
vi /etc/my.cnf
正常,說明主從搭建成功
㈡ Ubuntu配置Mysql主從資料庫
本次環境:虛擬機下
伺服器:Ubuntu
14.04
LTS
資料庫:
5.5.37
埠:3306
主IP:192.168.63.133
從IP:192.168.63.134
授權賬號:
user:suxh
password:111111
好了交代完環境:我們直接配置:
第一步:主從兩台伺服器要有同樣的資料庫(需要同步的)這里用的是backup
資料庫(不多說了,在同步開始前,把主庫的復制一份到從庫就行了)
第二步配置主(master)資料庫
編輯/etc/my.cnf
主要是開啟二進制日誌
和設置要同步的資料庫
等一些參數
#
binary
logging
format
-
mixed
recommended
binlog_format=mixed
binlog-ignore-db=mysql
binlog-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
omitted
server-id
=
1
參數解釋下:
server-id
這個是唯一的不能跟從伺服器相同。
binlog_format
二進制文件的格式
binlog_ignore-db
忽略的資料庫
binlog-do-db
要同步的資料庫
設置完了以後
重啟資料庫就可以了。
第三步從資料庫:
同樣修改/etc/my.cnf
在mysql
版本5.1.7
不支持master-host」類似的參數;
所以這里只要配置server-id=2
就可以了
然後登陸從資料庫設置
change
master
to
master_host='192.168.63.133',
master_user='suxh',
master_password='111111';
slave
start;
基本配置就好了。這是我的簡要筆記。