手動安裝工作負載安全代理程式和收集器
預設情況下,當有新版本的工作負載安全代理或收集器可用時,會發送升級前通知,並且代理程式和收集器會在您的租用戶上自動更新。然而,在安全控制的環境中,可能不需要自動升級。在這種情況下,可以配置工作負載安全性以手動安裝/升級代理程式和收集器,從而對系統上安裝的軟體提供更好的控制。
開始之前
-
在 swagger 中驗證名為「cloudsecure_installers.agent」和「cloudsecure_installers.collector」的 API 類別是否可用。如果沒有,則不支援手動代理安裝。請聯絡NetApp支援以啟用該功能。

-
以「root」使用者身分執行本文檔中提到的所有命令,或者,如果以其他使用者身分執行,則使用「sudo」執行命令。
安裝新代理
-
建立一個新的工作負載安全 API 存取令牌。
-
導航至*管理>API 存取*。選擇「工作負載安全性令牌」選項卡,然後按一下「+ API 存取權杖」。
-
設定易於識別的名稱和描述。
-
在「此令牌將用於呼叫哪種類型的 API?」下拉式功能表下,選擇_收集器管理_和_代理程式和收集器安裝_。
-
選擇所需的到期時間。
-
-
點選“儲存”。
-
-
複製產生的 API 存取令牌。請注意,一旦視窗關閉,就無法再檢索令牌。在這種情況下,您將需要產生一個新的令牌。


-
導航至*管理> API 存取> API 文件*(頁面右上角)並選擇_工作負載安全性_圖示。這將開啟工作負載安全 API 的 Swagger 文件。

-
授權存取_工作負載安全性_ API。
-
-
點擊頁面右上角的“授權”按鈕。
-
在「客戶 API 金鑰 (apiKey)」文字欄位中,貼上之前從步驟 1c。
-
按一下“授權”並關閉視窗。

-
下載代理安裝程式。
-
-
在 Swagger 中,選擇 cloudsecure_installers.agent > /v1/cloudsecure/agents/installers/{platform}/latest (GET) API。按一下“嘗試一下”。
-
在_platform_欄位中,輸入_linux_。按一下“執行”。

-
點擊“下載檔案”以下載安裝程式。
-
如果安裝程式檔案是從要安裝代理程式的系統以外的其他機器上外部下載的,請將安裝程式檔案複製到該系統。
-
或者,您可以複製 curl 命令並直接在應該安裝代理程式的系統中運行它。
-
將「-o {{file_name}}」參數附加到 curl 指令以使用所需名稱儲存安裝程式檔案。安裝程式檔案的實際名稱可以在 swagger 回應標頭部分找到。也可以使用該名稱。

