Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。
1.下载redis源码安装包
wget 'http://download.redis.io/releases/redis-3.0.0.tar.gz'
2.解压并进入安装目录
tar xvf redis-3.0.0.tar.gz
cd redis-3.0.0
查看一下安装目录下面又什么文件
[$ redis-3.0.0]# ll
total 144
-rw-rw-r-- 1 root root 25890 Apr 1 22:01 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 Apr 1 22:01 BUGS
-rw-rw-r-- 1 root root 1439 Apr 1 22:01 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 Apr 1 22:01 COPYING
drwxrwxr-x 6 root root 4096 Apr 1 22:01 deps
-rw-rw-r-- 1 root root 11 Apr 1 22:01 INSTALL
-rw-rw-r-- 1 root root 151 Apr 1 22:01 Makefile
-rw-rw-r-- 1 root root 4223 Apr 1 22:01 MANIFESTO
-rw-rw-r-- 1 root root 5201 Apr 1 22:01 README
-rw-rw-r-- 1 root root 41403 Apr 1 22:01 redis.conf
-rwxrwxr-x 1 root root 271 Apr 1 22:01 runtest
-rwxrwxr-x 1 root root 280 Apr 1 22:01 runtest-cluster
-rwxrwxr-x 1 root root 281 Apr 1 22:01 runtest-sentinel
-rw-rw-r-- 1 root root 7109 Apr 1 22:01 sentinel.conf
drwxrwxr-x 2 root root 4096 Apr 1 22:01 src
drwxrwxr-x 10 root root 4096 Apr 1 22:01 tests
drwxrwxr-x 5 root root 4096 Apr 1 22:01 utils
发现makefile文件已经存在
3.直接使用make命令进行编译
make && make install
直至到执行完成,查看src目录
[$ redis-3.0.0]# cd src
[$ bin]# ll | grep redis- | grep -v '\.[co]'
-rwxr-xr-x 1 root root 4587006 Apr 10 20:59 redis-benchmark #redis附带的性能测试工具
-rwxr-xr-x 1 root root 22177 Apr 10 20:59 redis-check-aof
-rwxr-xr-x 1 root root 45387 Apr 10 20:59 redis-check-dump
-rwxr-xr-x 1 root root 4689905 Apr 10 20:59 redis-cli #redis 命令行操作工具
-rwxr-xr-x 1 root root 6448177 Apr 10 20:59 redis-server #redis服务器程序
安装完成
4.配置&启动redis
这里简单说一下redis几个比较重要的配置,在redis目录下有一个redis.conf的配置文件
a)redis默认不是以后台进程运行,必须进行配置
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no #默认是no,后台运行需要改成yes
b)指定redis端口
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./
现在,可以启动redis了
[$ redis-3.0.0]# ./src/redis-server redis.conf
测试一下
[$ redis-3.0.0]# ./src/redis-cli ping
PONG
启动成功
最后说一下如何停止redis,resid-cli shutdown 命令,即可停止redis