本地Redis服务配置
本地Redis服务配置
要求:在虚拟机中启动redis服务,并要在windows物理机上取得链接
- 虚拟机安装略,(结果如下)
windows工作机上装了Oracle VM VirtualBox,并在其中装好了linux系统,
linux系统版本如下:
# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
# ip addr 【查看虚拟机ip,其中(10.10.12.18)为本虚拟机ip】
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:a8:1c:bd brd ff:ff:ff:ff:ff:ff
inet 10.10.12.18/24 brd 10.10.12.255 scope global dynamic enp0s3
valid_lft 77192sec preferred_lft 77192sec
inet6 fe80::a00:27ff:fea8:1cbd/64 scope link
valid_lft forever preferred_lft forever
windows中ping测试成功
C:\Users\hdb>ping 10.10.12.18
正在 Ping 10.10.12.18 具有 32 字节的数据:
来自 10.10.12.18 的回复: 字节=32 时间<1ms TTL=64
来自 10.10.12.18 的回复: 字节=32 时间<1ms TTL=64
来自 10.10.12.18 的回复: 字节=32 时间<1ms TTL=64
来自 10.10.12.18 的回复: 字节=32 时间=1ms TTL=64
10.10.12.18 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 1ms,平均 = 0ms
- redis安装与启动
步骤和官网一致:
安装
$ wget http://download.redis.io/releases/redis-4.0.9.tar.gz
$ tar xzf redis-4.0.9.tar.gz
$ cd redis-4.0.9
$ make
启动
$ src/redis-server
接下来问题来了,redis启动后,可以在linux中进行增删改查,但是外部windows无法取得链接
测试代码如下
public static void main(String[] args) {
@SuppressWarnings("resource")
Jedis jedis = new Jedis("10.10.12.18", 6379);
System.out.println(jedis.ping());
}
日志如下
/*
DENIED Redis is running in protected mode because protected mode is enabled,
no bind address was specified, no authentication password is requested to clients.
In this mode connections are only accepted from the loopback interface.
If you want to connect from external computers to Redis you may adopt one of the following solutions:
1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to
Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so.
Use CONFIG REWRITE to make this change permanent.
2) Alternatively you can just disable the protected mode by editing the Redis configuration file,
and setting the protected mode option to 'no', and then restarting the server.
3) If you started the server manually just for testing, restart it with the '--protected-mode no' option.
4) Setup a bind address or an authentication password.
NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
*/
解决办法:
- 在redis.conf文件中 ,注释掉:bind 127.0.0.1
- 在redis.conf文件中 ,把 protected-mode = yes 更改为 protected-mode = no
重启redis后,java测试代码运行成功($ src/redis-server redis.conf , 该命令可以确保更新的配置参数可以立即生效);
补充:redis默认端口6379 , 要保证linux对外开放了该端口,外部才能访问。我的虚拟机刚好默认关闭了防火墙,所以上面操作没有涉及开关防火墙或者开放指定端口的记录。
本地Redis服务配置的更多相关文章
- 在linux安装redis单机和集群后,如何在windows上使用redis客户端或者java代码访问错误的原因很简单,就是没有连接上redis服务,由于redis采用的安全策略,默认会只准许本地访问。需要通过简单配置,完成允许外网访问。
这几天在学习在linux上搭建服务器的工作,可谓历经艰辛.可喜最后收获也不少. 这次是在linux上搭建redis服务器后从windows上缺无法访问,连接不上. 仔细回忆以前搭建nginx和ftp的 ...
- Window环境下配置Redis服务的方法及查看缓存数据的工具介绍
工具下载位置:http://pan.baidu.com/s/1hqVh1f2,包括服务端配置以及查看缓存的工具. 服务端是以服务的形式运行,将Redis服务端解压到某个目录,然后执行cmd执行命令: ...
- Ubuntu 17.10 用 apt 搭建 lamp 环境、安装 phpmyadmin、redis 服务+扩展、mysql 扩展、开启错误提示、配置虚拟主机
2018-02-24 13:50:30 更新: 个人喜欢相对原生又不太麻烦,所以用 apt 构建环境.不过,最近使用到现在记得出现过了 3 次 apache 或 mysql 服务器无法启动或无法连接的 ...
- 阿里云服务上面部署redis + 本地Redis客户端连接方法
本文结合自己在阿里云服务器上面搭建redis服务器,在本地redis的客户端Redis Desktop Manager连接成功的操作,将操作中的一些方法做了一些归纳和总结,希望可以帮到有需要的同学. ...
- 阿里云服务器ecs配置之安装redis服务
一.介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多,包括st ...
- windows 本地链接 VMware虚拟机 redis服务
使用本地Windows链接 VMware虚拟机 redis服务 我用的虚拟机系统是:windows Server 2012 先把Redis服务器拷贝到服务器并解压,目录如下 这里仅仅作为演示,所以就不 ...
- 【转载】Windows安装Redis并添加本地自启动服务
概况 在windows本地搭建redis缓存,添加到本地计算机的服务中,保证每次开机自动启动服务. 第一步:下载redis(我的是计算机win10,64位) https://github.com/Mi ...
- redis服务及其配置与应用(window 环境下)
一.redis简介:Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API(源自百度百科),个人更喜欢下面的解释:我们 ...
- Windows安装Redis并添加本地自启动服务
概况 在windows本地搭建redis缓存,添加到本地计算机的服务中,保证每次开机自动启动服务. 第一步:下载redis(我的是计算机win10,64位) https://github.com/Mi ...
随机推荐
- 中山普及Day17——普及
今天换教室,本来教室多好嘛,易守难攻,结果...今天今天仅下午就被熊抄了2次,熊超真TMD不是人呐,走路连脚步声都没有. 然后,播报分数: 爆0了!!!
- Java知识总结:Java反射机制(用实例理解)
概念理解: 反射是指一类应用,它们能够自描述和自控制.也就是说,这类应用通过采用某种机制来 实现对自己行为的描述( self-representation )和检测( examination) ,并能 ...
- java比较器Comparator
1. 实现比较类 public class Comparator implements java.util.Comparator<TaskInfo>{ @Override public i ...
- c#数据四种执行方法(ExecuteNonQuery)-----转载
c#数据四种执行方法(ExecuteNonQuery) 1.使用ExecuteReader()操作数据库 2.使用ExecuteNonQuery()操作数据库 3.使用ExecuteScalar( ...
- Day2-E-Catch That Cow-POJ3278
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. ...
- Redis字符串类型
字符串是Redis中最基本的数据类型,他能存储任何形式的字符串,包括二进制数据. 命令 赋值 SET key value > SET key hello OK 取值 GET key > G ...
- pyhon 内置函数
chr() asci码 dir() 目录,显示目录. divmod(10,3) 返回商和余数 例如 (3, 1) 返回的为一个元组 可以用于分页 enumerate() ...
- ROS 命令行工具的使用
1.roscore 打开一个新的master(master:进程),只能运行一个,运行两个会报错,使用ROS第一步就是要打开roscore 2.rosrun rosrun的使用格式一般为:rosrun ...
- Ubuntu 18.04 安装ROS 配置环境 没有那个文件或目录的解决办法
Ubuntu 18.04版本,在安装ROS时运行 source ~/.bashrc 命令时出现没有那个文件夹或目录 或 No such file or directory的错误 在经过一番查询后发现 ...
- 设备树DTS 学习:Linux DTS文件加载过程
背景 了解机制有利于对内核有更深的认识. wget https://mirrors.aliyun.com/linux-kernel/v3.x/linux-3.2.61.tar.xz 内核 在drive ...