Ubuntu MySQL熱備份安裝(1)

來源:互聯網
上載者:User

參考資料:

http://www.cnblogs.com/wuhou/archive/2008/09/28/1301071.html

http://www.hebaodans.com/2009/02/m-y-s-q-l-shu-ju-ku-de-tong-bu-wen-ti-shuang-ji-re-bei/

1.安裝最新的Ubuntu Server版本,並更新系統。

2.安裝MySQL Server:sudo apt-get instal mysql-server,然後設定管理員密碼,去掉本地地址綁定,以便可以進行遠端存取。

主:192.168.137.12

從:192.168.137.13

3.設定utf8字元集來支援中文,在主從伺服器的設定檔/etc/mysql/my.cnf中加入:

[client]
default-character-set   = utf8

[mysqld]
default-character-set   = utf8

init_connect    = 'SET NAMES utf8;'

4.在伺服器中啟動備份。首先在主伺服器在設定檔中添加下面的內容。其中s3(舉個例子)為需要同步的資料庫。

[mysqld]

log-bin         = mysql-bin
server-id       = 1
binlog-do-db    = s3

5.重新啟動主要資料庫。

sudo service start mysql

6.串連到主要資料庫,並建立你需要同步的資料庫,如果已經存在可以忽略這一步。

mysql –u root –p

create database s3;

7.在伺服器中添加一個帳號(sync)用於同步資料庫,並賦予從備份的許可權,重要。

grant replication slave on *.* to 'sync'@'%' identified by '12345'

8.記錄s3資料庫的記錄檔名稱和位置,用於從機備份開始的位置。

mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000007 |      106 | s3           |                  |
+------------------+----------+--------------+-----------------

9.修改從機的設定檔。

[mysqld]
server-id       = 2
read-only
master-connect-retry     = 60
replicate-do-db = s3

10.重新啟動從機,建立資料庫(s3)或者從原來的資料庫恢複資料庫。並執行命令:

change master to MASTER_HOST='192.168.137.12', MASTER_USER='sync',MASTER_PASSWORD='12345',MASTER_LOG_FILE='mysql-bin.000007',MASTER_LOG_POS=106;


相關文章

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.