Sei sulla pagina 1di 47

Oracle Cloud Platform

Development
Partner Workshop

Practice Labs for Oracle Java


Cloud Service
Enterprise Application Development on the
Cloud using Oracle Java Cloud Service
Contents
Creating an Oracle Java Cloud Service Instance ........................................................................................ 3
Invoking the Create Oracle Java Cloud Service Instance Wizard ........................................................... 3
Defining the Subscription Type ............................................................................................................ 4
Selecting the Software Release ............................................................................................................ 5
Selecting the Software Edition ............................................................................................................. 6
Configuring the Service Instance .......................................................................................................... 7
Configuring the WebLogic Administrator ........................................................................................... 10
Configuring the Database .................................................................................................................. 10
Configuring the Load Balancer ........................................................................................................... 11
Configuring Backup and Recovery ...................................................................................................... 12
Confirming and Reviewing Your Oracle Java Cloud Service Instance Creation ..................................... 13
Reviewing Your Environment in the WebLogic Server Administration Console ................................... 17
Configuring the Load Balancer in Oracle Traffic Director .................................................................... 22
Deploying an Application to the Oracle Java Cloud Service Instance....................................................... 24
Deploying an Application ................................................................................................................... 24
Starting an Application ...................................................................................................................... 32
Testing an Application ....................................................................................................................... 34
Undeploying an Application ............................................................................................................... 36
Manage Oracle Java Cloud Service instances using REST API .................................................................. 39
Introduction and Prerequisites .......................................................................................................... 39
View All Instances .............................................................................................................................. 41
View a Service Instance ..................................................................................................................... 42
View All Managed Servers ................................................................................................................. 43
Healthcheck on a Service Instance ..................................................................................................... 44
View all Backups ................................................................................................................................ 45
View all Patches ................................................................................................................................. 46
Appendix A: Deleting an already existing JCS instance ........................................................................... 47
Creating an Oracle Java Cloud Service Instance
In this lab, you create an Oracle Java Cloud Service instance. Then, you review the
administration tools (WebLogic Server Administration Console, Fusion Middleware Control,
and Oracle Traffic Director) that help you administer your service instance in the cloud. You will
also use the Java Cloud Service REST API to monitor the Java Cloud Service Instance and
Servers.

Invoking the Create Oracle Java Cloud Service Instance Wizard

To invoke the Create Oracle Java Cloud Service Instance wizard:

1. Sign into the My Services application by clicking the link for JCS environment sent to
you by email (make sure you is not click the DevCS or JCS-SX environment links), by
providing the Identity Domain, Username and Password which have also been provided to you.

The My Services Dashboard is displayed.

2. In the Oracle Java Cloud Service section, click Service Console.


The Oracle Java Cloud Service Console page is displayed.

In the event that you already see an existing JCS instance (possibly from a previous class),
please proceed to Appendix A and complete the steps to delete the instance before returning to
do the next step.

3. To create a new Oracle Java Cloud Service instance, in the console click Create Service.

The Create Java Cloud Service Instance wizard is invoked, displaying the Subscription Type
page.
Defining the Subscription Type

Use the Subscription Type page to select the service level and billing frequency.
1. Select one of the following service levels:
o Oracle Java Cloud Service: Production-level service that supports Oracle Java
Cloud Service instance creation and monitoring. It also supports backup and recovery,
patching, and scaling.
o Oracle Java Cloud Service - Virtual Image: Developer-level service that supports
Oracle Java Cloud Service instance creation and monitoring.
For this tutorial, select Oracle Java Cloud Service.
2. Select one of the following billing frequencies:
o Hourly: Pay for the number of hours used during your billing period.
o Monthly: Pay one price for the full month irrespective of the number of hours
used.
For this tutorial, select Monthly. Then click Next.
Selecting the Software Release

Select the Oracle WebLogic Server software release that you want to run on your service
instance.

For this tutorial, select Oracle WebLogic Server 12c (12.1.3.0) Then click Next.
Selecting the Software Edition

Select the Oracle WebLogic Server software edition that you want to run on your service
instance.

