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
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 item | value | explain |
---|---|---|
port | 6379 | Client communication port, the port that the redis server starts |
daemonize | yes | Run in the background |
bind | 192.168.56.101 | The ip address bound when the redis service is started is the address of the local network card |
pidfile | /var/run/redis_6379.pid | When running in the background, a pid file will be generated |
logfile | /var/log/redis_6379.log | Specify the path of the log file |
dir | ./ | The path where the persistent file of the database is saved, which must be a directory |
appendonly | yes | Open aof persistence |
appendfsync | everysec | aof writes once per second |
appendfilename | appendonly.aof | aof file name |
requirepass | 123456 | Set a redis password, which can be more complicated |
maxclients | 10000 | Set the maximum number of connections that can be connected to the redis server |
maxmemory | 2GB | Set 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
If the above log appears, then we can modify vm.overcommit_memory=1
to solve it.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。