Getting Started with Redis

Source: Internet
Author: User
Tags redis version redis server

First, installation

Currently, the official latest stable version is 3.0.7

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

# cd/usr/local/

# tar Xvf/root/redis-3.0.7.tar.gz

# CD redis-3.0.7/

# make

Second, start

After the installation is complete, a startup execution program will be generated in the SRC directory, including Redis-server,redis-sentinel, REDIS-BENCHMARK,REDIS-CLI, etc.

# Src/redis-server

This is initiated by the foreground, and if the current terminal is closed, Redis shuts down automatically

As the logon information is displayed at the beginning of warning, this method of booting does not use a configuration file, so it is not recommended. Default Listener 6379 Port

24649: CGenevaFeb -: +:30.242# warning:no Configfilespecified, using the default Config. In order to specify a configfileUse src/redis-server/path/to/redis.conf24649: MGenevaFeb -: +:30.243* Increased maximum number of open files to10032(It is originally set to1024x768). _._                                                             _.-``__"'-._                                                   _.-``    `. `_."'-._ Redis3.0.7(00000000/0) -bit.-`` .-```. ```\/    _.,_"'-._                                    (    '      ,       .-`  | `,    ) Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'| Port:6379| `-._   `._    /     _.-'    | pid:24649`-._    `-._  `-./  _.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'| | `-._`-._        _.-'_.-'| http//Redis.io`-._    `-._`-.__.-'_.-'_.-'|`-._`-._    `-.__.-'    _.-'_.-'| | `-._`-._        _.-'_.-'|                                    `-._    `-._`-.__.-'_.-'_.-'`-._    `-.__.-'    _.-'                                                 `-._        _.-'`-.__.-'                                               24649: MGenevaFeb -: +:30.246# warning:the TCP Backlog setting of511Cannot be enforced because/proc/sys/net/core/somaxconn are set to the lower value of -.24649: MGenevaFeb -: +:30.246# Server started, Redis version3.0.724649: MGenevaFeb -: +:30.246# WARNING Overcommit_memory is set to0! Background save may fail under low memory condition. To fix this issue add'vm.overcommit_memory = 1'To/etc/sysctl.conf and ThenReboot or run the command'sysctl Vm.overcommit_memory=1'  forThis is take effect.24649: MGenevaFeb -: +:30.246# WARNING You has Transparent Huge Pages (THP) Support enabledinchYour kernel. This would create latency and memory usage issues with Redis. To fix this issue run the command'echo never >/sys/kernel/mm/transparent_hugepage/enabled'As root, and add it to your/etc/rc.localinchorder to retain the setting after a reboot. Redis must be restarted after THP is disabled.24649: MGenevaFeb -: +:30.247* The server is now a ready-to-accept connections on port6379

More usage of redis-server can be viewed through redis-server-h

# src/redis-server-h

Usage:./redis-server [/path/to/redis.conf] [options]./redis-server-(read config from stdin)./redis-server-v OR--version./redis-server-h OR--Help ./redis-server--test-memory <megabytes>Examples:./redis-Server (run the server with default conf)./redis-server/etc/redis/6379. conf./redis-server--port7777       ./redis-server--port7777--slaveof127.0.0.1 8888       ./redis-server/etc/myredis.conf--loglevel verbosesentinel mode:./redis-server/etc/sentinel.conf--sentinel

Common parameters in the configuration file are as follows:

Daemonize: Whether to run in the future daemon mode, the default is the foreground mode, that is, the default value is no

Pidfile:pid file location, default is:/run/redis.pid

Port: The port number to listen to, default is 6379

Bind 127.0.0.1 Configure the IP of the monitor NIC for scenarios with multiple network cards

Logfile:log file location, default value is stdout, using "standard output", the default background mode will be output to/dev/null

LogLevel notice, specifying the logging level, Redis supports a total of four levels: Debug,verbose,notice,warning, the default is notice

Debug: Record a lot of information for development and testing

Verbose: A lot of streamlined useful information, not as much as debug will record

Notice: Common verbose, often used in production environments

Warning: Only very important or critical information is recorded in the log

Third, set boot from start

Copy the startup script to the/ETC/INIT.D directory

# CP/USR/LOCAL/REDIS-3.0.7/UTILS/REDIS_INIT_SCRIPT/ETC/INIT.D/REDISD

Edit Startup script

# VIM/ETC/INIT.D/REDISD

#!/bin/SH# Chkconfig:2345  - Ten# Simple Redis INIT.D script conceived to work on Linux systems# as it does use of the/proc FileSystem. Redisport=6379EXEC=/usr/local/redis-3.0.7/src/redis-server#exec=/usr/local/bin/redis-servercliexec=/usr/local/redis-3.0.7/src/redis-Clipidfile=/var/run/redis_${redisport}.pidconf="/etc/redis/${redisport}.conf"

Two major changes were made,

One, added # chkconfig:2345 90 10

II. designation of the location of Redis-server and REDIS-CLI

Exec=/usr/local/redis-3.0.7/src/redis-server

Cliexec=/usr/local/redis-3.0.7/src/redis-cli

Attention:

PIDFILE=/VAR/RUN/REDIS_${REDISPORT}.PID Specifies the location of the PID file

Conf= "/etc/redis/${redisport}.conf" specifies the location of the configuration file

Creating a configuration file

# cd/etc/

# mkdir Redis

# cp/usr/local/redis-3.0.7/redis.conf Redis/6379.conf

Modifying a configuration file

Mainly setting up Redis to run in background process and PID file location

/var/run/redis_6379.pid

Start Redis in a service way

#/ETC/INIT.D/REDISD Start

Starting Redis Server ...

# Ps-ef |grep Redis

 root 29836  1  0  18 : 23 ? 00 : 00 :  XX /usr/local/redis-3.0 . 7 /src/redis-server *:root  4110  0  18 : 23  pts/0  00 : 00 : 00  grep --color=auto Redis 

Client Connection Test

# cd/usr/local/redis-3.0.7/src/

#./redis-cli

127.0. 0.1:6379123  hellook127.0. 0.1:6379123"hello"

The default connection to localhost 6379, viewing server information, is available via the info command.

Getting Started with 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.