Redis Installation and basic configuration (RPM)

Source: Internet
Author: User
Tags redis server

First, download and install

wget http://download.redis.io/releases/redis-3.0.0.tar.gztar -zxvf redis-3.0.0.tar.gz -c /usr/local/cd /usr/local/redis-3.0.0makemake install
    • 1
    • 2
    • 3
    • 4
    • 5

second, system parameter adjustment

vi/etc/sysctl.confvm.overcommit_memory = 1//Allow allocation of all physical memory Net.ipv4.tcp _max_syn_backlog = 2048//Incomplete TCP three-time handshake queue Length Net.core.somaxconn = 1024/sbin/sysctl–p//modify open File parameter vi/etc/security /limits.conf* soft nofile 65535* hard nofile 65535              
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

three, Redis persistence mode
1. RDB:
Save the data set at a point in time, losing data from the last snapshot when the server fails

900 1      //900s内,如果有1个key发生变化,就进行一个快照save 300 10save 60 10000
    • 1
    • 2
    • 3

2, AOF:
Set different Fsync policies (no, everysec, always) to maximize data security

appendonly no/yes    //关闭或开启appendfsync everysec  //每秒钟写一次aof文件 
    • 1
    • 2

four, Redis master-slave replication configuration

yestcp-backlog 1024logfile "./redis.log"dir ./save ""appendonly yesappendfsync everysecmasterauth "myredis"requirepass "myredis"
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
vi redis-slave.confdaemonize yestcp-backlog 1024logfile "/redis.log "dir./save " appendonly yesappendfsync everysecmasterauth  "Myredis" Requirepass Span class= "hljs-string" > "Myredis" slaveof 10.118.242.35 6379 
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

V. Start Redis

Redis-server --helpredis-server Redis.conf //default port number 6379, you can use the--port parameter to specify Redis-server redis-slave.conf --port 6378redis-cli -a myredis -p 6378~:6378>set key Valueredis-cli -a myredis -p 6378 shutdown            
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

Six, redis.conf main configuration parameters

daemonize: Whether to run Pidfile:pid file location after daemon mode port: Port number to listen timeout: Request time-out Loglevel: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 compressed dbfilename: Data Snapshot file name (just file name, excluding directory)  Dir: The data snapshot of the Save directory (this is the directory) AppendOnly: whether to open appendonlylog, each write operation will remember a log, which will improve the data anti-risk ability, but affect efficiency. Appendfsync:appendonlylog How to sync to disk (three options, each of which is forced to call Fsync each write, enable Fsync per second, do not call Fsync wait for the system to synchronize itself)    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

Vii. Redis Startup scripts

Vim/etc/init.d/redis#!/bin/bash## Init file for Redis## Chkconfig:-80 12# Description:redis Daemon## Processname:redis# config:/etc/redis.conf# Pidfile:/var/run/redis.pidSource/etc/init.d/functions#BIN = "/usr/local/bin" bin="/usr/local/bin" config="/etc/redis.conf" pidfile="/var/run/redis.pid"# # Read Configuration [-R"$SYSCONFIG "] &&Source"$SYSCONFIG "retval=0 prog="Redis-server" desc="Redis Server"Start () {if [-E$PIDFILE];ThenEcho"$desc already running .... "Exit1FiEcho-n $"Starting$desc: "Daemon$BIN/$prog$CONFIG retval=$?echo [$RETVAL-eq0] && touch/var/lock/subsys/$progReturn$RETVAL}Stop () {Echo-n $The Stop$desc: "Killproc$prog retval=$?echo [$RETVAL-eq0] && RM-f/var/lock/subsys/$prog$PIDFILEReturn$RETVAL}Restart () {Stop Start}case  "$1" in start) start; stop) stop;; restart) restart;; Condrestart) [-e/var/lock/subsys/ $prog] && Restart retval=$?;; Status) status  $prog retval=$?;; *) echo $" Usage: $0 {start|stop|restart|condrestart|status} "RETVAL=1 esac exit $ Retval# chmod 755/etc/init.d/redis # chkconfig--add Redis Span class= "hljs-comment" ># chkconfig--level 345 redis on # chkconfig--list redis  span>                
http://blog.csdn.net/jason5186/article/details/48269089

Redis Installation and basic configuration (RPM)

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.