Redis

安装

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[root@centos ~]# tar -zxvf redis-6.2.6.tar.gz

...

[root@centos ~]# cd redis-6.2.6
[root@centos redis-6.2.6]# ls
00-RELEASENOTES CONTRIBUTING INSTALL README.md runtest-cluster sentinel.conf TLS.md
BUGS COPYING Makefile redis.conf runtest-moduleapi src utils
CONDUCT deps MANIFESTO runtest runtest-sentinel tests
[root@centos redis-6.2.6]# ll
total 236
-rw-rw-r--. 1 root root 33624 Oct 4 2021 00-RELEASENOTES
-rw-rw-r--. 1 root root 51 Oct 4 2021 BUGS
-rw-rw-r--. 1 root root 5026 Oct 4 2021 CONDUCT
-rw-rw-r--. 1 root root 3384 Oct 4 2021 CONTRIBUTING
-rw-rw-r--. 1 root root 1487 Oct 4 2021 COPYING
drwxrwxr-x. 7 root root 145 Oct 4 2021 deps
-rw-rw-r--. 1 root root 11 Oct 4 2021 INSTALL
-rw-rw-r--. 1 root root 151 Oct 4 2021 Makefile
-rw-rw-r--. 1 root root 6888 Oct 4 2021 MANIFESTO
-rw-rw-r--. 1 root root 21567 Oct 4 2021 README.md
-rw-rw-r--. 1 root root 93724 Oct 4 2021 redis.conf
-rwxrwxr-x. 1 root root 275 Oct 4 2021 runtest
-rwxrwxr-x. 1 root root 279 Oct 4 2021 runtest-cluster
-rwxrwxr-x. 1 root root 1079 Oct 4 2021 runtest-moduleapi
-rwxrwxr-x. 1 root root 281 Oct 4 2021 runtest-sentinel
-rw-rw-r--. 1 root root 13768 Oct 4 2021 sentinel.conf
drwxrwxr-x. 3 root root 4096 Oct 4 2021 src
drwxrwxr-x. 11 root root 182 Oct 4 2021 tests
-rw-rw-r--. 1 root root 3055 Oct 4 2021 TLS.md
drwxrwxr-x. 9 root root 4096 Oct 4 2021 utils
[root@centos redis-6.2.6]# make

...

[root@centos redis-6.2.6]# make install PREFIX=/usr/local/redis/v6.2.6

...

配置文件

1
2
3
4
[root@centos redis-6.2.6]# mkdir /usr/local/redis/v6.2.6/conf
[root@centos redis-6.2.6]# cp redis.conf /usr/local/redis/v6.2.6/conf/
[root@centos redis-6.2.6]# cd /usr/local/redis/v6.2.6/conf
[root@centos conf]# vi redis.conf

修改下面内容:

1
2
3
4
5
6
7
8
9
# 绑定地址
bind 0.0.0.0

# 密码
requirepass 123456

protected-mode no

daemonize yes

启动服务

1
2
3
4
5
6
[root@centos redis-6.2.6]# cd /usr/local/redis/v6.2.6/bin/
[root@centos bin]# ./redis-server ../conf/redis.conf

[root@centos bin]# ps -ef|grep redis
root 1723 1 2 22:11 ? 00:00:11 /usr/local/redis/v6.2.6/bin/redis-server 0.0.0.0:6379
root 1745 1589 0 22:20 pts/0 00:00:00 grep --color=auto redis

注册 redis 服务

1
[root@centos ~]# vi /etc/systemd/system/redis.service

修改为以下内容:

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/v6.2.6/bin/redis-server /usr/local/redis/v6.2.6/conf/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target