GCP
GCE(Google Compute Engine) Ops Agent 설치
misankim
2023. 4. 29. 08:59
GCE(Google Compute Engine) Ops Agent 설치
https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/installation?hl=ko
# linux vm
## ops agent 설치
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
## ops agent 버전 확인(centos)
rpm --query --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n' google-cloud-ops-agent
## ops agent 버전 확인(ubuntu/debian)
dpkg-query --show --showformat '${Package} ${Version} ${Architecture} ${Status}\n' google-cloud-ops-agent
## ops agent 프로세스 상태 확인
systemctl status google-cloud-ops-agent
## ops agent 프로세스 재시작
sudo service google-cloud-ops-agent restart
# windows vm
## ops agent 설치
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.ps1", "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1")
Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall"
(참고) 만약 서명되지 않은 powershell 스크립트를 실행하여 보안 정책 관련 에러가 발생한다면
에러 메시지
PS C:\Users\premisan> Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall"
C:\Users\premisan\add-google-cloud-ops-agent-repo.ps1 : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\premisan\a
dd-google-cloud-ops-agent-repo.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies(https://go.microso
ft.com/fwlink/?LinkID=135170)를 참조하십시오.
위치 줄:1 문자:1
+ C:\Users\premisan\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : 보안 오류: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
현재 보안 정책 설정 확인
ExecutionPolicy
보안 정책 설정 변경
Set-ExecutionPolicy RemoteSigned
보안 정책 설정 변경 후 스크립트 재실행
보안 정책 설정 원복
Set-ExecutionPolicy Restricted
## ops agent 버전 확인
googet installed google-cloud-ops-agent
## http 프록시 설정
setx HTTP_PROXY http://10.10.10.10:3128 /m
setx HTTPS_PROXY http://10.10.10.10:3128 /m
setx no_proxy metadata.google.internal /m
## ops agent 프로세스 재시작
Restart-Service google-cloud-ops-agent -Force
# 로그 수집 설정
https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/configuration?hl=ko
vim /etc/google-cloud-ops-agent/config.yaml
logging:
receivers:
syslog:
type: files
include_paths:
- /var/log/messages
- /var/log/syslog
record_log_file_path: true
squid:
type: files
include_paths:
- /var/log/squid/*.log
record_log_file_path: true
rsyslog:
type: files
include_paths:
- /var/log/rsyslog/*.log
record_log_file_path: true
service:
pipelines:
default_pipeline:
receivers: [syslog, squid, rsyslog]
metrics:
receivers:
hostmetrics:
type: hostmetrics
collection_interval: 60s
processors:
metrics_filter:
type: exclude_metrics
metrics_pattern: []
service:
pipelines:
default_pipeline:
receivers: [hostmetrics]
processors: [metrics_filter]
서비스 재시작
systemctl restart google-cloud-ops-agent