SolarWinds监控体系在Windows Server 2022上的完整安装与配置指南 ...

打印 上一主题 下一主题

主题 1792|帖子 1792|积分 5376

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
第一部分:体系预备与SolarWinds安装

1. 体系预备

1.1 安装Windows Server 2022


  • 从Microsoft官网下载ISO镜像
  • 使用Rufus等工具创建启动U盘
  • 完成基本安装(选择"带GUI的服务器")
1.2 体系更新与基础配置

powershell 
  1. # 以管理员身份打开PowerShell执行以下命令
  2. # 检查并安装Windows更新
  3. Install-Module -Name PSWindowsUpdate -Force
  4. Import-Module PSWindowsUpdate
  5. Get-WindowsUpdate -AcceptAll -Install -AutoReboot
  6. # 启用远程桌面
  7. Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0
  8. Enable-NetFirewallRule -DisplayGroup "远程桌面"
  9. # 设置服务器静态IP(根据实际网络调整)
  10. New-NetIPAddress -IPAddress "192.168.1.100" -PrefixLength 24 -DefaultGateway "192.168.1.1" -InterfaceIndex (Get-NetAdapter).InterfaceIndex
  11. Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).InterfaceIndex -ServerAddresses ("8.8.8.8", "8.8.4.4")
  12. # 更改计算机名并重启
  13. Rename-Computer -NewName "SOLARWINDS-MONITOR" -Restart
复制代码
2. 安装SQL Server 2019(SolarWinds依赖)

2.1 下载SQL Server 2019

powershell 
  1. # 下载SQL Server 2019 Developer Edition(免费用于开发测试)
  2. $url = "https://go.microsoft.com/fwlink/?linkid=866662"
  3. $output = "$env:USERPROFILE\Downloads\SQLServer2019-SSEI-Dev.exe"
  4. Invoke-WebRequest -Uri $url -OutFile $output
  5. # 启动安装程序
  6. Start-Process -FilePath $output
复制代码
2.2 图形界面安装步调


  • 选择"基本"安装类型
  • 接受允许条款
  • 指定安装位置(建议保持默认)
  • 点击"安装"按钮
  • 安装完成后记下显示的SQL Server名称(通常为"主机名\SQLEXPRESS")
2.3 验证SQL Server安装

powershell 
  1. # 检查SQL Server服务状态
  2. Get-Service -Name "MSSQL`$SQLEXPRESS"
  3. # 应该看到状态为"Running"
复制代码
3. 安装SolarWinds Orion

3.1 下载SolarWinds Orion安装包

powershell 
  1. # 从SolarWinds官网下载评估版(需要注册)
  2. # 以下为示例命令,实际URL需从官网获取
  3. $url = "https://downloads.solarwinds.com/solarwinds/Release/Orion/2020.2.1/OrionInstaller.exe"
  4. $output = "$env:USERPROFILE\Downloads\OrionInstaller.exe"
  5. Invoke-WebRequest -Uri $url -OutFile $output
  6. # 启动安装程序
  7. Start-Process -FilePath $output
复制代码
3.2 图形界面安装步调


  • 接受允许协议
  • 选择"Complete Installation"
  • 输入SQL Server信息:

    • Server Name: 当地服务器名(如SOLARWINDS-MONITOR\SQLEXPRESS)
    • Authentication: Windows Authentication

  • 设置主账户信息:

    • Username: admin
    • Password: 设置强密码(建议包含巨细写字母、数字和特殊字符)

  • 选择安装组件(全选)
  • 点击"Install"开始安装
  • 安装完成后启动"Orion Web Console"
第二部分:添加网络装备监控

1. 配置SNMP服务(用于当地测试)

powershell 
  1. # 安装SNMP服务
  2. Install-WindowsFeature -Name SNMP-Service
  3. # 配置SNMP团体字符串
  4. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities" /v public /t REG_DWORD /d 4 /f
  5. # 允许来自任何主机的SNMP查询
  6. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d "*" /f
  7. # 重启SNMP服务
  8. Restart-Service -Name SNMP
