Redis joins the boot start service

Source: Internet
Author: User
Tags redis server

The path to my Redis installation is in the

/usr/local/redis

Mkdir/etc/redis #创建文件夹

cp/usr/local/redis/redis.conf/etc/redis/6379.conf #将redis. conf Copy to/etc/redis folder

Vim/etc/rc.d/init.d/redis #打开编辑器

Insert the following content

#!/bin/Sh#chkconfig:2345  the  -# Simple Redis init.d script conceived to work on Linux systems# asIt does use of the/proc FileSystem. Redisport=6379EXEC=/usr/local/redis/src/redis-servercliexec=/usr/local/redis/src/redis-Clipidfile=/var/run/redis_${redisport}.pidconf="/etc/redis/${redisport}.conf" Case " $" inchstart)if[ -F $PIDFILE] then echo"$PIDFILE exists, process is already running or crashed"        ElseEcho"starting Redis Server ..."$EXEC $CONF fi;; Stop)if[ ! -F $PIDFILE] then echo"$PIDFILE does not exist, process was not running"        ElsePID=$ (cat $PIDFILE) echo"stopping ..."$CLIEXEC-p $REDISPORT shutdown while[-x/proc/${pid}] DoEcho"waiting for Redis to shutdown ..."Sleep1Done Echo"Redis stopped"fi;; *) echo"Please use start or stop as first argument"        ;; Esac

chkconfig --add redis #添加服务

Service Redis Start #启动服务

Add the directory of the Redis command to the system parameter path

Modify Profile: Vi/etc/profile

Append in last line: Export path= "$PATH:/usr/local/redis/src"

Then apply this file immediately:. /etc/profile

This makes it possible to invoke the REDIS-CLI command directly, as follows:

$ redis-cli

Redis 127.0.0.1:6379> Auth Superman

Ok

Redis 127.0.0.1:6379> Ping

PONG

Redis 127.0.0.1:6379>

Redis joins the boot start service

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.