【Linux】【redis】redis安裝及開啟遠程訪問


系統環境:Centos7

Redis是一個開源的使用ANSI C語言編寫、支持網絡、可基於內存亦可持久化的日志型、Key-Value數據庫,並提供多種語言的API。

 

1.yum安裝過程參考:https://www.jianshu.com/p/5a001726b20d

啟動 systemctl start redis

設置開機自啟 systemctl enable redis

2.開啟遠程訪問

通過yum install -y redis安裝的話

redis.conf配置文件在 /etc/redis.conf

修改配置文件做如下修改

然后重啟redis  systemctl restart redis即可連接成功

redis客戶端推薦:https://github.com/qishibo/AnotherRedisDesktopManager/releases

 3.redis數據遷移

參考:http://www.cnblogs.com/zhoubaojian/articles/7866595.html

src_ip為源redis,dest_ip為目標redis
#!/bin/bash
src_ip=192.168.8.100
src_port=6379
dest_ip=192.168.8.20
dest_port=6379
i=1
redis-cli -h $src_ip -p $src_port keys "*" | while read key
do
    redis-cli -h $src_ip -p $src_port --raw dump $key | perl -pe 'chomp if eof' | redis-cli -h $dest_ip -p $dest_port -n 0 -x restore $key 0
    echo "$i migrate key $key"
    ((i++))
done

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM