Changing MySQL Options¶
You may require a configuration change for your application. MySQL allows the option to configure the database with a configuration file. You can pass the MySQL options from the my.cnf configuration file to the cluster in one of the following ways:
- Edit the CR.yaml file
- Use a ConfigMap
Edit the CR.yaml¶
You can add options from the my.cnf by editing the configuration section of the deploy/cr.yaml.
spec: secretsName: my-cluster-secrets pxc: ... configuration: | [mysqld] wsrep_debug=ON [sst] wsrep_debug=ON
See the Custom Resource options, PXC section for more details
Use a ConfigMap¶
You can use a configmap and the cluster restart to reset configuration options. A configmap allows Kubernetes to pass or update configuration data inside a containerized application.
kubectl command to create the configmap from external
resources, for more information see Configure a Pod to use a
For example, let’s suppose that your application requires more
connections. To increase your
max_connections setting in MySQL, you
my.cnf configuration file with the following setting:
[mysqld] ... max_connections=250
You can create a configmap from the
my.cnf file with the
kubectl create configmap command.
You should use the combination of the cluster name with the
suffix as the naming convention for the configmap. To find the cluster
name, you can use the following command:
kubectl get pxc
The syntax for
kubectl create configmap command is:
kubectl create configmap <cluster-name>-pxc <resource-type=resource-name>
The following example defines cluster1-pxc as the configmap name and the my-cnf file as the data source:
kubectl create configmap cluster1-pxc --from-file=my.cnf
To view the created configmap, use the following command:
kubectl describe configmaps cluster1-pxc
Make changed options visible to the Percona XtraDB Cluster¶
Do not forget to restart Percona XtraDB Cluster to ensure the cluster has updated the configuration (see details on how to connect in the Install Percona XtraDB Cluster on Kubernetes page).
Auto-tuning MySQL options¶
Few configuration options for MySQL can be calculated and set by the Operator automatically based on the available Pod resources (memory and CPU) if these options are not specified by user (either in CR.yaml or in ConfigMap).
Options which can be set automatically are the following ones:
If PXC Pod limits are defined, then limits values are used to calculate these options. If PXC Pod limits are not defined, Operator looks for PXC Pod requests as the basis for calculations. if neither PXC Pod limits nor PXC Pod requests are defined, auto-tuning is not done.