Configure Mysql workload under Kubesphere

First, the server page as shown in the figure appears to prove that kubesphere is installed successfully.
When we install our system, the admin account and password will appear when the installation is successful. We use the initialized account and password to log in to the system. When logging in for the first time, we need to change the default password to ensure the security of the system.
insert image description here
After logging in to the system, we can see the page as shown in the figure. At the beginning, it is an admin user. You can use the admin user to deploy multiple factories and other administrator users. However, in order to learn the deployment of mysql in a targeted manner, we use admin user to deploy.
insert image description here
First of all, we need to enter the access control to deploy the corresponding factory. After the factory is deployed, we can enter the corresponding factory to create the project. Since the above steps are too basic, we will no longer demonstrate and directly deploy the service for the project.

First of all, we configure the most basic configmap in config, which is the most basic configuration file we configure for mysql. The content of the configuration file is the /etc/mysql/my.cnf configuration file of mysql that we usually use.

The content of the configuration file we give here is:

[client]
default-character-set=utf8mb4
 
[mysql]
default-character-set=utf8mb4
 
[mysqld]
init_connect='SET collation_connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake

Next, we configure the most basic configuration file. Through the entry of configmaps under configuration, click create on the right, select basic information, enter the name and remarks of the configuration file, and click the Next button. insert image description here
Then we set the Data Value.
insert image description here
Among them, the value of key represents the name of the configuration file we need to create, and the value of value represents the content of our configuration file.

After entering the content, we press the black tick below, and then click Create.

insert image description here

Then we can see that a basic mysql-conf configuration file is created.

Next, we need to create a pvc for this configuration file. In multi-node mode, we need to apply for pv through network sharing NFS, but in a single-node host, we only need to apply for resources in the local hard disk.

We select Storage-volumes, create a PV storage file,
insert image description here
and set the basic PV name and storage capacity size, 10G.
insert image description here
After creating the basic pv, we can move on to creating our workload.

Select application workland, select workloads, since we need to deploy mysql, we need to deploy a stateful replica set instead of a daemon set, we select statefulsets on the right,

insert image description here
Enter a basic workload name and remarks.
Then select the most basic docker image file, configure the most basic environment variables according to the content displayed in the docker hub, and configure the time zone of the synchronization host.

insert image description here

After pressing the tick in the lower right corner, we click Next to configure the basic storage space.
insert image description here
We need to map our /var/lib/mysql working directory to the corresponding pv of our k8s. To correspond to the services we deploy later, to provide storage functions.
insert image description here

Also configure our corresponding configuration file information.
The effect diagram after configuring the storage file settings is as follows:
insert image description here
After we click Next, we can directly create the workload.
insert image description here
When our Status shows Running, it means that our mysql workload has been configured successfully.
insert image description here

We can directly find the pod container corresponding to this workload, and directly click the pod container to enter the corresponding container viewing interface.
insert image description here
Click the terminal icon above to enter the terminal.
insert image description here
It can be seen that we can successfully enter our mysql service through the pod container.

Continue to view our mysql configuration file

insert image description here
It can be seen that under the storage volume of /etc/mysql/conf.d, the key is my.cnf, and the value is the content of our file. We can view it through the cat command in the directory of /etc/mysql/conf.d The content we set for this file is the value of the value we set in the configmap.

Guess you like

Origin blog.csdn.net/qq_27180763/article/details/123704589