OGG 12.3 MA中最大的變化就是使用了restful api,在前面介紹的各個服務模組,其實就是引用restful api開發而來,這些API同時也提供對外的整合介面,詳細介面可參考:
http://docs.oracle.com/goldengate/c1230/gg-winux/OGGRA/QuickStart.html
服務分類
從上面可以看出,主要按服務模組分類,各服務模組又根據包含的功能分類
通過提供的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"}]}} |
[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的介紹到此結束。