Redis Installation (CentOS 6.5 32)

Source: Internet
Author: User
Tags redis server

1. Download

wget "http://codeload.github.com/antirez/redis/tar.gz/2.8.21"-O redis-2.8.21.tar.gz

2. Decompression

[Email protected] redis-2.8.21]# TAR-ZXVF redis-2.8.21.tar.gz

3. Compiling

[Email protected] redis-2.8.21]# CD redis-2.8.21

[[email protected] redis-2.8.21]# make

When you see the last Hint:it ' a good idea to run ' make test ';) Description compiled by

4. Installation

Make Prefix=/usr/local/redis Install

Prefix=/usr/local/redis is the specified installation path

[[email protected] redis-2.8.21]# make Prefix=/usr/local/redis Install
CD src && make install
MAKE[1]: Entering directory '/USR/LOCAL/SRC/REDIS-2.8.21/SRC '

Hint:it ' s a good idea to run ' make test ';)

Install Install
Install Install
Install Install
Install Install
Install Install
MAKE[1]: Leaving directory '/USR/LOCAL/SRC/REDIS-2.8.21/SRC '

when the installation is complete, Cd/usr/local/redis will see a bin directory in which the directory
They are redis-server, REDIS-CLI, Redis-benchmark, Redis-stat, respectively, and their functions are as follows:

Redis-server:redis Server Daemon startup program
Redis-cli:redis Command-line operation tool. Of course, you can also use Telnet to operate on its plain text protocol.
Redis-benchmark:redis Performance testing tools to test the read and write performance of Redis in your system and in your configuration
Redis-stat:redis Status Detection Tool to detect Redis current status parameters and delay status

5. Create a profile directory and define the Redis configuration file yourself

[Email protected] redis-2.8.21]# mkdir/usr/local/redis/etc

wget Http://www.apelearn.com/study_v2/.redis_conf-O/usr/local/redis/etc/redis.conf 2>/dev/null

The above download is a well-written configuration file

vim/usr/local/redis/etc/redis.conf//write the following:

daemonize Yes
Pidfile/usr/local/redis/var/redis.pid
Port 6379
Timeout
loglevel Debug
Logfile/usr/local/redis/var/redis.log
databases
Save 1
Save
Save 10000
rdbcompression Yes
dbfilename Dump.rdb
dir/usr/local/redis/var/
appendonly No
Appendfsync always


The following are the meanings of the main configuration parameters of redis.conf:
Daemonize: Whether to run daemon mode later
pidfile:pid File Location
Port: Port number for listening
Timeout: Request time-out
Loglevel:log Information Level
logfile:log File Location
databases: Number of open databases
Save *: How often the snapshot is saved, the first * indicates how long, and the third * indicates how many times the write operation is performed. Snapshots are automatically saved when a certain number of writes are performed within a certain amount of time. You can set multiple conditions.
Rdbcompression: Whether to use compression
dbfilename: Data Snapshot file name (only file name, excluding directory)
dir: Save directory for Data snapshot (this is the directory)
appendonly: If the appendonlylog is turned on, each write will record a log, which will improve the data anti-risk ability, but affect the efficiency.
Appendfsync:appendonlylog How to sync to disk (three options, each write is forced to call Fsync, Fsync per second, do not call Fsync wait for the system to synchronize itself)


6. Startup script

[Email protected] redis-2.8.21]# wget Http://www.apelearn.com/study_v2/.redis_init-O/etc/init.d/redis 2>/dev/ Null

[Email protected] redis-2.8.21]# Ls/etc/init.d/redis
/etc/init.d/redis

7, set the user, set permissions, start ( because the script starts with a Redis user, you need to increase the Redis user )

[Email protected] redis-2.8.21]# useradd-s/sbin/nologin Redis
[Email protected] redis-2.8.21]# Mkdir/usr/local/redis/var
[Email protected] redis-2.8.21]# chmod 777/usr/local/redis/var/
[Email protected] redis-2.8.21]# chmod 755/etc/init.d/redis
[Email protected] redis-2.8.21]# chkconfig--add Redis
[[email protected] redis-2.8.21]# chkconfig Redis on
[[Email protected] redis-2.8.21]# service Redis start
Starting redis-server: [OK]
[[Email protected] redis-2.8.21]# PS aux|grep Redis
Redis 5944 0.1 0.0 33876 1568? SSL 20:29 0:00/usr/local/redis/bin/redis-server *:6379#已经启动监听的是6379端口
Root 5953 0.0 0.0 4420 760 pts/0 s+ 20:30 0:00 grep redis

8. Simple test

[Email protected] redis-2.8.21]#/USR/LOCAL/REDIS/BIN/REDIS-CLI
127.0.0.1:6379> Set K1 v1
Ok
127.0.0.1:6379> Get K1
"V1"
127.0.0.1:6379>

Instructions for Redis installation, test OK.

Note: The startup script for Redis

[Email protected] redis-2.8.21]# Cat/etc/init.d/redis
#!/bin/sh
#
# Redis init file for starting up the Redis daemon
#
# Chkconfig:-20 80
# Description:starts and stops the Redis daemon.

# Source function library.
. /etc/rc.d/init.d/functions

Name= "Redis-server"
Basedir= "/usr/local/redis"
exec= "$basedir/bin/$name"
pidfile= "$basedir/var/redis.pid"
redis_config= "$basedir/etc/redis.conf"

[-e/etc/sysconfig/redis] &&. /etc/sysconfig/redis

Lockfile=/var/lock/subsys/redis

Start () {
[-F $REDIS _config] | | Exit 6
[-X $exec] | | Exit 5
Echo-n $ "Starting $name:"
Daemon--user ${redis_user-redis} "$exec $REDIS _config"
Retval=$?
Echo
[$retval-eq 0] && Touch $lockfile
Return $retval
}

Stop () {
Echo-n $ "Stopping $name:"
Killproc-p $pidfile $name
Retval=$?
Echo
[$retval-eq 0] && rm-f $lockfile
Return $retval
}

Restart () {
Stop
Start
}

Reload () {
False
}

Rh_status () {
Status-p $pidfile $name
}

Rh_status_q () {
Rh_status >/dev/null 2>&1
}


Case "$" in
Start
Rh_status_q && Exit 0
$
;;
Stop
Rh_status_q | | Exit 0
$
;;
Restart
$
;;
Reload
Rh_status_q | | Exit 7
$
;;
Force-reload)
Force_reload
;;
Status
Rh_status
;;
Condrestart|try-restart)
Rh_status_q | | Exit 0
Restart
;;
*)
echo $ "Usage: $ {Start|stop|status|restart|condrestart|try-restart}"
Exit 2
Esac
Exit $?


Redis Installation (CentOS 6.5 32)

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.