使用本地 PowerShell 脚本自动安装自承载集成运行时Automating self-hosted integration runtime installation using local PowerShell scripts

若要在本地计算机(而不是在可以通过资源管理器模板实现自动安装的 Azure VM 上)上自动安装自承载集成运行时,可以使用本地 PowerShell 脚本。To automate installation of Self-hosted Integration Runtime on local machines (other than Azure VMs where we can leverage the Resource Manager template instead), you can use local PowerShell scripts. 本文将介绍两个可用于实现自动安装的脚本。This article introduces two scripts you can use.

先决条件Prerequisites

  • 在本地计算机上启动 PowerShell。Launch PowerShell on your local machine. 若要运行脚本,需要选择“以管理员身份运行”。To run the scripts, you need to choose Run as Administrator.
  • 下载自承载集成运行时软件。Download the self-hosted integration runtime software. 复制下载的文件所在的路径。Copy the path where the downloaded file is.
  • 还需要“身份验证密钥”来注册自承载集成运行时。You also need an authentication key to register the self-hosted integration runtime.
  • 若要自动执行手动更新,需要具备一个预先配置的自承载集成运行时。For automating manual updates, you need to have a pre-configured self-hosted integration runtime.

脚本简介Scripts introduction

备注

以下脚本通过自承载集成运行时中记录的命令行实用工具创建。These scripts are created using the documented command line utility in the self-hosted integration runtime. 如果需要,可以相应地自定义这些脚本以满足其自动化需求。If needed one can customize these scripts accordingly to cater to their automation needs. 脚本需要应用于每个节点,因此确保在高可用性设置(2 个或更多节点)的情况下跨所有节点运行脚本。The scripts need to be applied per node, so make sure to run it across all nodes in case of high availability setup (2 or more nodes).

  • 自动安装:使用 InstallGatewayOnLocalMachine.ps1 安装并注册新的自承载集成运行时节点 - 该脚本可用于安装自承载集成运行时节点,并使用身份验证密钥对其进行注册。For automating setup: Install and register a new self-hosted integration runtime node using InstallGatewayOnLocalMachine.ps1 - The script can be used to install self-hosted integration runtime node and register it with an authentication key. 脚本接受两个参数,第一个指定本地磁盘上的自承载集成运行时的位置,第二个指定身份验证密钥(用于注册自承载 IR 节点) 。The script accepts two arguments, first specifying the location of the self-hosted integration runtime on a local disk, second specifying the authentication key (for registering self-hosted IR node).

  • 自动执行手动更新:使用 script-update-gateway.ps1 特定版本或最新版本更新自承载 IR 节点 - 如果你已关闭自动更新或需要对更新有更多的控制,此方法也同样受支持。For automating manual updates: Update the self-hosted IR node with a specific version or to the latest version script-update-gateway.ps1 - This is also supported in case you have turned off the auto-update, or want to have more control over updates. 该脚本可用于将自承载集成运行时节点更新到最新版本或指定的更高版本(无法降级)。The script can be used to update the self-hosted integration runtime node to the latest version or to a specified higher version (downgrade doesn’t work). 它接受用于指定版本号的参数(例如 -version 3.13.6942.1)。It accepts an argument for specifying version number (example: -version 3.13.6942.1). 未指定版本时,它始终将自承载 IR 更新到下载页面中可用的最新版本。When no version is specified, it always updates the self-hosted IR to the latest version found in the downloads.

    备注

    只能指定上 3 个版本。Only last 3 versions can be specified. 最好使用此脚本将现有节点更新到最新版本。Ideally this is used to update an existing node to the latest version. 本脚本假设你已有一个经过注册的自承载 IR。IT ASSUMES THAT YOU HAVE A REGISTERED SELF HOSTED IR.

用法示例Usage examples

自动安装For automating setup

  1. 此处下载自承载 IR。Download the self-hosted IR from here.

  2. 指定上述下载的 SHIR MSI(安装文件)所在的路径。Specify the path where the above downloaded SHIR MSI (installation file) is. 例如,如果路径为 C:\Users\username\Downloads\IntegrationRuntime_4.7.7368.1.msi,则可以使用下面的 PowerShell 命令行示例执行此任务:For example, if the path is C:\Users\username\Downloads\IntegrationRuntime_4.7.7368.1.msi, then you can use below PowerShell command-line example for this task:

    PS C:\windows\system32> C:\Users\username\Desktop\InstallGatewayOnLocalMachine.ps1 -path "C:\Users\username\Downloads\IntegrationRuntime_4.7.7368.1.msi" -authKey "[key]"
    

    备注

    将 [key] 替换为用以注册 IR 的身份验证密钥。Replace [key] with the authentication key to register your IR. 将“username”替换为你的用户名。Replace "username" with your user name. 运行此脚本时,指定“InstallGatewayOnLocalMachine.ps1”文件的位置。Specify the location of the "InstallGatewayOnLocalMachine.ps1" file when running the script. 在本例中,我们将其存储在桌面上。In this example we stored it on Desktop.

  3. 如果计算机上有一个预安装的自承载 IR,此脚本自动将其卸载,然后配置一个新的自承载 IR。If there is one pre-installed self-hosted IR on your machine, the script automatically uninstalls it and then configures a new one. 系统会弹出以下窗口:配置集成运行时You'll see following window popped out: configure integration runtime

  4. 安装和密钥注册完成后,PowerShell 中会显示“网关安装成功”和“网关注册成功”结果 。When the installation and key registration completes, you'll see Succeed to install gateway and Succeed to register gateway results in your local PowerShell. 脚本 1 运行结果script 1 run result

自动执行手动更新For automating manual updates

此脚本用于更新/安装和注册最新的自承载集成运行时。This script is used to update/install + register latest self-hosted integration runtime. 该脚本运行执行以下步骤:The script run performs the following steps:

  1. 检查当前自承载 IR 版本Check current self-hosted IR version
  2. 从参数获取最新版本或指定版本Get latest version or specified version from argument
  3. 如果存在比当前版本更新的版本:If there is newer version than current version:
    • 下载自承载 IR msidownload self-hosted IR msi
    • 执行升级upgrade it

可以按照以下命令行示例使用此脚本:You can follow below command-line example to use this script:

  • 下载并安装最新版网关:Download and install latest gateway:

    PS C:\windows\system32> C:\Users\username\Desktop\script-update-gateway.ps1
    
  • 下载并安装指定版本的网关:Download and install gateway of specified version:

    PS C:\windows\system32> C:\Users\username\Desktop\script-update-gateway.ps1 -version 3.13.6942.1
    

    如果当前版本已经是最新版本,系统会显示以下结果,表明不需要更新。If your current version is already the latest one, you'll see following result, suggesting no update is required.
    脚本 2 运行结果script 2 run result