官方地址

确保gcc已经安装

$ yum list installed | grep gcc
$ yum install gcc

下载、提取和编辑Redis:

$ wget http://download.redis.io/releases/redis-4.0.8.tar.gz
$ tar xzf redis-4.0..tar.gz
$ cd redis-4.0.
$ make MALLOC=libc
$ make test

运行Redis并放置到后台运行:

[root@localhost redis-4.0.]# src/redis-server

:C  Mar ::51.874 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Mar ::51.874 # Redis version=4.0., bits=, commit=, modified=, pid=, just started
:C Mar ::51.874 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
:M Mar ::51.875 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 6454
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Mar ::51.877 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Mar ::51.877 # Server initialized
:M Mar ::51.877 # WARNING overcommit_memory is set to ! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
:M Mar ::51.877 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will 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.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
:M Mar ::51.877 * Ready to accept connections
^Z #Ctrl + Z
[]+ Stopped src/redis-server
[root@localhost redis-4.0.]# bg %
[]+ src/redis-server &
[root@localhost redis-4.0.]# jobs
[]+ Running src/redis-server &

使用内置客户端与Redis交互:

[root@localhost redis-4.0.]# src/redis-cli
127.0.0.1:> set foo bar
OK
127.0.0.1:> get foo
"bar"
127.0.0.1:>

为了使Java代码能够连接到Redis服务器需要设置Redis密码和bind:

编辑redis.conf文件:

[root@localhost redis-4.0.]# find / -name redis.conf               #查找redis.conf文件
/opt/redis-4.0./redis.conf
[root@localhost redis-4.0.]# vi redis.conf #编辑redis.conf文件
......
################################## SECURITY ################################### # Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
requirepass 123456 #设置密码
......
################################## NETWORK ##################################### # By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1 #注释后redis会监听所有网络接口的连接请求

redis常用命令:

[root@localhost redis-4.0.]# src/redis-server redis.conf &            #后台运行redis server

[root@localhost redis-4.0.]# src/redis-cli                            #运行redis命令行接口
127.0.0.1:> auth 123456 #认证
OK
127.0.0.1:> keys * #列举
) "foo"
) "a"
) "age"
) "aaa"
127.0.0.1:> set qqq 12345
OK
127.0.0.1:> get qqq
""
127.0.0.1:> del qqq
(integer) 127.0.0.1:> keys *
) "aaa"
) "foo"
) "age"
) "a"
127.0.0.1:> shutdown #关闭redis服务端
:M Mar ::07.286 # User requested shutdown...
:M Mar ::07.286 * Saving the final RDB snapshot before exiting.
:M Mar ::07.291 * DB saved on disk
:M Mar ::07.291 * Removing the pid file.
:M Mar ::07.291 # Redis is now ready to exit, bye bye...
not connected>

关联文档:

Redis-4.0.8 readme.md

Redis安装-CentOs7的更多相关文章

  1. Redis安装--CentOS7上安装Redis

    echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 1.R ...

  2. CentOS7 服务器 JDK+TOMCAT+MYSQL+redis 安装日志

    防火墙配置(参考 CentOS7安装iptables防火墙) 检查是否安装iptables #先检查是否安装了iptables service iptables status #安装iptables ...

  3. VMWare12安装CentOS7以及redis安装和常用命令

    一.vmware安装centos7后没有网卡 VMWare 12版本不提供32位安装程序,只有64位安装程序,如果在安装CentOS时,选择的是CentOS而不是CentOS 64位,则会出现Cent ...

  4. vmware安装centos7 安装redis windows7访问redis

    1.在windows7中安装vmware 2.在vmware中安装centos7 3.禁用centos7自带的firewalld.service 4.安装iptables防火墙 5.安装Redis 3 ...

  5. CentOS7— Redis安装(转和延续)

    Part I. Redis安装(转载部分) 一.安装 wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.t ...

  6. CentOS7上Redis安装与配置

    一.redis安装(注意:最好先安装一遍gcc->yum -y install gcc:如果系统本身缺少,make时候会出错,后期修改稍麻烦) 1.wget命令下载 wget http://do ...

  7. centos7.x下环境搭建(四)—redis安装

    redis介绍 redis是用C语言开发的一个开源的高性能键值对(key-value)数据库.它通过提供多种键值数据类型来适应不同场景下的存储需求,目前为止redis支持的键值数据类型如下字符串.列表 ...

  8. centos7中redis安装

    官网地址:http://redis.io/ 官网下载地址:http://redis.io/download 1. 下载Redis源码(tar.gz),并上传到Linux:或 wget http://d ...

  9. centos7中redis安装配置

    1.官网下载对应版本,本例以5.0.5为例 2.tar -zxvf xxxxx 并mv到安装目录 3.进入redis-5.0.5目录下,执行编译命令 make 4.编译完成后,经redis安装到指定目 ...

随机推荐

  1. 最快的Hash表算法

    我们由一个简单的问题逐步入手:有一个庞大的字符串数组,然后给你一个单独的字符串,让你从这个数组中查找是否有这个字符串并找到它,你会怎么做?有一个方法最简单,老老实实从头查到尾,一个一个比较,直到找到为 ...

  2. PAT 1055 集体照

    https://pintia.cn/problem-sets/994805260223102976/problems/994805272021680128 拍集体照时队形很重要,这里对给定的 N 个人 ...

  3. calendar components

    calendar components 日历 angular, react, vue ??? react https://github.com/intljusticemission/react-big ...

  4. jquery/js iframe 元素操作

    1.判断id/ class 是否存在? <script> $(function(){ if(("#id_name").length()>0){ //如果id 存在 ...

  5. null?对象?异常?到底应该如何返回错误信息

    这篇文章记录我的一些思考.在工作了一段时间之后. 问题的核心很简单:到底如何返回错误信息. 学生时代,见到过当时的老师的代码: if (foo() == null) { } 当然,这位老师是一位比较擅 ...

  6. 遇到问题---java---myeclipse中maven项目引用另一个导致的resource文件混乱的问题

    遇到情况 情况是这样的,我们在构建项目时,经常会把一些公用的类和配置提取出去,作为一个公共项目.然后把公共项目作为一个jar包构件引入我们当前的项目中. 引入方式是 <dependency> ...

  7. codeforces 1015C

    C. Songs Compression time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Optimize Prime Sieve

    /// A heavily optimized sieve #include <cstdio> #include <cstring> #include <algorith ...

  9. idea xml 绿背景色 去掉拼写检查

    去掉背景色 去掉拼写检查

  10. SpringMVC——说说视图解析器

    学习SpringMVC——说说视图解析器   各位前排的,后排的,都不要走,咱趁热打铁,就这一股劲我们今天来说说spring mvc的视图解析器(不要抢,都有位子~~~) 相信大家在昨天那篇如何获取请 ...