Redis Second: CentOS under the configuration Redis boot

Source: Internet
Author: User
Tags mkdir redis server
1. Download and install
wget http://redis.googlecode.com/files/redis-2.2.13.tar.gz
tar-zxf redis-2.2.13.tar.gz
cd redis-2.2.13
make
sudo make install  
CP redis.conf/etc
When install, Redis's orders will be copied under/usr/local/bin.

2, create user and log directory

Before starting Redis for the first time, it is recommended that you create a separate user for Redis and create a new data and log folder

sudo useradd redis
sudo mkdir-p/var/lib/redis
sudo mkdir-p/var/log/redis
sudo chown redis.redis/var/lib/ Redis #db file here, to modify redis.conf
sudo chown redis.redis/var/log/redis

3, configuring the init script

In fact GitHub many foreigners write good startup script, but most of them are Ubuntu, for CentOS, also have a

https://gist.github.com/1335694
After modification, as follows:

########################### Path=/usr/local/bin:/sbin:/usr/bin:/bin redisport=6379 EXEC=/usr/local/bin/
    Redis-server redis_cli=/usr/local/bin/redis-cli pidfile=/var/run/redis.pid conf= "/etc/redis.conf" case "$" in Start) If [f $PIDFILE] then echo $PIDFILE exists, process is already running or crash Ed "Else echo" starting Redis server ... "$EXEC $CONF fi if [" $? "
    = "0"] then echo "Redis is running ..." FI;
        STOP) if [! f $PIDFILE] then echo "$PIDFILE does not exist, process isn't running"  Else pid=$ (cat $PIDFILE) echo "Stopping ..." $REDIS _cli-p $REDISPORT SHUTDOWN while [-X ${pidfile}] do echo waiting for Redis to Shutdow N ... "Sleep 1 done ECHo "Redis stopped" FI;
  restart|force-reload) ${0} stop ${0} start;; *) echo "Usage:/etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 Esac ############

Save the above code as Redis and put it under/etc/init.d/.

chmod +x/etc/init.d/redis

Actually make service start, also call Redis-server, if want it in backstage as Daemon run, then

Need to modify redis.conf, change daemonize No to daemonize Yes 4, set up boot service

sudo chkconfig redis on
5, start, stop Redis
Service Redis start   #或者/etc/init.d/redis start
service redis stop   #或者/etc/init.d/redis stop
6, Test Redis
REDIS-CLI 
redis 127.0.0.1:6379> set foo 123
OK
redis 127.0.0.1:6379> get foo
"123"
Redis 127.0.0.1:6379> exit


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.