1. Background

Redis is a very popular NOSQL database with the data type is very rich, here we simply record what the Centos7 on how to install Redis6 of. The installation of Redis is recommended to use the source code for installation.

Two, installation steps

1. Install gcc dependencies

安装Redis需要的依赖

2. Download redis6

wget https://download.redis.io/releases/redis-6.2.6.tar.gz

下载链接

3. Decompress and compile

# 解压
tar -zxvf redis-6.2.6.tar.gz
# 进入解压后的目录
cd redis-6.2.6
# 执行编译,如果make出错,可以看下方 可能出现的错误 的这个标题
make

4. Installation

1. Install to the default location

make install

2. Install redis to the specified location

make PREFIX=具体的路径 install

Here we install to the default path.

5. Start redis

1. Start the foreground

redis-server

2. Start in the background

vim redis.conf , this file defaults to redis-6.2.6/redis.conf
Revise

daemonize yes

start up

redis-server redis.conf

6. The firewall releases port 6379

[root@centos01 redis-6.2.6]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
success
[root@centos01 redis-6.2.6]# firewall-cmd --reload
success

7. Connect to redis

[appuser@centos01 ~]$ redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379>

Three, simple configuration of redis

Configuration itemvalueexplain
port6379Client communication port, the port that the redis server starts
daemonizeyesRun in the background
bind192.168.56.101The ip address bound when the redis service is started is the address of the local network card
pidfile/var/run/redis_6379.pidWhen running in the background, a pid file will be generated
logfile/var/log/redis_6379.logSpecify the path of the log file
dir./The path where the persistent file of the database is saved, which must be a directory
appendonlyyesOpen aof persistence
appendfsynceverysecaof writes once per second
appendfilenameappendonly.aofaof file name
requirepass123456Set a redis password, which can be more complicated
maxclients10000Set the maximum number of connections that can be connected to the redis server
maxmemory2GBSet the maximum memory available for redis

Four, possible errors

1. zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: no such file or directory

可能出现的错误
After Baidu, it can be known that the problem make MALLOC=libc

2. If there is Connection refused

1. Check whether the redis port is allowed
2. Check the bind value in redis.conf, it can only be accessed through 127.0.0.1 by default.
The learning test can be configured as bind 0.0.0.0 , but not in the production environment.

3. If rdb fails to save

rbd失败日志如果出现了如下日志时的处理
If the above log appears, then we can modify vm.overcommit_memory=1 to solve it.

Five, reference documents

1、Redis Quick Start


huan1993
207 声望31 粉丝

java工程师