-
雖然該檔案可以下載到任何位置,但建議將其下載到可以提取安裝程式 .zip 的空資料夾中。
-
新建一個資料夾(建議),將安裝程式檔案複製到該資料夾,然後解壓縮:
[root@demo-agent /]# mkdir agent_installers [root@demo-agent /]# cd agent_installers/ [root@demo-agent agent_installers]# pwd /agent_installers [root@demo-agent agent_installers]# ll total 0 [root@demo-agent agent_installers]# curl -X GET "https://netapp-demo.dev.cloudsecure.netapp.com/rest/v1/cloudsecure/agents/installers/linux/latest" -H "accept: application/octet-stream" -H "X-CloudInsights-ApiKey: <<API Access Token>>" -o cloudsecure-linux-agent-installer-1.617.0.zip [root@demo-agent agent_installers]# ll total 76012 -rw------- 1 root root 77834705 Apr 26 14:34 cloudsecure-linux-agent-installer-1.617.0.zip
[root@demo-agent agent_installers]# unzip cloudsecure-linux-agent-installer-1.617.0.zip Archive: cloudsecure-linux-agent-installer-1.617.0.zip inflating: cloudsecure-agent-image.zip inflating: cloudsecure-agent-install.sh inflating: cloudsecure-agent-upgrade.sh
-
為「cloudsecure-agent-install.sh」檔案設定_執行_權限。
[root@demo-agent agent_installers]# chmod +x cloudsecure-agent-install.sh [root@demo-agent agent_installers]# ll total 153344 -rw------- 1 root root 79154250 Apr 26 06:37 cloudsecure-agent-image.zip -rwx------ 1 root root 16574 Apr 26 06:25 cloudsecure-agent-install.sh -rw------- 1 root root 8586 Apr 26 06:25 cloudsecure-agent-upgrade.sh -rw------- 1 root root 77834705 Apr 26 14:34 cloudsecure-linux-agent-installer-1.617.0.zip
-
為新代理安裝產生一次性令牌。
注意:此步驟產生的一次性令牌與在步驟 1c。
-
-
-
在 Swagger 中,執行 cloudsecure_installers.agent > /v1/cloudsecure/agent/oneTimeToken API 並從回應中複製令牌。
-
將一次性令牌匯出為環境變數。
[root@demo-agent ~]# export TOKEN=<<one time token generated in step 7>>
-
如果使用代理伺服器,請將 https_proxy 匯出為環境變量,格式如下。
[root@demo-agent ~]# export HTTPS_PROXY='USER:PASSWORD@PROXY_SERVER:PORT'
-
可選:預設情況下,代理程式和收集器將安裝在路徑“/opt/netapp”中。若要安裝在不同的路徑,請設定以下環境變數”
[root@demo-agent ~]# export AGENT_INSTALL_PATH=/test_user/apps
注意:如果安裝在自訂路徑中,資料收集器和所有其他工件(如代理程式日誌)將僅在自訂路徑內建立。安裝日誌仍將存在於 - /var/log/netapp/cloudsecure/install。
-
返回下載代理安裝程式的目錄並執行“cloudsecure-agent-install.sh”
[root@demo-agent agent_installers]# ./ cloudsecure-agent-install.sh
注意:如果使用者沒有在“bash”shell 中執行,則匯出命令可能不起作用。在這種情況下,步驟 8 至 11 可以合併並按如下所示運行。 HTTPS_PROXY 和 AGENT_INSTALL_PATH 是可選的,如果不需要可以忽略。
sudo /bin/bash -c "TOKEN=<<one time token generated in step 7>> HTTPS_PROXY=<<proxy details in the format mentioned in step 9>> AGENT_INSTALL_PATH=<<custom_path_to_install_agent>> ./cloudsecure-agent-install.sh"
+
此時,代理應該已成功安裝。-
代理安裝的健全性檢查:
-
-
執行「systemctl status cloudsecure-agent.service」並驗證代理服務是否處於_running_狀態。
[root@demo-agent ~]# systemctl status cloudsecure-agent.service cloudsecure-agent.service - Cloud Secure Agent Daemon Service Loaded: loaded (/usr/lib/systemd/system/cloudsecure-agent.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2024-04-26 02:50:37 EDT; 12h ago Main PID: 15887 (java) Tasks: 72 CGroup: /system.slice/cloudsecure-agent.service ├─15887 java -Dconfig.file=/test_user/apps/cloudsecure/agent/conf/application.conf -Dagent.proxy.host= -Dagent.proxy.port= -Dagent.proxy.user= -Dagent.proxy.password= -Dagent.env=prod -Dagent.base.path=/test_user/apps/cloudsecure/agent -... -
代理應該在「代理」頁面中可見,並且處於「連線」狀態。

