Oracle by Example brandingCreate and Manage an Oracle Java Cloud Service Instance Using the CLI

section 0Before You Begin

This 30-minute tutorial shows you how to create, back up, and scale an Oracle Java Cloud Service instance from the command-line interface (CLI).

Background

The Platform Service Manager (PSM) CLI is a Python module for configuring and managing the lifecycle of PaaS services on Oracle Cloud, including Oracle Java Cloud Service instances.

Note: This tutorial creates a service instance within an Oracle Cloud Infrastructure Classic region. To learn about the differences between Oracle Cloud Infrastructure Classic and Oracle Cloud Infrastructure, see About Java Cloud Service Instances in Oracle Cloud Infrastructure.

What Do You Need?


section 1Download the CLI

  1. Sign in to Oracle Cloud as a user with the Java Administrator role.
  2. From the Oracle Cloud Infrastructure Console, click the Navigation menu Dashboard Menu Icon at the top left corner of the page, expand Platform Services, and then select Java.

    Note: On some older Oracle Cloud accounts, you use the Oracle Cloud Infrastructure Classic Console. Click the Navigation menu Dashboard Menu Icon, and then select Java.

  3. If this is the first time you have accessed Java Cloud Service then you may be presented with a Welcome screen. If this happens then you can continue to the console by clicking Go to Console.
  4. Make a note of your Data Region, which is shown in the upper right banner of the Oracle Cloud Infrastructure Console. For example: US East (Ashburn).
  5. From the Navigation menu Dashboard Menu Icon, select Identity, and then Federation. Click the name of your identity provider, and then click Oracle Identity Cloud Service Console.
  6. On the Oracle Identity Cloud Service Console, click on the User Profile menu on the upper right corner of the console and select About. Record the Instance GUID. This is the Identity Service ID.

    You will need the Data Region and Identity Service ID later when you configure the CLI.

  7. Find and record the REST endpoint URL of the Oracle Cloud Infrastructure Object Storage Classic service instance in the Infrastructure Classic Console. See Accessing Object Storage in Using Oracle Cloud Infrastructure Object Storage Classic.

    You will need this URL later when you configure backups.

    For example: https://foo.storage.oraclecloud.com/v1/MyService-bar.

  8. Navigate back to the Oracle Java Cloud Service console, and then click the user icon at the top right corner of the page. Expand Help, and then select Download Center.
  9. Locate the description of the PSM CLI, and then click Download Download Icon. Save the file psmcli.zip to your computer.

section 2Install and Configure the CLI

This tutorial assumes that your Python installation has been added to the PATH environment variable.

  1. Launch a command prompt and execute this Python command:
    pip3 install -U psmcli.zip

    On Linux, if Python was installed as the root user or to the default location on the file system, you must run this command using sudo.

  2. Run the setup command:
    psm setup
  3. When prompted, enter the credentials of an Oracle Cloud user with the Java Administrator role, along with your Identity Service ID.
    Username: your_username
    Password: your_password
    Retype Password: your_password
    Identity domain: your_identity_service_id
  4. When prompted for a region, enter one of the following values based on the Data Region for your cloud account:
    • us
    • emea
    • aucom
  5. Accept the default values for the remaining inputs. After the CLI setup has completed successfully, it displays the list of PaaS services in your cloud account, including Oracle Java Cloud Service (jcs). For example:
    'psm setup' was successful. Available services are:
      o dics
           Oracle Data Integration Platform Cloud Service
      o jcs
           Oracle Java Cloud Service
      ...

section 3Create a Service Instance

  1. Download create.json to your computer, and then open it in a text editor.
  2. Copy and paste your SSH public key into the value for the vmPublicKeyText attribute:
    "vmPublicKeyText": "your_public_key"
  3. Enter a password for Oracle WebLogic Server in the adminPassword attribute:
    "adminPassword": "your_weblogic_password"
  4. Enter the instance name and administrator password for your existing Oracle Database Cloud Service instance:
    "dbServiceName": "your_database_instance",
    "dbaName": "SYS",
    "dbaPassword": "your_database_password"
  5. Save your changes.

    Tip: For descriptions of all available payload attributes, see Create a Service Instance in REST API for Oracle Java Cloud Service.

  6. Run the create-service command and provide the location of create.json.
    psm jcs create-service -c create.json
  7. From the command output, identify the job ID. For example:
    Job ID: 55550001
  8. Run the operation-status command and specify the job ID. Periodically run this command until the status of the job is SUCCEED. For example:
    psm jcs operation-status -j 55550001
    
    Service:           MyJCS
    Operation Type:    CREATE_SERVICE
    Status:            SUCCEED

    Tip: For more detailed information about the job, specify the JSON output format: -of json.

  9. Run the service command to view details about your service instance, MyJCS.
    psm jcs service -s MyJCS
    
    Service:            MyJCS
    Status:             Ready
    Version:            12.2.1.2.180823
    Edition:            Enterprise Edition

section 4Back Up a Service Instance

  1. Run the add-backup-service command. Provide the name of your service instance, your Oracle Cloud credentials, and your storage REST endpoint.
    psm jcs add-backup-service -s MyJCS -k BOTH -wc true -g true -t your_cloud_user -o your_cloud_password -d your_storage_REST_endpoint/MyJCSBackup
    
    Command completed with status [SUCCEED].

    Tip: If you set the wc option to true, the command waits until it completes and a response it sent from the server.

  2. Run the backup command.
    psm jcs backup -s MyJCS -o "My Test Backup"
  3. From the command output, identify the job ID. For example:
    Job ID: 55550002
  4. Run the operation-status command and specify the job ID. Periodically run this command until the status of the job is SUCCEED. For example:
    psm jcs operation-status -j 55550002
    
    Service:           MyJCS
    Operation Type:    BACKUP
    Status:            SUCCEED
  5. Run the view-backups command.
    psm jcs view-backups -s MyJCS -of json
  6. From the command output, locate your new backup. For example:
    {
        "backups":[
            {
                "backupId":"11111111-2222-3333-4444-555555555555",
                "jobId":"55550002",
                "backupStartDate":"2018-10-02T20:22:18.837+0000",
                "backupCompleteDate":"2018-10-02T20:24:40.227+0000",
                "expirationDate":"2018-11-01T20:22:18.837+0000",
                ...
                "notes":"My Test Backup"
            }
        ]
    }

section 5Scale Out a Service Instance

  1. Download scale-out.json to your computer, and then open it in a text editor. No changes are necessary.

    Tip: For descriptions of all available payload attributes, see Scale Out a Service Instance REST API for Oracle Java Cloud Service.

  2. Run the scale-out command on your service instance, MyJCS. Provide the location of scale-out.json.
    psm jcs scale-out -s MyJCS -c scale-out.json
  3. From the command output, identify the job ID. For example:
    Job ID: 55550003
  4. Run the operation-status command and specify the job ID. Periodically run this command until the status of the job is SUCCEED. For example:
    psm jcs operation-status -j 55550003
    
    Service:           MyJCS
    Operation Type:    SCALE_OUT
    Status:            SUCCEED
  5. Run the service command.
    psm jcs service -s MyJCS -of json
  6. From the command output, verify that there are now two nodes in the service instance.
    ...
    "vmInstances":{
        "myjcs-wls-2":{
            ...
        },
        "myjcs-wls-1":{
            ...
        }
    }

more informationWant to Learn More?