Linux中安装Redis

一、环境

操作系统CentOS 7.6 64bit

二、安装步骤

1、下载安装包
(1) 下载地址
(2) 网盘地址

2、上传至opt文件夹下,并解压安装包

tar -zxvf redis-7.0.2.tar.gz 

3、Redis是使用C++编写的,需要安装C++环境

# 安装
yum install gcc-c++
# 查看gcc版本
gcc -v

4、编译安装

# 进入redis目录
cd /opt/redis-7.0.2
# 编译
make
# 安装
make install

5、修改redis.conf,位置在/opt/redis-7.0.2
(1) daemonize设置为yes(默认为no),redis就将会在后台运行

################################# GENERAL #####################################

# 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.
# When Redis is supervised by upstart or systemd, this parameter has no impact.
daemonize yes

(2) bind设置为0.0.0.0,redis就可以远程连接了

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# COMMENT OUT THE FOLLOWING LINE.
#
# You will also need to set a password unless you explicitly disable protected
# mode.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1 -::1
bind 0.0.0.0

(2) requirepass设置密码

# The requirepass is not compatible with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.
requirepass '密码'

6、后台启动

/opt/redis-7.0.2/src/redis-server /opt/redis-7.0.2/redis.conf

7、测试链接
在这里插入图片描述

三、其他配置

1、数据库的数量 databases,默认是16

# 数据库数量修改为32
databases 32

2、客户端最大连接数 maxclients,默认是10000

# 客户端最大连接数设置为100,超出100个后,连接就会被拒绝
maxclients 100
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

必成公

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值