For this tutorial, select Enterprise Edition. Then click Next.

Enterprise Edition includes all the features and benefits of Oracle WebLogic Server Standard
Edition plus proven clustering technology, cross-domain management, and comprehensive
diagnostic tooling.
Configuring the Service Instance

The Service Details page appears. On this page, you configure details in the following areas:
Service instance configuration
WebLogic Server configuration
Database configuration
Load balancer configuration
Backup and recovery configuration

If at anytime you are not sure about how to complete a field, click the Help icon adjacent to the
field for assistance (as shown in the following figure).
Configure the service instance details by completing the fields in the Service
Configuration section.
1. Enter a display name for the service instance in the Service Name field.
The name must be unique within your identity domain. For this tutorial, enter WlsJCS.
2. Optionally enter a description of the service instance in the Description field.
3. Select the number of Manged Servers to create in the WebLogic Server cluster from
the Cluster Size drop-down list.
For this tutorial, select 2. When you select 2 or more, a load balancer is automatically enabled in
the wizard. While you can elect to disable the load balancer, Oracle recommends for clusters
with two or more Managed Servers that the load balancer be enabled. You'll configure the load
balancer later.
4. Select a compute shape from the Shape drop-down list.
The compute shape specifies the number of Oracle Compute Units (OCPUs) and amount of
memory (RAM) allocated for each VM on the new service instance. Oracle Java Cloud Service
offers several OCPU/RAM combinations. The larger the compute shape, the greater the
processing power.
For this tutorial, select OC3 - 1 OCPU, 7.5 GB RAM to allocate one OCPU and 7.5 GBs of
memory for each VM on the new service instance. This selection gives you a moderately-sized
compute shape to work with.
5. Associate the public key of the SSH key pair provided in the support files folder by
clicking Edit next to the SSH Public Key field.
Note: For this tutorial, you will upload the public key, DemoSSHKey.pub available in the
Supporting Files folder.

Select the key file name of the SSH public key, by clicking Browse, selecting the public key
file that you have downloaded, and clicking Enter. The file you select will be uploaded to your
service instance virtual machine during this service creation process.

Select the checkbox for Enable access to Administration Consoles as below.


Configuring the WebLogic Administrator

Configure the WebLogic administrator user name and password by completing the fields in
the WebLogic section. You will use the user name and password specified to access the
administration consoles later in this tutorial. For this lab use:weblogic/myweblogic1.
Optionally, select the Deploy Sample Application checkbox to deploy automatically a sample
application during provisioning.

Configuring the Database

Configure the database by completing the fields in the Database Configuration section.
1. Select the Oracle Database Cloud - Database as a Service instance from the Name drop-
down list.
2. Set the PDB Name field to <use default>.
In this case, the PDB name provided with the Oracle Database Cloud - Database as a Service
instance was created will be used.
3. Enter the user name, SYS, and password, ********* in the Administrator User
Name and Password fields, respectively. For your lab, this is:
Username: Sys Password: Welcome_1
Note: For service instances based on Oracle WebLogic Server 12c (12.1.3), this value must be
set to a database user with SYSDBA system privileges. You can use the default user SYS or
any user that has been granted the SYSDBA system privilege.
Configuring the Load Balancer

Configure the load balancer by completing the fields in the Load Balancer section.

Recall, when you selected a cluster size of 2 when configuring the service instance details, the
load balancer was enabled by default. Oracle recommends for clusters with two or more
Managed Servers that the load balancer be enabled.

For this tutorial, you'll provision the load balancer, and keep the default policy and compute
shape. After the service instance is created, up and running, and processing requests, the load
balancer policy, Least Connection Count, passes each new request to the Managed Server with
the least number of connections. This policy is useful for smoothing distribution when Managed
Servers get bogged down. Managed Servers with greater processing power to handle requests
receive more connections over time.

For this tutorial, you'll use a single load balancer node. However, for high availability and
greater application throughput, you also have the option to add a second load balancer node to a
service instance.
Configuring Backup and Recovery

