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/src
Directory (if you install it in another directory, You need to modify the path later), download Redis, the latest version is 2.8.13.
- Cd/usr/src
- Wget http://download.redis.io/releases/redis-2.8.13.tar.gz
2. decompress the package and switch the directory.
- Tar xzf redis-2.8.13.tar.gz
- Cd redis-2.8.13
3. Compile
- Make
- Make install
4. Openredis.conf
The key to modifying the configuration file is the following lines. For other settings, refer to the official documentation:
- Daemonize yes
- Loglevel notice
- Logfile/var/log/redis. log
- Dir ./
5. Set overcommit_memory of the system and run
- Vi/etc/sysctl. conf
Add a row to the file and save:
- Vm. overcommit_memory = 1
Run:
- Sysctl vm. overcommit_memory = 1
6. Add the startup script and execute:
- Vi/etc/init. d/redis
Write the following code and save it:
- #! /Bin/sh
- #
- # Redis Startup script for Redis Server
- #
- # Chkconfig:-90 10
- # Description: Redis is an open source, advanced key-value store.
- #
- # Processname: redis-server
- # Config:/etc/redis. conf
- # Pidfile:/var/run/redis. pid
-
- REDISPORT = 6379
- EXEC =/usr/local/bin/redis-server
- REDIS_CLI =/usr/local/bin/redis-cli
- PIDFILE =/var/run/redis. pid
- CONF = "/usr/src/redis-2.8.13/redis. conf"
- Case "$1" in
- Start)
- If [-f $ PIDFILE]
- Then
- Echo "$ PIDFILE exists, process is already running or crashed"
- 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 is not running"
- Else
- PID = $ (cat $ PIDFILE)
- Echo "Stopping ..."
- $ REDIS_CLI-p $ REDISPORT SHUTDOWN
- While [-x $ {PIDFILE}]
- Do
- Echo "Waiting for Redis to shutdown ..."
- 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
Set permissions and start upon startup:
- Chmod + x/etc/init. d/redis
- Chkconfig -- add redis
- Chkconfig redis on
OK. Now the installation is complete. Start redisservice redis start
Or/etc/init.d/redis start
Command to stop redisservice redis stop
Or/etc/init.d/redis stop
To 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: