在 Amazon EC2 上執行 X-Ray 常設程式 - AWS X-Ray

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 Amazon EC2 上執行 X-Ray 常設程式

您可以在 Amazon EC2 上的下列作業系統中執行 X-Ray 常設程式:

  • Amazon Linux

  • Ubuntu

  • Windows Server (2012 R2 和更新版本)

使用實例配置文件授予協助程式將追蹤資料上傳至 X-Ray 的許可。如需詳細資訊,請參閱 授予守護進程將數據發送到 X-Ray 的權限

利用使用者資料指令碼,在您啟動執行個體時自動執行協助程式。

範例 使用者資料指令碼 - Linux
#!/bin/bash curl https://s3.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-3.x.rpm -o /home/ec2-user/xray.rpm yum install -y /home/ec2-user/xray.rpm
範例 使用者資料指令碼 - Windows Server
<powershell> if ( Get-Service "AWSXRayDaemon" -ErrorAction SilentlyContinue ) { sc.exe stop AWSXRayDaemon sc.exe delete AWSXRayDaemon } $targetLocation = "C:\Program Files\Amazon\XRay" if ((Test-Path $targetLocation) -eq 0) { mkdir $targetLocation } $zipFileName = "aws-xray-daemon-windows-service-3.x.zip" $zipPath = "$targetLocation\$zipFileName" $destPath = "$targetLocation\aws-xray-daemon" if ((Test-Path $destPath) -eq 1) { Remove-Item -Recurse -Force $destPath } $daemonPath = "$destPath\xray.exe" $daemonLogPath = "$targetLocation\xray-daemon.log" $url = "https://s3.dualstack.us-west-2.amazonaws.com/aws-xray-assets.us-west-2/xray-daemon/aws-xray-daemon-windows-service-3.x.zip" Invoke-WebRequest -Uri $url -OutFile $zipPath Add-Type -Assembly "System.IO.Compression.Filesystem" [io.compression.zipfile]::ExtractToDirectory($zipPath, $destPath) New-Service -Name "AWSXRayDaemon" -StartupType Automatic -BinaryPathName "`"$daemonPath`" -f `"$daemonLogPath`"" sc.exe start AWSXRayDaemon </powershell>