-
安裝後清理。
-
-
如果代理安裝成功,則可以刪除下載的代理安裝程式檔案。
安裝新的資料收集器。
注意:本文檔包含安裝「ONTAP SVM 資料收集器」的說明。相同的步驟適用於「Cloud Volumes ONTAP資料收集器」和「Amazon FSx for NetApp ONTAP資料收集器」。
-
進入需要安裝收集器的系統,在_agent安裝路徑_目錄下建立一個名為_./tmp/collectors_的目錄。
注意:如果代理程式安裝在 /opt/netapp 中,則導覽至 /opt/netapp/cloudsecure。
[root@demo-agent ~]# cd {agent-install-path}/cloudsecure [root@demo-agent ~]# mkdir -p ./tmp/collectors -
遞歸地將 tmp 目錄的所有權變更為 cssys:cssys(cssys 使用者和群組將在代理安裝期間建立)。
[root@demo-agent /]# chown -R cssys:cssys tmp/ [root@demo-agent /]# cd ./tmp [root@demo-agent tmp]# ll | grep collectors drwx------ 2 cssys cssys 4096 Apr 26 15:56 collectors
-
現在我們需要取得收集器版本和收集器的 UUID。導航至“cloudsecure_config.collector-types”API。
-
到 swagger,「cloudsecure_config.collector-types > /v1/cloudsecure/collector-types」(GET)API。在「collectorCategory」下拉式選單中,選擇收集器類型為「DATA」。選擇“全部”以取得所有收集器類型詳細資訊。
-
複製所需收集器類型的 UUID。

-
下載收集器安裝程式。
-
導覽至「cloudsecure_installers.collector > /v1/cloudsecure/collector-types/installers/{collectorTypeUUID}」 (GET) API。輸入上一步驟複製的 UUID 並下載安裝程式檔案。

-
如果安裝程式檔案是在不同的機器上外部下載的,請將安裝程式檔案複製到代理程式正在執行的系統並放置在目錄 /{agent-install-path}/cloudsecure/tmp/collectors 中。
-
或者,您可以從相同的 API 複製 curl 命令並直接在要安裝收集器的系統上執行它。
請注意,檔案名稱應與下載收集器 API 的回應標頭中的名稱相同。請參見下面的螢幕截圖。
注意:如果代理程式安裝在 /opt/netapp 中,則導覽至 /opt/netapp/cloudsecure/tmp/collectors。

[root@demo-agent collectors]# cd {agent-install-path}/cloudsecure/tmp/collectors [root@demo-agent collectors]# pwd /opt/netapp/cloudsecure/tmp/collectors [root@demo-agent collectors]# curl -X GET "https://netapp-demo.dev.cloudsecure.netapp.com/rest/v1/cloudsecure/collector-types/installers/1829df8a-c16d-45b1-b72a-ed5707129870" -H "accept: application/octet-stream" -H "X-CloudInsights-ApiKey: <<API Access Token>>" -o cs-ontap-dsc_1.286.0.zip -
-
將收集器安裝程式 zip 檔案的擁有權變更為 cssys:cssys。
-rw------- 1 root root 50906252 Apr 26 16:11 cs-ontap-dsc_1.286.0.zip [root@demo-agent collectors]# chown cssys:cssys cs-ontap-dsc_1.286.0.zip [root@demo-agent collectors]# ll total 49716 -rw------- 1 cssys cssys 50906252 Apr 26 16:11 cs-ontap-dsc_1.286.0.zip
-
導覽至 工作負載安全性 > 收集器 並選擇 +收集器。選擇 ONTAP SVM 收集器。
-
配置收集器詳細資料並_儲存_收集器。
-
點選「儲存」後,代理程式將從_/{agent-install-path}/cloudsecure/tmp/collectors/_ 目錄中找到收集器安裝程式並安裝收集器。
-
作為替代選項,除了透過 UI 新增收集器之外,還可以透過 API 新增。
-
導覽至“cloudsecure_config.collectors”>“/v1/cloudsecure/collectors”(POST)API。
-
在範例下拉式選單中,選擇“ONTAP SVM 資料收集器 json 範例”,更新收集器配置詳細資訊並執行。

-
-
收集器現在應該在“數據收集器”部分下可見。