复制代码
2. 添加思科装备


  • 登录SolarWinds Web控制台(http://localhost:8787)
  • 导航至"Settings" > "Network Discovery"
  • 点击"New Discovery"
  • 配置发现参数:

    • Discovery Type: IP Range
    • IP Address Range: 输入思科装备IP范围(如192.168.1.1-192.168.1.10)
    • SNMP Credentials: 添加新的SNMP凭据

      • Community String: public(或装备实际团体字)
      • Version: v2c


  • 在"Select Pollers"中勾选:

    • Cisco Discovery
    • Interface Statistics
    • Node Performance

  • 点击"Discover Now"
3. 添加华为装备


  • 导航至"Settings" > "Network Discovery"
  • 点击"New Discovery"
  • 配置发现参数:

    • Discovery Type: IP Range
    • IP Address Range: 输入华为装备IP范围
    • SNMP Credentials: 使用与思科相同的凭据或创建新的

  • 在"Select Pollers"中勾选:

    • Generic SNMP Device Discovery
    • Interface Statistics
    • Node Performance

  • 点击"Advanced" > "SNMP Options":

    • 添加华为特定OID: 1.3.6.1.4.1.2011

  • 点击"Discover Now"
4. 添加华三装备


  • 导航至"Settings" > "Network Discovery"
  • 点击"New Discovery"
  • 配置发现参数:

    • Discovery Type: IP Range
    • IP Address Range: 输入华三装备IP范围
    • SNMP Credentials: 使用现有凭据

  • 在"Select Pollers"中勾选:

    • Generic SNMP Device Discovery
    • Interface Statistics
    • Node Performance

  • 点击"Advanced" > "SNMP Options":

    • 添加华三特定OID: 1.3.6.1.4.1.25506

  • 点击"Discover Now"
5. 添加锐捷装备


  • 导航至"Settings" > "Network Discovery"
  • 点击"New Discovery"
  • 配置发现参数:

    • Discovery Type: IP Range
    • IP Address Range: 输入锐捷装备IP范围
    • SNMP Credentials: 使用现有凭据

  • 在"Select Pollers"中勾选:

    • Generic SNMP Device Discovery
    • Interface Statistics
    • Node Performance

  • 点击"Advanced" > "SNMP Options":

    • 添加锐捷特定OID: 1.3.6.1.4.1.4881

  • 点击"Discover Now"
第三部分:告警配置

1. 配置邮件关照


  • 导航至"Settings" > "All Settings" > "Alerting" > "Mail Server"
  • 配置SMTP服务器:

    • SMTP Server: 输入邮件服务器地址(如smtp.office365.com)
    • Port: 587(TLS)或465(SSL)
    • Authentication: 选择"Basic"
    • Username: 发件邮箱地址
    • Password: 邮箱密码
    • From Address: 发件人邮箱

  • 点击"Test"验证配置
  • 点击"Save"
2. 配置短信关照(以Twilio为例)


  • 导航至"Settings" > "All Settings" > "Alerting" > "Custom Scripts"
  • 创建新脚本:

    • Name: Twilio SMS Alert
    • Script Type: PowerShell

  • 输入以下脚本(更换Twilio账户信息):
powershell 
  1. param($Subject, $Message, $Recipients)
  2. $AccountSid = "YOUR_TWILIO_ACCOUNT_SID"
  3. $AuthToken = "YOUR_TWILIO_AUTH_TOKEN"
  4. $FromNumber = "YOUR_TWILIO_PHONE_NUMBER"
  5. $TwilioApiUrl = "https://api.twilio.com/2010-04-01/Accounts/$AccountSid/Messages.json"
  6. foreach ($recipient in $Recipients) {
  7.     $Body = @{
  8.         From = $FromNumber
  9.         To = $recipient
  10.         Body = "$Subject`n$Message"
  11.     }
  12.    
  13.     $Bytes = [System.Text.Encoding]::UTF8.GetBytes("$AccountSid`:$AuthToken")
  14.     $Base64 = [System.Convert]::ToBase64String($Bytes)
  15.    
  16.     $Headers = @{
  17.         Authorization = "Basic $Base64"
  18.     }
  19.    
  20.     try {
  21.         Invoke-RestMethod -Uri $TwilioApiUrl -Method Post -Body $Body -Headers $Headers
  22.     } catch {
  23.         Write-Error "Failed to send SMS to $recipient: $_"
  24.     }
  25. }
复制代码

  • 点击"Save"
3. 创建CPU使用率告警


  • 导航至"Alert Central"
  • 点击"Create New Alert"
  • 选择"Node CPU Load"
  • 配置条件:

    • Trigger when: CPU Load > 80%
    • For at least: 5 minutes

  • 配置动作:

    • 添加邮件关照:选择之前配置的邮件服务器
    • 添加短信关照:选择Twilio SMS Alert脚本

  • 点击"Save"
4. 创建接口丢包告警


  • 导航至"Alert Central"
  • 点击"Create New Alert"
  • 选择"Interface Packet Loss"
  • 配置条件:

    • Trigger when: Packet Loss > 1%
    • For at least: 3 minutes

  • 配置动作:

    • 添加邮件和短信关照

  • 点击"Save"
5. 创建装备宕机告警


  • 导航至"Alert Central"
  • 点击"Create New Alert"
  • 选择"Node Down"
  • 配置条件:

    • Trigger when: Node is down
    • For at least: 1 minute

  • 配置动作:

    • 添加邮件和短信关照

  • 点击"Save"
第四部分:体系测试

1. 装备监控测试

powershell 
  1. # 测试思科设备SNMP可达性
  2. Test-NetConnection -ComputerName <思科设备IP> -Port 161
  3. # 使用SNMPWalk测试(需安装SNMP工具)
  4. snmpwalk -v 2c -c public <思科设备IP> .1.3.6.1.2.1.1.1.0
复制代码
2. 告警触发测试

powershell 
  1. # 模拟高CPU负载(在目标设备上)
  2. # 对于Windows设备:
  3. Start-Job -ScriptBlock { while($true) { } }
  4. # 对于Linux设备(通过SSH):
  5. Invoke-Command -ComputerName <Linux设备IP> -ScriptBlock { while true; do :; done } -Credential (Get-Credential)
复制代码
第五部分:Python一键部署脚本

创建deploy_solarwinds.py文件:
python 
  1. import os
  2. import subprocess
  3. import time
  4. import requests
  5. import winreg
  6. import ctypes
  7. def run_powershell(cmd, admin=False):
  8.     if admin:
  9.         ctypes.windll.shell32.ShellExecuteW(None, "runas", "powershell.exe", f"-Command {cmd}", None, 1)
  10.     else:
  11.         subprocess.run(["powershell", "-Command", cmd], check=True)
  12. def install_prerequisites():
  13.     print("安装系统更新和必要组件...")
  14.     commands = [
  15.         "Install-Module -Name PSWindowsUpdate -Force -Confirm:$false",
  16.         "Import-Module PSWindowsUpdate",
  17.         "Get-WindowsUpdate -AcceptAll -Install -AutoReboot",
  18.         "Install-WindowsFeature -Name SNMP-Service",
  19.         "Set-ItemProperty -Path 'HKLM:\\System\\CurrentControlSet\\Control\\Terminal Server' -Name 'fDenyTSConnections' -Value 0",
  20.         "Enable-NetFirewallRule -DisplayGroup '远程桌面'"
  21.     ]
  22.     for cmd in commands:
  23.         try:
  24.             run_powershell(cmd, admin=True)
  25.         except subprocess.CalledProcessError as e:
  26.             print(f"执行命令失败: {cmd}\n错误: {e}")
  27. def configure_snmp():
  28.     print("配置SNMP服务...")
  29.     try:
  30.         # 设置SNMP团体字符串
  31.         key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
  32.                             r"SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities",
  33.                             0, winreg.KEY_SET_VALUE)
  34.         winreg.SetValueEx(key, "public", 0, winreg.REG_DWORD, 4)
  35.         winreg.CloseKey(key)
  36.         
  37.         # 允许所有管理器
  38.         key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
  39.                             r"SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers",
  40.                             0, winreg.KEY_SET_VALUE)
  41.         winreg.SetValueEx(key, "1", 0, winreg.REG_SZ, "*")
  42.         winreg.CloseKey(key)
  43.         
  44.         # 重启SNMP服务
  45.         run_powershell("Restart-Service -Name SNMP", admin=True)
  46.     except Exception as e:
  47.         print(f"配置SNMP失败: {e}")
  48. def download_and_install(url, file_name, install_args=None):
  49.     print(f"下载并安装 {file_name}...")
  50.     try:
  51.         # 下载文件
  52.         download_path = os.path.join(os.environ["USERPROFILE"], "Downloads", file_name)
  53.         response = requests.get(url, stream=True)
  54.         with open(download_path, "wb") as f:
  55.             for chunk in response.iter_content(chunk_size=8192):
  56.                 f.write(chunk)
  57.         
  58.         # 安装
  59.         if install_args:
  60.             subprocess.run([download_path] + install_args, check=True)
  61.         else:
  62.             subprocess.run([download_path], check=True)
  63.     except Exception as e:
  64.         print(f"安装 {file_name} 失败: {e}")
  65. def configure_solarwinds():
  66.     print("配置SolarWinds Orion...")
  67.     # 这里可以添加自动配置SolarWinds的代码
  68.     # 实际生产环境中可能需要使用SolarWinds API或CLI工具
  69.     print("请手动完成SolarWinds的初始配置:")
  70.     print("1. 访问 http://localhost:8787")
  71.     print("2. 使用admin账户登录")
  72.     print("3. 完成初始向导")
  73. def main():
  74.     print("=== SolarWinds监控系统一键部署脚本 ===")
  75.    
  76.     # 1. 安装系统更新和必要组件
  77.     install_prerequisites()
  78.    
  79.     # 2. 配置SNMP服务
  80.     configure_snmp()
  81.    
  82.     # 3. 下载并安装SQL Server 2019
  83.     sql_url = "https://go.microsoft.com/fwlink/?linkid=866662"
  84.     download_and_install(sql_url, "SQLServer2019-SSEI-Dev.exe")
  85.    
  86.     # 4. 下载并安装SolarWinds Orion
  87.     # 注意:需要替换为实际的SolarWinds下载URL
  88.     sw_url = "https://downloads.solarwinds.com/solarwinds/Release/Orion/2020.2.1/OrionInstaller.exe"
  89.     download_and_install(sw_url, "OrionInstaller.exe")
  90.    
  91.     # 5. 配置SolarWinds
  92.     configure_solarwinds()
  93.    
  94.     print("部署完成!")
  95. if __name__ == "__main__":
  96.     main()
复制代码
使用分析


  • 将上述Python脚本保存为deploy_solarwinds.py
  • 以管理员身份运行PowerShell
  • 执行以下下令运行脚本:
    powershell 
    1. python deploy_solarwinds.py
    复制代码
  • 脚本将自动完成大部分安装配置,部分步调必要手动完成
留意事项


  • 生产情况中应使用更安全的SNMP团体字符串替代"public"
  • 邮件和短信关照配置必要根据实际使用的服务提供商举行调解
  • SolarWinds Orion的完整功能大概必要额外的允许证
  • 定期备份SolarWinds配置和数据库
  • 确保防火墙允许SolarWinds使用的端口(如8787、17778等)
 
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
继续阅读请点击广告
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

曂沅仴駦

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表