Redis (13) Three ways to start Redis

Source: Internet
Author: User

Part I. Direct-Start download

Download website

Installation
Tar zxvf redis-2.8.9.tar.gzcd redis-2.8.9#直接make compilemake #可使用root用户执行 ' do install ' to copy executables to/usr/local/ The bin directory. This allows you to run the program directly by typing the name. Make install 
Start
#加上 ' & ' makes Redis run as a daemon. /redis-server &
Detection
#检测后台进程是否存在ps-ef |grep redis6379#使用 ' redis-cli ' client to detect the connection is normal./redis-cli127.0. 0. 1:Set) 127.0. 0. 1:"Hello world" OK127.0. 0. 1:get key' Hello World '  
Stop it
Shutdown#因为Redis可以妥善处理SIGTERM信号, so direct kill-9 is also possible. Kill-9 PID  
Part Ii. To launch a configuration file by specifying a profile

The specified configuration file can be started for the Redis service, and the configuration file is redis.conf under the Redis root directory.

No6379"/home/futeng/logs/redis.log"#配置持久化文件存放位置dir/home/futeng/data/redisdata  
Specify configuration file at startup
Redis-server./redis.conf#如果更改了端口, when using the ' redis-cli ' client connection, you also need to specify a port, for example: Redis-cli-p 6380

Other start-stop and Direct starting mode. 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. To set up a boot startup script using Redis startup 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.

#大致浏览下该启动脚本, 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 is stored with '/usr/local/bin/redis-server ' after make install, if not Install will need to modify the path, the same. Exec=/usr/local/bin/redis-server#客户端位置CLIEXEC =/usr/local/bin/redis-cli#Redis的PID文件位置PIDFILE =/var/run/ Redis_${redisport}.pid#配置文件位置, 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.

MKDIR/ETC/REDISCP 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).

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:

#!/bin/sh# chkconfig:   2345 #Description: Redis is  a persistent key-value database# /c4>

Set it again to succeed.

#设置为开机自启动服务器chkconfig REDISD on#打开服务service redisd start#关闭服务service REDISD stop 

Redis (13) Three ways to start Redis

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.