命令行接口是基于PaaS REST API的,它调用这些API来支持PaaS的日常管理维护等工作。例如创建和管理Oracle Java云服务、Oracle数据库云服务实例、Oracle MySQL云服务等等。还支持Oracle Cloud Stack Manager,这是一个能够自动提供和删除云环境的PaaS工具。
下载psm安装包(通过web页面也可以)
curl -X GET -u <USER>:<PWD> -H X-ID-TENANT-NAME:<IDENTITY_DOMAIN> https://<REST_SERVER>/paas/core/api/v1.1/cli/<IDENTITY_DOMAIN>/client -o psmcli.zip
Where <USER> and <PWD> are the credentials <IDENTITY_DOMAIN> is the Identity Domain ID specified during the account creation <REST_SERVER> is the REST API server name which is: psm.us.oraclecloud.com if you are using a US datacenter psm.aucom.oraclecloud.com if you are in the AuCom region psm.europe.oraclecloud.com otherwise安装psm
pip install -U psmcli.zip
配置psm(两种方式,任选一种)
psm setup(交互式配置)
psm setup -c profile.json(通过配置文件)
{ "username":"<USER>", "password":"<PASSWORD>", "identityDomain":"<IDENTITY_DOMAIN>", "region":"<REGION>", "outputFormat":"<OUTPUT_FORMAT>", "oAuth":{ "clientId":"", "clientSecret":"", "accessTokenServer":"" } }
psm命令的模式
psm <product> <command> <parameters>
Where product is the Oracle cloud product e.g. dbcs, analytics, BigDataAppliance, for a complete list use psm help command is the action to be executed against the product e.g. services, stop, start, create-service parameters is the list of parameters to pass depending on the command executed以数据库服务为例
psm dbcs services (查看数据库服务信息)
psm dbcs start/stop/restart -s <INSTANCE_NAME>(启动或停止数据库服务的信息)
psm dbcs operation-status -j <JOB_ID>(查看JOB的状态)
创建一个数据库实例
$ psm dbcs create-service --config-payload create_db12c-ee.json"Accepted" Job ID : 553993
查看JOB的状态
$ psm dbcs operation-status --job-id 553993
{ "activityLogId":241360, "authDomain":"usexample", "authUser":"dbaasadmin", "endDate":"2016-05-03T05:05:14.192+0000", "identityDomain":"usexample", "initiatedBy":"USER", "jobId":553993, "messages":[ { "activityDate":"2016-05-03T04:33:34.809+0000", "message":"Activity Submitted" }, { "activityDate":"2016-05-03T04:33:38.379+0000", "message":"Activity Started" }, { "activityDate":"2016-05-03T04:40:20.762+0000", "message":"Started all Compute resources..." }, { "activityDate":"2016-05-03T04:40:21.639+0000", "message":"SSH access to VM [DB_1/vm-1] succeeded..." }, { "activityDate":"2016-05-03T04:58:38.863+0000", "message":"Oracle Database Server Configuration completed..." }, { "activityDate":"2016-05-03T05:04:43.178+0000", "message":"Service Reachabilty Check (SRC) of Oracle Database Server completed..." }, { "activityDate":"2016-05-03T05:04:43.247+0000", "message":"Successfully provisioned Oracle Database Server..." }, { "activityDate":"2016-05-03T05:05:14.192+0000", "message":"Activity Ended" } ], "operationId":23156, "operationType":"CREATE_SERVICE", "serviceId":23156, "serviceName":"db12c-ee", "serviceType":"dbaas", "startDate":"2016-05-03T04:33:34.809+0000", "status":"SUCCEED", "summaryMessage":"CREATE_SERVICE" }create_db12c-ee.json脚本内容
{ "serviceName": "db12c-ee", "version": "12.1.0.2", "level": "PAAS", "edition": "EE", "subscriptionType": "MONTHLY", "shape": "oc3", "vmPublicKeyText": "ssh-rsa AAAAB3Nz...", "parameters": [ { "type": "db", "usableStorage": "25", "adminPassword": "password", "sid": "ORCL", "backupDestination": "BOTH", "cloudStorageContainer": "Storage-usexample\/dbcsbackups", "cloudStorageUser": "dbaasadmin", "cloudStoragePwd": "password" } ] }
https://docs.oracle.com/en/cloud/paas/java-cloud/pscli/abouit-paas-service-manager-command-line-interface.html
https://docs.oracle.com/en/cloud/paas/java-cloud/pscli/dbcs-create-service.html
https://apicatalog.oraclecloud.com/ui/
http://www.oracledbwr.com/18c-dataguard/oracle-18c-performing-a-data-guard-failover-using-dbcs-console/
http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/objectstorage/creating_containers_REST_API/files/installing_curl_command_line_tool_on_windows.html