Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1924 from LiskHQ/1922-mysql-complaints-usage-of-d…
Browse files Browse the repository at this point in the history
…eprecated-auth-plugin

MySQL complaints usage of deprecated auth plugin
  • Loading branch information
sameersubudhi authored Nov 17, 2023
2 parents 5284ad8 + 362a609 commit e5ac04f
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
mysql-primary:
image: mysql:8
platform: linux/amd64
command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_connections=500
command: mysqld --max_connections=500
volumes:
- ./docker/mysql/primary/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- mysql-primary-data:/var/lib/mysql
Expand All @@ -62,7 +62,7 @@ services:
mysql-primary:
condition: service_healthy
platform: linux/amd64
command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_connections=500
command: mysqld --max_connections=500
volumes:
- ./docker/mysql/read/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- ./docker/mysql/read/init:/docker-entrypoint-initdb.d
Expand Down
19 changes: 19 additions & 0 deletions docker/mariaDB/primary/conf/mysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[mysqld]

# Default authentication plugin
default-authentication-plugin=caching_sha2_password

# Default character charset
character-set-server=utf8mb4

# Default collation server
collation-server=utf8mb4_unicode_ci

# Unique identifying number of the server.
server-id = 1

# Set binary log file base name.
log_bin=mysql-bin.log

# Log row changes for replication. Other possible way is to log statements.
binlog_format = ROW
22 changes: 22 additions & 0 deletions docker/mariaDB/read/conf/mysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[mysqld]

# Default authentication plugin
default-authentication-plugin=caching_sha2_password

# Default character charset
character-set-server=utf8mb4

# Default collation server
collation-server=utf8mb4_unicode_ci

# Max connections
max_connections=500

# Unique identifying number of the server.
server-id = 2

# Set binary log file base name. This should be identical to the binary log file base name in source.
log_bin=mysql-bin.log

# Set the relay log file base name used by replica. This is needed to avoid error incase hostname is changed in future.
relay_log=mysql-relay-bin.log
9 changes: 9 additions & 0 deletions docker/mysql/primary/conf/mysql.cnf
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
[mysqld]

# Default authentication plugin
default-authentication-plugin=caching_sha2_password

# Default character charset
character-set-server=utf8mb4

# Default collation server
collation-server=utf8mb4_unicode_ci

# Unique identifying number of the server.
server_id = 1

Expand Down
2 changes: 1 addition & 1 deletion docker/mysql/primary/init/01-databases.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ CREATE DATABASE IF NOT EXISTS `lisk`;
GRANT ALL PRIVILEGES ON *.* TO 'lisk'@'%';

-- Create user for replica and grant replication privilege.
CREATE USER 'replica'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
CREATE USER 'replica'@'%' IDENTIFIED WITH caching_sha2_password BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replica'@'%';
FLUSH PRIVILEGES;
9 changes: 9 additions & 0 deletions docker/mysql/read/conf/mysql.cnf
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
[mysqld]

# Default authentication plugin
default-authentication-plugin=caching_sha2_password

# Default character charset
character-set-server=utf8mb4

# Default collation server
collation-server=utf8mb4_unicode_ci

# Unique identifying number of the server.
server_id = 2

Expand Down
5 changes: 3 additions & 2 deletions docker/mysql/read/init/01-databases.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Create `reader` user for read queries and grant read privilages.
CREATE USER 'reader'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
CREATE USER 'reader'@'%' IDENTIFIED WITH caching_sha2_password BY 'password';
GRANT SELECT ON *.* TO 'reader'@'%';
FLUSH PRIVILEGES;

Expand All @@ -8,4 +8,5 @@ CHANGE REPLICATION SOURCE TO
SOURCE_PORT = 3306,
SOURCE_USER = 'replica',
SOURCE_PASSWORD = 'password',
SOURCE_AUTO_POSITION = 1;
SOURCE_AUTO_POSITION = 1,
GET_SOURCE_PUBLIC_KEY = 1;
21 changes: 21 additions & 0 deletions jenkins/mariadb-with-replication/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: clean up down
all: up

compose := docker-compose -f docker-compose.yml

up:
$(compose) up --detach

down:
$(compose) down --volumes --remove-orphans

logs:
$(compose) logs

clean: down

cli-primary:
$(compose) exec mysql-primary mysql -u root -ppassword lisk

cli-replica:
$(compose) exec mysql-read-replica mysql -u root -ppassword lisk
64 changes: 64 additions & 0 deletions jenkins/mariadb-with-replication/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: '3.3'
services:
mysql-primary:
image: mariadb:10
container_name: mysql-primary
command: mysqld
volumes:
- ../../docker/mariadb/primary/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- mysql-primary-data:/var/lib/mysql
- ../../docker/mariadb/primary/init:/docker-entrypoint-initdb.d
restart: always
networks:
- services_network
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=lisk
- MYSQL_PASSWORD=password
ports:
- '127.0.0.1:3306:3306'
healthcheck:
test: ['CMD', 'mysqladmin', 'ping', '-hlocalhost', '-ppassword']

mysql-read-replica:
image: mariadb:10
depends_on:
mysql-primary:
condition: service_healthy
command: mysqld
volumes:
- ../../docker/mariadb/read/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- ../../docker/mariadb/read/init:/docker-entrypoint-initdb.d
restart: always
expose:
- '3306'
networks:
- services_network
deploy:
mode: replicated
replicas: 1
endpoint_mode: vip
environment:
- MYSQL_ROOT_PASSWORD=password
healthcheck:
test: ['CMD', 'mysqladmin', 'ping', '-hlocalhost', '-ppassword']

mysql-read-replica-haproxy:
image: nginx:latest
depends_on:
mysql-read-replica:
condition: service_healthy
volumes:
- ../../docker/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- '127.0.0.1:3307:3307'
networks:
- services_network
healthcheck:
test: ['CMD', 'service', 'nginx', 'status']

networks:
services_network:

volumes:
mysql-primary-data:
3 changes: 3 additions & 0 deletions jenkins/mariadb-with-replication/mysql-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

mysql -h"$HOSTNAME" -u"$MARIADB_USER" -p"$MARIADB_PASSWORD" --silent -e"use $MARIADB_DATABASE"
5 changes: 3 additions & 2 deletions jenkins/mariadb/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
version: '3.3'
services:
mariadb:
image: mariadb:10.7
command: mysqld --default-authentication-plugin=mysql_native_password
image: mariadb:10
command: mysqld --max_connections=500
volumes:
- ../../docker/mariadb/primary/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- db-data:/var/lib/mysql
- ./mysql-healthcheck.sh:/healthcheck.sh
restart: always
Expand Down
4 changes: 2 additions & 2 deletions jenkins/mysql-with-replication/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: mysql:8
container_name: mysql-primary
platform: linux/amd64
command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_connections=500
command: mysqld
volumes:
- ../../docker/mysql/primary/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- mysql-primary-data:/var/lib/mysql
Expand All @@ -27,7 +27,7 @@ services:
mysql-primary:
condition: service_healthy
platform: linux/amd64
command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_connections=500
command: mysqld
volumes:
- ../../docker/mysql/read/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- ../../docker/mysql/read/init:/docker-entrypoint-initdb.d
Expand Down
3 changes: 2 additions & 1 deletion jenkins/mysql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ services:
mysql:
image: mysql:8
platform: linux/amd64
command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_connections=500
command: mysqld --max_connections=500
volumes:
- ../../docker/mysql/primary/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- db-data:/var/lib/mysql
- ./mysql-healthcheck.sh:/healthcheck.sh
restart: always
Expand Down

0 comments on commit e5ac04f

Please sign in to comment.