Remote-access Guide

mysql openshift remote access

by Dr. Rafael Green Published 2 years ago Updated 1 year ago
image

To remotely access MySQL on Openshift, you can configure NodePort or LoadBalancer as the type on the Service instead of the default ClusterIP. This will allow external tcp access to your database. Note a nodeport will be defined in the 30000-32767 range by default which will map to the targetport.

To remotely access MySQL on Openshift, you can configure NodePort or LoadBalancer as the type on the Service instead of the default ClusterIP. This will allow external tcp access to your database. Note a nodeport will be defined in the 30000-32767 range by default which will map to the targetport.Nov 3, 2013

Full Answer

Can I run MySQL on OpenShift Container Platform?

OpenShift Container Platform provides a container image for running MySQL. This image can provide database services based on username, password, and database name settings provided via configuration. Currently, OpenShift Container Platform provides versions 5.6 and 5.7 of MySQL. This image comes in two flavors, depending on your needs:

Where can I find RHEL 7 images for OpenShift?

The RHEL 7 image is available through the Red Hat Registry: CentOS images for MySQL 5.6 and 5.7 are available on Docker Hub: To use these images, you can either access them directly from these registries or push them into your OpenShift Container Platform container image registry.

How to run MySQL interactive session from a bash shell?

Then, open a remote shell session to the pod: When you enter the container, the required SCL is automatically enabled. You can now run the mysql command from the bash shell to start a MySQL interactive session and perform normal MySQL operations. For example, to authenticate as the database user:

How do I host a MySQL server on localhost?

This command allocates a free port on your local machine to host the MySQL server from the pod. Open the MySQL Workbench and add a new connection using your database credentials and the allocated port to your localhost. After you are connected, run the following query to create a new table:

image

Create a MySQL instance on Red Hat OpenShift on IBM Cloud and integrate it with an example microservices-based application

Typically, deploying your database to an online server is not as easy as it sounds. It takes a lot of configuration to get it done and to integrate it to your application. Even after successfully deploying the database, maintaining, updating, monitoring, and logging the deployment could be really painful tasks.

Prerequisites

Before you begin this tutorial, you should have basic SQL knowledge and set up the following environment:

Summary

As you saw throughout the tutorial, when you use OpenShift, a lot of steps and configurations are cut out of your process, replaced with few clicks.

Why is MySQL image mounted?

The MySQL image can be run with mounted volumes to enable persistent storage for the database:

How to tell MySQL to be the master?

To tell a MySQL server to act as the master, the command field in the container’s definition in the deployment configuration must be set to run- mysqld-master. This script acts as an alternative entrypoint for the MySQL image and configures the MySQL server to run as the master in replication.

What is a MySQL master pod?

The pods created by the MySQL slave replication controller must reach the MySQL master server in order to register for replication. The example template defines a headless service named mysql-master for this purpose. This service is not used only for replication, but the clients can also send the queries to mysql-master:3306 as the MySQL host.

How to turn off AIO usage?

Turn off AIO usage entirely by setting environment variable MYSQL_AIO to have value 0 . On subsequent deployments, this arranges for the MySQL configuration variable innodb_use_native_aio to have value 0.

What is persistent storage in MySQL?

mysql-persistent uses a persistent volume store for the database data which means the data will survive a pod restart. Using persistent volumes requires a persistent volume pool be defined in the OpenShift Container Platform deployment. Cluster administrator instructions for setting up the pool are located in Persistent Storage Using NFS.

Where are MySQL templates registered?

The MySQL templates should have been registered in the default openshift project by your cluster administrator during the initial cluster setup. See Loading the Default Image Streams and Templates for more details, if required.

Why is MySQL ephemeral?

mysql-ephemeral is for development or testing purposes only because it uses ephemeral storage for the database content. This means that if the database pod is restarted for any reason, such as the pod being moved to another node or the deployment configuration being updated and triggering a redeploy, all data will be lost.

How to use OpenShift image stream?

To use these images, you can either access them directly from these registries or push them into your OpenShift Container Platform Docker registry. Additionally, you can create an ImageStream that points to the image, either in your Docker registry or at the external location. Your OpenShift Container Platform resources can then reference the ImageStream. You can find example ImageStream definitions for all the provided OpenShift Container Platform images.

What happens if you don't specify all three in OpenShift?

If you do not specify all three, the pod will fail to start and OpenShift Container Platform will continuously try to restart it.

What is OpenShift Container Platform?

OpenShift Container Platform provides a template to make creating a new database service easy. The template provides parameter fields to define all the mandatory environment variables (user, password, database name, etc) with predefined defaults including auto-generation of password values. It will also define both a deployment configuration and a service.

How to tell MySQL to be the master?

To tell a MySQL server to act as the master, the command field in the container’s definition in the deployment configuration must be set to run- mysqld-master. This script acts as an alternative entrypoint for the MySQL image and configures the MySQL server to run as the master in replication.

Why is MySQL image mounted?

The MySQL image can be run with mounted volumes to enable persistent storage for the database:

Where are MySQL templates registered?

The MySQL templates should have been registered in the default openshift project by your cluster administrator during the initial cluster setup. See Loading the Default Image Streams and Templates for more details, if required.

Why is MySQL unable to use AIO?

MySQL’s storage engine was unable to use the kernel’s AIO (Asynchronous I/O) facilities due to resource limits.

Where is OpenShift stored?

The resulting image will be stored in the OpenShift cluster's internal registry.

How many microservices are there in OpenShift?

At this point, you have two microservices that will retrieve a customer list and a single customer from your MySQL database, running in OpenShift — as is our ephemeral MySQL database. We also have a website that uses these two services. We can see the URL for our website by running the following command:

What is S2I in OpenShift?

The S2I feature allows you to reference a GitHub repo in OpenShift and trigger automatic builds from source. OpenShift will fetch the source code, analyze it, and build it according to what type of source code it is (e.g., Node.js, Ruby, etc.). The resulting image will be stored in the OpenShift cluster's internal registry.

Do you need to alter MySQL_USER and MySQL_PASSWORD?

Note: You need to alter the MYSQL_USER and MYSQL_PASSWORD values to match the credentials that were supplied when you created the database (in the previous article). If you don't have those values, you'll need to add a user with the proper rights to your MySQL instance.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9