centos7 安装redis,并设置远程链接

个人博客,防止重复造轮子

cd ~
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
gzip redis-4.0.10.tar.gz
cd redis-4.0.10
make 
make install
# 安装完毕

# 查找redis.conf
find / -name redis.conf

# 配置redis.conf
vi /etc/redis.conf

为了保证redis可以远程链接,需要配置以下两点内容

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

# 将上面的注释掉,如下(为了取消链接限制)
# bind 127.0.0.1
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

# 将上面的daemonize no 改成yes(为了将redis后台运行)
daemonize yes
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes

# 将protected-mode yes 改成 no
 protected-mode no

完成以上三步,就可以进行远程链接。

推荐使用管理软件 redisdesktop

给redis设置密码

vi /etc/redis.conf
#查找requirepass
/requirepass

# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass XXXX

# 将上面取消注释,并改成自己的密码
# 重启redis
ps ax |grep redis
kill (pid)
redis-server /etc/redis.conf

猜你喜欢

转载自blog.csdn.net/m0_38092942/article/details/80974306
今日推荐