redis-windows

redis系列——windows下redis设置及安装windows服务

0.088 字数 1,018 阅读 1,169
redis-white-201918141258

前言

Redis是一个开源(BSD许可),内存数据结构存储,用作数据库,缓存和消息代理。 它支持数据结构,如字符串,散列,列表,集合,带有范围查询的排序集,位图,超级日志,带有半径查询和流的地理空间索引。 Redis具有内置复制,Lua脚本,LRU驱逐,事务和不同级别的磁盘持久性,并通过Redis Sentinel提供高可用性并使用Redis Cluster自动分区。本文简单记录一下windows下redis设置及安装成windows服务。

介绍

  • REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。

  • 百度百科:Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。 它通常被称为数据结构服务器,因为值(value)可以是 字符串(String), 哈希(Map), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型。

  • 官网介绍: Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. Google 翻译:Redis是一个开源(BSD许可),内存数据结构存储,用作数据库,缓存和消息代理。 它支持数据结构,如字符串,散列,列表,集合,带有范围查询的排序集,位图,超级日志,带有半径查询和流的地理空间索引。 Redis具有内置复制,Lua脚本,LRU驱逐,事务和不同级别的磁盘持久性,并通过Redis Sentinel提供高可用性并使用Redis Cluster自动分区。

准备

下载windows版的redis(解压版),下载地址:https://github.com/ServiceStack/redis-windows/tree/master/downloads

下载Redis可视化工具 Redis Desktop Manager,

下载地址:https://redisdesktop.com/download
百度网盘:链接:https://pan.baidu.com/s/1vcRywB4JTA2xPCUvh0n1DA 提取码:y1vv

安装步骤

解压redis-64.3.0.503.zip;cmd命令进入该目录

文件作用
redis-server启动redis
redis-cliredis命令行工具
redis-benchmark基准测试工具
redis-check-aofAOF持久化文件检测工具和修复工具
redis-check-dumpRDB持久化文件检测工具和修复工具
redis-sentinel启动redis-sentinel
在解压后的文件夹里面,按住 shift,然后鼠标右键点击空白区域,选择【在此处打开命令窗口】,快捷打开cmd窗口和当前目录。

启动:

带配置文件启动redis:

redis.windows.conf 这个文件是redis的配置文件,使用以下命令启动:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-server.exe redis-windows.conf

</pre>

不带配置文件启动:

双击 redis-server.exe;或者使用以下命令启动:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-server.exe

</pre>

出现如下图时,启动成功。

redis-windows-install-1-2019110133458

登录redis

启动redis服务后,需要登录redis来进行操作,这个时候需要按照上面步骤重新打开一个命令窗口,使用 redis-cli命令进行登录,命令如下

  • -h 服务器/主机地址,本地就是 127.0.0.1
  • -p 端口号,默认应该是6379
  • -a 密码

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-cli.exe -h 127.0.0.1 -a lucifer

</pre>

登录成功后,如下图示:
redis-windows-install-登录成功-2-2019110163813

重置密码

打开redis.conf配置文件,我下载的版本配置文件名是 redis-windows.conf,找到# requirepass foobared,去掉注释,井号代表注释,然后修改如下即可:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. requirepass 你的密码 #我设置的是lucifer

</pre>

安装成windows服务

自己本地练习的时候呢,每一次都要打开目录,然后输入命令来启动服务,再打开另外一个窗口进行操作,确实是不方便,接下来将redis服务安装成windows服务。 命令窗口执行以下命令:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-server --service-install redis.windows.conf

</pre>

常用命令

  1. 启动命令:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-server --service-start

</pre>

  1. 停止命令:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-server --service-stop

</pre>

  1. 卸载命令:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto !important; font-family: Consolas, Menlo, Courier, monospace; font-size: 10px; background: rgb(29, 31, 33); border: 1px solid rgb(136, 136, 136); padding: 2px; color: rgb(80, 97, 109); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; line-height: 12px;">

  1. redis-server --service-uninstall

</pre>

Redis可视化工具RedisDesktopManager

使用黑窗口操作虽然看起来足够炫酷,但是终究还是不那么方便,因此,需要使用到RDM工具,这块比较简单了就。安装,一路next。
redis-windows-install-安装RDM-3-2019110165151

填入连接名,随便填,你认识就行;服务器地址、端口号、密码,点测试连接;
redis-windows-install-测试连接-4-2019110165446

可以缓存到内容
redis-windows-install-连接成功-5-201911018212
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值