Based on CentOS release 6.5 Final, redis version 3.0.2 [the middle bit of the redis version number is the even version is the stable version, the odd number is the unstable version]
First, install redis
1) Download the redis installation package
You can go to the official website http://redis.io, or through the wget command,
[[email protected] srv] # wget http://download.redis.io/redis-stable.tar.gz
2) Unzip
[[email protected] srv] # tar -zxvf redis-stable.tar.gz
3) Compile and install (compile and install Development tools and Desktop Platfrom development kit group tools)
[[email protected] srv] # cd redis-stable
[[email protected] redis-stable] # ll
total 200
-rw-r--r--. 1 1000 1000 78892 Oct 26 15:17 00-RELEASENOTES
-rw-r--r--. 1 1000 1000 53 Oct 26 15:17 BUGS
-rw-r--r--. 1 1000 1000 1805 Oct 26 15:17 CONTRIBUTING
-rw-r--r--. 1 1000 1000 1487 Oct 26 15:17 COPYING
drwxr-xr-x. 7 1000 1000 4096 Oct 26 15:17 deps
-rw-r--r--. 1 1000 1000 11 Oct 26 15:17 INSTALL
-rw-r--r--. 1 1000 1000 151 Oct 26 15:17 Makefile
-rw-r--r--. 1 1000 1000 4223 Oct 26 15:17 MANIFESTO
-rw-r--r--. 1 1000 1000 6834 Oct 26 15:17 README.md
-rw-r--r--. 1 1000 1000 46695 Oct 26 15:17 redis.conf
-rwxr-xr-x. 1 1000 1000 271 Oct 26 15:17 runtest
-rwxr-xr-x. 1 1000 1000 280 Oct 26 15:17 runtest-cluster
-rwxr-xr-x. 1 1000 1000 281 Oct 26 15:17 runtest-sentinel
-rw-r--r--. 1 1000 1000 7606 Oct 26 15:17 sentinel.conf
drwxr-xr-x. 2 1000 1000 4096 Oct 26 15:17 src
drwxr-xr-x. 10 1000 1000 4096 Oct 26 15:17 tests
drwxr-xr-x. 7 1000 1000 4096 Oct 26 15:17 utils
[[email protected] redis-stable] # make
CC geo.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
CC redis-check-aof.o
LINK redis-check-aof
Hint: It ‘s a good idea to run ‘make test’;)
make [1]: Leaving directory `/ srv / redis-stable / src’
[[email protected] redis-stable] # make install
cd src && make install
make [1]: Entering directory `/ srv / redis-stable / src’
Hint: It ‘s a good idea to run ‘make test’;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make [1]: Leaving directory `/ srv / redis-stable / src’
[[email protected] redis-stable] #
[[email protected] redis-stable] # ls / usr / local / bin
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
[[email protected] redis-stable] #
[[email protected] redis-stable] # / usr / local / bin / redis-server -v
Redis server v = 3.2.5 sha = 00000000: 0 malloc = jemalloc-4.0.3 bits = 64 build = 661b15c1ebfa36b
Note: If you execute redis-server –v (view version command) at this time, if you are prompted with redis-server command not found, you need to add the / usr / local / bin directory to the environment variable. How to add it will not be described in detail here , Can view and modify / etc / profile, (view environment variable command: echo $ PATH)
At this point, redis installation is complete, and then configure.
Second, modify the configuration file. Conf
1) Create configuration file directory, dump file directory, process directory, log directory, etc.
Configuration files are generally placed under / etc / to create the fedis directory
[[email protected] redis-stable] # cd / etc /
[[email protected] etc] # mkdir redis
Dump file, process directory, log directory, etc., generally placed in / var / directory
[[email protected] etc] # cd redis /
[[email protected] redis] # ls
[[email protected] redis] # cd / var
[[email protected] var] # mkdir redis
[[email protected] var] # cd redis /
[[email protected] redis] # mkdir data log run
[[email protected] redis] # ll
total 12
drwxr-xr-x. 2 root root 4096 Dec 5 15:58 data
drwxr-xr-x. 2 root root 4096 Dec 5 15:58 log
drwxr-xr-x. 2 root root 4096 Dec 5 15:58 run
[[email protected] redis] #
At this point, the directory is created.
2) Modify the configuration file and configuration parameters
First copy the redis.conf file under the decompressed package to / etc / redis
[[email protected] redis-stable] # cp redis.conf / etc / re
readahead.conf redhat-lsb / redhat-release redis / resolv.conf resolv.conf.save
[[email protected] redis-stable] # cp redis.conf / etc / redis /
[[email protected] redis-stable] # vi /etc/redis/redis.conf It is best to make a backup copy of redis.conf.bak
# Accept connections on the specified port, default is 6379 (IANA # 815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
##### Modify the default port
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/run/redis_6379.pid
##### Modify the pid directory to a new directory
# The working directory.
##
# The DB will be written inside this directory, with the filename specified
# above using the ‘dbfilename’ configuration directive.
##
# The Append Only File will also be created inside this directory.
##
# Note that you must specify a directory here, not a file name.
dir ./
##### Change the dump directory to a new directory
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to / dev / null
logfile ""
##### Modify the log storage directory to a new directory
3) Persistence
The default RDB, you can choose whether to open AOF, if open, modify the appendend
4) Start redis and view the files in each directory
[[email protected] redis-stable] # redis-server /etc/redis/redis.conf
View dump, log, pid, etc.
[[email protected] redis] # cd data
[[email protected] data] # ll
total 0
[[email protected] data] # ll ../ log
-bash: ll ../ log: No such file or directory
[[email protected] data] # ll ../log
total 4
-rw-r--r--. 1 root root 1861 Dec 5 16:15 redis.log
[[email protected] data] # ll ../run
total 4
-rw-r--r--. 1 root root 6 Dec 5 16:15 redis_6379.pid
[[email protected] data] #
It is found that there are only logs, no dump and pid information, because the current redis service is still running in console mode, and there is no data storage operation
Stop the redis service, modify the configuration file so that redis runs in the background
650) this.width = 650; "src =" http://img.blog.csdn.net/20150804102119940 "style =" border: none; height: auto; "/>
Change to yes, save, restart redis service
5) The client connects to redis
[[email protected] run] # redis-cli
127.0.0.1:6379> ##### default port 6379
6) At this point, the basic configuration of redis is completed, if there are other related configuration adjustments, you can find the document is being modified
3. Service and self-starting
1) Create a redis startup script
Copy the redis startup script under utils under the decompression package to /etc/init.d
[[email protected] redis-stable] # cd / srv / redis-stable / utils /
[[email protected] utils] # cp redis_init_script /etc/init.d/
Modify the script name to redis and modify the script pid and conf path to the actual path
650) this.width = 650; "src =" http://s3.51cto.com/wyfs02/M00/8B/21/wKiom1hFKBnDjPSAAACxz8I5Acw322.png-wh_500x0-wm_3-wmp_4-s_2660817963.png "title =" Q8.png "alt =" wKiom1hFKBnDjPSAAACxz8I5Acw322.png-wh_50 "/>
At this point, in the /etc/init.d directory, you can start / stop the redis service through service redis start / stop.
2. Add delete permission to the startup script
#chmod + x /etc/init.d/redis Add permissions to the startup script
#chmod -x /etc/init.d/redis delete permissions
3. Set self-start
#chkconfig redis on
If an error is reported during operation, it will prompt
[[email protected] init.d] # chkconfig redis on
service redis does not support chkconfig
Because redis startup priority information is not added to the startup script, you can add the following
650) this.width = 650; "src =" http://s2.51cto.com/wyfs02/M01/8B/1E/wKioL1hFKgmA0SZ_AACZLQrW7SU504.png-wh_500x0-wm_3-wmp_4-s_2790079623.png "title =" 442.png "alt =" wKioL1hFKgmA0SZ_AACZLQrW7SU504.png-wh_50 "/>
Execute chkconfig redis on again, success, and the configuration has been completed since the start.
This experiment is completed with reference to http://blog.csdn.net/ludonqin/article/details/47211109.
centos 6.5 install and configure redis