Enterprise Manager Database As A Service REST API Cookbook

Transcription

Enterprise ManagerDatabase as a ServiceREST API Cookbook

Table of ContentsDISCLAIMER . 2INTRODUCTION . 2IMPLEMENTATION REQUIREMENTS . 3IMPLEMENTATION FLOW . 4ADMINISTRATIVE IMPLEMENTATION . 4OPERATIONAL USE . 4JSON VALIDATION & TESTING . 4VERSION CONTROL . 4JSON SYNTAX VALIDATION . 4JSON TESTING . 4INTEGRATION OPPORTUNITIES . 5ADMINISTRATIVE IMPLEMENTATION . 5EMCLI LOGIN . 5CREATE ROLES . 5USER CREATION . 5CREATION ZONES . 6CREATING DATABASE POOLS. 7CREATING QUOTAS . 7ENABLING RESOURCE SETTINGS . 8CREATING A DATABASE PROFILE . 9DEFINING A SERVICE CATALOG . 9CREATING SERVICE TEMPLATES. 1111gR4 w/standby using Database Template . 1112cR2 w/standby using Database Template . 15SERVICE TEMPLATE PRE AND POST SCRIPTS . 19OPERATIONAL IMPLEMENTATION . 2512CR2 DB REQUEST BY ZONE WITH OPTIONAL STANDBY . 2511GR4 DB REQUEST BASED ON ZONE WITH OPTIONAL STANDBY . 25VIEWING DETAILS OF A SERVICE INSTANCE . 26VIEWING DETAILS OF THE ATTRIBUTES OF A SERVICE INSTANCE . 26VIEWING DETAILS OF THE AVAILABLE ACTIONS ON A SERVICE INSTANCE . 26VIEWING DETAILS OF THE ACTION INPUTS REQUIRED TO EXECUTE AN ACTION ON A SERVICE INSTANCE 27START DATABASE . 27DELETE DATABASE . 27VIEWING DETAILS OF A RESOURCE PROVIDER (ZONE OR SOFTWARE POOL) . 27OTHER USEFUL API CALLS . 28CREATE DB SIZES . 28LIST THE DB SIZES AVAILABLE. 28CONCLUSION . 28

DisclaimerThis document is intended to provide direction and requirements for the execution of a Database as a Service(DBaaS) specific to the use of the REST API provided with the Cloud Pack for Oracle Database and should bereviewed/executed in a specific customer’s environment for accuracy. This document is intended to provide anoperational best practices reference only, using calls that will facilitate the administration and execute of theDBaaS features.IntroductionWith the latest release of Oracle Enterprise Manager 12c,enhancements have been made to the REST APIthat now facilitate the administration as well as the operational use of features in the Cloud Pack for Oracledatabase that enable customers to now fully automate the administration of assets. It also facilitates the selfservice model for private cloud, enabling the customer to fully automate the actual request and governors ofdatabase needs by a given Line of Business. (LOBs). Through the use of the REST API, the customer canstreamline the process of delivering critically needed databases to the LOBs at a fraction of the currentOperational Expenses (OPEX) cost. Some critical business benefits are as follows:Standardization – With the implementation of DBaaS REST API the customer will be able to reduce (OPEX)by standardizing the provisioning of databases in a fully automated fashion. That is to say, the databaserequest from various organizations would be self-service and based on a standard build of the databasespecific to the binaries, structure and data.Centralization – With the streamlining of database provisioning via DBaaS REST API, the customer cancentralize the overall management and lifecycle of the entire private cloud landscape and ensure that servicelevels are maintained as well as ensuring that the service offerings meet the customer’s needs.Simplification – With a central and standard delivery model, the customer will also simplify the entireconfiguration landscape. This will reduce OPEX by way of reducing the number of Oracle Homes (OH) anddatabases being managed. Consolidation of OHs and databases will also contribute to a reduction in CapitalExpense (CAPEX) by ensuring that the customer maximizes the use of existing resources in a datacenter orensure that pending purchases are fully used. Finally, the simplification and consolidation will also reduceCAPEX by reducing environments in the datacenter itself. This translates to reduced power, A/C and areduction in real estate required to satisfy the business needs while ensuring that IT can provide the properenvironments, maintaining world-class standards for the business.2ENTERPRISE MANAGER DATABASE AS A SERVICE REST API COOKBOOK

