Subscribe to the Oracle Cloud service, a free trial is available at https://cloud.oracle.com/en_US/tryit if not already subscribed. Next, Create an Instance of Oracle Container Cloud Service. A My Services URL is including Username and Password are sent to a new subscriber. Log in to the My Services Dashboard. Click on Create Instance. In Create Instance select the All services to list the available cloud services. Click on Application Development>Container Classic>Create. If the Container Classic service is not listed in the Create Instance>All Services customize the dashboard with the Customize Dashboard button to show the Container Classic service and select the Container Classic service. In Oracle Container Cloud Service Services console click on Create Service. The Create Service wizard gets started.A new service requires the fields discussed in Table 1.
Table 1. Service Fields
Field Description Default Value
Service Name Service name -
Description Service description -
Email Address Email address -
SSH Public Key SSH Public Key -
Admin Username Administrator Username admin
Admin Password Administrator Password -
Worker node Compute Shape Compute shape for worker node. The compute shape is defined by the CPU and RAM allocated to a worker node. OC3- 1.0 ocpu, 7.5GB RAM Number of worker nodes Number of worker nodes - Worker node data volume size (GiB) Worker node data volume size in GiB -
Specify a service name, description and click on Edit for the SSH Public Key field. The SSH Public/private key pair gets generated with the Edit button. The private key may be used to connect with the manager node in the service. In the SSH Public Key for VM Access select the Create a New Key option and click on Enter. In Download Keys click on Download. A sshkeybundle.zip file gets downloaded. The sshkeybundle.zip file consists of a privateKey and a publicKey file. Click on Done after downloading the sshkeybundle.zip file. The SSH Public Key gets added to the field. Specify an Admin Password including Confirm Admin Password. Select a Worker node Compute Shape from the choices in the drop-down. The default number of worker nodes is 1 and the Worker node data volume size is 30 GiB by default. In the Confirmation page click on Create. The new service orclccs starts to get created. Click on the Refresh button periodically to refresh the service status. When the service gets created the Submitted On timestamp gets replaced with Created On.
To access the Container Console select Manage this service>Container Console. In the login page specify Username as admin and Password as the password specified when configuring the service. Click on Login. The Container Console gets displayed. The number of Deployments, number of Hosts and number of Resource Pools are listed. In the navigation bar links are provided for Dashboard, Search, Tasks & Events, Services, Stacks, Deployments, Containers, Images, Hosts, Resource Pools, Registries, Tags and Service Discovery.
In this section we shall deploy a MySQL database service to Oracle Container Cloud Service. Click on Services in the navigation bar and click on Deploy for the MySQL service. In Deploy MySQL click on Deploy. Select from the deployment options: per-pool, per-tag or per-host. Select a Scheduling Policy: Random, CPU or Memory. To add constraints click on Add Constraint and select from Tag or Host. Click on Deploy. The MySQL service gets deployed. The Deployments>MySQL details page lists the service detail including the Containers.
To get details about the Docker container click on the container link in the Containers tab. The container details page gets displayed. In Network tab, which is selected by default, the Hosts ports lists the 3306 port. Click on Host Details button to get details about the host. The MySQL container is deployed on the worker node. The Public IP address and Docker Version (1.12.6) are listed in the host details page. The Containers tab lists the containers on the host. The MySQL Service containers are listed as running on the worker host. The Environment variables tab lists the environment variables for the Docker container. Copy the value of the MYSQL_ROOT_PASSWORD, which is my-secret-pw by default. We shall use the MYSQL root password when starting a MYSQL command line interface (CLI) to connect to the MySQL database.
In this section we shall scale the number of Docker containers in the MySQL service from the default 1 to 3. To scale the MySQL service click on Deployments in the navigation to display the deployments. Click on the MySQL deployment link. Click on Change Scaling for the MySQL deployment. In the Scaling dialog the Quantity: mysql is listed as 1. Modify the Quantity to 3 and click on Change. The MySQL service deployment becomes unavailable while being scaled as indicated by a message. Two of the containers are shown in Pending state. As a new Docker container gets created its state is Stopped at first and after the container gets started its state becomes Running. Two Docker containers are listed as Running and one is Stopped. When all three Docker containers have started the service becomes available again. Click on a host link in the Hostname column. The containers on the host include three Docker containers for MySQL. To scale down from 3 to 1 Docker containers click on Change scaling again. Modify the Quantity to 1 and click on Change. The number of Docker containers get scaled down to 1.
In this section we shall connect to the manager node in the Oracle Container Cloud service orclccs. To connect to the manager node obtain the Public IP for the worker node on which the MySQL Docker container is installed. The Public IP address in the Worker host details page. Copy the privateKey downloaded in the sshkeybundle.zip to a local Linux machine from which a SSH connection to the manager node is to be made.
cp //sshkeybundle/privateKey .
Modify the permissions on the privateKey to 600, which is read and write permissions to the user, but not any permissions to group or other.
chmod 600 privateKey
SSH login to the manager node using the privateKey and the Public IP Address of the manager node with user as opc.
ssh -i privateKey email@example.com
The command prompt on the manager node gets displayed.
List the databases with the show databases command. Select the mysql database with the use mysql command. List the tables with the show tables command. The output from the commands to list databases, select a database and list tables.
Create a database table wlslog with the following SQL Script.
CREATE TABLE wlslog(time_stamp VARCHAR(255) PRIMARY KEY,category VARCHAR(255),type VARCHAR(255),servername VARCHAR(255), code VARCHAR(255),msg VARCHAR(255)); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:16-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000365','Server state changed to STANDBY'); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:17-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000365','Server state changed to STARTING'); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:18-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000365','Server state changed to ADMIN'); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:19-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000365','Server state changed to RESUMING'); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:20-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000361','Started WebLogic AdminServer'); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:21-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000365','Server state changed to RUNNING'); INSERT INTO wlslog(time_stamp,category,type,servername,code,msg) VALUES('Apr-8-2014-7:06:22-PM-PDT','Notice','WebLogicServer','AdminServer','BEA-000360','Server started in RUNNING mode');
A database table gets created and data added.
Run a SELECT statement to query the table created. Table data gets listed.
To list the Docker images click on Images. One image used in this article gets displayed. Click on the mysql image to display its detail.
For tasks and events click on Tasks & Events. Events include an image getting pulled, a Docker container getting created and deployed.
Three different resource pools are provided by default. To get resource pool detail click on Resource Pools. The three resource pools are default, Development, and Production.
To display the Docker registries click on Registries. One registry index.docker.io gets displayed.
To search for a service click on Search in navigation and specify the service name or a sub string appearing in the service and click on Search. The MySQL service gets listed. Click on the Containers tab to list the Docker containers for the service. To view detail about a Docker container click on View Container.
To stop the MySQL deployment click on Stop. The MySQL deployment Docker container gets stopped. The service state becomes Stopped. To remove the MySQL deployment click on Remove. The MySQL deployment gets removed. The Docker container for the deployment also gets removed.
To delete a Oracle Container Cloud Service instance click on Manage this service and select Delete. To delete the service ignoring any PaaS script failures select the Force service deletion and click on Delete. The service starts to gets deleted as indicated by a message.
In this article we introduced the Oracle Container Cloud Service. We started by creating an Oracle Container Cloud Service. Subsequently we created an instance of Container Classic to deploy Docker service for MySQL database. We also discussed scaling the MySQL service, starting a Bash shell to access a Docker container running MySQL database, and create & query a database table.