Home > Archives > Centos 安装 Redis

Centos 安装 Redis

Publish:

下载压缩包

1
2
[root@iZuf6gk461dc7xwwmsrakfZ ~]# cd /usr/local/
[root@iZuf6gk461dc7xwwmsrakfZ local]# wget http://download.redis.io/releases/redis-4.0.6.tar.gz

解压压缩包

1
[root@iZuf6gk461dc7xwwmsrakfZ local]# tar -zxvf redis-4.0.6.tar.gz

yum安装gcc依赖

1
[root@iZuf6gk461dc7xwwmsrakfZ local]# yum install gcc

编译安装

1
2
3
[root@iZuf6gk461dc7xwwmsrakfZ local]# cd redis-4.0.6
[root@iZuf6gk461dc7xwwmsrakfZ redis-4.0.6]# make MALLOC=libc
[root@iZuf6gk461dc7xwwmsrakfZ redis-4.0.6]# cd src && make install

测试是否安装成功

1
2
[root@iZuf6gk461dc7xwwmsrakfZ redis-4.0.6]# cd src/
[root@iZuf6gk461dc7xwwmsrakfZ src]# ./redis-server 

以后台进程方式启动redis

1
2
3
4
5
[root@iZuf6gk461dc7xwwmsrakfZ src]# vim ../redis.conf 

From 'daemonize no' to 'daemonize yes'

[root@iZuf6gk461dc7xwwmsrakfZ src]# ./redis-server /usr/local/redis-4.0.6/redis.conf 

关闭redis

1
2
[root@iZuf6gk461dc7xwwmsrakfZ src]# ps -aux | grep redis
[root@iZuf6gk461dc7xwwmsrakfZ src]# kill -9 16850

设置redis开机自启动

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@iZuf6gk461dc7xwwmsrakfZ src]# mkdir /etc/redis
[root@iZuf6gk461dc7xwwmsrakfZ src]# cp /usr/local/redis-4.0.6/redis.conf /etc/redis/6379.conf
[root@iZuf6gk461dc7xwwmsrakfZ src]# cp /usr/local/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd
[root@iZuf6gk461dc7xwwmsrakfZ src]# vim /etc/init.d/redisd

#!/bin/sh
# chkconfig:   2345 90 10
# description:  Redis is a persistent key-value database


[root@iZuf6gk461dc7xwwmsrakfZ src]# chkconfig redisd on
[root@iZuf6gk461dc7xwwmsrakfZ src]# service redisd start
[root@iZuf6gk461dc7xwwmsrakfZ src]# service redisd stop

参考

Centos7下安装redis

redis 安装cannot find ‘ld’

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo