您的位置:首页 > 数据库 > Redis

centos7下redis的安装

2015-07-15 16:25 525 查看
1,在官网下载redis2.8安装包

[root@localhost redis]# wget -v -O redis-2.8.21.tar.gz    https://github.com/antirez/redis/archive/2.8.21.tar.gz --2015-07-15 15:02:40--  https://github.com/antirez/redis/archive/2.8.21.tar.gz 正在解析主机 github.com (github.com)... 192.30.252.131
正在连接 github.com (github.com)|192.30.252.131|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://codeload.github.com/antirez/redis/tar.gz/2.8.21 [跟随至新的 URL]
--2015-07-15 15:02:43--  https://codeload.github.com/antirez/redis/tar.gz/2.8.21 正在解析主机 codeload.github.com (codeload.github.com)... 192.30.252.146
正在连接 codeload.github.com (codeload.github.com)|192.30.252.146|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1272195 (1.2M) [application/x-gzip]
正在保存至: “redis-2.8.21.tar.gz”

100%[=========================================================================================================================================>] 1,272,195   35.1KB/s 用时 19s

2015-07-15 15:03:03 (64.3 KB/s) - 已保存 “redis-2.8.21.tar.gz” [1272195/1272195])


2,解压安装包

[root@localhost redis]# tar -xxvf redis-2.8.21.tar.gz
redis-2.8.21/
redis-2.8.21/.gitignore
redis-2.8.21/00-RELEASENOTES
redis-2.8.21/BUGS
redis-2.8.21/CONTRIBUTING
redis-2.8.21/COPYING
redis-2.8.21/INSTALL
redis-2.8.21/MANIFESTO
redis-2.8.21/Makefile
redis-2.8.21/README
redis-2.8.21/deps/
redis-2.8.21/deps/Makefile
redis-2.8.21/deps/hiredis/
redis-2.8.21/deps/hiredis/.gitignore
redis-2.8.21/deps/hiredis/.travis.yml
redis-2.8.21/deps/hiredis/CHANGELOG.md
redis-2.8.21/deps/hiredis/COPYING
redis-2.8.21/deps/hiredis/Makefile
redis-2.8.21/deps/hiredis/README.md
redis-2.8.21/deps/hiredis/adapters/
redis-2.8.21/deps/hiredis/adapters/ae.h
redis-2.8.21/deps/hiredis/adapters/libev.h
redis-2.8.21/deps/hiredis/adapters/libevent.h
redis-2.8.21/deps/hiredis/adapters/libuv.h
redis-2.8.21/deps/hiredis/async.c


3,编译源文件

[root@localhost redis]# cd redis-2.8.21
[root@localhost redis-2.8.21]# make
cd src && make all
make[1]: 进入目录“/home/joeyon/redis/redis-2.8.21/src”
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)


4,安装redis

[root@localhost redis-2.8.21]# make PREFIX=/usr/local/redis-2.8.21  install
cd src && make install
make[1]: 进入目录“/home/joeyon/redis/redis-2.8.21/src”

Hint: It's a good idea to run 'make test' ;)

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: 离开目录“/home/joeyon/redis/redis-2.8.21/src”


5,安装tcl8.5(如不进行redis test测试可以不安装)

[root@localhost src]# yum install tcl
已加载插件:fastestmirror
base                                                                                                                                                        | 3.6 kB  00:00:00
extras                                                                                                                                                      | 3.4 kB  00:00:00
updates                                                                                                                                                     | 3.4 kB  00:00:00
updates/7/x86_64/primary_db                                                                                                                                 | 2.5 MB  00:00:03
Determining fastest mirrors
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 tcl.x86_64.1.8.5.13-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===================================================================================================================================================================================
Package                                架构                                      版本                                               源                                       大小
===================================================================================================================================================================================
正在安装:
tcl                                    x86_64                                    1:8.5.13-4.el7                                     base                                    1.9 M

事务概要
===================================================================================================================================================================================
安装  1 软件包

总下载量:1.9 M
安装大小:4.4 M
Is this ok [y/d/N]: y
Downloading packages:
tcl-8.5.13-4.el7.x86_64.rpm                                                                                                                                 | 1.9 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装    : 1:tcl-8.5.13-4.el7.x86_64                                                                                                                                      1/1
验证中      : 1:tcl-8.5.13-4.el7.x86_64                                                                                                                                      1/1

已安装:
tcl.x86_64 1:8.5.13-4.el7

完毕!


6,验证redis是否安装成功

[root@localhost src]# cd ..
[root@localhost redis-2.8.21]# cd src/
[root@localhost src]# make test
Cleanup: may take some time... OK
Starting test server at port 11111
[ready]: 17103
Testing unit/printver
[ready]: 17104
Testing unit/auth
[ready]: 17105
Testing unit/protocol
.......
46 seconds - integration/replication-3
25 seconds - unit/hyperloglog
48 seconds - unit/aofrw
50 seconds - integration/replication-4
70 seconds - integration/replication
65 seconds - unit/obuf-limits

\o/ All tests passed without errors!

Cleanup: may take some time... OK

7,拷贝redis.conf文件到安装目录

cd /home/joeyon/redis/redis-2.8.21
cp redis.conf /usr/local/redis-2.8.21/

8,创建redis日志目录,和数据文件目录

[root@localhost redis-2.8.21]# mkdir -p /usr/local/redis-2.8.21/log
[root@localhost redis-2.8.21]# mkdir -p /usr/local/redis-2.8.21/db

9,修改redis.conf下面的配置项

pidfile /usr/local/redis-2.8.21/redis.pid
logfile /usr/local/redis-2.8.21/log
dir /usr/local/redis-2.8.21/db
daemonize yes

10,启动redis
[root@localhost bin]# cd /usr/local/redis-2.8.21/bin/
[root@localhost bin]# ./redis-server ../redis.conf
11,启动客户端

[root@localhost bin]# ./redis-cli
127.0.0.1:6379>


12,测试
127.0.0.1:6379> set welcome 'hello redis'
OK
127.0.0.1:6379> get welcome
"hello redis"
127.0.0.1:6379>

13,关闭服务
redis-cli shutdown

add by joeyon1985
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: