Install Redis and MongoDB in CentOS 7

Source: Internet
Author: User
Tags download redis redis cluster value store

Install Redis and MongoDB in CentOS 7

The previous article recorded Node. js. This time we talked about installing Redis and MongoDB in CentOS 7, so we basically installed the entire development environment of Node. js.

Redis

Installing apsaradb for Redis in CentOS is also relatively simple. You can perform the operations step by step without errors.

1. Switch/usr/srcDirectory (if you install it in another directory, You need to modify the path later), download Redis, the latest version is 2.8.13.

  1. Cd/usr/src
  2. Wget http://download.redis.io/releases/redis-2.8.13.tar.gz

2. decompress the package and switch the directory.

  1. Tar xzf redis-2.8.13.tar.gz
  2. Cd redis-2.8.13

3. Compile

  1. Make
  2. Make install

4. Openredis.confThe key to modifying the configuration file is the following lines. For other settings, refer to the official documentation:

  1. Daemonize yes
  2. Loglevel notice
  3. Logfile/var/log/redis. log
  4. Dir ./

5. Set overcommit_memory of the system and run

  1. Vi/etc/sysctl. conf

Add a row to the file and save:

  1. Vm. overcommit_memory = 1

Run:

  1. Sysctl vm. overcommit_memory = 1

6. Add the startup script and execute:

  1. Vi/etc/init. d/redis

Write the following code and save it:

  1. #! /Bin/sh
  2. #
  3. # Redis Startup script for Redis Server
  4. #
  5. # Chkconfig:-90 10
  6. # Description: Redis is an open source, advanced key-value store.
  7. #
  8. # Processname: redis-server
  9. # Config:/etc/redis. conf
  10. # Pidfile:/var/run/redis. pid
  11.  
  12. REDISPORT = 6379
  13. EXEC =/usr/local/bin/redis-server
  14. REDIS_CLI =/usr/local/bin/redis-cli
  15. PIDFILE =/var/run/redis. pid
  16. CONF = "/usr/src/redis-2.8.13/redis. conf"
  17. Case "$1" in
  18. Start)
  19. If [-f $ PIDFILE]
  20. Then
  21. Echo "$ PIDFILE exists, process is already running or crashed"
  22. Else
  23. Echo "Starting Redis server ..."
  24. $ EXEC $ CONF
  25. Fi
  26. If ["$? "=" 0 "]
  27. Then
  28. Echo "Redis is running ..."
  29. Fi
  30. ;;
  31. Stop)
  32. If [! -F $ PIDFILE]
  33. Then
  34. Echo "$ PIDFILE does not exist, process is not running"
  35. Else
  36. PID = $ (cat $ PIDFILE)
  37. Echo "Stopping ..."
  38. $ REDIS_CLI-p $ REDISPORT SHUTDOWN
  39. While [-x $ {PIDFILE}]
  40. Do
  41. Echo "Waiting for Redis to shutdown ..."
  42. Sleep 1
  43. Done
  44. Echo "Redis stopped"
  45. Fi
  46. ;;
  47. Restart | force-reload)
  48. $ {0} stop
  49. $ {0} start
  50. ;;
  51. *)
  52. Echo "Usage:/etc/init. d/redis {start | stop | restart | force-reload}"> & 2
  53. Exit 1
  54. Esac

Set permissions and start upon startup:

  1. Chmod + x/etc/init. d/redis
  2. Chkconfig -- add redis
  3. Chkconfig redis on

OK. Now the installation is complete. Start redisservice redis startOr/etc/init.d/redis startCommand to stop redisservice redis stopOr/etc/init.d/redis stopTo use redis in windows, refer to this article.

You may also like the following articles about Redis. For details, refer:

Install and test Redis in Ubuntu 14.04

Basic configuration of Redis master-slave Replication

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

This article permanently updates the link address:

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.