---
# System prepended metadata

title: 1/31 私有雲案場排查

---

# 1/31 普漢私有雲告警中心案場排查 (docker)

1. event-handler 顯示錯誤訊息，client token 錯誤
![image](https://hackmd.io/_uploads/S1p9jIP5T.png)

首先要去拿SSO token
```
curl -X POST "http://172.21.84.10:8188/v4.0/auth/native" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"username\": \"iotedge@iotedge.sense\",  \"password\": \"XXXXX\",  \"userDetail\": true}"
```
再去拿 client token 
```
curl -X POST "http://172.21.84.10:8188/v4.0/clients" -H  "accept: application/json" -H  "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJjb3VudHJ5IjoiIiwiY3JlYXRpb25UaW1lIjoxNjkzOTA3MzE1LCJleHAiOjE2OTQxNTY3NzEsImZpcnN0TmFtZSI6IiIsImlhdCI6MTY5NDE1MzE3MSwiaWQiOiI2MThiMGI3OC00YmQxLTExZWUtOWNiZi0wMjQyMGEwMDAwZTIiLCJpc3MiOiJ3aXNlLXBhYXMiLCJsYXN0TW9kaWZpZWRUaW1lIjowLCJsYXN0TmFtZSI6IiIsInJlZnJlc2hUb2tlbiI6ImNmMjY4MjY5LTRlMGQtMTFlZS04YjA1LTAyNDIwYTAwMDAzNSIsInJvbGVzIjpudWxsLCJzY29wZXMiOltdLCJzdGF0dXMiOiJBY3RpdmUiLCJ1c2VyU3Vic2NyaXB0aW9ucyI6W3sic3Vic2NyaXB0aW9uSWQiOiIxMjg5YTY2Yi01ODMzLTRjY2QtODMwYi00YjAzZWExZmM3N2EtYXhhLndpc2UtcGFhcy5jb20uY24iLCJzdWJzY3JpcHRpb25OYW1lIjoiTVBEZWZhdWx0R3JvdXAiLCJzdWJzY3JpcHRpb25Sb2xlIjoiYWRtaW4iLCJjb21wYW55IjoiQXBpTWFuYWdlbWVudCJ9XSwidXNlcm5hbWUiOiJpb3RlZGdlQGlvdGVkZ2Uuc2Vuc2UifQ.BJ81pevsZv0QxTm6BmFPwQIVFWc657JHTNzlBKTiE0L2TJDDohR6hahBMEy1jQDXfSIgNkFpW9EFmmGyD2LVxw" -H  "Content-Type: application/json" -d "{\t\"appName\": \"notification\",\t\"appId\": \"test\",\t\"serviceName\": \"Notification\",\t\"cluster\": \"test\",\t\"workspace\": \"123\",\t\"namespace\": \"test\",\t\"datacenter\": \"test\",\t\"scopes\": []}"
```
透過編輯env檔案，將錯誤修正
```
"clientId": "notification-1694153409",
"clientSecret": "NWQyZWU1YTUtNGUwZS0xMWVlLThiMDUtMDI0MjBhMDAwMDM1",
```

重新啟動服務
```
docker stack rm iotedge
docker stack deploy -c iotedge-ulimate.yaml iotedge
```

2. PG錯誤
![image](https://hackmd.io/_uploads/BkaTm_PqT.png)

連進去PG 然後執行以下指令
```
CREATE GROUP "g_alarmcenter";
CREATE GROUP "g_rw_public"; 
ALTER SCHEMA "public" OWNER TO "g_rw_public";
GRANT ALL on schema public to "g_rw_public";
ALTER DEFAULT PRIVILEGES FOR USER "iotedge" IN SCHEMA public GRANT ALL ON TABLES TO "g_rw_public";
GRANT "g_rw_public" TO "iotedge";
GRANT "g_alarmcenter" TO "iotedge";
GRANT ALL PRIVILEGES ON DATABASE "alarmec" TO "iotedge";
```
重啟

3. rabbitmq 錯誤
![image](https://hackmd.io/_uploads/rymF8Ov96.png)

推測是沒有建立vhost，連進去下指令建立
```
rabbitmqctl add_vhost ec
rabbitmqctl set_permissions -p ec root ".*" ".*" ".*"
```

重啟

4. ec 錯誤
![image](https://hackmd.io/_uploads/rJal5dPqp.png)

掛載目錄的權限不夠
```
mkdir /mnt/ec 
```

重啟