Linux下安装Redis

Linux下安装Redis

 

安装chkconfig:

rpm -aq |grep chkconfig

chkconfig-1.3.30.1-2

# export PATH=/sbin:$PATH

# chkconfig

 

或是 vi /etc/profile

加入 export PATH=/sbin:$PATH

执行 source /etc/profile

执行 chkconfig

 

安装redis:

tar -xvf redis-3.0.6.tar.gz 

cd redis-3.0.6

make PREFIX=/usr/local/redis install

 

配置redis服务:

cp utils/redis_init_script /etc/rc.d/init.d/redis

 

添加注册服务:

vi /etc/rc.d/init.d/redis

 

第2行添加

# chkconfig:   2345 90 10

# description:  Redis is a persistent key-value database

 

redis服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10。

 

修改EXEC和CLIEXEC路径(安装文件目录):

EXEC=/app/re/redis-3.0.6/src/redis-server

CLIEXEC=/app/re/redis-3.0.6/src/redis-cli

 

redis开启的命令,以后台运行的方式执行。

$EXEC $CONF & 

 

改完了保存!

 

mkdir /etc/redis    

cp redis.conf /etc/redis/6379.conf

 

/etc/profile 加入

export REDIS_HOME=/usr/local/redis

export PATH=${PATH}:${REDIS_HOME}/bin

 

执行 source /etc/profile

 

注册redis服务:

chkconfig --add redis

 

#设置为开机自启动服务器

chkconfig redis on

#打开服务

service redis start

#关闭服务

service redis stop

 

 

 WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

 

sysctl vm.overcommit_memory=1

 

 

$ redis-cli   

127.0.0.1:6379> ping

PONG

127.0.0.1:6379> set aa bb

OK

127.0.0.1:6379> get aa

"bb"

127.0.0.1:6379> 

 

你可能感兴趣的:(Linux下安装Redis)