LINUX(Redhat)下安装redis &指定配置文件启动redis

参照官网:linux

Installation

Download, extract and compile Redis with:redis

$ wget http://download.redis.io/releases/redis-2.8.19.tar.gz
$ tar xzf redis-2.8.19.tar.gz
$ cd redis-2.8.19
$ make

The binaries that are now compiled are available in the src directory. Run Redis with:bash

$ src/redis-server

You can interact with Redis using the built-in client:编辑器

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

====================================================================ui

参考另外一安装过程:spa

我用的系统是:redhat.net

[root@infa ~]# wget http://download.redis.io/releases/redis-2.8.12.tar.gzcode

 

tar xzf redis-2.8.12.tar.gzorm

[root@infa ~]# tar xzf redis-2.8.12.tar.gzserver

[root@infa ~]# cd redis-2.8.12

[root@infa redis-2.8.12]# ls

00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README  redis.conf  runtest  runtest-sentinel  sentinel.conf  src  tests  utils

[root@infa redis-2.8.12]# make

可是这样子编译会报错,貌似是由于系统的缘由;

报错以下:

 

解决方法,就是加上编译参数设置,以下:

[root@infa redis-2.8.12]# make CFLAGS="-march=i686"

 

编译成功;

启动并运行redis

[root@infa redis-2.8.12]# src/redis-server

 

打开另一个终端运行,redis客户端

 

[root@infa redis-2.8.12]# src/redis-cli

127.0.0.1:6379> set name chenzhou

OK

127.0.0.1:6379> get name

"chenzhou"

127.0.0.1:6379> 

 

 

复制代码

附2:把Redis做为Linux服务开机启动
这里只提供一种最简单的方式,最好的是经过编写开机启动脚原本作。
若是要开机启动redis,咱们须要把redis设置为daemon后台启动(若是不设置为后台启动,则linux启动后图形界面会卡在一个空白的页面),而redis只有1个启动参数,就是redis的配置文件路径。redis的默认配置文件redis.conf位于redis的安装目录下。咱们能够把该文件copy到/etc目录下
Shell代码  
1[root@localhost redis-2.6.14]# cp redis.conf /etc/  redis的默认配置文件中daemonize参数的值为no,表明为非后台启动,因此咱们须要把该参数的值修改成yes。至于其它的参数在这里就不详细说了,具体能够参见:http://blog.csdn.net/htofly/article/details/7686436修改完daemonize参数以后,redis就可以经过daemon方式启动了,那么下一步就是把redis加入到linux开机启动服务配置中了,具体步骤以下:
使用VI编辑器打开Linux开机启动服务配置文件/etc/rc.local,并在其中加入下面的一行代码:
Shell代码  
2/usr/local/redis-2.6.14/src/redis-server /etc/redis.conf  
编辑完后保存,而后重启系统就OK了。
中止Redis服务:
Shell代码  
3src/redis-cli shutdown

复制代码

指定配置文件启动redis:   redis-server ./redis.conf
相关文章
相关标签/搜索