Installing Redis services under Linux

Source: Internet
Author: User
Tags install redis redis server

I. Installing Redis to/usr/local/redis


Execute command:

1. Mkdir/usr/local/redis

2. Cd/usr/local/src

3. wget http://download.redis.io/releases/redis-3.2.4.tar.gz

4. Tar-xzf redis-2.6.14.tar.gz

5. Ln-s redis-2.6.14 Redis #建立一个链接

6. CD Redis

7. Make Prefix=/usr/local/redis Install #安装到指定目录中

* After installing Redis successfully, you will be able to see a bin directory in/usr/local/redis, which includes the following files:

# Redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server


Two. Make Redis a service


  1. Copy script to/etc/rc.d/init.d directory


    PS: The script in the/etc/rc.d/init.d/directory is similar to the registry in Windows, and some of the specified scripts will be executed when the system is started.
    When you install Redis as per the above steps, its service script is located at:

    /usr/local/src/redis/utils/redis_init_script
    It must be copied to the/ETC/RC.D/INIT.D directory:

    Cp/usr/local/src/redis/utils/redis_init_script/etc/rc.d/init.d/redis

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

    If you add a registration service at this point:

    Chkconfig--add Redis
    The following error will be reported:

    Redis service does not support Chkconfig (Redis scripts need to be changed)


  2. To change the Redis script, open the script using VI to view the script information:


  3. Vim/etc/rc.d/init.d/redis

  4. What you see is as follows (the following is a change of good information):

  5. #!/bin/sh

  6. #chkconfig: 2345 80 90

  7. # simple Redis INIT.D script conceived to work on Linux systems

  8. # as it does use of the/proc filesystem.


  9. redisport=6379

  10. Exec=/usr/local/redis/bin/redis-server

  11. Cliexec=/usr/local/redis/bin/redis-cli


  12. Pidfile=/var/run/redis_${redisport}.pid

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


  14. Case "$" in

  15. Start

  16. If [-F $PIDFILE]

  17. Then

  18. echo "$PIDFILE exists, process is already running or crashed"

  19. Else

  20. echo "Starting Redis server ..."

  21. $EXEC $CONF &

  22. Fi

  23. ;;

  24. Stop

  25. if [!-F $PIDFILE]

  26. Then

  27. echo "$PIDFILE does not exist, process was not running"

  28. Else

  29. pid=$ (Cat $PIDFILE)

  30. echo "Stopping ..."

  31. $CLIEXEC-P $REDISPORT shutdown

  32. While [-x/proc/${pid}]

  33. Do

  34. echo "Waiting for Redis to shutdown ..."

  35. Sleep 1

  36. Done

  37. echo "Redis stopped"

  38. Fi

  39. ;;

  40. *)

  41. echo "Please use Start or stop as first argument"

  42. ;;

  43. Esac


3. Copy the Redis configuration file to/etc/redis/${redisport}.conf


Mkdir/etc/redis
Cp/usr/local/src/redis/redis.conf/etc/redis/6379.conf

In this way, the conf specified by the Redis service script exists. By default, Redis does not have authentication enabled, and you can specify a verification password by turning on the requirepass of 6379.conf.

After the above operation is complete, you can register Yedis service: Chkconfig--add Redis
Start Redis Services: Service Redis start

4. Add the directory of the Redis command to the system parameter path

Modify Profile: Vi/etc/profile

Append in last line: Export path= "$PATH:/usr/local/redis/bin"

Then apply this file immediately:. /etc/profile
This makes it possible to invoke the REDIS-CLI command directly, as follows:

$ redis-cli

Redis 127.0.0.1:6379> Auth Superman

OK


This article is from the "7059211" blog, please be sure to keep this source http://7069211.blog.51cto.com/7059211/1864897

Installing Redis services under Linux

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.