-
安裝後清理。
-
如果收集器安裝成功,則可以刪除目錄 /{agent-install-path}/cloudsecure/tmp/collectors 中的所有檔案。
-
安裝新的使用者目錄收集器
注意:在本文檔中,我們提到了安裝 LDAP 收集器的步驟。安裝 AD 收集器也適用相同的步驟。
-
1.進入需要安裝收集器的系統,在_agent安裝路徑_目錄下建立一個名為_./tmp/collectors_的目錄。
注意:如果代理程式安裝在 /opt/netapp 中,則導覽至 /opt/netapp/cloudsecure。
[root@demo-agent ~]# cd {agent-install-path}/cloudsecure [root@demo-agent ~]# mkdir -p ./tmp/collectors-
將 collectors 目錄的所有權變更為 cssys:cssys
[root@demo-agent /]# chown -R cssys:cssys tmp/ [root@demo-agent /]# cd ./tmp [root@demo-agent tmp]# ll | grep collectors drwx------ 2 cssys cssys 4096 Apr 26 15:56 collectors
-
-
現在我們需要取得收集器的版本和 UUID。導航至“cloudsecure_config.collector-types”API。在 collectorCategory 下拉式選單中,選擇收集器類型為“USER”。選擇“全部”以在單一請求中取得所有收集器類型詳細資訊。

-
複製 LDAP 收集器的 UUID。

-
下載收集器安裝程式。
-
導覽至「cloudsecure_installers.collector」>「/v1/cloudsecure/collector-types/installers/{collectorTypeUUID}」(GET)API。輸入上一步驟複製的 UUID 並下載安裝程式檔案。

-
如果安裝程式檔案是在不同的機器上外部下載的,請將安裝程式檔案複製到代理程式正在執行的系統和目錄 /{agent-installation-path}/cloudsecure/tmp/collectors 中。
-
或者,您可以從相同的 API 複製 curl 命令並直接在應該安裝收集器的系統中執行它。
請注意,檔案名稱應與下載收集器 API 的回應標頭中的名稱相同。請參見下面的螢幕截圖。
另請注意,如果代理程式安裝在 /opt/netapp 中,則導覽至 /opt/netapp/cloudsecure/tmp/collectors。

[root@demo-agent collectors]# cd {agent-install-path}/cloudsecure/tmp/collectors [root@demo-agent collectors]# pwd /opt/netapp/cloudsecure/tmp/collectors [root@demo-agent collectors]# curl -X GET "https://netapp-demo.dev.cloudsecure.netapp.com/rest/v1/cloudsecure/collector-types/installers/37fb37bd-6078-4c75-a64f-2b14cb1a1eb1" -H "accept: application/octet-stream" -H "X-CloudInsights-ApiKey: <<API Access Token>>" -o cs-ldap-dsc_1.322.0.zip -
-
將收集器安裝程式 zip 檔案的擁有權變更為 cssys:cssys。
[root@demo-agent collectors]# ll total 37156 -rw------- 1 root root 38045966 Apr 29 10:02 cs-ldap-dsc_1.322.0.zip [root@demo-agent collectors]# chown cssys:cssys cs-ldap-dsc_1.322.0.zip [root@demo-agent collectors]# ll total 37156 -rw------- 1 cssys cssys 38045966 Apr 29 10:02 cs-ldap-dsc_1.322.0.zip
-
導航至“使用者目錄收集器”頁面並點擊“+ 使用者目錄收集器”。

-
選擇“LDAP 目錄伺服器”。

-
輸入 LDAP 目錄伺服器詳細資訊並點擊“儲存”

-
點選「儲存」後,代理服務將從_/{agent-install-path}/cloudsecure/tmp/collectors/_ 目錄中找到收集器安裝程式並安裝收集器。
-
作為替代選項,除了透過 UI 新增收集器之外,還可以透過 API 新增。
-
導覽至“cloudsecure_config.collectors”>“/v1/cloudsecure/collectors”(POST)API。
-
在範例下拉選單中,選擇“LDAP 目錄伺服器使用者收集器 json 範例”,更新收集器配置詳細信息,然後按一下“執行”。

