After compiling and installing Redis (V2.8.19) under CentOS (Linux), the following considerations are summarized:
To download and install Redis:
$ wget http://download. redis.io/releases/redis-2.8.19.tar.gz$ tar xzfredis-2.8.19 . tar.gz$ cd redis-2.8.19$ make
TIPS: You can download the Redis file on the official website, and you can view the website's compilation and installation Method (Portal).
- Under the Redis root directory, directly
make
make
After success, if required make test
, you need to configure tcl8.5/tcl8.6 for testing
- TCL8.6 when installing non-default (CentOS version is low), be sure to create a file in path to connect to tclsh8.6, while note that the file name must be tclsh8.5/tclsh8.6, because when make test, will use which to find the 8.5 or 8.6 version of TCL
- Install: Direct
make install
, default installation /usr/local/bin
under, if you need to set a custom path, use make PREFIX=/usr/local/redis install
to install
- After installation, the default is no configuration files, need to be configured, after successful installation can use utils inside
install_server.sh
to configure the server.
Install_server.sh There are a lot of bugs, if you do not modify you will find that/etc/init.d/redis_*** is not working properly-the configuration file inside is a lot of \ n, not escaped.
line 163,177: if [ !`which chkconfig` ]; then
there should be a space between ' which chkconfig ' and not appear.
line 165: echo
you should then need an-e parameter, which means that the escape character is allowed.
- Configuration:
- To prevent the system from crashing due to full memory, you need to set the maxmemory in/ETC/REDIS/*.CNF
- Prevent errors, you can adjust the memory allocation policy
/etc/sysctl.conf This is a recommendation you can see in the Redis log: add Vm.overcommit_memory=1 Save, and execute: sysctl vm.overcommit_memory=1 make it effective/proc/ Sys/vm/overcommit_memory, this is the overcommit_memory value, this can be updated by the above settings. 0, indicates that the kernel will check for sufficient available memory to be used by the process, and if sufficient memory is available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process. 1, which means that the kernel allows all physical memory to be allocated regardless of the current memory state. 2, which indicates that the kernel allows allocating more memory than the sum of all physical memory and swap space
After completion, you can turn on Redis and test for normal.
The following test assigns value to TestKey:
$ redis-cli127.0.0.1:6379>set testkey value OK 127.0 .0 .1 : 6379 >get testkey< Span class= "string", "value" 127.0 .0 .1 : 6379 >exit plus a boot-up script: on GitHub: https:// gist.github.com/markalanevans/1335694 #!/bin/sh## redis Startup script for Redis server## chkconfig:-10# Description:redis was an open source, Advan CED Key-value Store. # # processname:redis-server# config:/etc/redis.conf# pidfile:/var/run/redis.pid path=/usr/local/bin:/sbin:/usr/bin :/bin redisport=6379exec=/opt/redis/redis-serverredis_cli=/opt/redis/redis-cli PIDFILE=/var/run/redis.pidCONF= "/ Opt/redis/redis.conf "Case" $ "in Start" if [-f $PIDFILE] then Echo-n "$PIDFILE exists , process is already running or crashed\n "Else echo-n" starting Redis server...\n " $EXEC $CONF fi;; STOP) if [!-F $PIDFILE] then Echo-n "$PIDFILE does not exist, process is not running\n" elsepid=$ (cat $PIDFILE) echo-n "stopping ... \ n" $REDIS _cli-p $REDISPORT SHUTDOWN whil e [-X ${pidfile}] do echo "Waiting for Redis to shutdown ..." Sleep 1 done echo "Redis stopped" FI;; Esac
Here, use the cat-v file_name to see if there is a Windows end character in the file.Windows file line breaks yes "\ r \ n" You can use the Cat-v file name to see if the newline character is, and if it is, the end of the line will be ^m
Some words are replaced with this command:Sed ' s/\r//' original file > converted file This is the pit I've stepped on!
Then put this file in/etc/init.d/redis give the Execute permission chmod.
Then Chkconfig Redis on set boot up
Start or Stop Redis
- Service Redis start #或者/etc/init.d/redis start
- Service Redis stop #或者/etc/init.d/redis stop
Complete!
CentOS 7 Compile and install Redis