install redis properly

ref : http://redis.io/topics/quickstart
make -j8 && make test && make install 

mkdir /etc/redis
mkdir /var/redis
cp utils/redis_init_script /etc/init.d/redis_6379
#to modify head lines if centos
vi /etc/init.d/redis_6379


#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig:   - 85 15
# description:  Redis is a persistent key-value database
# processname: redis-server

Make sure to modify REDIS_PORT accordingly to the port you are using. Both the pid file path and the configuration file name depend on the port number.

Copy the template configuration file you'll find in the root directory of the Redis distribution into /etc/redis/ using the port number as name, for instance:
cp redis.conf /etc/redis/6379.conf

Create a directory inside /var/redis that will work as data and working directory for this Redis instance:
mkdir /var/redis/6379
vi /etc/redis/6379.conf


## port 6379 example
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
loglevel warning
logfile /var/log/redis_6379.log 
dir /var/redis/6379


Edit the configuration file, making sure to perform the following changes:
Set daemonize to yes (by default it is set to no).
Set the pidfile to /var/run/redis_6379.pid (modify the port if needed).
Change the port accordingly. In our example it is not needed as the default port is already 6379.
Set your preferred loglevel.
Set the logfile to /var/log/redis_6379.log
Set the dir to /var/redis/6379 (very important step!)

Finally add the new Redis init script to all the default runlevels using the following command:
#update-rc.d redis_6379 defaults  for ubuntu
chkconfig redis_6379 on
/etc/init.d/redis_6379 start

猜你喜欢

转载自uzoice.iteye.com/blog/2165957
今日推荐