TheRiver | blog

You have reached the world's edge, none but devils play past here

0%

redis 安装

安装

下载地址,我下的5.0的版本,然后make即可。

测试:

server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@**** ]# ./src/redis-server 
27306:C 02 Sep 2020 17:51:42.050 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27306:C 02 Sep 2020 17:51:42.051 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=27306, just started
27306:C 02 Sep 2020 17:51:42.051 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 27306
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'

27306:M 02 Sep 2020 17:51:42.052 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
27306:M 02 Sep 2020 17:51:42.052 # Server initialized
27306:M 02 Sep 2020 17:51:42.052 * Ready to accept connections

client

1
2
3
4
5
6
[root@**** ]# ./src/redis-cli 
127.0.0.1:6379> set key value
OK
127.0.0.1:6379> get key
"value"
127.0.0.1:6379>

前台运行是这样的,后台运行需要配合配置文件。

修改redis.conf

1
2
#daemonize no
daemonize yes

运行

1
2
3
4
[root@**** ]# ./src/redis-server  ./redis.conf 
27989:C 02 Sep 2020 17:58:47.478 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27989:C 02 Sep 2020 17:58:47.478 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=27989, just started
27989:C 02 Sep 2020 17:58:47.478 # Configuration loaded

开机启动

参考: redis开机自动启动服务设置

step 1

1
cp /usr/local/redis/redis-5.0.9/utils/redis_init_script /etc/init.d/redis

step 2

修改配置文件

1
2
3
4
5
6
7
8
9
REDISPORT=6379
#EXEC=/usr/local/bin/redis-server
#CLIEXEC=/usr/local/bin/redis-cli
EXEC=/usr/local/redis/redis-5.0.9/src/redis-server
CLIEXEC=/usr/local/redis/redis-5.0.9/src/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
#CONF="/etc/redis/${REDISPORT}.conf"
CONF="/usr/local/redis/redis-5.0.9/redis.conf"

step 3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//加入chkconfig
[root@**** ]# chkconfig --add redis
//开机启动
[root@**** ]# chkconfig redis on
[root@**** ]# ps aux | grep redis
root 27990 0.0 0.0 51304 2880 ? Ssl 17:58 0:00 ./src/redis-server 127.0.0.1:6379
root 28960 0.0 0.0 12148 688 pts/1 S+ 18:09 0:00 grep --color=auto redis
//stop redis
[root@**** ]# service redis stop
Stopping ...
Redis stopped
[root@**** ]# ps aux | grep redis
root 29107 0.0 0.0 12148 684 pts/1 S+ 18:10 0:00 grep --color=auto redis
//start redis
[root@**** ]# service redis start
Starting Redis server...
29120:C 02 Sep 2020 18:10:16.256 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
29120:C 02 Sep 2020 18:10:16.256 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=29120, just started
29120:C 02 Sep 2020 18:10:16.256 # Configuration loaded
[root@**** ]# ps aux | grep redis
root 29121 0.0 0.0 51304 2744 ? Ssl 18:10 0:00 /usr/local/redis/redis-5.0.9/src/redis-server 127.0.0.1:6379
root 29126 0.0 0.0 12148 688 pts/1 S+ 18:10 0:00 grep --color=auto redis

ending

----------- ending -----------