Configure the backup and recovery by completing the fields in the Backup and Recovery
Configuration section.
1. Enter the name of the cloud storage container that you created earlier in this tutorial in
the Cloud Storage Containerfield.
When specifying the name of the container, use the format: storageservicename-
id_domain/container, wherestorageservicename is the name of the Oracle Storage Cloud
Service instance, id_domain is the identity domain ID (not identity domain name),
and container is the name of the container. For example: Storage-
myIdentityDomain/MyJCSContainer.

An example for your workshop could be the following:


Storage-usoraclept31958/Alpha01A-JCS-SC
Modify this to the name of your
identity domain. Leave the rest as is.
name
2. Enter the user name and password of the Oracle Cloud Storage Service container
administrator in the Cloud Storage User Name and Password fields, respectively.
For example: In your case, this is the same as your student credentials for this JCS environment
that should have been provided to you.
Your screen should now look like this:

3. Click Next.

Confirming and Reviewing Your Oracle Java Cloud Service Instance


Creation

To confirm your Oracle Java Cloud Service instance definition:


1. On the Confirmation page, confirm your selections and click Create.
When you return to the Oracle Java Cloud Service console, you will see your new service
instance listed. It will have a status of "In Progress" until the service instance creation is
completed. Service instance creation will take a number of minutes; possibly 30 or more.

2. To see the details of the service instance creation, including any errors, click In
Progress.

3. Click the name of the service instance to open its Details page.
The Details page provides detailed information about the service instance, such as the host
information and public IP addresses for the servers and load balancer. During the creation
process, the status of the process is shown at the bottom of the page.
4. Click Oracle Java Cloud Service in the breadcrumb to return to your Oracle Java Cloud

Service Console.

5. When the process is completed, you can see that your new instance was created
successfully.

Reviewing Your Environment in the WebLogic Server Administration


Console
After creating your instance, you can open the WebLogic Server Administration Console and
administer the service instance just as you'd administer your on-premises WebLogic Server
domain.
1. On your Oracle Java Cloud Service Console, click the icon for the service instance
that you want to manage, and then click Open WebLogic Server Console. [If you get a
warning regarding connection not being secure, just accept any exceptions and continue to the
site]

2. Enter the user name and password that you set on the wizard's Service Details page when
you created your instance; for example, weblogic/myweblogic1.
The WebLogic Server Administration Server is displayed. If you are familiar with the
traditional, on-premises Administration Console, the console will look very familiar to you.
D
escription of this image
3. In the navigation tree, under the domain name, click the Plus icon next
to Environment, and then click Clusters.
Note: The name of domain is created by using the first eight letters of the service name
appended by _domain. In this case, the name of the domain is WlsJcs_domain.

A default cluster, WlsJcs_cluster, was created in the domain.


4. Click Servers to see the servers that were created in this cluster.

Description of this image


When you created your instance, you selected a cluster size of two on the Service Details page
of the wizard. That number specified how many Managed Servers to create. The first entry is
for the Administration Server. The other entries are the two Managed Servers that you requested
when you created the service instance.

5. Click the first Managed Server to see further details about it. In this example,
click WlsJcs_d_server_1.
The server details page displays information about the server, including the address and the port
that the service instance uses for incoming connections. By default, Managed Servers use port
8001 for regular (non-SSL) incoming connections and port 8002 for secure incoming
connections.

Configuring the Load Balancer in Oracle Traffic Director

Oracle Java Cloud Service doesn't provide administrative interfaces for configuring the load
balancer for an Oracle Java Cloud Service instance. Instead, you use the Oracle Traffic Director
administration console to configure the load balancer. Oracle Traffic Director is used as the load
balancer for an Oracle Java Cloud Service instance.
1. In the Java Cloud Service Console, click the icon for the service instance that you
want to manage, and then select Open Load Balancer Console.

2. Log in with the same WebLogic Server credentials that you used for the WebLogic
Server Administration Console.
Oracle Traffic Director is displayed.

Deploying an Application to the Oracle Java Cloud Service


