Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mysql 8.4 on CentOS Stream 10 #376

Merged
merged 17 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 8.0/root/usr/share/container-scripts/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ Variables that can be used in the scripts provided to s2i:
`$mysql_flags`
arguments for the `mysql` tool that will connect to the locally running `mysqld` during initialization

`$MYSQL_RUNNING_AS_MASTER`
variable defined when the container is run with `run-mysqld-master` command
`$MYSQL_RUNNING_AS_SOURCE`
phracek marked this conversation as resolved.
Show resolved Hide resolved
variable defined when the container is run with `run-mysqld-source` command

`$MYSQL_RUNNING_AS_SLAVE`
variable defined when the container is run with `run-mysqld-slave` command
`$MYSQL_RUNNING_AS_REPLICA`
variable defined when the container is run with `run-mysqld-replica` command

`$MYSQL_DATADIR_FIRST_INIT`
variable defined when the container was initialized from the empty data dir
Expand Down Expand Up @@ -330,8 +330,8 @@ Some applications may wish to use `row` binlog_formats (for example, those built
with change-data-capture in mind). The default replication/binlog format is
`statement` but to change it you can set the `MYSQL_BINLOG_FORMAT` environment
variable. For example `MYSQL_BINLOG_FORMAT=row`. Now when you run the database
with `master` replication turned on (ie, set the Docker/container `cmd` to be
`run-mysqld-master`) the binlog will emit the actual data for the rows that change
with `source/replica` replication turned on (ie, set the Docker/container `cmd` to be
`run-mysqld-source`) the binlog will emit the actual data for the rows that change
as opposed to the statements (ie, DML like insert...) that caused the change.


Expand Down
15 changes: 8 additions & 7 deletions 8.4/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ FROM quay.io/sclorg/s2i-core-c9s:c9s
# * $MYSQL_DATABASE - Name of the database to create
# * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account

ENV MYSQL_VERSION=8.0 \
MYSQL_SHORT_VERSION=80 \
ENV MYSQL_VERSION=8.4 \
MYSQL_SHORT_VERSION=84 \
APP_DATA=/opt/app-root/src \
HOME=/var/lib/mysql \
NAME=mysql

ENV SUMMARY="MySQL 8.0 SQL database server" \
ENV SUMMARY="MySQL 8.4 SQL database server" \
DESCRIPTION="MySQL is a multi-user, multi-threaded SQL database server. The container \
image provides a containerized packaging of the MySQL mysqld daemon and client application. \
The mysqld server daemon accepts connections from clients and provides access to content from \
Expand All @@ -40,7 +40,8 @@ EXPOSE 3306
# This image must forever use UID 27 for mysql user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind-utils groff-base mysql-server" && \
RUN RUN yum -y module enable mysql:$MYSQL_VERSION && \
phracek marked this conversation as resolved.
Show resolved Hide resolved
INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind-utils groff-base mysql-server" && \
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf -y clean all --enablerepo='*' && \
Expand All @@ -51,9 +52,9 @@ RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind-utils groff-ba
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \
MYSQL_PREFIX=/usr

COPY 8.0/root-common /
COPY 8.0/s2i-common/bin/ $STI_SCRIPTS_PATH
COPY 8.0/root /
COPY 8.4/root-common /
COPY 8.4/s2i-common/bin/ $STI_SCRIPTS_PATH
COPY 8.4/root /

# Hard links are not supported in Testing Farm approach during sync to guest
# operation system. Therefore tests are failing on error
Expand Down
8 changes: 4 additions & 4 deletions 8.4/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/fedora/s2i-core:40
FROM quay.io/fedora/s2i-core:41
phracek marked this conversation as resolved.
Show resolved Hide resolved

# MySQL image for OpenShift.
#
Expand Down Expand Up @@ -54,9 +54,9 @@ RUN INSTALL_PKGS="rsync tar gettext hostname bind-utils groff-base community-mys
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \
MYSQL_PREFIX=/usr

