GCP ops agent安装

GCP ops agent安装

首页枪战射击C-Ops重装上阵更新时间:2024-04-27

作者:MeshCloud脉时云公有云架构师 王高利

Ops Agent 是用于从 Compute Engine 实例收集遥测数据的主要代理。通过将日志记录和指标组合到单个代理中,Ops Agent 对日志使用 Fluent Bit(支持高吞吐量日志记录),对指标使用 OpenTelemetry 收集器。

命令安装:

curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh sudo bash add-google-cloud-ops-agent-repo.sh --also-install

返回消息:消息中存在installation succeeded时,表示安装成功

google-cloud-ops-agent 0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded. Need to get 45.2 MB of archives. After this operation, 143 MB of additional disk space will be used. Get:1 https://packages.cloud.google.com/apt google-cloud-ops-agent-bullseye-all/main amd64 google-cloud-ops-agent amd64 2.22.0~debian11 [45.2 MB] Fetched 45.2 MB in 8s (5763 kB/s) Selecting previously unselected package google-cloud-ops-agent. (Reading database ... 53759 files and directories currently installed.) Preparing to unpack .../google-cloud-ops-agent_2.22.0~debian11_amd64.deb ... Unpacking google-cloud-ops-agent (2.22.0~debian11) ... Setting up google-cloud-ops-agent (2.22.0~debian11) ... Created symlink /etc/systemd/system/multi-user.target.wants/google-cloud-ops-agent.service → /lib/systemd/system/google-cloud-ops-agent.service. google-cloud-ops-agent installation succeeded.控制台安装:

复制安装命令,在机器内部或cloud shell执行。

安装后效果:

其他:

若在控制台安装报错,可根据引导进行排查。

案例:

root@dasan:~# :> agents_to_install.csv && \ echo '"projects/test-202/zones/asia-northeast1-b/instances/dasan","[{""type"":""ops-agent""}]"' >> agents_to_install.csv && \ curl -sSO https://dl.google.com/cloudagents/mass-provision-google-cloud-ops-agents.py && \ python3 mass-provision-google-cloud-ops-agents.py --file agents_to_install.csv See log files in folder: ./google_cloud_ops_agent_provisioning/20221021-081619_347828 2022-10-21T08:16:19.348823Z Processing instance: projects/test-202/zones/asia-northeast1-b/instances/dasan. ---------------------Getting output------------------------- Progress: |==================================================| 100.0% [1/1] (100.0%) completed; [0/1] (0.0%) succeeded; [1/1] (100.0%) failed; Instance: projects/test-202/zones/asia-northeast1-b/instances/dasan fails to run ops-agent. See log file in: ./google_cloud_ops_agent_provisioning/20221021-081619_347828/test-202_asia-northeast1-b_dasan.log SUCCEEDED: [0/1] (0.0%) FAILED: [1/1] (100.0%) COMPLETED: [1/1] (100.0%) root@dasan:~# cat ./google_cloud_ops_agent_provisioning/20221021-081619_347828/test-202_asia-northeast1-b_dasan.log Installing ops-agent WARNING: The private SSH key file for gcloud does not exist. WARNING: The public SSH key file for gcloud does not exist. WARNING: You do not have an SSH key for gcloud. WARNING: SSH keygen will be executed to generate a key. Generating public/private rsa key pair. Your identification has been saved in /root/.ssh/google_compute_engine Your public key has been saved in /root/.ssh/google_compute_engine.pub The key fingerprint is: SHA256:wBfr/SytA05DrAEfS8ssPwktzxSY 40cfKvu556r3fw root@dasan The key's randomart image is: ---[RSA 3072]---- | o . | | . o | | Xo*o | | = % . | | @ XS.. | | @ * | | = o. | | ..o .o | | o =*. oE | ----[SHA256]----- ERROR: (gcloud.compute.ssh) Could not fetch resource: - Request had insufficient authentication scopes.

解决方案:

需要gcloud授权通过gcloud auth login后,再次执行安装命令即可。

test@cloudshell:~ (test-202)$ :> agents_to_install.csv && echo '"projects/test-202/zones/asia-northeast1-b/instances/dasan","[{""type"":""ops-agent""}]"' >> agents_to_install.csv && curl -sSO https://dl.google.com/cloudagents/mass-provision-google-cloud-ops-agents.py && python3 mass-provision-google-cloud-ops-agents.py --file agents_to_install.csv See log files in folder: ./google_cloud_ops_agent_provisioning/20221021-082008_345601 2022-10-21T08:20:08.347387Z Processing instance: projects/test-202/zones/asia-northeast1-b/instances/dasan. ---------------------Getting output------------------------- Progress: |==================================================| 100.0% [1/1] (100.0%) completed; [1/1] (100.0%) succeeded; [0/1] (0.0%) failed; Instance: projects/test-202/zones/asia-northeast1-b/instances/dasan successfully runs ops-agent. See log file in: ./google_cloud_ops_agent_provisioning/20221021-082008_345601/mec-test-344202_asia-northeast1-b_dasan.log SUCCEEDED: [1/1] (100.0%) FAILED: [0/1] (0.0%) COMPLETED: [1/1] (100.0%)

参考文档:https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/installation

,
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved