溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Redis On Windows安裝記錄

發(fā)布時(shí)間:2020-08-07 23:12:25 來(lái)源:ITPUB博客 閱讀:172 作者:realkid4 欄目:關(guān)系型數(shù)據(jù)庫(kù)

Redis 是目前比較流行的內(nèi)存非關(guān)系型數(shù)據(jù)庫(kù)解決方案,依托高性能、復(fù)制特性和面向問(wèn)題的數(shù)據(jù)結(jié)構(gòu),越來(lái)越多被作為系統(tǒng)核心組件采納應(yīng)用。大部分應(yīng)用環(huán)境, Redis 是基于 Linux 體系環(huán)境的,但是也提供了 Windows 環(huán)境安裝方案。

 

本篇主要介紹安裝 Redis On Windows 方法,提供給需要的朋友待查。

 

1、   環(huán)境和介質(zhì)

 

首先,我們從 Redis 官網(wǎng) https://redis.io/ 上,是不能找到 Windows 版本的 Redis 介質(zhì)的。但是,在 GitHub 上,能找到對(duì)應(yīng)的舊版 Redis On Windows 介質(zhì),網(wǎng)址: ttps://github.com/MSOpenTech/redis/releases

 

筆者下載的是 64 3.2 版本,介質(zhì)名稱: Redis-x64-3.2.100.zip 。注意:和其他軟件一樣, Redis 也提供了安裝 exe/mis 版本和 zip 解壓縮版。對(duì)于用戶而言, exe 版本安裝比較簡(jiǎn)單,本篇集中在 zip 版本介紹上。

 

2、   安裝配置

 

解壓 zip 文件,到指定的安裝目錄上。

 

-- 放在對(duì)應(yīng)目錄上

C:\>cd redis

 

C:\Redis>dir

  驅(qū)動(dòng)器 C 中的卷沒(méi)有標(biāo)簽。

  卷的序列號(hào)是 360A-018F

 

 C:\Redis 的目錄

 

2018/07/16  22:03    <DIR>          .

2018/07/16  22:03    <DIR>          ..

2016/07/01  16:27             1,024 EventLog.dll

2016/07/01  16:07            12,509 Redis on Windows Release Notes.docx

2016/07/01  16:07            16,727 Redis on Windows.docx

(篇幅原因,有省略 ……

2016/07/01  16:07            48,212 redis.windows-service.conf

2016/07/01  16:07            48,201 redis.windows.conf

2016/07/01  09:17            14,265 Windows Service Documentation.docx

              14 個(gè)文件      22,470,282 字節(jié)

               2 個(gè)目錄 30,208,651,264 可用字節(jié)

 

 

默認(rèn)情況下的運(yùn)行參數(shù),是需要我們進(jìn)行簡(jiǎn)單調(diào)整的。注意:如果是投產(chǎn)環(huán)境,就需要仔細(xì)斟酌。

 

主要調(diào)整文件是 redis.windows.conf ,其中以 key-value 方式進(jìn)行數(shù)據(jù)組織。我們調(diào)整兩個(gè)參數(shù),一個(gè)是內(nèi)存使用大小,另一個(gè)是驗(yàn)證模式。

 

 

# maxmemory <bytes>

maxmemory 1073741824

 

# requirepass foobared

requirepass test

 

 

3 、啟動(dòng)和測(cè)試實(shí)驗(yàn)

 

如果需要,可以在環(huán)境配置文件 PATH 中增加 Redis 目錄。通過(guò) command 命令行,執(zhí)行啟動(dòng)服務(wù)器命令。

 

 

C:\Users\51ibm>redis-server.exe redis.windows.conf

Invalid argument during startup: Failed to open the .conf file: redis.windows.conf CWD=C:\Users\51ibm

 

 

需要切換到安裝目錄進(jìn)行執(zhí)行,否則不能找到對(duì)應(yīng)配置文件。

 

 

C:\Users\51ibm>cd c:/redis

c:\Redis>redis-server.exe redis.windows.conf

                _._

           _.-``__ ''-._

      _.-``    `.  `_.  ''-._           Redis 3.2.100 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 9392

 

[9392] 16 Jul 22:17:26.870 # Server started, Redis version 3.2.100

[9392] 16 Jul 22:17:26.871 * The server is now ready to accept connections on port 6379

 

 

服務(wù)器啟動(dòng)后,在特定端口(默認(rèn)端口 6379 )等待連接。 Redis 提供了標(biāo)準(zhǔn)命令行訪問(wèn)工具 redis-cli.exe ,用來(lái)進(jìn)行訪問(wèn)。

 

 

C:\Users\51ibm>redis-cli.exe

127.0.0.1:6379> info

NOAUTH Authentication required.

127.0.0.1:6379> auth test

OK

127.0.0.1:6379> info

 

# Memory

used_memory:690096

maxmemory:1073741824

(篇幅原因,有省略 ……

 

 

Windows 環(huán)境上,如果關(guān)閉后臺(tái)的命令窗口,服務(wù)器自動(dòng)關(guān)閉。

 

 

[9392] 16 Jul 22:19:52.594 # User requested shutdown...

[9392] 16 Jul 22:19:52.594 * Saving the final RDB snapshot before exiting.

[9392] 16 Jul 22:19:52.680 * DB saved on disk

[9392] 16 Jul 22:19:52.680 # Redis is now ready to exit, bye bye...

 

 

4 、安裝啟動(dòng)服務(wù)

 

Windows 上,類似服務(wù)最好以操作系統(tǒng)服務(wù) Service 的方式進(jìn)行管理。可以通過(guò)專門命令行進(jìn)行配置。

 

 

c:\Redis>redis-server --service-install redis.windows.conf --loglevel verbose

[9236] 16 Jul 22:22:54.376 # Granting read/write access to 'NT AUTHORITY\NetworkService' on: "c:\Red

is" "c:\Redis\"

[9236] 16 Jul 22:22:54.377 # Redis successfully installed as a service.

 

c:\Redis>

 

 

啟動(dòng)服務(wù)后,系統(tǒng)可以正常訪問(wèn)。

 

 

127.0.0.1:6379> auth test

OK

127.0.0.1:6379> set name Tom

OK

127.0.0.1:6379> get name

"Tom"

127.0.0.1:6379>

 

 

 

 


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI