我用的系统是:redhat linux
[root@infa ~]# wget http://download.redis.io/releases/redis-2.8.12.tar.gz redis
tar xzf redis-2.8.12.tar.gz 编辑器
[root@infa ~]# tar xzf redis-2.8.12.tar.gz spa
[root@infa ~]# cd redis-2.8.12 .net
[root@infa redis-2.8.12]# ls code
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-sentinel sentinel.conf src tests utils server
[root@infa redis-2.8.12]# make blog
可是这样子编译会报错,貌似是由于系统的缘由; get
报错以下: io
解决方法,就是加上编译参数设置,以下:
[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