MySQL is a lightweight relational database management system developed by MySQL AB in Sweden and currently owned by Oracle Corporation. Currently, MySQL is widely used on medium and small websites on the Internet due to its small size, fast speed, low total cost of ownership, open-source nature, and free availability. Most medium and small website developments choose Linux + MySQL as their website database.
MySQL is a relational database management system that stores data in different tables rather than in a single large repository, which increases speed and flexibility.
# According to the cluster plan, label the k8s node that needs to deploy the MySQL service (single node)# xxx represents the actual node in the cluster used to deploy the MySQL servicekubectllabelnodesxxxmysql=true
# Copy the following YAML content into the k8s cluster and save it as a YAML file. Modify it according to your actual situation before deployment.apiVersion:storage.k8s.io/v1allowVolumeExpansion:truekind:StorageClassmetadata:annotations:cas.openebs.io/config:|- name: StorageTypevalue: "hostpath"- name: BasePathvalue: "/data/mysql" # This path can be modified based on actual conditions. Ensure sufficient storage space and that the path exists.name:openebs-mysql# The name must be unique within the cluster. Modify it before deployment in the file /etc/kubeasz/guance/infrastructure/yaml/mysql.yaml provisioner:openebs.io/localreclaimPolicy:RetainvolumeBindingMode:WaitForFirstConsumer
Ensure that the /data/mysql directory has sufficient disk capacity.
Configure data storage space:
# Modify as needed in /etc/kubeasz/guance/infrastructure/yaml/mysql.yaml---apiVersion:v1kind:PersistentVolumeClaimmetadata:name:mysql-dataspec:accessModes:-ReadWriteOncevolumeMode:Filesystemresources:requests:storage:10Gi# Set the storage size according to actual usagestorageClassName:openebs-mysql
# The default root administrator password is "mQ2LZenlYs1UoVzi"# You can modify it before installation via /etc/kubeasz/guance/infrastructure/yaml/mysql.yaml# Create namespacekubectlcreatensmiddleware
# Deploy MySQL servicekubectlapply-f/etc/kubeasz/guance/infrastructure/yaml/mysql.yaml-nmiddleware
# The default root administrator password is "mQ2LZenlYs1UoVzi"# You can modify it before installation via /etc/kubeasz/guance/infrastructure/yaml/mysql.yaml[root@k8s-node01/etc/kubeasz/guance/infrastructure/yaml]# kubectl exec -it -n middleware mysql-xxxxx -- mysql -uroot -pEnterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis3Serverversion:5.7.40MySQLCommunityServer(GPL)Copyright(c)2000,2022,Oracleand/oritsaffiliates.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>showdatabases;+--------------------+
|Database|+--------------------+
|information_schema||FT2.0||mysql||performance_schema||sys|+--------------------+
5rowsinset(0.00sec)