Instance
In this section of the tutorial, you use the Oracle WebLogic Server Administration Console to
deploy a web application to an Oracle Java Cloud Service instance. You can deploy and un-
deploy applications to an Oracle Java Cloud Service instance by using the Oracle WebLogic
Server Administration Console, Oracle Fusion Middleware Control, and the command-line
deployment utilities, just as you would deploy and undeploy them in an on-premises
environment.

Deploying an Application
To deploy an application to a Oracle Java Cloud Service instance by using the WebLogic Server
Administration Console:
1. On your Oracle Java Cloud Service Console, click the icon for the service instance
that you want to manage, and then click Open WebLogic Server Console.
2. Enter the user name and password that you set on the wizard's Service Details page when
you created your instance; for example, weblogic/myweblogic1.

The WebLogic Server Administration Server is displayed. If you are familiar with the
traditional, on-premises Administration Console, the console will look very familiar to you.
3. Click Lock & Edit.

4. Under Domain Structure, click domain > Deployments, where domain is the domain
into which you want to deploy the application.
Description of this image

5. On the Deployments page, click Install.

6. On the Install page, click upload your file(s) to upload files from your local computer.
7. In the Install Application Assistant, click Browse to find the application you want to
deploy and upload it.

If you downloaded the sample application benefits.war from the Supporting Files folder, as
described earlier, locate the file on your local computer. Otherwise, upload your own
application.

8. After the file is uploaded, its name appears next to the Browse button. Click Next.

9. Select the file, and then click Next.


10. You can either install the deployment as an application or as a library. Choose your
selection, and then click Next. For this tutorial, you'll install as an application.

11. Select the servers or clusters to which you want to deploy the application. For this
tutorial, choose to deploy the application to all the servers in the cluster, and then click Next.
12. Optionally update the following deployment settings:
The deployed name of the web application.
The security model that is applied to the application.
How the source files (WAR or exploded directory contents) are made
available to targeted Managed Servers and clusters.
How the deployment plan source files are made available to all targeted
Managed Servers and clusters.
Typically, the default settings are adequate. Click Next.

13. Review the configuration settings you specified. You can choose to fine-tune your
configuration, but for this tutorial, select No, I will review the configuration later, and then
click Finish.
A message announces that the deployment was successfully installed.

The application shows a status of distribute Initializing on the Deployments table.

14. In the Change Center, click Activate Changes.

The changes are activated and no restart is necessary. The WebLogic Server Console shows the
application in a Prepared state.
Starting an Application

You must start the application that you just deployed in order for it to accept requests.
To start a deployed application:
1. Open the WebLogic Server Administration Console for the service instance containing
the application you want to start, as described in steps 1 and 2 in Using the WebLogic Server
Administration Console to Deploy an Application, above.
2. Click the Control tab if it is not already selected.
3. Under Domain Structure, click WlcJcs_domain > Deployments.

4. On the Deployments table on the WebLogic Server Administration Console, select the
application.
5. Click Start, and then select Servicing all requests.

6. Click Yes to confirm the deployment.

The application is now in the Active state and is ready to accept requests.
7. Optionally, in the Change Center, click Release Configuration if it is not disabled.

The configuration lock is released and no restart is necessary.

Testing an Application

To test an application that you have deployed and started on an Oracle Java Cloud Service
instance:
1. Open the Oracle Java Cloud Service Console, if it is not already open.
2. Click the name of the service instance to which the application is deployed.
3. On the service instance details pages, find the list of nodes, and take note of the public IP
Address for the load balancer.

The URL for the application is:


o https://public_ip_of_load_balancer/context_root -- Application URL for secure
HTTPS port
For example: https://123.xx.xx.xx/benefits.
Note: These are default settings. You can change the user facing ports to any value you like
from the Load Balancer Administration Console (Oracle Traffic Director). To open Oracle
Traffic Director, go to your Oracle Java Cloud Service Console, click the icon for the
service instance you want to manage, and select Open Load Balancer Console.
4. You should now see the home page of your application.
Undeploying an Application

