【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
原文地址:https://www.cnblogs.com/jxd283465/p/11555739.html