redis資料庫通過dump.rdb檔案恢複資料庫或者資料庫遷移

來源:互聯網
上載者:User

標籤:通過   資料庫遷移   啟動   模式   sys   複數   centos7   gre   3.2   

環境:centos7.2
軟體:redis-3.2.10(yum安裝)

情景一:公司之前的redis沒有開啟aof模式,一直是rdb模式,但是資料又非常重要,資料一點也不能丟失,所以需要開啟aof,但是redis預設是從appendonly.aof載入資料,systemctl start redis的時候,資料庫是空的,因為我們並沒有appendonly.aof檔案,而且關閉redis的時候,會把dump.rdb清空

情景二:redis資料庫遷移,我們可以只用dump.rdb檔案,因為dump.rdb檔案比較小,方便攜帶

第一步:我們在/etc/redis.conf設定檔中,只開啟rdb模式,啟動redis,這樣資料檔案就載入進來了

第二步:使用redis-cli命令,登入redis,執行BGREWRITEAOF命令,重建aof檔案

第三步:關閉redis,在/etc/redis.conf中開啟aof模式

第四步:重新開啟redis服務,這時候,redis就會讀取appendonly.aof檔案,載入完整資料庫了

redis資料庫通過dump.rdb檔案恢複資料庫或者資料庫遷移

聯繫我們

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