Let Redis run as a service under centos6.x

Source: Internet
Author: User

1. After downloading redis-2.8.9.tar.gz from the official website, the Redis is extracted under the/usr/local, the directory is redis-2.8.9, and then the method of Redis can be installed according to the official website.

2. Perform src/redis-server in the redis-2.8.9 directory after installation
Then execute the SRC/REDIS-CLI in another shell window to run correctly.
But we obviously want to start the operation as a service.

3. Here is the procedure 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

Copy Redis_init_script to/etc/rc.d/init.d/and easily name Redis

Then Vi/etc/rc.d/init.d/redis
Add in the second line of the document

# chkconfig:2345 80 90

Then notice

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, the above two lines are changed to

Exec=/usr/local/redis-2.8.9/src/redis-server

Cliexec=/usr/local/redis-2.8.9/src/redis-cli

Also pay attention to the Redis file's

$EXEC $CONF

Here, add & at the back of Conf

$EXEC $CONF &

"&", that is, to move the service back to the meaning of running, otherwise when the service is started, the Redis service will occupy the foreground, occupying the main user interface, resulting in other commands can not be executed.

4. You can see that in the/etc/init.d/redis file, there is a line:

conf= "/etc/redis/${redisport}.conf"

The Redis configuration file is then copied to the/etc/redis/

Mkdir/etc/redis

Cp/usr/local/redis-2.8.9/redis.conf/etc/redis/6379.conf

5. After completing the above operation, you can register the service:

Chkconfig--add Redis

Then start the Redis service

Service Redis Start

Redis can be run as service mode

Let Redis run as a service under centos6.x

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.