COPY 8.0/root-common /
COPY 8.0/s2i-common/bin/ $STI_SCRIPTS_PATH
COPY 8.0/root /
COPY 8.4/root-common /
COPY 8.4/s2i-common/bin/ $STI_SCRIPTS_PATH
COPY 8.4/root /

# Hard links are not supported in Testing Farm approach during sync to guest
# operation system. Therefore tests are failing on error
Expand Down
15 changes: 8 additions & 7 deletions 8.4/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ FROM ubi9/s2i-core
# * $MYSQL_DATABASE - Name of the database to create
# * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account

ENV MYSQL_VERSION=8.0 \
MYSQL_SHORT_VERSION=80 \
ENV MYSQL_VERSION=8.4 \
MYSQL_SHORT_VERSION=84 \
APP_DATA=/opt/app-root/src \
HOME=/var/lib/mysql \
NAME=mysql

ENV SUMMARY="MySQL 8.0 SQL database server" \
ENV SUMMARY="MySQL 8.4 SQL database server" \
DESCRIPTION="MySQL is a multi-user, multi-threaded SQL database server. The container \
image provides a containerized packaging of the MySQL mysqld daemon and client application. \
The mysqld server daemon accepts connections from clients and provides access to content from \
Expand All @@ -40,7 +40,8 @@ EXPOSE 3306
# This image must forever use UID 27 for mysql user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind-utils groff-base mysql-server" && \
RUN RUN yum -y module enable mysql:$MYSQL_VERSION && \
INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind-utils groff-base mysql-server" && \
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf -y clean all --enablerepo='*' && \
Expand All @@ -51,9 +52,9 @@ RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind-utils groff-ba
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \
MYSQL_PREFIX=/usr

COPY 8.0/root-common /
COPY 8.0/s2i-common/bin/ $STI_SCRIPTS_PATH
COPY 8.0/root /
COPY 8.4/root-common /
COPY 8.4/s2i-common/bin/ $STI_SCRIPTS_PATH
COPY 8.4/root /

# Hard links are not supported in Testing Farm approach during sync to guest
# operation system. Therefore tests are failing on error
Expand Down
14 changes: 7 additions & 7 deletions 8.4/root/usr/share/container-scripts/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ Variables that can be used in the scripts provided to s2i:
`$mysql_flags`
arguments for the `mysql` tool that will connect to the locally running `mysqld` during initialization

`$MYSQL_RUNNING_AS_MASTER`
variable defined when the container is run with `run-mysqld-master` command
`$MYSQL_RUNNING_AS_SOURCE`
variable defined when the container is run with `run-mysqld-source` command

`$MYSQL_RUNNING_AS_SLAVE`
variable defined when the container is run with `run-mysqld-slave` command
`$MYSQL_RUNNING_AS_REPLICA`
variable defined when the container is run with `run-mysqld-replica` command

`$MYSQL_DATADIR_FIRST_INIT`
variable defined when the container was initialized from the empty data dir
Expand Down Expand Up @@ -330,14 +330,14 @@ Some applications may wish to use `row` binlog_formats (for example, those built
with change-data-capture in mind). The default replication/binlog format is
`statement` but to change it you can set the `MYSQL_BINLOG_FORMAT` environment
variable. For example `MYSQL_BINLOG_FORMAT=row`. Now when you run the database
with `master` replication turned on (ie, set the Docker/container `cmd` to be
`run-mysqld-master`) the binlog will emit the actual data for the rows that change
with `source/replica` replication turned on (ie, set the Docker/container `cmd` to be
`run-mysqld-source`) the binlog will emit the actual data for the rows that change
as opposed to the statements (ie, DML like insert...) that caused the change.


Changing the authentication plugin
----------------------------------
MySQL 8.4 introduced 'caching_sha2_password' as its default authentication plugin.
MySQL 8.0 introduced 'caching_sha2_password' as its default authentication plugin.
It is faster and provides better security then the previous default authentication plugin.
However, not all software implements this algorithm, and client applications might report
issue like "The server requested authentication method".
Expand Down
2 changes: 1 addition & 1 deletion examples/extend-image/mysql-init/80-add-arbitrary-users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ mysql $mysql_flags <<EOSQL
EOSQL
}

