[One]linux under Redis installation

Source: Internet
Author: User
Tags redis version install redis redis server

I. What is Redis

Redis is a key-value storage system. Similar to memcached, it supports storing more value types, including string (string), list (linked list), set (set), and Zset (ordered collection)

More introduction will not copy, Direct crossing network Https://redis.io/topics/introduction

Two. Yum Install Redis

1. Pre-installation environment instructions, system based on Centos-6.7-x86_64-minimal.iso

2. Installing the Epel source

[Email protected] ~]# RPM-IVH http://mirrors.ustc.edu.cn/centos/6/extras/x86_64/Packages/epel-release-6-8.noarch.rpm

3. Installation of Redis, the current version is redis-2.4.10, relatively low

Yum Install -y Reids

4. Start Redis

[Email protected] ~]#/etc/init.d/redis startstarting redis-server:                                     [  OK  ]

Viewing the boot log

[Email protected] ~]#Cat/var/log/redis/Redis.log [1425] -Dec -: A: A* Server started, Redis version2.4.Ten[1425] -Dec -: A: A# 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. [1425] -Dec -: A: A* DB loaded from disk:0seconds[1425] -Dec -: A: A* The server is now a ready-to-accept connections on port6379

Fix error message

[Email protected] ~]#Echo "vm.overcommit_memory = 1">>/etc/sysctl.conf [[email protected]~]# Sysctl vm.overcommit_memory=1vm.overcommit_memory=1#重启服务 [[email protected]~]#/etc/init.d/Redis restartstopping Redis-server: [OK]starting Redis-server: [OK] #再次查看日志, no error has been made, the first log is not provided [[email protected]~]#Cat/var/log/redis/Redis.log [1425] -Dec -: $: -# Received SIGTERM, scheduling shutdown ... [1425] -Dec -: $: -# User requested shutdown ... [1425] -Dec -: $: -*Saving the final RDB snapshot before exiting. [1425] -Dec -: $: -*DB saved on disk[1425] -Dec -: $: -* Removing the PIDfile. [1425] -Dec -: $: -# Redis is now ready to exit, Bye bye ... [1446] -Dec -: $: -* Server started, Redis version2.4.Ten[1446] -Dec -: $: -* DB loaded from disk:0seconds[1446] -Dec -: $: -* The server is now a ready-to-accept connections on port6379

5.redis some basic configuration

[Email protected] ~]#grep-ve"^$|#"/etc/redis.confdaemonize Yes #以deamon形式运行在后台pidfile/var/run/redis/Redis.pidport6379#监听端口bind127.0.0.1#绑定地址timeout0loglevel Noticelogfile/var/log/redis/Redis.log #redis日志databases -#创建的数据库数据save the 1Save - TenSave - 10000rdbcompression yesdbfilename Dump.rdb #数据文件名dir/var/lib/redis/#数据目录

6. Client Connection Data test

[Email protected] ~]# redis-127.0. 0.1:6379>127.0. 0.1:6379> get name"Jack"127.0 . 0.1:6379> Exit

Three. SOURCE Installation Redis

0. Uninstall the previous Yum installed package

[Email protected] ~]#/etc/init.d/redis stopstopping redis-server:                                     [  OK  Yum Remove-y Redis

1. Download source package, version Select Access Http://download.redis.io/releases

[Email protected] ~]# cd/usr/local/wget http://download.redis.io/releases/ Redis-3.2.4.tar.gz

2. Installing Redis

# Detailed installation content can refer to Readme[[email protected] src]# CD/usr/local/src/[email protected] src]#TarZXVF redis-3.2.4.Tar. Gz[[email protected] src]# CD Redis-3.2.4[[email protected] Redis-3.2.4]# Morereadme.md
#minimal系统缺少组件gcc
[email protected] ~]# Yum install-y gcc
#安装到自定义路径, easy to uninstall [[email protected] Redis-3.2.4]# MakePrefix=/usr/local/redisInstall#有个报错无法还原了, about selecting a non.-default memory allocator when building Redis is Doneby setting the ' malloc ' environment variable# need to add make MALLOC when make=libc

#拷贝配置文件
[Email protected] redis-3.2.4]# Mkdir/etc/redis
[email protected] redis-3.2.4]# CP redis.conf/etc/redis/6379.conf
[Email protected] redis-3.2.4]# vim/etc/redis/6379.conf
Daemonize Yes #no改成yes
LogFile "/var/log/redis_6379.log" #日志文件
Dir/var/lib/redis #数据目录
Requirepass Mima #开启密码认证

#服务启动脚本
[Email protected] redis-3.2.4]# Cp/usr/local/src/redis-3.2.4/utils/redis_init_script/etc/init.d/redis
[Email protected] redis-3.2.4]# chmod +x/etc/init.d/redis
[Email protected] redis-3.2.4]# Vim/etc/init.d/redis
7 Exec=/usr/local/redis/bin/redis-server
8 CLIEXEC=/USR/LOCAL/REDIS/BIN/REDIS-CLI
$CLIEXEC-P $REDISPORT-a mima shutdown

3. Start the service and fix the error

[Email protected] ~]#/etc/init.d/redis Start[[email protected]~]#Cat/var/log/Redis_6379.log1613: M -Dec -: -:47.132* Increased maximum number of open files to10032(It is originally set to1024x768). _._                                                             _.-``__"'-._                                                   _.-``    `. `_."'-._ Redis3.2.4(00000000/0) -bit.-`` .-```. ```\/    _.,_"'-._                                    (    '      ,       .-`  | `,    ) Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'| Port:6379| `-._   `._    /     _.-'    | pid:1613`-._    `-._  `-./  _.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'| | `-._`-._        _.-'_.-'| http//Redis.io`-._    `-._`-.__.-'_.-'_.-'|`-._`-._    `-.__.-'    _.-'_.-'| | `-._`-._        _.-'_.-'|                                    `-._    `-._`-.__.-'_.-'_.-'`-._    `-.__.-'    _.-'                                                 `-._        _.-'`-.__.-'                                               1613: M -Dec -: -:47.134# warning:the TCP Backlog setting of511Cannot be enforced because/proc/sys/net/core/somaxconn are set to the lower value of -.1613: M -Dec -: -:47.134# Server started, Redis version3.2.41613: M -Dec -: -:47.134# 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.1613: M -Dec -: -:47.134* DB loaded from disk:0.000seconds1613: M -Dec -: -:47.134* The server is now a ready-to-accept connections on port6379

#修复报错, the Yum installation method has fixed a to fix this issue add ' vm.overcommit_memory = 1 ' to/etc/sysctl.conf
[Email protected] ~]# echo >/proc/sys/net/core/somaxconn
[Email protected] ~]# echo never >/sys/kernel/mm/transparent_hugepage/enabled
[Email protected] ~]# echo "echo >/proc/sys/net/core/somaxconn" >>/etc/rc.local
[Email protected] ~]# echo "echo never >/sys/kernel/mm/transparent_hugepage/enabled" >>/etc/rc.local

4. Restart Redis Test Read/write

[Email protected] ~]#/etc/init.d/Redis restartplease use Start or stop as first argument[[email protected]~]#/etc/init.d/Redis stopstopping ... Redis Stopped[[email protected]~]#/etc/init.d/redis startstarting Redis server ...
#读写测试 [[Email protected]~]#/usr/local/redis/bin/redis-CLI127.0.0.1:6379>Auth MIMAOK127.0.0.1:6379> Keys *(empty list or set)127.0.0.1:6379>Set name Jackok127.0.0.1:6379>Get name"Jack"127.0.0.1:6379> Exit

[One]linux under Redis 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.