Part I. Direct startDownload
Download website
Installation
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
Tar zxvf redis-2.8. 9. tar.gz
CD redis-2.8. 9
#直接make compilation
Make
#可使用root用户执行 ' make install ' to copy the executable file to the/usr/local/bin directory. This allows you to run the program directly by typing the name.
Make install
Start
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#加上 ' & ' makes Redis run as a daemon
./redis-server &
Detection
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#检测后台进程是否存在
Ps-ef |grep Redis
#检测 the 6379 port is listening
NETSTAT-LNTP | grep 6379
#使用 ' redis-cli ' client detects if the connection is healthy
./redis-cli
127.0. 0.1:6379> Keys *
(empty list or set)
127.0. 0.1:6379> Set key "Hello World"
Ok
127.0. 0.1:6379> Get key
"Hello World"
Stop it
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#使用客户端
REDIS-CLI shutdown
#因为Redis可以妥善处理SIGTERM信号, so direct kill-9 is also possible.
Kill-9 PID
Part Ii. starting by specifying a profileConfiguration file
The specified configuration file can be started for the Redis service, and the configuration file is redis.conf
under the Redis root directory.
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#修改daemonize为yes, that is, the default way to run the program (remember to manually use & to force the background to run earlier).
Daemonize No
#可修改默认监听端口
Port 6379
#修改生成默认日志文件位置
LogFile "/home/futeng/logs/redis.log"
#配置持久化文件存放位置
Dir/home/futeng/data/redisdata
Specify configuration file at startup
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
Redis-server./redis.conf
#如果更改了端口, you also need to specify a port when using the ' redis-cli ' client connection, for example:
Redis-cli-p 6380
other start-stop with Direct Start Way. Configuration files are a very important configuration tool, and it is important to use the configuration files in the first place as they become progressively more intensive.
Part iii. setting up boot-up with Redis startup scriptsStartup scripts
It is recommended that you start the Redis service in a production environment using startup scripting. The startup script redis_init_script
is located in the Redis /utils/
directory.
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#大致浏览下该启动脚本, it is found that Redis habitually uses the port name of the listener as the configuration file, and we follow this convention later.
#redis服务器监听的端口
redisport=6379
#服务端所处位置, the default storage and '/usr/local/bin/redis-server ' after make install, if not make install, you need to modify the path, the same as below.
Exec=/usr/local/bin/redis-server
#客户端位置
Cliexec=/usr/local/bin/redis-cli
#Redis的PID文件位置
Pidfile=/var/run/redis_${redisport}.pid
#配置文件位置, you need to modify
conf="/etc/redis/${redisport}.conf"
Configuring the Environment
1. According to the startup script requirements, copy the modified configuration file to the specified directory with the name of the port. Need to use root user.
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
Mkdir/etc/redis
CP redis.conf/etc/redis/6379. conf
2. Copy the startup script to the/ETC/INIT.D directory, this example names the startup script REDISD (usually ending with D as the background self-starting service).
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
CP REDIS_INIT_SCRIPT/ETC/INIT.D/REDISD
3. set to boot from boot
The direct configuration here is to turn on self-booting chkconfig redisd on
to report an error:service redisd does not support chkconfig
referring to this article , add the following two lines of comments at the beginning of the startup script to modify its runlevel:
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#!/bin/sh
# chkconfig: 2345
# Description:redis is a persistent key-value database
#
Set it again to succeed.
Shell code 650) this.width=650; "class=" star "src=" Http://futeng.iteye.com/images/icon_star.png "alt=" Favorites code "/>
#设置为开机自启动服务器
Chkconfig REDISD on
#打开服务
Service REDISD Start
#关闭服务
Service REDISD Stop
This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://pizibaidu.blog.51cto.com/1361909/1674290
Three ways to start Redis