繁体   English   中英

如何使用DSC包资源安装MongoDB?

[英]How do I use the DSC package resource to install MongoDB?

我尝试了似乎是直截了当的方法,并在MongoDB MSI的节点配置中添加了Package资源。 我收到以下错误:“无法获取文件的https流”。

这是我尝试的包配置:

    package MongoDB {
        Name = "MongoDB 3.6.11 2008R2Plus SSL (64 bit)"
        Path = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi"
        ProductId = "88F7AA23-BDD2-4EBE-9985-EBB5D2E23E83"
        Arguments = "ADDLOCAL=`"all`" SHOULD_INSTALL_COMPASS=`"0`" INSTALLLOCATION=`"C:\MongoDB\Server\3.6`""
    }

(我在那里有$ConfigurationData引用,但为简单起见取代了文字)

我收到以下错误: Could not get the https stream for file

可能的TLS版本问题? 我发现Invoke-WebRequest需要以下内容才能使它与同一个mongo下载URL一起使用。 有没有办法用包资源做到这一点? [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

使用nmap来查询nodejs.org和fastdl.mongodb.org(实际上是在云端),确实TLS支持不同。 Node仍然支持TLS版本1.0,这恰好与PowerShell一起使用。 但MongoDB的站点仅支持TLS版本1.1或1.2。

正如我在我的问题中提到的,我怀疑设置.Net安全协议是有效的,事实确实如此。 没有办法将任意脚本添加到DSC 资源中,因此我需要创建一个脚本块来运行此代码,并让包资源依赖于它。

这就是我的工作:

Node $AllNodes.Where{$_.Role -contains 'MongoDBServer'}.NodeName {

Script SetTLS {
    GetScript = { @{ Result = $true } }
    SetScript = { [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" }
    TestScript = { $false } #Always run
}

package MongoDB {
    Ensure = 'Present'
    Name = 'MongoDB 3.6.11 2008R2Plus SSL (64 bit)'
    Path = 'https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.11-signed.msi'
    ProductId = ''
    Arguments = 'ADDLOCAL="all" SHOULD_INSTALL_COMPASS="0" INSTALLLOCATION="C:\MongoDB\Server\3.6"'
    DependsOn = '[Script]SetTLS'
}
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM