摘要:原文地址下載安裝版是上的一個(gè)開(kāi)源項(xiàng)目我們可以直接下載解壓使用。通過(guò)快捷方式啟動(dòng)服務(wù)修改的默認(rèn)配置設(shè)置的最大占用內(nèi)存設(shè)置最大占用內(nèi)存,打開(kāi)配置文件,找到如下段落,設(shè)置參數(shù),是字節(jié)類(lèi)型,注意轉(zhuǎn)換。是近期最少使用算法。
原文地址
下載安裝Redis--Window版是GitHub上的一個(gè)開(kāi)源項(xiàng)目我們可以直接下載解壓使用。
Download Now
在D盤(pán)下新建Redis文件(這個(gè)路徑可以自定義),將Redis解壓至該文件
安裝完后 打開(kāi) win控制臺(tái) cd 進(jìn)入 Redis 目錄
運(yùn)行:redis-server.exe redis.windows.conf
如果出現(xiàn)以下信息則說(shuō)明安裝成功。
配置之前先關(guān)掉Redis服務(wù)
添加啟動(dòng)Redis的快捷方式為redis-server.exe創(chuàng)建快捷方式redis(名字 自定義)
修改redis的屬性,為redis的目標(biāo)屬性,加入并指定讀取的配置文件redis.windows.conf,前面要加空格。
通過(guò)快捷方式redis啟動(dòng)Redis服務(wù)
修改Redis的默認(rèn)配置 設(shè)置Redis的最大占用內(nèi)存Redis設(shè)置最大占用內(nèi)存,打開(kāi)redis配置文件,找到如下段落,設(shè)置maxmemory參數(shù),maxmemory是bytes字節(jié)類(lèi)型,注意轉(zhuǎn)換。修改如下所示:
# NOTE: since Redis uses the system paging file to allocate the heap memory, # the Working Set memory usage showed by the Windows Task Manager or by other # tools such as ProcessExplorer will not always be accurate. For example, right # after a background save of the RDB or the AOF files, the working set value # may drop significantly. In order to check the correct amount of memory used # by the redis-server to store the data, use the INFO client command. The INFO # command shows only the memory used to store the redis data, not the extra # memory used by the Windows process for its own requirements. Th3 extra amount # of memory not reported by the INFO command can be calculated subtracting the # Peak Working Set reported by the Windows Task Manager and the used_memory_peak # reported by the INFO command. # # maxmemory根據(jù)自己需求配置 maxmemory 2147483648
如果不設(shè)置maxmemory或者設(shè)置為0,64位系統(tǒng)不限制內(nèi)存,32位系統(tǒng)最多使用3GB內(nèi)存。
修改數(shù)據(jù)默認(rèn)存放位置這里自定義一個(gè)文件夾,用來(lái)存放Redis數(shù)據(jù)
# The working directory. # # The DB will be written inside this directory, with the filename specified # above using the "dbfilename" configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir D:MyRedisSwap設(shè)置LRU算法刪除數(shù)據(jù)
設(shè)置了maxmemory的選項(xiàng),redis內(nèi)存使用達(dá)到上限??梢酝ㄟ^(guò)設(shè)置LRU算法來(lái)刪除部分key,釋放空間。默認(rèn)是按照過(guò)期時(shí)間的,如果set時(shí)候沒(méi)有加上過(guò)期時(shí)間就會(huì)導(dǎo)致數(shù)據(jù)寫(xiě)滿maxmemory。
LRU是Least Recently Used 近期最少使用算法。
volatile-lru -> 根據(jù)LRU算法生成的過(guò)期時(shí)間來(lái)刪除。
-allkeys-lru -> 根據(jù)LRU算法刪除任何key。
volatile-random -> 根據(jù)過(guò)期設(shè)置來(lái)隨機(jī)刪除key。
allkeys->random -> 無(wú)差別隨機(jī)刪。
volatile-ttl -> 根據(jù)最近過(guò)期時(shí)間來(lái)刪除(輔以TTL)
noeviction -> 誰(shuí)也不刪,直接在寫(xiě)操作時(shí)返回錯(cuò)誤。
如果設(shè)置了maxmemory,一般都要設(shè)置過(guò)期策略。Redis默認(rèn)有六種過(guò)期策略
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select among five behaviors: # # volatile-lru -> remove the key with an expire set using an LRU algorithm # allkeys-lru -> remove any key according to the LRU algorithm # volatile-random -> remove a random key with an expire set # allkeys-random -> remove a random key, any key # volatile-ttl -> remove the key with the nearest expire time (minor TTL) # noeviction -> don"t expire at all, just return an error on write operations # # Note: with any of the above policies, Redis will return an error on write # operations, when there are no suitable keys for eviction. # # At the date of writing these commands are: set setnx setex append # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby # getset mset msetnx exec sort # # The default is: # # maxmemory-policy noeviction maxmemory-policy volatile-lru
以下是其他配置:
Redis默認(rèn)不是以守護(hù)進(jìn)程的方式運(yùn)行,可以通過(guò)該配置項(xiàng)修改,使用yes啟用守護(hù)進(jìn)程 (在Windows上不支持守護(hù)進(jìn)程)
daemonize no
指定Redis監(jiān)聽(tīng)端口,默認(rèn)端口為6379
(在Windows上不支持守護(hù)進(jìn)程)
port 6379
綁定的主機(jī)地址
bind 127.0.0.1
指定在多長(zhǎng)時(shí)間內(nèi),有多少次更新操作,就將數(shù)據(jù)同步到數(shù)據(jù)文件,可以多個(gè)條件配合
save
Redis默認(rèn)配置文件中提供了三個(gè)條件:
save 900 1 save 300 10 save 60 10000
分別表示900秒(15分鐘)內(nèi)有1個(gè)更改,300秒(5分鐘)內(nèi)有10個(gè)更改以及60秒內(nèi)有10000個(gè)更改。
指定更新日志文件名,默認(rèn)為appendonly.aof
appendfilename appendonly.aof
指定更新日志條件,共有3個(gè)可選值:
no:表示等操作系統(tǒng)進(jìn)行數(shù)據(jù)緩存同步到磁盤(pán)(快) always:表示每次更新操作后手動(dòng)調(diào)用fsync()將數(shù)據(jù)寫(xiě)到磁盤(pán)(慢,安全) everysec:表示每秒同步一次(折衷,默認(rèn)值) appendfsync everysec
指定在超過(guò)一定的數(shù)量或者最大的元素超過(guò)某一臨界值時(shí),采用一種特殊的哈希算法
hash-max-zipmap-entries 64 hash-max-zipmap-value 512
參考鏈接:
Redis中文網(wǎng)
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/69248.html
摘要:第步配置環(huán)境變量在中使用即可,不用寫(xiě)第步輸入進(jìn)入中,輸入檢驗(yàn)是否安裝成功。安裝服務(wù)啟動(dòng)服務(wù)停止服務(wù)切換到目錄下運(yùn)行參考安裝解壓,配置環(huán)境變量,下開(kāi)啟和關(guān)閉窗口方式啟動(dòng)安裝服務(wù)啟動(dòng)協(xié)助服務(wù)命令校驗(yàn)是否啟動(dòng)輸入?yún)⒖? 1.安裝jdk 第1步:在官網(wǎng)下載和自己電腦位數(shù)相同的安裝包 第2步:選擇安裝路徑,默認(rèn)在C盤(pán),建議自定義選擇其他盤(pán)符,避免c盤(pán)重裝系統(tǒng)后,需要重新安裝。 第3步:安裝過(guò)程中...
摘要:整體與很像,但是做了一些更改,為了更適應(yīng)中國(guó)國(guó)內(nèi)的開(kāi)發(fā)網(wǎng)絡(luò)環(huán)境。表示宿主機(jī)器的目錄,表示環(huán)境目錄。將虛擬機(jī)置于休眠狀態(tài)。在開(kāi)發(fā)過(guò)程中可能會(huì)需要增加多個(gè)站點(diǎn)來(lái)運(yùn)行不同的開(kāi)發(fā)程序。與擴(kuò)展名重名,建議將的改成為佳。 SimfaseDevEnv 介紹 SimfaseDevEnv是為php開(kāi)發(fā)者提供的開(kāi)發(fā)環(huán)境,構(gòu)建在vagrant之上;Vagrant的Vagrangfile配置文件是在Homes...
閱讀 6979·2021-09-22 15:36
閱讀 5738·2021-09-02 10:20
閱讀 1886·2019-08-30 15:44
閱讀 2666·2019-08-29 14:06
閱讀 1165·2019-08-29 11:17
閱讀 1618·2019-08-26 14:05
閱讀 3115·2019-08-26 13:50
閱讀 1563·2019-08-26 10:26