Skip to content

Commit 436746e

Browse files
hhorakphracek
authored andcommitted
Fix replication and use source/replica instead of master/slave
1 parent f8d52af commit 436746e

File tree

20 files changed

+181
-169
lines changed

20 files changed

+181
-169
lines changed

8.0/root/usr/share/container-scripts/mysql/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ Variables that can be used in the scripts provided to s2i:
247247
`$mysql_flags`
248248
arguments for the `mysql` tool that will connect to the locally running `mysqld` during initialization
249249

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

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

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

337337

8.4/root/usr/share/container-scripts/mysql/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ Variables that can be used in the scripts provided to s2i:
247247
`$mysql_flags`
248248
arguments for the `mysql` tool that will connect to the locally running `mysqld` during initialization
249249

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

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

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

337337

338338
Changing the authentication plugin
339339
----------------------------------
340-
MySQL 8.4 introduced 'caching_sha2_password' as its default authentication plugin.
340+
MySQL 8.0 introduced 'caching_sha2_password' as its default authentication plugin.
341341
It is faster and provides better security then the previous default authentication plugin.
342342
However, not all software implements this algorithm, and client applications might report
343343
issue like "The server requested authentication method".

examples/extend-image/mysql-init/80-add-arbitrary-users.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ mysql $mysql_flags <<EOSQL
1212
EOSQL
1313
}
1414

15-
if ! [ -v MYSQL_RUNNING_AS_SLAVE ]; then
15+
if ! [ -v MYSQL_RUNNING_AS_REPLICA ]; then
1616
create_arbitrary_users
1717
fi

examples/extend-image/mysql-init/90-init-db.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ init_arbitrary_database() {
77
mysql $mysql_flags ${MYSQL_DATABASE} < ${init_data_file}
88
}
99

10-
if ! [ -v MYSQL_RUNNING_AS_SLAVE ] && $MYSQL_DATADIR_FIRST_INIT ; then
10+
if ! [ -v MYSQL_RUNNING_AS_REPLICA ] && $MYSQL_DATADIR_FIRST_INIT ; then
1111
init_arbitrary_database
1212
fi

examples/extend-image/mysql-pre-init/80-check-arbitrary-users.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ check_arbitrary_users() {
55
fi
66
}
77

8-
if ! [ -v MYSQL_RUNNING_AS_SLAVE ]; then
8+
if ! [ -v MYSQL_RUNNING_AS_REPLICA ]; then
99
check_arbitrary_users
1010
fi

examples/replica/README.md

+49-49
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ production. Use at your own risk.**
77

88
## What is MySQL replication?
99

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

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

2626
## Persistent storage
2727

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

36-
### Service 'mysql-master'
36+
### Service 'mysql-source'
3737

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

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

47-
### Service 'mysql-slave'
47+
### Service 'mysql-replica'
4848

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

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

56-
### ReplicationController 'mysql-master'
56+
### ReplicationController 'mysql-source'
5757

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

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

80-
Once the MySQL master server is started, it has no slaves preconfigured as the
81-
slaves registers automatically.
80+
Once the MySQL source server is started, it has no replicas preconfigured as the
81+
replicas registers automatically.
8282

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

88-
To check that the master MySQL server is working, you can issue the following
89-
command on the master container:
88+
To check that the source MySQL server is working, you can issue the following
89+
command on the source container:
9090

9191
```
92-
mysql> SHOW MASTER STATUS;
92+
mysql> SHOW BINARY LOG STATUS;
9393
+------------------+----------+--------------+------------------+
9494
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
9595
+------------------+----------+--------------+------------------+
@@ -98,44 +98,44 @@ mysql> SHOW MASTER STATUS;
9898
1 row in set (0.00 sec)
9999
```
100100

101-
### ReplicationController 'mysql-slave'
101+
### ReplicationController 'mysql-replica'
102102

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

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

116-
To check the 'slave' status, you can issue the following command on the slave
116+
To check the 'replica' status, you can issue the following command on the replica
117117
container:
118118

119119
```
120-
mysql> SHOW SLAVE STATUS\G
120+
mysql> SHOW REPLICA STATUS\G
121121
*************************** 1. row ***************************
122-
Slave_IO_State: Waiting for master to send event
123-
Master_Host: 172.17.0.17
124-
Master_User: master
125-
Master_Port: 3306
122+
Replica_IO_State: Waiting for source to send event
123+
Source_Host: 172.17.0.17
124+
Source_User: source
125+
Source_Port: 3306
126126
Connect_Retry: 60
127127
```
128128

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

132-
To see the 'slave' hosts from the 'master', you can issue the following command
133-
on the 'master' container:
132+
To see the 'replica' hosts from the 'source', you can issue the following command
133+
on the 'source' container:
134134

135135
```
136-
mysql> SHOW SLAVE HOSTS;
136+
mysql> SHOW REPLICA HOSTS;
137137
+------------+-------------+------+------------+
138-
| Server_id | Host | Port | Master_id |
138+
| Server_id | Host | Port | Source_id |
139139
+------------+-------------+------+------------+
140140
| 3314680171 | 172.17.0.20 | 3306 | 1301393349 |
141141
| 3532875540 | 172.17.0.18 | 3306 | 1301393349 |
@@ -144,8 +144,8 @@ mysql> SHOW SLAVE HOSTS;
144144
145145
```
146146

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

149149
```
150-
$ oc scale rc mysql-slave --replicas=4
150+
$ oc scale rc mysql-replica --replicas=4
151151
```

0 commit comments

Comments
 (0)