PowerShell Install Rabbitmq
Posted CIAS
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PowerShell Install Rabbitmq相关的知识,希望对你有一定的参考价值。
Rabbitmq 前言
RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)。RabbitMQ服务器是用Erlang语言编写的,而集群和故障转移是构建在开放电信平台框架上的。所有主要的编程语言均有与代理接口通讯的客户端库。
Rabbitmq dowload
Rabbitmq | download |
erlang otp | download |
Rabbitmq & otp 对应版本 | 参考 |
Rabbitmq 端口使用参考 | 参考 |
Powershell 使用使用参数 | 参考 |
前提条件
- 开启wmi,配置网卡,参考
一键自动化部署Rabbitmq
- 最终实现下载rabbitmq,otp,安装装rabbitmq,otp,环境变量配置,启动rabbitmq,防火墙配置,删除安装包。
- 目前存在问题,自动化脚本中68-84行由于服务启动问题无法正常创建,目前在找解决方法,后续更新
- 版本显示问题已修复
Write-Host "otp check version" -ForegroundColor Green
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshellWrite-Host "rabbitmq check version" -ForegroundColor Green
rabbitmqctl.bat version
powershell-install-rebbitmq.ps1
<# Powershell Install rebbitmq
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+ _____ _____ _ _ _ +
+ | __ \\ / ____| | | | |+
+ | |__) |____ _____ _ _| (___ | |__ ___| | |+
+ | ___/ _ \\ \\ /\\ / / _ \\ '__\\___ \\| '_ \\ / _ \\ | |+
+ | | | (_) \\ V V / __/ | ____) | | | | __/ | |+
+ |_| \\___/ \\_/\\_/ \\___|_| |_____/|_| |_|\\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++
# Powershell Install rebbitmq
# .\\powershell-install-rebbitmq.ps1
#>
$drive="c:\\"
$rebbitmq_url="https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.11.9/"
$rebbitmq_zip="rabbitmq-server-windows-3.11.9.zip"
$rebbitmq_site="C:\\Program Files\\"
$rebbitmq_new="rabbitmq-server"
$rebbitmq_catalogue="rabbitmq_server-3.11.9"
$rebbitmq_conf="redis.6379.conf"
$otp_url="https://github.com/erlang/otp/releases/download/OTP-25.2/"
$otp_exe="otp_win64_25.2.exe"
Write-Host "download otp" -ForegroundColor Green
wget -Uri $otp_url$otp_exe-UseBasicParsing -OutFile $drive$otp_exe
Write-Host "download rebbitmq" -ForegroundColor Green
wget -Uri $rebbitmq_url$rebbitmq_zip -UseBasicParsing -OutFile $drive$rebbitmq_zip
Write-Host "install otp" -ForegroundColor Green
Start-Process -FilePath $drive\\$otp_exe -ArgumentList /install /S /v /qn -wait -PassThru
Write-Host "decompression rebbitmq" -ForegroundColor Green
Expand-Archive -Path $drive\\$rebbitmq_zip -DestinationPath $rebbitmq_site
Write-Host "Rename the rebbitmq folder name" -ForegroundColor Green
Rename-Item -Path $rebbitmq_site$rebbitmq_catalogue -NewName $rebbitmq_new
Write-Host "Create rebbitmq environment variables" -ForegroundColor Green
$env:path += ";C:\\Program Files\\rabbitmq-server\\sbin"
$env:path += ";C:\\Program Files\\Erlang OTP\\bin"
setx PATH $env:path
setx PATH $env:path /M
Write-Host "firewall rabbitmq port" -ForegroundColor Green
New-NetFirewallRule -DisplayName "rabbitmq-out" -Direction Outbound -profile any -LocalPort 15671,15672,5671,5672,25672,4369 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "rabbitmq-int" -Direction Inbound -profile any -LocalPort 15671,15672,5671,5672,25672,4369 -Protocol TCP -Action Allow
Write-Host "Enable rabbitmq web monitoring" -ForegroundColor Green
rabbitmq-plugins.bat enable rabbitmq_management
Write-Host "Create rabbitmq system service" -ForegroundColor Green
rabbitmq-service.bat install
rabbitmq-service.bat start
Write-Host "copy .erlang.cookie" -ForegroundColor Green
Copy-Item -Path C:\\Users\\Administrator\\.erlang.cookie -Destination C:\\Windows\\System32\\config\\systemprofile\\.erlang.cookie -Force
Write-Host "Check the rabbitmq status" -ForegroundColor Green
rabbitmq-plugins.bat enable rabbitmq_management
rabbitmq-service.bat stop
rabbitmq-service.bat start
rabbitmqctl.bat start_app
rabbitmqctl.bat status
Write-Host "rabbitmq create an account" -ForegroundColor Green
rabbitmqctl add_user admin Report@123
Write-Host "rabbitmq ground bush administrator" -ForegroundColor Green
rabbitmqctl set_user_tags admin administrator
Write-Host "rabbitmq After the role is created and assigned, check and confirm" -ForegroundColor Green
rabbitmqctl list_users
Write-Host "otp check version" -ForegroundColor Green
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
Write-Host "rabbitmq check version" -ForegroundColor Green
rabbitmqctl.bat version
Write-Host "delete rabbitmq software package" -ForegroundColor Green
Remove-Item $drive$rebbitmq_zip -recurse
执行安装
.\\powershell-install-rebbitmq.ps1
结果输出
此处报错目前解决方式需要人工干预,自动化方式目前在找方式解决完成后将更新
自动化脚本68-84行管理创建失败,需要手动进行创建
解决后最终启动成功
rabbitmqctl.bat start_app
rabbitmqctl.bat status
创建管理员登录账号
rabbitmqctl add_user admin Report@123
rabbitmqctl set_user_tags admin administrator
网页登陆测试
- http://YOU-IP:15672
- admin/Report@123
以上是关于PowerShell Install Rabbitmq的主要内容,如果未能解决你的问题,请参考以下文章
powershell install_chocolatey.ps1
powershell Windows 10 Fresh Install(Chocolatey + Boxstarter)