PowerShell Install Redis
Posted CIAS
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PowerShell Install Redis相关的知识,希望对你有一定的参考价值。
Redis 前言
Redis(Remote Dictionary Server ),即远程字典服务,是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。
Redis dowload
Redis Windows | download |
Redis Linux | download |
Redis(Windows & Linux 整合下载) | download |
Redis 客户端 | download |
Powershell 使用使用参数 | 参考 |
前提条件
- 开启wmi,配置网卡,参考
一键自动化部署redis
- 最终实现,下载redis,创建目录,解压redis,redis环境全局变量,创建redis.6379.conf配置,创建redis系统服务,启动redis,防火墙配置,删除redis安装包
- "C:\\Program Files\\redis" # redis 安装位置
- "C:\\Program Files\\redis\\redis.6379.conf" #此处是配置文件,可自行更改
- 默认密码Report@123,可执行更改
- Redis(Windows & Linux 整合下载) Windows包含了(5,6,7版本全部测试完成可用)建议下载下来放置C盘根目录进行安装
.\\powershell-install-redis.ps1
<# Powershell Install redis
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+ _____ _____ _ _ _ +
+ | __ \\ / ____| | | | |+
+ | |__) |____ _____ _ _| (___ | |__ ___| | |+
+ | ___/ _ \\ \\ /\\ / / _ \\ '__\\___ \\| '_ \\ / _ \\ | |+
+ | | | (_) \\ V V / __/ | ____) | | | | __/ | |+
+ |_| \\___/ \\_/\\_/ \\___|_| |_____/|_| |_|\\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++
# Powershell Install redis
# .\\powershell-install-redis.ps1
#>
$drive="c:\\"
$redis_url="https://github.com/tporadowski/redis/releases/download/v5.0.14.1/"
$redis_zip="Redis-x64-5.0.14.1.zip"
$redis_site="C:\\Program Files\\"
$redis_new="redis"
$redis_conf="redis.6379.conf"
Write-Host "download redis" -ForegroundColor Green
wget -Uri $redis_url$redis_zip -UseBasicParsing -OutFile $drive$redis_zip
Write-Host "Create a directory for storing redis" -ForegroundColor Green
New-Item -ItemType Directory "$redis_site\\$redis_new"
Write-Host "decompression redis" -ForegroundColor Green
Expand-Archive -Path $drive\\$redis_zip -DestinationPath $redis_site$redis_new
Write-Host "Create redis environment variables" -ForegroundColor Green
$env:path += ";C:\\Program Files\\redis"
setx PATH $env:path
setx PATH $env:path /M
Write-Host "View the environment variables protected by path" -ForegroundColor Green
Get-ChildItem env:path
Write-Host "redis version check" -ForegroundColor Green
redis-server --version
Write-Host "redis conf configuration" -ForegroundColor Green
$functionText_redis_6379 = @"
bind 0.0.0.0
requirepass Report@123
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
loglevel notice
logfile ""
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error no
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
"@
New-Item "$redis_site$redis_new\\$redis_conf" -type file -force -value $functionText_redis_6379
Write-Host "Create the redis system startup service" -ForegroundColor Green
redis-server.exe --service-install $redis_site$redis_new\\$redis_conf
Write-Host "start redis service" -ForegroundColor Green
redis-server --service-start
Write-Host "Viewing redis process port" -ForegroundColor Green
netstat -an|findstr 6379
Write-Host "delete redis software package" -ForegroundColor Green
Remove-Item $drive$redis_zip -recurse
Write-Host "firewall redis port" -ForegroundColor Green
New-NetFirewallRule -DisplayName "redis" -Direction Outbound -profile any -LocalPort 6379 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "redis" -Direction Inbound -profile any -LocalPort 6379 -Protocol TCP -Action Allow
执行安装
.\\powershell-install-redis.ps1
输出结果
客户端访问
以上是关于PowerShell Install Redis的主要内容,如果未能解决你的问题,请参考以下文章
powershell install_chocolatey.ps1
powershell Windows 10 Fresh Install(Chocolatey + Boxstarter)