Redis 3.0 Compilation Installation

Source: Internet
Author: User
Tags redis server

Official Main station: http://www.redis.io/

: http://www.redis.cn/download.html

Command api:http://www.redis.cn/commands.html
Redis Official documents: http://redis.io/documentation

I. Redis Introduction:
Redis is an abbreviation for remote Dictionary server. He is essentially a key/value database, similar to the memcached NoSQL database, but his data can be persisted on disk, resolving the problem of data not lost after service restart, his value can be string (string), list, sets ( Collection) or ordered sets (the sorted collection), all data types have Push/pop, Add/remove, perform service-side aggregation, intersection, two sets sets of differences, and so on, these operations are atomic, Redis also supports a variety of different sorting capabilities.

Two. Redis deployment
1. Install the dependent packages:
Yum-y install gcc gcc-c++ cmake make

2. Install the Tcmalloc package [try new memory allocation method]
Redis does not implement its own memory pool, and does not add its own stuff to the standard system memory allocator.
Therefore, the performance and fragmentation rate of the system memory allocator can have some performance impact on Redis.
In the latest version, Jemalloc has been included in the source package as part of the source package, so it can be used directly.
If you want to use Tcmalloc, you need to install it yourself.

Tcmalloc is part of Google-proftools (Http://code.google.com/p/gperftools/downloads/list),
So we actually need to install Google-proftools. If you are installing on a 64-bit machine, you need to first install its dependent Libunwind library, and the 32-bit system does not require
: http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz

(1). Install Libunwind
Tar zxvf libunwind-0.99-alpha.tar.gz
CD libunwind-0.99-alpha/
Cflags=-fpic./configure
Make Cflags=-fpic
Make Cflags=-fpic Install

(2). Install Gperftools
Tar zxvf gperftools-2.1.tar.gz
CD gperftools-2.1
./configure--disable-cpu-profiler-- Disable-heap-profiler--disable-heap-checker--disable-debugalloc--enable-minimal
make && make install
Cd/usr/local/lib
Ln-sv libtcmalloc_minimal.so.4.1.2 libtcmalloc.so
# Bold section if you do not, then compile Redis will error: USR/BIN/LD : Cannot find Ltcmalloc
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf #如果没有这个文件, build yourself a
/sbin/ Ldconfig

3.redis installation:
Tar zxvf redis-3.0.0.tar.gz
CD redis-3.0.0
mkdir-p/usr/local/redis-3.0
# make prefix=  Install
#/bin Redis under/usr/local/redis-3.0/bin
# make prefix=/usr/local/redis-3.0 install # this way, Use the default memory allocation method for Linux
make prefix=/usr/local/redis-3.0 use_tcmalloc=yes force_libc_malloc=yes install

4. Build the relevant directory, and configure the redis.conf file [simple configuration]
cd/usr/local/redis-3.0/
mkdir etc #存放配置文件, here directory name, can be built as: conf
mkdir Log # Storing log and PID files
mkdir data #存放数据
Vim etc/redis.conf
daemonize Yes
Port 6379
pidfile/usr/local/redis-3.0/ Log/redis_6379.pid
Dir/usr/local/redis-3.0/data
Logfile/usr/local/redis-3.0/log/redis_6379.log

5.Redis service startup, shutdown
(1). Start the service:
/usr/local/redis-3.0/bin/redis-server/usr/local/redis-3.0/etc/redis.conf
Note:
This command has only one startup parameter, a configuration file under the specified directory, and no parameters to perform the default configuration.
Test start:
/usr/local/redis-3.0/bin/redis-cli Ping
Returns Pong, the startup succeeds.
To see if the port is occupied:
NETSTAT-NTLP |grep 6379

(2). Close the service:
/USR/LOCAL/REDIS-3.0/BIN/REDIS-CLI shutdown
If not the default port, you can specify a port:
/usr/local/redis-3.0/bin/redis-cli-p 6380 shutdown

(3). Verify that the Redis memory allocation method is using Tcmalloc
lsof-n |grep tcmalloc
redis-ser 2754 root mem REG 253,0 1078467 1725996/usr/local /lib/libtcmalloc_minimal.so.4.1.2

6.Redis Service startup script
Redis itself provides the Redis installation script: utils/install_server.sh
But this script includes installation Services, a bit annoying, we directly take its installation script:
#!/bin/sh
#Configurations injected by Install_server below ....
Exec=/usr/local/redis-3.0/bin/redis-server
Cliexec=/usr/local/redis-3.0/bin/redis-cli
Pidfile=/usr/local/redis-3.0/log/redis_6379.pid
conf= "/usr/local/redis-3.0/etc/redis.conf"
Redisport= "6379"

Case "$" in
Start
If [-F $PIDFILE]
Then
echo "$PIDFILE exists, process is already running or crashed"
Else
echo "Starting Redis server ..."
$EXEC $CONF
Fi
;;
Stop
if [!-F $PIDFILE]
Then
echo "$PIDFILE does not exist, process was not running"
Else
pid=$ (Cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC-P $REDISPORT shutdown
While [-x/proc/${pid}]
Do
echo "Waiting for Redis to shutdown ..."
Sleep 1
Done
echo "Redis stopped"
Fi
;;
Status
pid=$ (Cat $PIDFILE)
if [!-x/proc/${pid}]
Then
Echo ' Redis is not running '
Else
echo "Redis is running ($PID)"
Fi
;;
Restart
$ stop
$ start
;;
*)
echo "Please use start, stop, restart or status as first argument"
;;
Esac



Redis 3.0 Compilation Installation

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.