一、环境
操作系统CentOS 7.6 64bit
二、安装步骤
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