Redis安装-CentOs7
确保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安装-CentOs7的更多相关文章
- Redis安装--CentOS7上安装Redis
echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 1.R ...
- CentOS7 服务器 JDK+TOMCAT+MYSQL+redis 安装日志
防火墙配置(参考 CentOS7安装iptables防火墙) 检查是否安装iptables #先检查是否安装了iptables service iptables status #安装iptables ...
- VMWare12安装CentOS7以及redis安装和常用命令
一.vmware安装centos7后没有网卡 VMWare 12版本不提供32位安装程序,只有64位安装程序,如果在安装CentOS时,选择的是CentOS而不是CentOS 64位,则会出现Cent ...
- vmware安装centos7 安装redis windows7访问redis
1.在windows7中安装vmware 2.在vmware中安装centos7 3.禁用centos7自带的firewalld.service 4.安装iptables防火墙 5.安装Redis 3 ...
- CentOS7— Redis安装(转和延续)
Part I. Redis安装(转载部分) 一.安装 wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.t ...
- CentOS7上Redis安装与配置
一.redis安装(注意:最好先安装一遍gcc->yum -y install gcc:如果系统本身缺少,make时候会出错,后期修改稍麻烦) 1.wget命令下载 wget http://do ...
- centos7.x下环境搭建(四)—redis安装
redis介绍 redis是用C语言开发的一个开源的高性能键值对(key-value)数据库.它通过提供多种键值数据类型来适应不同场景下的存储需求,目前为止redis支持的键值数据类型如下字符串.列表 ...
- centos7中redis安装
官网地址:http://redis.io/ 官网下载地址:http://redis.io/download 1. 下载Redis源码(tar.gz),并上传到Linux:或 wget http://d ...
- centos7中redis安装配置
1.官网下载对应版本,本例以5.0.5为例 2.tar -zxvf xxxxx 并mv到安装目录 3.进入redis-5.0.5目录下,执行编译命令 make 4.编译完成后,经redis安装到指定目 ...
随机推荐
- 5for Java
① 从字符串“耿丹计算机Java20170320”中提取日期 public class Xx1 { /** * @param args */ public static void main(Strin ...
- vue中表单的动态绑定
有一个表单: <el-form :model="configForm"> </el-form> 如果configForm初始化为{},此对象是动态变化的,如 ...
- ui-grid从后端获取数据后更改数据显示的格式
从后端获取的数据时是这样的: { "TotalCount":14,"Items": [ { "ProfileId":14, "Na ...
- 【bzoj3488】[ONTAK2010]Highways DFS序+树上倍增+树状数组
题目描述 一棵n个点的树,给定m条路径,q次询问包含一条路径的给定路径的个数+1 输入 The first line of input contains a single integer N(1< ...
- Intel QuickAssist Technology and OpenSSL – Benchmarks and Setup Tips
Intel QuickAssist Technology and OpenSSL – Benchmarks and Setup Tips 来源:https://www.servethehome.com ...
- MySQL触发器写法
触发器创建语法四要素:1.监视地点(table) 2.监视事件(insert/update/delete) 3.触发时间(after/before) 4.触发事件(insert/update/dele ...
- POJ2502:Subway(最短路)
Subway Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14634 Accepted: 4718 题目链接:http ...
- bzoj 4880 [Lydsy1705月赛]排名的战争 贪心
[Lydsy1705月赛]排名的战争 Time Limit: 8 Sec Memory Limit: 256 MBSubmit: 338 Solved: 69[Submit][Status][Di ...
- Ecplise添加XML自动提示
这里以struts.xml为例 第一步: 首先找到 struts2的核心jar包,我这里是struts2-core-2.3.20.jar用压缩工具打开或者解压下来
- jquery序列化表单
没有使用其他的东西 , 数据传送是最基本的. 前台: var info = $('#dataForm').serialize() ; alert(decodeURIComponent(info,tru ...