apollo api调用初始化配置

程序员 2024-10-4 22:24:26 67 0 来自 中国
1、登录(apollo/admin 超管) 获取登录的Cookies,手动存起来

curl -u apollo:admin --X POST 'http://$apollo-portal:8070'2、创建项目(目标: 生成默认的application和用户的App)

curl --location --request POST --X POST 'http://$apollo-portal:8070/apps' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=BD705E7B2B7C61BF5277E6857421E5DE' \--header 'Content-Type: application/json' \--data '{"appId": "tianzehao123","name": "tianzehao123","orgId": "TZH","orgName": "大数据与区块链研发中央","ownerName": "apollo","admins": []}'3、创建第三方应用(目标: 注册Apollo的开放平台,得到token)

curl --location --request POST --X POST 'http://$apollo-portal:8070/consumers' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=B75B99ECEEFCBFF64D07FC6625295D59' \--header 'Content-Type: application/json' \--data '{"appId": "tainzehao123","name": "tainzehao123","orgId": "TZH","orgName": "大数据与区块链研发中央","ownerName": "apollo"}'4、赋权 【Namespace级别权限包罗: 修改、发布Namespace。应用级别权限包罗: 创建Namespace、修改或发布应用下任何Namespace】(这里我们采用应用级别权限)Namespace级别权限:

curl --location --request POST --X POST 'http://$apollo-portal:8070/consumers/df7c0b67fb0ac60326080d97937c881a039560cc/assign-role?type=NamespaceRole' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=B75B99ECEEFCBFF64D07FC6625295D59' \--header 'Content-Type: application/json' \--data '{"appId": "tainzehao123","namespaceName": "application"}'5、项目配置

5.1、创建NameSpace

curl --location --request POST --X POST 'http://$apollo-portal:8070/openapi/v1/apps/tainzehao123/appnamespaces' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Authorization: df7c0b67fb0ac60326080d97937c881a039560cc' \--header 'Content-Type: application/json' \--data '{"appId": "tainzehao123","name": "TZH.fc.sssoo","comment": "吞吞吐吐","isPublic": false,"format": "properties","dataChangeCreatedBy":"apollo"}'5.2、关联namespace(目标: 利用公共配置) 利用cookie

curl --location --request POST --X POST 'http://$apollo-portal:8070/apps/tianzehao123/namespaces' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=BD705E7B2B7C61BF5277E6857421E5DE' \--header 'Content-Type: application/json' \--data '[    {        "env": "RO",        "namespace": {            "appId": "tianzehao123",            "clusterName": "default",            "namespaceName": "TZH.TZH.fc.sssoo"            }        }]'5.3、新增配置接口

curl --location --request POST --X POST 'http://$apollo-portal:8070/openapi/v1/envs/PRO/apps/tainzehao123/clusters/default/namespaces/TZH.fc.sssoo/items' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Authorization: 7c3a748be5087b86795ecbe92f914bd3a2567683' \--header 'Content-Type: application/json' \--data '{"key": "env11","value": "sit11","comment": "huanjing","dataChangeCreatedBy": "apollo"}'5.4、修改配置

curl --location --request PUT --X PUT 'http://$apollo-portal:8070/openapi/v1/envs/PRO/apps/inc-bst-sdp-exet-external/clusters/default/namespaces/TZH.TZH.fc.sssoo/items/asd' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Authorization: df7c0b67fb0ac60326080d97937c881a039560cc' \--header 'Content-Type: application/json' \--data '{"key": "asd","value": "sit12","comment": "huanjing","dataChangeLastModifiedBy": "apollo","dataChangeCreatedBy": "apollo"}'5.4、发布配置接口

curl --location --request POST --X POST 'http://$apollo-portal:8070/openapi/v1/envs/PRO/apps/tainzehao123/clusters/default/namespaces/TZH.fc.sssoo/releases' \--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \--header 'Authorization: df7c0b67fb0ac60326080d97937c881a039560cc' \--header 'Content-Type: application/json' \--data '{"releaseTitle": "20220518174157-release","releaseComment": "发布","releasedBy": "apollo"}'6、sql删除project

    delete from ApolloConfigDB.App where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";    delete from ApolloConfigDB.AppNamespace where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";    delete from ApolloConfigDB.Namespace where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";    delete from ApolloConfigDB.Cluster where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";    delete from ApolloPortalDB.App where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";    delete from ApolloPortalDB.AppNamespace where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";7、apollo搭建标题办理

7.1、No available admin server.

报错如下

  Env health check failed, maybe because of meta server down or configure wrong meta server address.  env: PRO, meta server address: http://dsl-bigdata-bdp-dev-07.dsl.com:8070com.ctrip.framework.apollo.common.exception.ServiceException: No available admin server. Maybe because of meta server down or all admin server down.Meta server address: http://dsl-bigdata-bdp-dev-07.dsl.com:8070缘故起因

apollo-portal 支持多环境,这是pro环境的apollo-configservice的服务配置地点错误
办理

vim apollo-env.properties
pro.meta=http://xxxxxxx-07.dsl.com:80807.2、重置暗码

update `Users` set `Password`='$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS' where  id =1附录

初始化脚本;
http://qiniu.asdu.cn/scripts/init_aollo.py
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-11-23 16:25, Processed in 0.147760 second(s), 32 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表