-
-
現在應該在“用戶目錄收集器”部分下可以看到收集器。

-
安裝後清理。
-
如果收集器安裝成功,則可以刪除目錄 /{agent-install-path}/cloudsecure/tmp/collectors 中的所有檔案。
-
升級代理
當代理/收集器有新版本可用時,將會發送電子郵件通知。
-
下載最新的代理安裝程式。
-
下載最新安裝程式的步驟與「安裝新代理程式」中的步驟類似。在 swagger 中,選擇「cloudsecure_installers.agent」>「/v1/cloudsecure/agents/installers/{platform}/latest」 API,輸入平台「linux」並下載安裝程式 zip 檔案。或者,也可以使用 curl 指令。解壓縮安裝程式檔案。
-
-
設定“cloudsecure-agent-upgrade.sh”檔案的執行權限。
[root@demo-agent agent_installers]# unzip cloudsecure-linux-agent-installer-1.618.0.zip Archive: cloudsecure-linux-agent-installer-1.618.0.zip inflating: cloudsecure-agent-image.zip inflating: cloudsecure-agent-install.sh inflating: cloudsecure-agent-upgrade.sh [root@demo-agent agent_installers]# ll total 153344 -rw------- 1 root root 79154230 Apr 26 2024 cloudsecure-agent-image.zip -rw------- 1 root root 16574 Apr 26 2024 cloudsecure-agent-install.sh -rw------- 1 root root 8586 Apr 26 2024 cloudsecure-agent-upgrade.sh -rw------- 1 root root 77834660 Apr 26 17:35 cloudsecure-linux-agent-installer-1.618.0.zip [root@demo-agent agent_installers]# chmod +x cloudsecure-agent-upgrade.sh [root@demo-agent agent_installers]# ll total 153344 -rw------- 1 root root 79154230 Apr 26 2024 cloudsecure-agent-image.zip -rw------- 1 root root 16574 Apr 26 2024 cloudsecure-agent-install.sh -rwx------ 1 root root 8586 Apr 26 2024 cloudsecure-agent-upgrade.sh -rw------- 1 root root 77834660 Apr 26 17:35 cloudsecure-linux-agent-installer-1.618.0.zip
-
執行“cloudsecure-agent-upgrade.sh”腳本。如果腳本成功運行,它將在輸出中列印訊息「Cloudsecure 代理程式已成功升級。」。
-
執行以下命令“systemctl daemon-reload”
[root@demo-agent ~]# systemctl daemon-reload
-
重新啟動代理服務。
[root@demo-agent ~]# systemctl restart cloudsecure-agent.service
此時,代理應該已成功升級。
-
代理升級後進行健全性檢查。
-
導覽至安裝代理程式的路徑(例如,「/opt/netapp/cloudsecure/」)。符號連結“agent”應該指向新版本的代理。
[root@demo-agent cloudsecure]# pwd /opt/netapp/cloudsecure [root@demo-agent cloudsecure]# ll total 40 lrwxrwxrwx 1 cssys cssys 114 Apr 26 17:38 agent -> /test_user/apps/cloudsecure/cloudsecure-agent-1.618.0 drwxr-xr-x 4 cssys cssys 4096 Apr 25 10:45 agent-certs drwx------ 2 cssys cssys 4096 Apr 25 16:18 agent-logs drwx------ 11 cssys cssys 4096 Apr 26 02:50 cloudsecure-agent-1.617.0 drwx------ 11 cssys cssys 4096 Apr 26 17:42 cloudsecure-agent-1.618.0 drwxr-xr-x 3 cssys cssys 4096 Apr 26 02:45 collector-image drwx------ 2 cssys cssys 4096 Apr 25 10:45 conf drwx------ 3 cssys cssys 4096 Apr 26 16:39 data-collectors -rw-r--r-- 1 root root 66 Apr 25 10:45 sysctl.conf.bkp drwx------ 2 root root 4096 Apr 26 17:38 tmp
-
代理應該在「代理」頁面中可見,並且處於「連線」狀態。

