Run redis as a service in centos 6.x

Source: Internet
Author: User
Tags download redis install redis

1.download redis-2.8.9.tar.gz from the official network, the redis decompress in/usr/local, the directory is a redis-2.8.9, and then according to the official site to install redis.

2. Run src/redis-server in the redis-2.8.9 directory after installation
Run src/redis-cli in another shell window to run the command correctly.
However, we obviously want to start running as a service.

3. The following describes how to configure redis as a Service. First, copy the utils/redis_init_script file to/etc/init. d.

Cp/usr/local/redis-2.8.9/utils/redis_init_script/etc/rc. d/init. d/redis copies redis_init_script to/etc/rc. d/init. d/, easy to name as redis
Then vi/etc/rc. d/init. d/redis
Add
# chkconfig: 2345 80 90
Then pay attention
EXEC=/usr/local/redis/bin/redis-server  CLIEXEC=/usr/local/redis/bin/redis-cli  
Because our installation directory is/usr/local/redis-2.8.9, so the above two lines change
EXEC=/usr/local/redis-2.8.9/src/redis-server  CLIEXEC=/usr/local/redis-2.8.9/src/redis-cli  
Pay attention to
$EXEC $CONF
Add &
$EXEC $CONF &
"&" Means to forward the service to the end for running. Otherwise, when the service is started, the Redis service occupies the front-end and occupies the main user interface, causing other commands to fail to be executed.

4. You can see that there is such a line in the/etc/init. d/redis file:
CONF="/etc/redis/${REDISPORT}.conf"
Copy the redis configuration file to/etc/redis /.
mkdir /etc/redis   cp /usr/local/redis-2.8.9/redis.conf /etc/redis/6379.conf  
5. After completing the above operations, you can register the service:
chkconfig --add redis 
Then start the redis Service
service redis start 
Redis can run in Service Mode

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.