當前位置:首頁 » 雲伺服器 » 資料庫主從伺服器搭建

資料庫主從伺服器搭建

發布時間: 2023-03-13 04:05:17

㈠ 如何實現兩個mysql資料庫之間的主從同步

  • 配置主的配置文件

    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;

基本配置就好了。這是我的簡要筆記。

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:566
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:855
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:555
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:733
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:656
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:975
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:227
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:87
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:777
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:683