CentOS Installation Redis

Source: Internet
Author: User

Redis Installation Steps

1. Download Redis

(1) Get permission: su root

(2) Plan the downloaded directory: mkdir/usr/local/soft/

(3) Enter the new directory, ready to download: cd/usr/local/soft/

(4) Download the latest Redis stable version:

wget http://download.redis.io/releases/redis-3.0.0.tar.gz

2. Unzip and install Redis

(1) Unzip the TAR package: Tar zxvf redis-3.0.0.tar.gz

(2) Enter the new directory after decompression: CD redis-3.0.0

(3) Compiling source code: Make

(4) Verify that the compilation is correct: Make test

3. manually start redisto test If Redis is functioning properly

(1) Enter the command to start Redis:src/redis-server in the current Redis directory

(2) Check whether the process has Redis: PS aux | grep Redis, you can see a process called "src/redis-server" in the list of processes.

(3) Start the Redis-brought client and test:

Start the client and connect to the local redis:src/redis-cli

> Set foo Bar--Prompts "OK" to indicate normal setting of key values.

> Get foo--can prompt to return the correct "bar", indicating that it is working properly.

> Quit--Quit client

4. add Redis to the boot sequence

(1) redis.conf configuration file Daemonize No change to daemonize Yes

(2) Scripting/etc/init.d/redis:

###########################

#chkconfig: 2345 10 90

#description: Start and Stop Redis

Path=/usr/local/bin:/sbin:/usr/bin:/bin

redisport=6379 #实际环境而定

Exec=/usr/local/soft/redis-3.0.0/src/redis-server #实际环境而定

REDIS_CLI=/USR/LOCAL/SOFT/REDIS-3.0.0/SRC/REDIS-CLI #实际环境而定

Pidfile=/var/run/redis.pid

conf= "/usr/local/soft/redis-3.0.0/redis.conf" #实际环境而定

Case "$" in

Start

If [-F $PIDFILE]

Then

echo "$PIDFILE exists, process is already running or crashed"

Else

echo "Starting Redis server ..."

$EXEC $CONF

Fi

If ["$?" = "0"]

Then

echo "Redis is running ..."

Fi

;;

Stop

if [!-F $PIDFILE]

Then

echo "$PIDFILE does not exist, process was not running"

Else

pid=$ (Cat $PIDFILE)

echo "Redis is stopping ..."

$REDIS _cli-p $REDISPORT SHUTDOWN

While [-X ${pidfile}]

Do

echo "Waiting for Redis to shutdown ..."

Sleep 1

Done

echo "Redis stopped"

Fi

;;

Restart|force-reload)

${0} stop

${0} start

;;

*)

echo "Usage:/etc/init.d/redis {start|stop|restart|force-reload}" >&2

Exit 1

Esac

##############################

(3) executive authority: chmod +x/etc/init.d/redis

(4) boot start:

# try to start or stop Redis

Service Redis Start

Service Redis Stop

# Turn on Service self-boot

sudo chkconfig redis on

CentOS Installation 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.