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-cli redis命令行工具
redis-benchmark 基準測試工具
redis-check-aof AOF持久化文件檢測工具和修復工具
redis-check-dump RDB持久化文件檢測工具和修復工具
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章