官方地址

确保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. 剑指offer:从头到尾打印链表

    目录 题目 解题思路 具体代码 题目 题目链接 剑指offer:从头到尾打印链表 题目描述 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList. 解题思路 首先题目实际给出的要求是返回ve ...

  2. android命令模式IntentService 远程下载文件

    服务可用在一下情景: 1,用户离开activity后,仍需要继续工作,例如从网络下载文件,播放音乐. 2,无论activity出现或离开,都需要持续工作,例如网络聊天应用. 3,连接网络服务,正在使用 ...

  3. mysqli DB封装

    <?php class DB { //私有的属性 private static $dbcon = false; private $host; private $port; private $us ...

  4. elmentUI组件怎么绑定原生事件

    el-input为例: <el-input id="user-input" type="textarea" placeholder="请换行输入 ...

  5. Qt5.6关联VS2013,配置VAssistX

    1. 安装Qt qt-creator-opensource-windows-x86-4.2.0.exe 2. 安装Qt VS插件 qt-vs-addin-1.2.5.exe 3. 配置ASSISTX ...

  6. JSP九大内置对象及其方法

    内置对象包括 request response pageContext session application out config page exception 1.out (1)clear()清除 ...

  7. AGC016B Colorful Hats(构造)

    题目大意: 给定n和n个数,每个数a[i]代表除了i外序列中颜色不同的数的个数,问能否构造出来这个数列. 比较简单,首先先求出来a数列的最大值Max, 如果有数小于Max-1,那么显然是不存在的 接下 ...

  8. JAVA 异常处理的认知学习过程

    没有异常处理 学生时代,我编写的java代码中,很少会有try catch.最主要的原因如下: 应用的规模很小 没有不确定因素 代码可控性高 如果规模小,往往就没有复杂的逻辑链路,整个软件的分层也很浅 ...

  9. JS格式化 /Date(xxxxxx)/的日期类型

    //用来转换/Date(xxxxxx)/类型的JSON日期为要求的日期格式字符串String.prototype._formatJsonDate = function (format) { var s ...

  10. WPS是个坑

    WPS2016 10.1.0.5740 存储的EXCEL表格文件,用PHP mime_content_type函数获取到的mime类型是“application/zip”