OGG 12.3 MA中最大的变化就是使用了restful api,在前面介绍的各个服务模块,其实就是引用restful api开发而来,这些API同时也提供对外的集成接口,详细接口可参考:

http://docs.oracle.com/goldengate/c1230/gg-winux/OGGRA/QuickStart.html

服务分类

GoldenGate 12.3 MA架构介绍系列(4)–Restful API介绍-LMLPHP  GoldenGate 12.3 MA架构介绍系列(4)–Restful API介绍-LMLPHP

从上面可以看出,主要按服务模块分类,各服务模块又根据包含的功能分类GoldenGate 12.3 MA架构介绍系列(4)–Restful API介绍-LMLPHP

GoldenGate 12.3 MA架构介绍系列(4)–Restful API介绍-LMLPHP

通过提供的API,可以在定制程序中实现对OGG的完全控制。

使用示例

创建用户

curl -i -X POST -u admin:admin -H "Accept: application/json" -d "{\"credential\":\"test\",\"info\":\"fullname\"}" http://192.168.89.132:9101/services/v2/authorizations/user/test

或者把数据保存到文件后引用

curl -i -X POST -u admin:admin -H "Accept: application/json" --data @Q:\data.json http://192.168.89.132:9101/services/v2/authorizations/user/caidl

data.json:

{

"credential":"test",

"info":"test user #3"

}

删除用户

curl -i -X DELETE -u admin:admin -H "Accept: application/json" http://192.168.89.132:9101/services/v2/authorizations/user/test

response

HTTP/1.1 401 Unauthorized

Content-Security-Policy: script-src 'self' 'unsafe-eval' 'unsafe-inline'

X-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

X-Content-Type-Options: nosniff

Cache-Control: max-age=0, no-cache, no-store, must-revalidate

Pragma: no-cache

Expires: 0

Set-Cookie: ogg.sca…;

Domain=192.168.89.132; Path=/; HttpOnly

Content-Type: application/json

Content-Length: 559

{"$schema":"api:standardResponse","links":[{"href":"http://192.168.89.132:9101/services/v2/authorizations/user/test","mediaType":"application/json","rel":"canonical"},{"href":"http://192.168.89.132:9101/services/v2/authorizations/user/test","mediaType":"application/json","rel":"self"}],"messages":[{"$schema":"ogg:message","code":"OGG-12070","issued":"2017-12-23T12:06:42Z","severity":"ERROR","title":"'test' cannot be located in the user database for the specified role. 'user'.","type":http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2}]}

创建extract

ogg_ext.json

{

"config":[

"Extract EXT2",

"ExtTrail X2 Format Release 12.3",

"UseridAlias ggsrc",

"Table tkggadmin.*;"

],

"source":{

"tranlogs":"classic"

},

"credentials":{

"alias":"ggsrc"

},

"registration":"default",

"begin":"now",

"targets":[

{

"name":"X2"

}

]

}

curl -i -X POST -u admin:admin -H "Accept: application/json" --data @Q:\ogg_ext.json http://192.168.89.132:9101/services/v2/extracts/EXT2


获取各个服务的信息

[oracle@ol73 ~]$ curl -i -X GET -u admin:admin -H "Content-Type: application/json" http://192.168.89.132:9100/services/v2/deployments/demo1/services

HTTP/1.1 200 OK

Content-Security-Policy: script-src 'self' 'unsafe-eval' 'unsafe-inline'

X-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

X-Content-Type-Options: nosniff

Cache-Control: max-age=0, no-cache, no-store, must-revalidate

Pragma: no-cache

Expires: 0

Set-Cookie: =; Domain=192.168.89.132; Path=/; HttpOnly

Content-Type: application/json

Content-Length: 1764

{"$schema":"api:standardResponse","links":[{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services","mediaType":"application/json","rel":"canonical"},{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services","mediaType":"application/json","rel":"self"},{"href":"http://192.168.89.132:9100/services/v2/metadata-catalog/services","mediaType":"application/schema+json","rel":"describedby"}],"messages":[],"response":{"$schema":"ogg:collection","items":[{"$schema":"ogg:collectionItem","links":[{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services","mediaType":"application/json","rel":"parent"},{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services/adminsrvr","mediaType":"application/json","rel":"canonical"}],"name":"adminsrvr"},{"$schema":"ogg:collectionItem","links":[{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services","mediaType":"application/json","rel":"parent"},{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services/distsrvr","mediaType":"application/json","rel":"canonical"}],"name":"distsrvr"},{"$schema":"ogg:collectionItem","links":[{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services","mediaType":"application/json","rel":"parent"},{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services/pmsrvr","mediaType":"application/json","rel":"canonical"}],"name":"pmsrvr"},{"$schema":"ogg:collectionItem","links":[{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services","mediaType":"application/json","rel":"parent"},{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services/recvsrvr","mediaType":"application/json","rel":"canonical"}],"name":"recvsrvr"}]}}

获取admin server 信息

[oracle@ol73 ~]$ curl -i -X GET -u admin:admin -H "Content-Type: application/json" http://192.168.89.132:9100/services/v2/deployments/demo1/services/adminsrvr

HTTP/1.1 200 OK

Content-Security-Policy: script-src 'self' 'unsafe-eval' 'unsafe-inline'

X-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

X-Content-Type-Options: nosniff

Cache-Control: max-age=0, no-cache, no-store, must-revalidate

Pragma: no-cache

Expires: 0

Set-Cookie: sruY=; Domain=192.168.89.132; Path=/; HttpOnly

Content-Type: application/json

Content-Length: 798

{"$schema":"api:standardResponse","links":[{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services/adminsrvr","mediaType":"application/json","rel":"canonical"},{"href":"http://192.168.89.132:9100/services/v2/deployments/demo1/services/adminsrvr","mediaType":"application/json","rel":"self"},{"href":"http://192.168.89.132:9100/services/v2/metadata-catalog/service","mediaType":"application/schema+json","rel":"describedby"}],"messages":[],"response":{"$schema":"ogg:service","config":{"authorizationDetails":{"common":{"allow":["Basic","x-Cert"]}},"authorizationEnabled":true,"legacyProtocolEnabled":true,"network":{"serviceListeningPort":9101},"security":false,"taskManagerEnabled":true,"workerThreadCount":5},"configForce":true,"enabled":true,"quiet":true,"status":"running"}}

至此,有关goldengate 12.3 micorservice architect的介绍到此结束。

04-14 23:13