if ! [ -v MYSQL_RUNNING_AS_SLAVE ]; then
if ! [ -v MYSQL_RUNNING_AS_REPLICA ]; then
create_arbitrary_users
fi
2 changes: 1 addition & 1 deletion examples/extend-image/mysql-init/90-init-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ init_arbitrary_database() {
mysql $mysql_flags ${MYSQL_DATABASE} < ${init_data_file}
}

if ! [ -v MYSQL_RUNNING_AS_SLAVE ] && $MYSQL_DATADIR_FIRST_INIT ; then
if ! [ -v MYSQL_RUNNING_AS_REPLICA ] && $MYSQL_DATADIR_FIRST_INIT ; then
init_arbitrary_database
fi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ check_arbitrary_users() {
fi
}

if ! [ -v MYSQL_RUNNING_AS_SLAVE ]; then
if ! [ -v MYSQL_RUNNING_AS_REPLICA ]; then
check_arbitrary_users
fi
98 changes: 49 additions & 49 deletions examples/replica/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ production. Use at your own risk.**

## What is MySQL replication?

Replication enables data from one MySQL database server (the master) to be
replicated to one or more MySQL database servers (the slaves). Replication is
asynchronous - slaves do not need not be connected permanently to receive updates from
the master. This means that updates can occur over long-distance connections and
Replication enables data from one MySQL database server (the source) to be
replicated to one or more MySQL database servers (the replicas). Replication is
asynchronous - replicas do not need not be connected permanently to receive updates from
the source. This means that updates can occur over long-distance connections and
even over temporary or intermittent connections such as a dial-up service.
Depending on the configuration, you can replicate all databases, selected
databases, or even selected tables within a database.
Expand All @@ -21,7 +21,7 @@ See: https://dev.mysql.com/doc/refman/en/replication.html

The provided JSON file (`mysql_replica.json`) contains a `Template` resource that
groups the Kubernetes and OpenShift resources which are meant to be created.
This template will start with one MySQL master server and one slave server.
This template will start with one MySQL source server and one replica server.

## Persistent storage