Implementation RequirementsPrior to using the REST API, it is critical to have all the required Packs installed in Enterprise Manager. ThesePacks enable the functionality and empower the customer to take advantage of all the OPEX and CAPEXsavings by way of streamlining IT and business process.The following are the software requirements: Database Lifecycle Management Pack (DBLM) – This pack is used in the provisioning of thedatabase itself. That is to say, the foundation of Database as a Service is the speed of implementationof a DB build or the “time to market”. The DBLM Pack enables this with standard “out of the box”features that enable the customer to implement very quickly with no required customizations. Otherfeatures in the pack enable the customer to manage patching of DBs, configuration management andsecurity compliance. The provisioning features of the pack are what enable the backend requirementsfor the Cloud Pack for Oracle Database. Cloud Management Pack for Oracle Database – This is the “heart” of the DBaaS offering andenables the actual REST API. Once this pack is enabled, the customer has access to all the richfeatures in the REST API that will be discussed in this document. This unlocks the administration anduse of the DBaaS offering in Enterprise Manager. This includes the Self Service Portal, REST API,and administration of zones, pools, quotas and service templates. Finally, the Cloud Pack for OracleDatabase enables metering of resources being used in your private cloud estate. This includeschargeback/show back of resources used at the OS and DB level to ensure that proper accounting iskept for resource usage in your private cloud. EM Command Line Installation (EMCLI) – Prior to the full implementation of the DBaaS RESTintegration, you will need to install the EM on a central orchestration server. The following are thedetails as to the installation:oDownload the EMCLI code:§wget --no-check-certificatehttps:// your em host:port /em/public lib download/emcli/kit/emclikit.jar§setenv JAVA HOME /usr/local/packages/j2sdk1.6.0 43§ JAVA HOME/bin/java -jar emclikit.jar -install dir em cli home dir §/emcli setup -url "EM-URL" -username sysman -password passwd -trustallOnce the installation is complete, you will be ready to use the EMCLI call to obtain various inputsrequired to execute a specific REST call. Access to the “EMCLI” executable should be very limitedto the user on the host who would be executing the orchestration via the REST calls.3ENTERPRISE MANAGER DATABASE AS A SERVICE REST API COOKBOOK

Implementation FlowWith the implementation of DBaaS and the use of the REST API, there is a specific implementation flow. Thatprocess is outlined in this document, based on operational best practices.Administrative implementationThis is the setup and administration of the artifacts that will drive the private cloud implementation in yourenvironment. With the implementation of a private cloud, one should change the way they think of allocatingresources for the building of databases. In the “old days” one would create all of the storage, OS and networkrequirements for each and every database that was requested or built. With a private cloud setup, theresources are “pooled” and therefore, the setup and administration of the private cloud resources are managedon an “as required” basis. Once the zones, pools and storage are allocated to the private cloud environment,the customer only manages by exception and enables the end user to access those resources when needed,streamlining the entire build process. The build of the “cloud framework” is completed first before the user canconsume the private cloud resources.Operational UseThis is when and how the customer actually begins to consume the private cloud resources. This is where “therubber hits the road” as they say. Once the administrative tasks are completed and setup in a standard fashionas to simply and reduce OPEX, the service templates then can be offered to the consumer via EnterpriserdManager REST API. A 3 party orchestration tool can then access the REST API and make calls to theautomation framework in Enterprise Manager, based on input from the customer or workflow process. Thisevokes the use of the REST API and the resources are built in a fully automated fashion. Once the customerhas completed the administrative tasks and further incorporated the operational use cases into the workflow,you now begin to see further OPEX reduction as well as a streamlining of asset delivery to the customer, thereduction of “time to market’.JSON Validation & TestingVersion ControlSpecific to JSON, this document references V1 and V2 specific to the calls offered in the Cloud Pack for OracleDatabase. Oracle continues to simplify the calls, working hard to improve the ease of implementation of theREST API. V2 is the primary focus in this document and V1 calls are used at this time to round out therequirements. Eventually, the V1 version will be deprecated and will be announced via the standard OracleSupport channels.JSON Syntax ValidationAs you exercise the required calls, adjustments will be required. In coding the bodies of each JSON call, it willbe critical to ensure that the syntax is correct and as well, avoid “code frustrations”. From a best practicesperspective, Oracle recommends you use a JSON syntax validation tool. We frequently use the JSON codevalidation tool here. Simply copy the required body code into the JSONLint tool and click “validate”. This willtell you if the JSON body code is authored correctly. Once validated, you can be confident that the JSON bodyis structured correctly.JSON TestingTo execute a give JSON call, you will need a tool to validate the call as well as the ability to review the return ofa given call. As a best practice, Oracle recommends you use the Chrome Postman RESTful Client.rdPostman will enable you to exercise the required calls before working to fully integrate into the desired 3 partyworkflow/integration tool.4ENTERPRISE MANAGER DATABASE AS A SERVICE REST API COOKBOOK

