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 compiled make# can use the root user to execute ' make install ' and 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
#加上 ' &' makes Redis run as a daemon. /redis-server &
Detection
#检测后台进程是否存在ps-ef |grep redis# detects if port 6379 is listening netstat-LNTP | Grep6379#使用 ' Redis-The CLI ' client detects whether the connection is healthy./redis-CLI127.0.0.1:6379> Keys *(empty list orSet)127.0.0.1:6379>SetKey"Hello World"OK127.0.0.1:6379>GetKey"Hello World"
Stop it
#使用客户端redis---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.

#修改daemonize为yes, that is, the default way to run the program (remember to manuallyuse the &6379"/home/futeng/logs/ Redis.log"/home/futeng/data/redisdata
Specify configuration file at startup
Redis-server./redis.conf# If you change the port, you also need to specify a port when using the ' Redis-CLI ' client connection, for example: Redis6380

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#服务端所处位置, which is stored by default with '/usr/local/bin/redis-server ' after make install ' If you do not install it, you need to modify the path. EXEC=/usr/local/bin/redis-server# client location cliexec=/usr/local/bin/redis-cli#redis pid file location pidfile =/var/run/redis_${redisport}.pid# configuration file location, needs to be modified 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//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:  is a Persistent key-value database#

Set it again to succeed.

#设置为开机自启动服务器chkconfig REDISD on# Open Service services REDISD start# shut down services service REDISD stop

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.