惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
V
V2EX - 技术
S
Secure Thoughts
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
S
Securelist
S
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
Recent Commits to openclaw:main
Recent Commits to openclaw:main
G
GRAHAM CLULEY
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
Intezer
Google Online Security Blog
Google Online Security Blog
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
The Cloudflare Blog
I
InfoQ
L
LangChain Blog
U
Unit 42
P
Proofpoint News Feed
S
Schneier on Security
S
Security Affairs
Y
Y Combinator Blog
T
Tenable Blog
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
量子位
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
D
Darknet – Hacking Tools, Hacker News & Cyber Security
GbyAI
GbyAI
AWS News Blog
AWS News Blog

Redis on 轻风云

暂无文章

CentOS7中编译安装redis5.0
2019-07-12 · via Redis on 轻风云
  1. 环境介绍

CentOS7 (未安装Development Tools)

  1. 下载Redis5.0-rc3
1
wget -O redis-5.0-rc3.tar.gz https://github.com/antirez/redis/archive/5.0-rc3.tar.gz
  1. 解压redis
1
tar -zxvf redis-5.0-rc3.tar.gz -C /usr/local
  1. 编译并安装
1
2
cd /usr/local/redis-5.0-rc3
    make

此时会出错:

1
2
3
4
compilation terminated.
    make[1]: *** [adlist.o] Error 1
    make[1]: Leaving directory `/usr/local/redis-5.0-rc3/src'
    make: *** [all] Error 2

安装Development Tools

1
yum groupinstall 'Development Tools'

再次执行,还会报错

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
make
    cd src && make all
    make[1]: Entering directory `/usr/local/redis-5.0-rc3/src'
        CC adlist.o
    In file included from adlist.c:34:0:
    zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
     #include <jemalloc/jemalloc.h>
                                   ^
    compilation terminated.
    make[1]: *** [adlist.o] Error 1
    make[1]: Leaving directory `/usr/local/redis-5.0-rc3/src'
    make: *** [all] Error 2

最后解决方案如下:

1
cd /usr/local/redis-5.0-rc3/deps; make hiredis lua jemalloc linenoise

编译完成后再次在/usr/local/redis-5.0-rc3中执行make命令

1
2
cd /usr/local/redis-5.0-rc3
    make

出现如下即编译成功

1
2
Hint: It's a good idea to run 'make test' ?
    make[1]: Leaving directory `/usr/local/redis-5.0-rc3/src'

然后在/usr/local/redis-5.0-rc3/src中执行安装命令:

1
2
cd /usr/local/redis-5.0-rc3/src
    make install

会出现如下日志信息

1
2
3
4
5
6
7
Hint: It's a good idea to run 'make test' ?
    
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
        INSTALL install
  1. 修改redis.conf配置文件
1
vim /usr/local/redis-5.0-rc3/redis.conf

只需要调整如下几个即可

1
2
protected-mode no # 关闭保护模式
    daemonize yes     # 守护进程模式开启
  1. 启动redis5.0
1
/usr/local/redis-5.0-rc3/src/redis-server /usr/local/redis-5.0-rc3/redis.conf

其实我们在执行make install的时候会将src下面的几个命令复制到/usr/local/bin/下面去,也可以执行如下命令启动redis5.0

1
/usr/local/bin/redis-server /usr/local/redis-5.0-rc3/redis.conf

检查端口

1
netstat -ltnp |grep 6379

如果有端口监听,说明redis已经启动成功。

连接下试试

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
redis-cli 
    
    127.0.0.1:6379> info
    # Server
    redis_version:4.9.103
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:207f31cf830c081e
    redis_mode:standalone
    os:Linux 3.10.0-693.17.1.el7.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    atomicvar_api:atomic-builtin
    gcc_version:4.8.5
    process_id:20361
    run_id:4835668974ad86f1db9b3c8b98e02be1a87a7b9b
    tcp_port:6379
    uptime_in_seconds:689
    uptime_in_days:0
    hz:10
    lru_clock:3944003

为什么能在任意目录执行redis-cli命令呢,因为redis-cli命令在/usr/local/bin目录里面,而该目录又配置在PATH中,所以你可以向执行ls、mkdir等命令的方式去执行redis-cli或者redis-server等命令。

一般我们在安装完redis后就会将其安装包给删除,那么我们只需要将redis.conf配置文件移动的其他目录,比如:/etc/redis/redis.conf中,具体位置在哪请按照自己的习惯或者规范放置即可。