CentOS 7 yum安装 Redis
  dIZ4mPo2q5Ch 2023年11月02日 53 0


1、下载fedora的epel仓库

yum install epel-release

2、安装redis数据库

yum install redis -y

3、启动redis

systemctl start redis   # 启动redis
systemctl stop redis   # 停止redis
systemctl status redis # 查看redis运行状态
ps -ef | grep redis # 查看redis进程

4、设置开机启动

systemctl enable redis

5、开放防火墙

vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT  #添加

6、修改配置文件

vi /etc/redis.conf
################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# 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 123456  #修改密码 123456

# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

添加注释,远程可以访问
# bind 127.0.0.1  

# yes 改 no
protected-mode no

7、使用端口登陆

[root@centos7 ~] redis-cli -h 127.0.0.1 -p 6379   #测试
127.0.0.1:6379> ping                 #ping命令
(error) NOAUTH Authentication required.      #提示输入密码
127.0.0.1:6379> auth 123456             #输入密码
OK                           #成功

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: CentOS 7 网络配置 下一篇: CentOS 7 配置网络
  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  b1UHV4WKBb2S   2023年11月13日   40   0   0 ide抗锯齿
  b1UHV4WKBb2S   2023年11月13日   34   0   0 裁剪ideflutter
  zSWNgACtCQuP   2023年11月13日   32   0   0 ide
dIZ4mPo2q5Ch