Integration OpportunitiesThe primary drive for using the REST API is to complete the implementation of a fully integrated andautomated flow that will minimize the “human touch” and streamline processes. With the implementation of theREST API, one can take advantage of this automated flow. Cloud Management Pack for Oracle Database is acritical piece of the integration and will enable the customers to provision and administer Oracle databases aspart of a wider automation strategy. There are a number of tools that can be interfaced with the REST APIincluding Ansible, Putty, Chef, Jenkins and OpenStack just to name a few. As the REST API provided byEnterprise Manager is based on standard JSON calls, it is wide open to interface with whatever automationsolution a customer chooses that can interface with REST APIs.Administrative ImplementationThe following section outlines the flow and calls required to implement a private cloud via the CloudManagement Pack for Oracle Database REST API. This flow will ensure that you have the proper foundationin place to successfully deploy your private cloud via REST API.The administrative flow incorporates the use of the Enterprise Manager Command Line Interface (EMCLI) aswell as the Cloud REST API as some of the setup requirements focus on user creation and DB creation thatare part of the core EM functionality. Additional documentation around the EMCLI can be found here. We willprovide the calls needed to complete the administrative flow in this document.As well in this section, you will see actual REST API calls that should be used to execute administrative tasks.Note that under each REST API call, there are “Actions”. These are helpful notes to assist in obtaining all ofthe input variables for a give call. Remember, these are critical in the successful use of any give REST APIcall.EMCLI LoginPrior to executing the below EMCLI commands, one needs to log into the EMCLI, as follows; OMS HOME/oms/bin/emcli login -username sysman (password will be requested after submission)Create RolesAll entitlements are driven by roles in Enterprise Manager for the UI and the REST API is no different. Thereare specific roles needed to access the REST API. Before we can enable these features for a given user, theroles that are to be assigned to the user need to be created. Use the following to create the proper roles: OMS HOME/oms/bin/emcli create role -name “ACME DBAAS ROLE” -type ”em role” -description ”CloudRole” -roles ”em ssa user”User CreationBefore we can use the REST API to call a service template request for a database, we need to authenticateinto the REST API. This is no different than the login requirement at the UI level and drives all privileges usedin the REST API by the user login. All access and entitlements for private cloud implementation are driven byroles and user accounts in Enterprise Manager. Use the following to create a user in Enterprise Managerspecific to Cloud: OMS HOME/oms/bin/emcli create user -name ”ACME DBAAS USER” -password ” user password ” –type ”em user” -roles ”cloud role” -email user@domain.com -desc ”cloud user”5ENTERPRISE MANAGER DATABASE AS A SERVICE REST API COOKBOOK

Creation ZonesZones are based on a group of OS/hosts that are managed targets in Enterprise Manger. Prior to creating thezones, the agents must be deployed to the OS/host. Additional information on agent deployment can be foundhere. Remember, an OS/host can be part of only one zone and the zones are based on location, OS version andtype (i.e., RAC or Single Instance). Use the following REST API call to create a zone:FeatureURIRequest headersBodyNote: hosts can onlybelong to one : basic ZGVtb3VzZXI6ZGVtb3VzZXI Content-Type: application/json{"useExistingTarget": false,"name": "ACME PAAS ZONE","type": "self service zone","memberTargetType": "host","members": mydomain.com"],Action: Get the"credentials": {"name": "normal credential guid","value": "NC HOST ORACLE"credential guid via ./emclilist named credentials noheader grep –I replace cred name awk '{ print 1}’Request method},"placementConstraints": [{"name": "MAX CPU UTILIZATION","value": "80"},{"name": "MAX MEMORY ALLOCATION","value": "80"}],"memberConstraints": []}POST6ENTERPRISE MANAGER DATABASE AS A SERVICE REST API COOKBOOK

Creating Database PoolsOnce the Zone is created, the next step is to create the DB Pool. A DB Pool is simply an Oracle Home (OH).There will be multiple pools in a zone. That is to say, you would have more than one OH on an OS/host. In mostcases you will have a single ZONE with multiple DB pools (OHs). The following will create a pool based ondiscovered Oracle Homes and named credentials created proper to private cloud setup.FeatureURIRequest headersBodyAction: Get the OHmembers via ./emcliget targets targets \"%sidb%:oracle home\"Action: Get the credGUID via emcliget named credential cred name "host cred"”Request on: basic ZGVtb3VzZXI6ZGVtb3VzZXI Content-Type: application/json{"name": "11gR2 4 RAC Pool","poolTargetType": "oracle cloud zone","description": "RAC Database Pool of Oracle Homes of version 11.2.0.4","paasZone": "ACME PAAS ZONE","members": ["OraDB11g home2 2015 11 11 11 06 36 exd1db05.mydomain.com","OraDB11g home2 2015 11 11 11 06 34 exd1db06.mydomain.com","OraDB11g home2 2015 11 11 11 06 34 exd1db07.mydomain.com","OraDB11g home2 2015 11 11 11 06 35 exd1db08.mydomain.com"],"serviceFamily": "DBAAS","serviceType": "DBAAS","constraints": {"items": [{"name": "MAX INSTANCES","value": "25"}]},"filters": {"items": [{"name": "CONFIGURATION","value": "rac database"},{"nam

a given call. As a best practice, Oracle recommends you use the Chrome Postman RESTful Client. Postman will enable you to exercise the required calls before working to fully integr