To undeploy an application from a Oracle Java Cloud Service instance by using the Oracle
WebLogic Server Administration Console:
1. Open the WebLogic Server Administration Console for the service instance containing
the application you want to undeploy, as described in steps 1 and 2 in Using the WebLogic
Server Administration Console to Deploy an Application, above.
2. If you haven't done so already, click Lock & Edit.

3. In the Domain Structure area, click Deployments.


4. You need to stop the deployment before you can delete it. On the Deployments table,
select the benefits application, click Stop, and then select when you want it to stop.
Choose Force Stop Now.

5. When you are asked if you want to stop the deployment, click Yes.

6. On the Deployments table, make sure the name of the application is selected, and then
click Delete.
7. Click Yes to confirm the deletion.

A message confirms that the deployment was deleted.


8. In the Change Center, click Activate Changes.

The changes are activated and no restart is necessary.


Manage Oracle Java Cloud Service instances using REST API

Introduction and Prerequisites

The Oracle Java Cloud Service REST API enables you to manage Oracle Java Cloud Service instances.
This API provides an alternative to using the web-based user interface.
In this section of the Lab, we will invoke REST API on our recently created Java Cloud Service
instance. To do so you have choice of any REST tool or client you wish to use. For this lab we use
Postman.
As a prerequisite, please download and install Postman App for Chrome (you need Google Chrome
on your computer) from here.
http://www.getpostman.com/
Once installed please start up Postman. The interface will look similar to the screenshot shown
below.

A general JCS API URL looks something like this

https://region-prefix.oraclecloud.com/resource-path

For example for your instances a URL could be

https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/usoraclept53502
You access the Oracle Java Cloud Service REST resources over HTTPS and must provide the
following information for authentication:
User name and password for your Oracle Java Cloud Service account.

Custom header, X-ID-TENANT-NAME, to identify the identity domain ID.


Enter your
Username/Password here This is where you enter the
REST API URL

This is where you enter the X-


ID-TENANT-NAME header

Now let us look perform a few REST API calls


View All Instances
This is a typical starting point where you list all the JCS instance in a particular cloud environment.

SYNTAX

GET https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/{identityDomainName}

E.g.
GET https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/usoraclept53502

RESPONSE SAMPLE

Service Name
View a Service Instance
Once all the service instances have been listed we can drill down into the details of any one of the
service instances since we now know the service name.
SYNTAX

GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/{identityDomainName}/{JCSINst
anceName}

E.g.
GET https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/usoraclept53502/WlsJCS

RESPONSE SAMPLE
View All Managed Servers
SYNTAX

GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/{identityDomainName}/{JCSINst
anceName}/servers

E.g.
GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/usoraclept53502/WlsJCS/server
s

RESPONSE SAMPLE
Healthcheck on a Service Instance
SYNTAX

GET
https://jaas.oraclecloud.com/paas/core/api/v1.1/healthcheck/{identityDomainName}/services/jaa
s/instances/{JCSInstanceName}

E.g.
GET
https://jaas.oraclecloud.com/paas/core/api/v1.1/healthcheck/usoraclept53502/services/jaas/inst
ances/WlsJCS

RESPONSE SAMPLE
View all Backups
SYNTAX

GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/{identityDomainName}/{JCSINst
anceName}/backups

E.g.
GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/usoraclept53502/WlsJCS/backu
ps/

RESPONSE SAMPLE
View all Patches
SYNTAX

GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/{identityDomainName}/{JCSINst
anceName}/patches

E.g.
GET
https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/usoraclept53502/WlsJCS/patche
s/

RESPONSE SAMPLE

For complete REST API Documentation please check this URL


https://docs.oracle.com/cloud/latest/jcs_gs/JSRMR/
Appendix A: Deleting an already existing JCS instance
In the event that you already see an existing JCS instance in the service console such as shown
below, then delete the instance.

If you see an
existing instance
like this

Delete it

In the dialog box that follows, enter the database credentials as:
Username: Sys Password: Welcome_1
Click Delete.

Potrebbero piacerti anche