Expand All @@ -33,36 +33,36 @@ claimed when the template is instantiated. Refer to the [OpenShift
documentation](https://docs.okd.io/latest/install_config/persistent_storage/persistent_storage_nfs.html)
to learn how to create persistent volumes.

### Service 'mysql-master'
### Service 'mysql-source'

This resource provides 'headless' Service for the MySQL server(s) which acts
as the 'master'. The headless means that the Service does not use IP
as the 'source'. The headless means that the Service does not use IP
addresses but it uses the DNS sub-system. This behavior is configured by setting
the `clusterIP` attribute to `None`.

In this case, you can query the DNS (eg. `dig mysql-master A +search +short`) to
In this case, you can query the DNS (eg. `dig mysql-source A +search +short`) to
obtain the list of the Service endpoints (the MySQL servers that subscribe to
this service).

### Service 'mysql-slave'
### Service 'mysql-replica'

This resource provides the 'headless' Service for the MySQL servers that the
MySQL master uses as 'slaves' which are used to replicate the data from the
MySQL master.
MySQL source uses as 'replicas' which are used to replicate the data from the
MySQL source.

You can use the same DNS lookup as mentioned above to obtain the list of the
Service endpoints.

### ReplicationController 'mysql-master'
### ReplicationController 'mysql-source'

This resource defines the `PodTemplate` of the MySQL server that acts as the
'master'. The Pod uses the `quay.io/sclorg/mysql-80-c9s` image, but it sets the
special 'entrypoint' named `mysqld-master`. This will tell the MySQL image to
configure the MySQL server as the 'master'.
'source'. The Pod uses the `quay.io/sclorg/mysql-80-c9s` image, but it sets the
special 'entrypoint' named `mysqld-source`. This will tell the MySQL image to
configure the MySQL server as the 'source'.

To configure the 'master', you have to provide the credentials for the user that
will act as the 'master' admin. This user has special privileges to add or
remove 'slaves'.
To configure the 'source', you have to provide the credentials for the user that
will act as the 'source' admin. This user has special privileges to add or
remove 'replicas'.
The other thing you have to provide is the regular MySQL username that you can
use to connect to the MySQL server. This user has lower privileges and it is
safe to use it in your application.
Expand All @@ -77,19 +77,19 @@ If you want to perform administration tasks, you can also set the
`MYSQL_ROOT_PASSWORD`. In that case you will be able to connect to the MySQL
server as the 'root' user and create more users or more databases.

Once the MySQL master server is started, it has no slaves preconfigured as the
slaves registers automatically.
Once the MySQL source server is started, it has no replicas preconfigured as the
replicas registers automatically.

Note that currently the multiple-master configuration is not supported (even
though the `mysql-master` is defined as ReplicationController. If you increase the
number of replicas, then a new MySQL master server is started, but it will not
receive any slaves. This will be solved in future.
Note that currently the multiple-source configuration is not supported (even
though the `mysql-source` is defined as ReplicationController. If you increase the
number of replicas, then a new MySQL source server is started, but it will not
receive any replicas. This will be solved in future.

To check that the master MySQL server is working, you can issue the following
command on the master container:
To check that the source MySQL server is working, you can issue the following
command on the source container:

```
mysql> SHOW MASTER STATUS;
mysql> SHOW BINARY LOG STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
Expand All @@ -98,44 +98,44 @@ mysql> SHOW MASTER STATUS;
1 row in set (0.00 sec)
```

### ReplicationController 'mysql-slave'
### ReplicationController 'mysql-replica'

This resource defines the `PodTemplate` of the MySQL servers that act as the
`slaves` to the `master` server. In the provided JSON example, this Replication
Controller starts with 3 slaves. Each `slave` server first waits for the `master`
server to become available (getting the `master` server IP using the DNS
lookup). Once the `master` is available, the MySQL 'slave' server is started and
connected to the `master`. The unique `server-id` configuration property is
`replicas` to the `source` server. In the provided JSON example, this Replication
Controller starts with 3 replicas. Each `replica` server first waits for the `source`
server to become available (getting the `source` server IP using the DNS
lookup). Once the `source` is available, the MySQL 'replica' server is started and
connected to the `source`. The unique `server-id` configuration property is
generated from the unique IP address of the container (and hashed to a number).
Each `slave` must have unique `server-id`.
Each `replica` must have unique `server-id`.

Once the `slave` is running, it will fetch the database and users from the
`master` server, so you don't have to configure the user accounts for this
Once the `replica` is running, it will fetch the database and users from the
`source` server, so you don't have to configure the user accounts for this
resources.

To check the 'slave' status, you can issue the following command on the slave
To check the 'replica' status, you can issue the following command on the replica
container:

```
mysql> SHOW SLAVE STATUS\G
mysql> SHOW REPLICA STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.17.0.17
Master_User: master
Master_Port: 3306
Replica_IO_State: Waiting for source to send event
Source_Host: 172.17.0.17
Source_User: source
Source_Port: 3306
Connect_Retry: 60
```

This output means that the 'slave' is successfully connected to the 'master'
This output means that the 'replica' is successfully connected to the 'source'
MySQL server running on '172.17.0.17'.

To see the 'slave' hosts from the 'master', you can issue the following command
on the 'master' container:
To see the 'replica' hosts from the 'source', you can issue the following command
on the 'source' container:

```
mysql> SHOW SLAVE HOSTS;
mysql> SHOW REPLICA HOSTS;
+------------+-------------+------+------------+
| Server_id | Host | Port | Master_id |
| Server_id | Host | Port | Source_id |
+------------+-------------+------+------------+
| 3314680171 | 172.17.0.20 | 3306 | 1301393349 |
| 3532875540 | 172.17.0.18 | 3306 | 1301393349 |
Expand All @@ -144,8 +144,8 @@ mysql> SHOW SLAVE HOSTS;

```

You can add more slaves if you want, using the following `oc` command.
You can add more replicas if you want, using the following `oc` command.

```
$ oc scale rc mysql-slave --replicas=4
$ oc scale rc mysql-replica --replicas=4
```
Loading