Contents

首先当然是安装redis了
索性写的全面一点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
redis在第三方的源里,首先添加源,最常用的是epel源

yum install epel-release

然后就可以安装redis了

yum install redis

安装完成以后配置文件/etc/redis.conf
启动redis服务端

redis-server /etc/redis.conf

查看是否启动

ps -ef|grep redis

启动客户端

redis-cli

后台运行的话,记得加&

OK,进入正文

默认安装的redis的端口是6379,我们再搞一个端口是6380的redis

修改 redis 配置文件:

1
2
3
4
5
cd /etc/redis

cp redis.conf redis-6380.conf

vi redis-6380.conf

修改这几项为:

1
2
3
4
5
6
7
port 6380

pidfile /var/run/redis/redis-server-6380.pid

logfile /var/log/redis/redis-server-6380.log

dbfilename dump-6380.rdb

修改 redis 启动文件:

1
2
3
4
5
cd /etc/init.d/

cp redis-server redis-server-6380

vi redis-server-6380

修改这几项为:

1
2
3
4
5
DAEMON_ARGS=/etc/redis/redis-6380.conf

DESC=redis-server-6380

PIDFILE=$RUNDIR/redis-server-6380.pid

添加 service:

1
2
3
cp /lib/systemd/system/redis-server.service /lib/systemd/system/redis-server-6380.service

vi /lib/systemd/system/redis-server-6380.service

修改这几项为:

1
2
3
ExecStart=/usr/bin/redis-server /etc/redis/redis-6380.conf

PIDFile=/var/run/redis/redis-server-6380.pid

加软链:

1
2
3
cd /etc/systemd/system

ln -s /lib/systemd/system/redis-server-6380.service redis-6380.service

启动 redis-server-6380:

1
2
3
service redis-server-6380 start 

ps -ef | grep redis

1
2
redis     5885     1  0 Jul20 ?        00:00:40 /usr/bin/redis-server 127.0.0.1:6379
redis 9339 1 0 09:20 ? 00:00:00 /usr/bin/redis-server 127.0.0.1:6380
Contents