-
-
安裝後清理。
-
如果代理安裝成功,則可以刪除下載的代理安裝程式檔案。
-
升級收集器
注意:所有類型的收集器的升級步驟都是相同的。我們將在本文檔中示範「ONTAP SVM」收集器升級。
-
前往需要升級收集器的系統,並在_代理安裝路徑_目錄下建立目錄_./tmp/collectors_(如果尚不存在)。
注意:如果代理程式安裝在 /opt/netapp 中,則導覽至 /opt/netapp/cloudsecure 目錄。
[root@demo-agent ~]# cd {agent-install-path}/cloudsecure [root@demo-agent ~]# mkdir -p ./tmp/collectors -
確保目錄“collectors”歸 cssys:cssys 所有。
[root@demo-agent /]# chown -R cssys:cssys tmp/ [root@demo-agent /]# cd ./tmp [root@demo-agent tmp]# ll | grep collectors drwx------ 2 cssys cssys 4096 Apr 26 15:56 collectors
-
在 swagger 中,導覽至「cloudsecure_config.collector-types」GET API。在“collectorCategory”下拉式選單中,選擇“DATA”(對於使用者目錄收集器,選擇“USER”或“ALL”)。
從回應主體複製 UUID 和版本。

-
下載最新的收集器安裝程式檔案。
-
導覽至 cloudsecure_installers.collector > /v1/cloudsecure/collector-types/installers/{collectorTypeUUID} API。輸入從上一步複製的_collectorTypeUUID_。將安裝程式下載到 /{agent-install-path}/cloudsecure/tmp/collectors 目錄。
-
或也可以使用相同API的curl指令。

注意:檔案名稱應與下載收集器 API 的回應頭中的名稱相同。
-
-
將收集器安裝程式 zip 檔案的擁有權變更為 cssys:cssys。
[root@demo-agent collectors]# ll total 55024 -rw------- 1 root root 56343750 Apr 26 19:00 cs-ontap-dsc_1.287.0.zip [root@demo-agent collectors]# chown cssys:cssys cs-ontap-dsc_1.287.0.zip [root@demo-agent collectors]# ll total 55024 -rw------- 1 cssys cssys 56343750 Apr 26 19:00 cs-ontap-dsc_1.287.0.zip
-
觸發升級收集器 API。
-
在 swagger 中,導覽至「cloudsecure_installers.collector」>「/v1/cloudsecure/collector-types/upgrade」(PUT)API。
-
在「範例」下拉式選單中,選擇「ONTAP SVM 資料收集器升級 json 範例」以填入範例負載。
-
用從中複製的版本取代版本步驟3並點選“執行”。

等待幾秒鐘。收集器將自動升級。
-
-
健全性檢查。
收集器應該在 UI 中處於運作狀態。
-
升級後清理:
-
如果收集器升級成功,則可以刪除目錄 /{agent-install-path}/cloudsecure/tmp/collectors 中的所有檔案。
-
重複上述步驟來升級其他類型的收集器。
常見問題和修復。
-
AGENT014 錯誤
如果收集器安裝程式檔案不在 /{agent-install-path}/cloudsecure/tmp/collectors 目錄中或無法存取,則會出現此錯誤。確保安裝程式檔案已下載,並且_collectors_和安裝程式 zip 檔案的完整目錄結構歸 cssys:cssys 所有,然後重新啟動代理服務:systemctl restart cloudsecure-agent.service。

-
未授權錯誤
{ "errorMessage": "Requested public API is not allowed to be accessed by input API access token.", "errorCode": "NOT_AUTHORIZED" }如果產生 API 存取權杖時沒有選擇所有必要的 API 類別,則會顯示此錯誤。透過選擇所有必要的 API 類別來產生新的 API 存取令牌。