├── .github └── workflows │ └── release-ubi.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── mariadb_repo_setup └── maxscale.cnf /.github/workflows/release-ubi.yml: -------------------------------------------------------------------------------- 1 | name: Release UBI 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | version: 6 | description: 'MaxScale version' 7 | required: true 8 | type: string 9 | tags: 10 | description: 'Tags separated by comma' 11 | required: true 12 | type: string 13 | default: 'mariadb/maxscale:insert_version_here-ubi' 14 | 15 | jobs: 16 | release: 17 | name: Release 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | with: 23 | ref: "rhel-ubi8" 24 | fetch-depth: 0 25 | 26 | - name: Setup QEMU 27 | uses: docker/setup-qemu-action@v3 28 | 29 | - name: Setup Docker Buildx 30 | uses: docker/setup-buildx-action@v3 31 | id: buildx 32 | 33 | - name: Login DockerHub 34 | uses: docker/login-action@v3 35 | with: 36 | username: ${{ secrets.DOCKERHUB_USER }} 37 | password: ${{ secrets.DOCKERHUB_TOKEN }} 38 | 39 | - name: Publish multi-arch Docker image 40 | uses: docker/build-push-action@v5 41 | with: 42 | push: true 43 | builder: ${{ steps.buildx.outputs.name }} 44 | context: . 45 | file: ./Dockerfile 46 | build-args: | 47 | MXS_VERSION=${{ github.event.inputs.version }} 48 | platforms: linux/amd64,linux/arm64 49 | tags: | 50 | ${{ github.event.inputs.tags }} 51 | labels: | 52 | name=MariaDB MaxScale 53 | maintainer="docker-maintainers@mariadb.com" 54 | vendor="MariaDB, plc" 55 | version=${{ github.event.inputs.version }} 56 | release=${{ github.event.inputs.version }} 57 | revision=${{ github.sha }} 58 | summary="MariaDB MaxScale database proxy" 59 | description=MariaDB MaxScale is a database proxy that extends the high availability, scalability, and security of MariaDB Server 60 | source=${{ github.event.repository.html_url }} 61 | url=${{ github.event.repository.html_url }} 62 | 63 | - name: Preflight image 64 | run: | 65 | IFS=',' read -r -a TAGS_ARRAY <<< "${{ github.event.inputs.tags }}" 66 | for TAG in "${TAGS_ARRAY[@]}"; do 67 | echo "Running preflight for \"$TAG\"" 68 | PREFLIGHT_IMAGE="$TAG" make preflight-image-submit 69 | done 70 | env: 71 | MXS_VERSION: "${{ github.event.inputs.version }}" 72 | REDHAT_API_KEY: "${{ secrets.REDHAT_API_KEY }}" 73 | REDHAT_PROJECT_ID: "${{ secrets.REDHAT_PROJECT_ID }}" 74 | 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries 2 | /bin/ 3 | 4 | # Preflight 5 | /artifacts/ 6 | 7 | # Log 8 | *.log -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1179.1741795396 2 | 3 | ARG MXS_VERSION 4 | 5 | COPY --chmod=500 mariadb_repo_setup /tmp/mariadb_repo_setup 6 | RUN /tmp/mariadb_repo_setup --mariadb-maxscale-version=${MXS_VERSION} --skip-check-installed 7 | 8 | # Install MaxScale 9 | RUN microdnf -y install maxscale shadow-utils && microdnf clean all 10 | COPY maxscale.cnf /etc/ 11 | 12 | # Copy licenses. Required for OpenShift container certification. 13 | COPY LICENSE /licenses/ 14 | 15 | # Expose REST API port. 16 | EXPOSE 8989 17 | 18 | # Create maxscale user 19 | RUN useradd -r maxscale && \ 20 | chown maxscale:maxscale /var/{lib,run,log,cache}/maxscale 21 | 22 | # Run as non root. Required for OpenShift container certification. 23 | USER maxscale 24 | 25 | ENTRYPOINT ["maxscale","--nodaemon", "--log=stdout"] 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. 2 | “Business Source License” is a trademark of MariaDB Corporation Ab. 3 | 4 | Parameters 5 | 6 | Licensor: MariaDB Corporation Ab 7 | Licensed Work: MariaDB MaxScale (TM) v.2.3. 8 | The Licensed Work is (c) 2017 MariaDB Corporation Ab 9 | Additional Use Grant: You may use the Licensed Work when your application 10 | uses the Licensed Work with a total of less than three 11 | server instances for any purpose. 12 | 13 | Change Date: 2020-01-01 14 | 15 | Change License: Version 2 or later of the GNU General Public License as 16 | published by the Free Software Foundation. 17 | 18 | For information about alternative licensing arrangements for the Software, 19 | please visit: https://mariadb.com/products/mariadb-enterprise 20 | 21 | Notice 22 | 23 | The Business Source License (this document, or the “License”) is not an Open 24 | Source license. However, the Licensed Work will eventually be made available 25 | under an Open Source License, as stated in this License. 26 | 27 | For more information on the use of the Business Source License for MariaDB 28 | products, please visit the MariaDB Business Source License FAQ at 29 | https://mariadb.com/bsl-faq-mariadb. 30 | 31 | For more information on the use of the Business Source License generally, 32 | please visit the Adopting and Developing Business Source License FAQ at 33 | https://mariadb.com/bsl-faq-adopting. 34 | 35 | ----------------------------------------------------------------------------- 36 | 37 | Business Source License 1.1 38 | 39 | Terms 40 | 41 | The Licensor hereby grants you the right to copy, modify, create derivative 42 | works, redistribute, and make non-production use of the Licensed Work. The 43 | Licensor may make an Additional Use Grant, above, permitting limited 44 | production use. 45 | 46 | Effective on the Change Date, or the fourth anniversary of the first publicly 47 | available distribution of a specific version of the Licensed Work under this 48 | License, whichever comes first, the Licensor hereby grants you rights under 49 | the terms of the Change License, and the rights granted in the paragraph 50 | above terminate. 51 | 52 | If your use of the Licensed Work does not comply with the requirements 53 | currently in effect as described in this License, you must purchase a 54 | commercial license from the Licensor, its affiliated entities, or authorized 55 | resellers, or you must refrain from using the Licensed Work. 56 | 57 | All copies of the original and modified Licensed Work, and derivative works 58 | of the Licensed Work, are subject to this License. This License applies 59 | separately for each version of the Licensed Work and the Change Date may vary 60 | for each version of the Licensed Work released by Licensor. 61 | 62 | You must conspicuously display this License on each original or modified copy 63 | of the Licensed Work. If you receive the Licensed Work in original or 64 | modified form from a third party, the terms and conditions set forth in this 65 | License apply to your use of that work. 66 | 67 | Any use of the Licensed Work in violation of this License will automatically 68 | terminate your rights under this License for the current and all other 69 | versions of the Licensed Work. 70 | 71 | This License does not grant you any right in any trademark or logo of 72 | Licensor or its affiliates (provided that you may use a trademark or logo of 73 | Licensor as expressly required by this License). 74 | 75 | TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON 76 | AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, 77 | EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF 78 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND 79 | TITLE. 80 | 81 | MariaDB hereby grants you permission to use this License’s text to license 82 | your works, and to refer to it using the trademark “Business Source License”, 83 | as long as you comply with the Covenants of Licensor below. 84 | 85 | Covenants of Licensor 86 | 87 | In consideration of the right to use this License’s text and the “Business 88 | Source License” name and trademark, Licensor covenants to MariaDB, and to all 89 | other recipients of the licensed work to be provided by Licensor: 90 | 91 | 1. To specify as the Change License the GPL Version 2.0 or any later version, 92 | or a license that is compatible with GPL Version 2.0 or a later version, 93 | where “compatible” means that software provided under the Change License can 94 | be included in a program with software provided under GPL Version 2.0 or a 95 | later version. Licensor may specify additional Change Licenses without 96 | limitation. 97 | 98 | 2. To either: (a) specify an additional grant of rights to use that does not 99 | impose any additional restriction on the right granted in this License, as 100 | the Additional Use Grant; or (b) insert the text “None”. 101 | 102 | 3. To specify a Change Date. 103 | 104 | 4. Not to modify this License in any other way. 105 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | IMAGE_NAME := mariadb/maxscale 2 | MXS_VERSION ?= 3 | IMAGE_TAG := $(IMAGE_NAME):$(MXS_VERSION)-ubi 4 | USAGE := "Usage: make build-image MXS_VERSION=" 5 | REDHAT_PROJECT_ID ?= 6 | REDHAT_API_KEY ?= 7 | DOCKER_CONFIG ?= $(HOME)/.docker/config.json 8 | 9 | ## Location to install dependencies to 10 | LOCALBIN ?= $(shell pwd)/bin 11 | $(LOCALBIN): 12 | mkdir -p $(LOCALBIN) 13 | ## Tool Binaries 14 | PREFLIGHT ?= $(LOCALBIN)/preflight 15 | 16 | .PHONY: help 17 | 18 | ifeq ($(MXS_VERSION), ) 19 | $(error MXS_VERSION is empty. $(USAGE)) 20 | endif 21 | 22 | help: 23 | @echo $(USAGE) 24 | 25 | build-image: 26 | docker build -f Dockerfile -t $(IMAGE_TAG) --build-arg MXS_VERSION=$(MXS_VERSION) . 27 | 28 | PREFLIGHT_IMAGE ?= "" 29 | .PHONY: preflight-image 30 | preflight-image: preflight ## Run preflight tests on the image. 31 | $(PREFLIGHT) check container $(PREFLIGHT_IMAGE) --docker-config $(DOCKER_CONFIG) 32 | 33 | .PHONY: preflight-image-submit 34 | preflight-image-submit: preflight ## Run preflight tests on the image and submit the results to Red Hat. 35 | $(PREFLIGHT) check container $(PREFLIGHT_IMAGE)\ 36 | --submit \ 37 | --pyxis-api-token=$(REDHAT_API_KEY) \ 38 | --certification-component-id=$(REDHAT_PROJECT_ID)\ 39 | --docker-config $(DOCKER_CONFIG) 40 | 41 | .PHONY: preflight 42 | preflight: ## Download preflight locally if necessary. 43 | @{ \ 44 | set -e ;\ 45 | PREFLIGHT_VERSION=$$(curl -s https://api.github.com/repos/redhat-openshift-ecosystem/openshift-preflight/releases/latest | jq -r .tag_name) ;\ 46 | mkdir -p $(dir $(PREFLIGHT)) ;\ 47 | OS=$$(uname | tr '[:upper:]' '[:lower:]') ;\ 48 | ARCH=$$(uname -m) ;\ 49 | if [ "$$ARCH" = "x86_64" ]; then ARCH="amd64"; fi ;\ 50 | if [ "$$ARCH" = "aarch64" ]; then ARCH="arm64"; fi ;\ 51 | curl -sSLo $(PREFLIGHT) https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/download/$$PREFLIGHT_VERSION/preflight-$$OS-$$ARCH ;\ 52 | chmod +x $(PREFLIGHT) ;\ 53 | } -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | I am contributing the new code of the whole pull request, including one or 2 | several files that are either new files or modified ones, under the BSD-new 3 | license. 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](https://mariadb.com/wp-content/uploads/2019/11/mariadb-logo_blue-transparent.png) 2 | 3 | # MariaDB MaxScale Docker image 4 | 5 | This Docker image runs MariaDB MaxScale. Two image variants can be built: 6 | 7 | 1. [Tini](https://github.com/krallin/tini)-based image running on [Rocky Linux 8](https://rockylinux.org/) 8 | 2. Minimal image running on [Red Hat Universal Base Image 8 Minimal](https://catalog.redhat.com/software/containers/ubi8/ubi-minimal/5c359a62bed8bd75a2c3fba8?q=Red%20Hat%20Unive&architecture=amd64&image=660383f31ba64b6bd44df0a7) 9 | 10 | The image type and the contained MaxScale version depend on the Git branch used. 11 | 12 | ## Building 13 | 14 | Build the Tini-based image: 15 | ``` 16 | make build-image 17 | ``` 18 | 19 | Build the RHEL-UBI-based image: 20 | ``` 21 | make build-image MXS_VERSION= 22 | ``` 23 | For example, to build an image with MaxScale 24.02.1 running on RHEL-UBI run 24 | `make build-image MXS_VERSION=24.02.1` 25 | 26 | ## Running 27 | 28 | Pull the latest MaxScale image from docker hub: 29 | ``` 30 | docker pull mariadb/maxscale:latest 31 | ``` 32 | 33 | Run the MaxScale container as "mxs": 34 | ``` 35 | docker run -d --rm --name mxs mariadb/maxscale:latest 36 | ``` 37 | 38 | ## Configuration 39 | 40 | The default configuration for the container is minimal and only enables the 41 | REST API. 42 | 43 | The REST API by default listens on port 8989. The default user is "admin" with 44 | password "mariadb". Accessing it from the docker host requires a port mapping 45 | specified on container startup. The example below shows general information via 46 | curl. 47 | ``` 48 | docker run -d --rm -p 8989:8989 --name mxs mariadb/maxscale:latest 49 | curl -u admin:mariadb http://localhost:8989/v1/maxscale 50 | ``` 51 | 52 | See [MaxScale documentation](https://mariadb.com/kb/en/mariadb-maxscale-2208-rest-api/) 53 | for more information about the REST API. 54 | 55 | ### Configure via configuration file 56 | 57 | Custom configuration can be given in an additional configuration file (e.g. 58 | `my-maxscale.cnf`). The file needs to be mounted into `/etc/maxscale.cnf.d/`: 59 | ``` 60 | docker run -d --rm -p 8989:8989 --name mxs -v $PWD/my-maxscale.cnf:/etc/maxscale.cnf.d/my-maxscale.cnf mariadb/maxscale:latest 61 | ``` 62 | 63 | If the `[maxscale]`-section of the configuration file needs to be altered, the 64 | new file should override the default configuration file. 65 | ``` 66 | docker run -d --rm -p 8989:8989 --name mxs -v $PWD/my-maxscale.cnf:/etc/maxscale.cnf mariadb/maxscale:latest 67 | ``` 68 | 69 | ### Commandline Access 70 | 71 | `docker exec -it mxs bash` 72 | -------------------------------------------------------------------------------- /mariadb_repo_setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=2016 disable=1091 disable=2059 3 | 4 | version="2024-08-14" 5 | 6 | # Notes: 7 | # 2024-08-14 - Add support for 11.6 8 | # 2024-06-06 - Update MariaDB default to 11.rolling 9 | # 2024-05-30 - Update MariaDB default to 11.4, add support for 11.5 10 | # - Add Ubuntu 24.04 LTS "noble" 11 | # 2024-02-16 - Update MariaDB default to 11.3, add support for 11.4 12 | # 2023-11-21 - Update MariaDB default to 11.2, add support for 11.3 13 | # 2023-08-21 - Update MariaDB default to 11.1, add support for 11.2 14 | # 2023-08-14 - Add Debian 12 Bookworm 15 | # 2023-06-09 - Update MariaDB default to 11.0, add support for 11.1 16 | # 2023-06-08 - Fix for uname reporting alternate arch names 17 | # 2023-02-16 - Update MariaDB default to 10.11, add support for 11.0 18 | # 2023-01-23 - Add to the error message about missing/wrong version 19 | # 2023-01-23 - Better support for setting up old repositories 20 | # 2022-11-17 - Update MariaDB default to 10.10, add support for 10.11 21 | # 2022-09-12 - Minor updates to some info messages 22 | # 2022-08-22 - Fix 10.10 issue with Ubuntu 22.04 and Debian 11 23 | # 2022-08-15 - Update MariaDB to 10.9, add support for 10.10 24 | # 2022-08-09 - Add RHEL/Rocky 9 25 | # 2022-07-27 - Remove Debian 9 Stretch 26 | # 2022-06-14 - Add --skip-verify option for skipping version verification 27 | # 2022-06-13 - Handle case where invalid os+server combo, but Maxscale OK 28 | # 2022-06-06 - Add function to test for known invalid os+server combinations 29 | # 2022-06-03 - Update MariaDB to 10.8, add support for 10.9 30 | # 2022-06-02 - Look up current MariaDB versions 31 | # 2022-06-01 - Add --skip-eol-check and --skip-os-eol-check options for 32 | # testing old eol versions of mariadb 33 | # 2022-05-31 - move all repos to dlm.mariadb.com 34 | # 2022-05-03 - Add Rocky 8 to usage/help output, Remove CentOS 8 35 | # 2022-04-21 - add Ubuntu 22.04 LTS "jammy" 36 | # 2022-02-08 - Adjust repo pinning for Ubuntu/Debian, update MariaDB to 10.7 37 | # 2022-01-31 - Verify that server version is valid 38 | # 2022-01-18 - Add aarch64 RHEL/SLES repositories 39 | # 2021-12-10 - Update keyring URL 40 | # 2021-11-18 - Update default URL of script 41 | # 2021-11-08 - Add support for 10.7 42 | # 2021-08-02 - Add Debian 11 Bullseye & aarch64/arm64 MaxScale repositories 43 | # 2021-07-30 - Remove Ubuntu 16.04 Xenial 44 | # 2021-07-06 - Update MariaDB to 10.6 45 | # 2021-06-28 - Fix warnings with debug repositories on Ubuntu 18.04 Bionic 46 | # 2021-06-24 - MDEV-25991, adjust apt-transport-https dependency 47 | # 2021-06-21 - Download repo keys to pki folder on RHEL, SLES 48 | # 2021-06-09 - Limit deb repos to amd64,arm64 architectures 49 | # 2021-06-07 - MDEV-25805 fix detection for Rocky and Alma Linux 8 50 | # 2021-06-01 - Clean Package Cache after yum/dnf/zyp repository configuration 51 | # 2021-05-26 - Fix URL handling, remove unneeded warning 52 | # 2021-05-21 - Set 10.6 repos to pull from the correct place 53 | # 2021-05-03 - Fix MaxScale repository paths, add --skip-check-installed flag 54 | # 2021-03-04 - Add chmod step to ensure apt can read the keyring 55 | # 2021-02-12 - Include dbgsym ddeb packages for Ubuntu 56 | # 2021-01-26 - Validate manually supplied --os-type and --os-version 57 | # 2021-01-22 - Remove ambiguous $releasever and $basearch from rhel repo 58 | # 2021-01-22 - Remove ambiguous $basearch from sles repo 59 | # 2021-01-14 - Add --version flag 60 | # 2020-12-16 - Fix issue with detecting CentOS 8.3+ 61 | # 2020-12-16 - remove CentOS 6, deprecated as of Nov 2020 62 | # 2020-12-07 - remove Debian 8 Jessie, deprecated as of Jun 2020 63 | # 2020-10-15 - Add check_installed function to ensure script can run 64 | # 2020-10-15 - Update MariaDB MaxScale to use CDN 65 | # 2020-10-15 - Change default MaxScale to 'latest' 66 | # 2020-09-11 - Update default MaxScale version to 2.5 67 | # 2020-06-25 - Update MariaDB to 10.5, also deprecate Ubuntu 14.04 'trusty' 68 | # 2020-05-12 - update curl command to correctly handle CDN redirects 69 | # 2020-03-27 - add Ubuntu 20.04 "focal" 70 | # 2020-01-22 - add "module_hotfixes = 1" to RHEL/CentOS 8 config (MDEV-20673) 71 | # 2020-01-22 - update msg strings for better output and consistency 72 | # 2020-01-08 - add autorefresh=1 to sles repo configs 73 | # 2019-12-04 - add RHEL 8, and CentOS 8 74 | # 2019-09-25 - add Debian 10 "buster" 75 | # 2019-09-25 - MDEV-20654 - change gpg key importing 76 | # 2019-09-24 - Update to MaxScale Version 2.4 77 | # 2019-06-18 - Update to MariaDB 10.4 78 | # 2018-12-24 - Update to MaxScale Version 2.3 79 | 80 | # This script will identify the OS distribution and version, make sure it's 81 | # supported, and set up the appropriate MariaDB software repositories. 82 | 83 | supported="# The MariaDB Repository only supports these distributions: 84 | # * RHEL/Rocky 8 & 9 (rhel) 85 | # * RHEL/CentOS 7 (rhel) 86 | # * Ubuntu 20.04 LTS (focal), 22.04 LTS (jammy), and 24.04 LTS (noble) 87 | # * Debian 10 (buster), Debian 11 (bullseye), and Debian 12 (bookworm) 88 | # * SLES 12 & 15 (sles)" 89 | 90 | otherplatforms="# See https://mariadb.com/kb/en/mariadb/mariadb-package-repository-setup-and-usage/#platform-support" 91 | 92 | url_base="dlm.mariadb.com" 93 | url_mariadb_repo="https://${url_base}/repo/mariadb-server" 94 | mariadb_server_version=mariadb-11.rolling 95 | mariadb_server_version_real=mariadb-11.rolling 96 | mariadb_maxscale_version=latest 97 | write_to_stdout=0 98 | skip_key_import=0 99 | skip_maxscale=0 100 | skip_server=0 101 | skip_tools=0 102 | skip_verify=0 103 | skip_check_installed=0 104 | skip_eol_check=0 105 | skip_os_eol_check=0 106 | extra_options="" 107 | version_info="" 108 | 109 | usage="Usage: curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- [OPTIONS] 110 | 111 | https://mariadb.com/kb/en/mariadb/mariadb-package-repository-setup-and-usage/ 112 | 113 | $supported 114 | 115 | Options: 116 | --help Display this help and exit. 117 | 118 | --version Output the script version and exit. 119 | 120 | --mariadb-server-version= 121 | Override the default MariaDB Server version. 122 | By default, the script will use '$mariadb_server_version'. 123 | 124 | --mariadb-maxscale-version= 125 | Override the default MariaDB MaxScale version. 126 | By default, the script will use '$mariadb_maxscale_version'. 127 | 128 | --os-type= Override detection of OS type. Acceptable values 129 | include 'debian', 'ubuntu', 'rhel', and 'sles'. 130 | 131 | --os-version= Override detection of OS version. Acceptable values 132 | depend on the OS type you specify. 133 | 134 | --arch= Override detection of CPU architecture. Acceptable 135 | values are 'x86_64', 'aarch64', 'amd64', & 'arm64'. 136 | 137 | --skip-key-import Skip importing GPG signing keys. 138 | 139 | --skip-maxscale Skip the 'MaxScale' repository. 140 | 141 | --skip-server Skip the 'MariaDB Server' repository. 142 | 143 | --skip-tools Skip the 'Tools' repository. 144 | 145 | --skip-verify Skip verification of MariaDB Server versions. 146 | Use with caution as this can lead to an invalid 147 | repository configuration file being created. 148 | 149 | --skip-check-installed Skip tests for required prerequisites for this script. 150 | 151 | --skip-eol-check Skip tests for versions being past their EOL date 152 | 153 | --skip-os-eol-check Skip tests for operating system versions being past EOL date 154 | 155 | --write-to-stdout Write output to stdout instead of to the OS's 156 | repository configuration. This will also skip 157 | importing GPG keys and updating the package 158 | cache on platforms where that behavior exists. 159 | " 160 | 161 | # os_type = ubuntu, debian, rhel, sles 162 | os_type= 163 | # os_version as demanded by the OS (codename, major release, etc.) 164 | os_version= 165 | 166 | # These GPG key IDs are used to fetch keys from a keyserver on Ubuntu & Debian 167 | key_ids=( 0x8167EE24 0xE3C94F49 0xcbcb082a1bb943db 0xf1656f24c74cd1d8 0x135659e928c12247 ) 168 | # These GPG URLs are used to fetch GPG keys on RHEL and SLES 169 | key_urls=( 170 | https://supplychain.mariadb.com/MariaDB-Server-GPG-KEY 171 | https://supplychain.mariadb.com/MariaDB-MaxScale-GPG-KEY 172 | https://supplychain.mariadb.com/MariaDB-Enterprise-GPG-KEY 173 | ) 174 | 175 | msg(){ 176 | type=$1 #${1^^} 177 | shift 178 | printf "# [$type] %s\n" "$@" >&2 179 | } 180 | 181 | error(){ 182 | msg error "$@" 183 | exit 1 184 | } 185 | 186 | cap() 187 | { 188 | printf '%s' "$1" | head -c 1 | tr [:lower:] [:upper:] 189 | printf '%s' "$1" | tail -c '+2' 190 | } 191 | 192 | verify_server_os_combo() { 193 | local failed=0 194 | local not_available="MariaDB Server ${mariadb_server_version_real} is not available for $(cap ${os_type}) $(cap ${os_version})" 195 | case $mariadb_server_version_real in 196 | *10.1[0-1]*) ;; # need to handle 10.10+ 197 | *10.[0-4]*) case ${os_version} in jammy|bullseye|noble) failed=1 ;; esac ;; 198 | *10.5*) case ${os_version} in jammy|noble) failed=1 ;; esac ;; 199 | esac 200 | if (( $failed )) 201 | then 202 | # This verify_server_os_combo function only runs if MariaDB is not being 203 | # skipped. If Maxscale is being skipped then we return an error, otherwise 204 | # we just return a warning and skip configuring the Server repo. 205 | if ((skip_maxscale)) 206 | then 207 | error "${not_available}" 208 | else 209 | msg warning "${not_available}, skipping..." 210 | skip_server=1 211 | fi 212 | fi 213 | } 214 | 215 | verify_mariadb_server_version() { 216 | # version regex 217 | if (($skip_eol_check)); then 218 | rx='^(mariadb-){0,1}(10\.[0-9]|10\.1[0-1]|10\.[0-9]\.[1-9]{0,1}[0-9]{1}|10\.1[0-1]\.[1-9]{1}[0-9]{0,1}|11\.[0-6]|11\.[0-6]\.[1-9]{1}[0-9]{0,1}|11\.rc|11\.rolling)$' 219 | else 220 | rx='^(mariadb-){0,1}(10\.[4569]|10\.1[0-1]|10\.[4569]\.[1-9]{0,1}[0-9]{1}|10\.1[0-1]\.[1-9]{1}[0-9]{0,1}|11\.[0-6]|11\.[0-6]\.[1-9]{1}[0-9]{0,1}|11\.rc|11\.rolling)$' 221 | fi 222 | if [[ $@ =~ $rx ]] ; then 223 | case $os_type in 224 | ubuntu|debian) 225 | verify_url="${url_mariadb_repo}/${mariadb_server_version_real}/repo/${os_type}/dists/${os_version}/Release" 226 | ;; 227 | rhel) 228 | verify_url="${url_mariadb_repo}/${mariadb_server_version_real}/yum/rhel/${os_version}/${arch}/repodata/repomd.xml" 229 | ;; 230 | sles) 231 | verify_url="${url_mariadb_repo}/${mariadb_server_version_real}/yum/sles/${os_version}/x86_64/repodata/repomd.xml" 232 | ;; 233 | esac 234 | error_log=$(mktemp) 235 | http_status_code=$(curl -LsS --stderr ${error_log} -o /dev/null -I -w "%{http_code}" ${verify_url}) 236 | return_code="$?" 237 | error_output=$(cat ${error_log}) 238 | rm -f ${error_log} 239 | 240 | case ${http_status_code} in 241 | 200) 242 | msg info "MariaDB Server version ${mariadb_server_version_real} is valid" 243 | ;; 244 | 403|404) 245 | get_version_info_server 246 | error "MariaDB Server version ${mariadb_server_version_real} is not working. 247 | # Please verify that the version is correct. 248 | # Not all releases of MariaDB are available on all distributions. 249 | #${version_info}" 250 | ;; 251 | *) 252 | error_message="Problem encountered while trying to verify the MariaDB Server version:" 253 | if [[ "${return_code}" -gt "0" ]]; then 254 | get_version_info_server 255 | error "${error_message} 256 | $error_output ${version_info}" 257 | else 258 | get_version_info_server 259 | error "${error_message} 260 | Unexpected HTTP response code '${http_status_code}' ${version_info}" 261 | fi 262 | ;; 263 | esac 264 | else 265 | get_version_info_server 266 | error "MariaDB Server version ${mariadb_server_version_real} is not valid. ${version_info}" 267 | fi 268 | } 269 | 270 | get_version_info_server() { 271 | if [[ "${version_info}" = "" ]]; then 272 | latest_versions_server=$(curl -s https://dlm.mariadb.com/rest/releases/mariadb_server/) 273 | 274 | version_info=" 275 | # The latest MariaDB Server versions are: 276 | # ${latest_versions_server} 277 | # 278 | # More information on MariaDB releases is available at: 279 | # https://mariadb.com/kb/en/release-notes/" 280 | fi 281 | } 282 | 283 | version(){ 284 | printf "mariadb_repo_setup %s\n" "$version" 285 | } 286 | 287 | while :; do 288 | case $1 in 289 | --version) 290 | version 291 | exit 0 292 | ;; 293 | --mariadb-server-version) 294 | if [[ -n $2 ]] && [[ $2 != --* ]]; then 295 | mariadb_server_version=$2 296 | shift 297 | else 298 | error "The $1 option requires an argument" 299 | fi 300 | ;; 301 | --mariadb-server-version=?*) 302 | mariadb_server_version=${1#*=} 303 | ;; 304 | --mariadb-server-version=) 305 | error "The $1 option requires an argument" 306 | ;; 307 | --mariadb-maxscale-version) 308 | if [[ -n $2 ]] && [[ $2 != --* ]]; then 309 | mariadb_maxscale_version=$2 310 | shift 311 | else 312 | error "The $1 option requires an argument" 313 | fi 314 | ;; 315 | --mariadb-maxscale-version=?*) 316 | mariadb_maxscale_version=${1#*=} 317 | ;; 318 | --mariadb-maxscale-version=) 319 | error "The $1 option requires an argument" 320 | ;; 321 | 322 | --write-to-stdout) 323 | write_to_stdout=1 324 | ;; 325 | 326 | --skip-key-import) 327 | skip_key_import=1 328 | ;; 329 | --skip-maxscale) 330 | skip_maxscale=1 331 | ;; 332 | --skip-server) 333 | skip_server=1 334 | ;; 335 | --skip-tools) 336 | skip_tools=1 337 | ;; 338 | --skip-verify) 339 | skip_verify=1 340 | ;; 341 | --skip-check-installed) 342 | skip_check_installed=1 343 | ;; 344 | --skip-eol-check) 345 | skip_eol_check=1 346 | ;; 347 | --skip-os-eol-check) 348 | skip_os_eol_check=1 349 | ;; 350 | 351 | --os-type) 352 | if [[ -n $2 ]] && [[ $2 != --* ]]; then 353 | os_type=$2 354 | shift 355 | else 356 | error "The $1 option requires an argument" 357 | fi 358 | ;; 359 | --os-type=?*) 360 | os_type=${1#*=} 361 | ;; 362 | --os-type=) 363 | error "The $1 option requires an argument" 364 | ;; 365 | --arch) 366 | if [[ -n $2 ]] && [[ $2 != --* ]]; then 367 | os_type=$2 368 | shift 369 | else 370 | error "The $1 option requires an argument" 371 | fi 372 | ;; 373 | --arch=?*) 374 | arch=${1#*=} 375 | # normalize arch names 376 | case $arch in 377 | amd64|x86_64) 378 | arch='x86_64' 379 | ;; 380 | aarch64|arm64) 381 | arch='aarch64' 382 | ;; 383 | *) 384 | error "You set arch=$arch but valid architectures are: x86_64 (amd64) and aarch64 (arm64)" 385 | ;; 386 | esac 387 | ;; 388 | --arch=) 389 | error "The $1 option requires an argument" 390 | ;; 391 | --os-version) 392 | if [[ -n $2 ]] && [[ $2 != --* ]]; then 393 | os_version=$2 394 | shift 395 | else 396 | error "The $1 option requires an argument" 397 | fi 398 | ;; 399 | --os-version=?*) 400 | os_version=${1#*=} 401 | ;; 402 | --os-version=) 403 | error "The $1 option requires an argument" 404 | ;; 405 | --help) 406 | version 407 | printf "%s" "$usage" 408 | exit 409 | ;; 410 | -?*) 411 | msg warning "Unknown option (ignored): $1\n" 412 | ;; 413 | *) 414 | break 415 | esac 416 | shift 417 | done 418 | 419 | # We accept setting os-type to centos or rocky, but we normalize it to 'rhel' 420 | case ${os_type} in 421 | centos|rocky*) os_type='rhel' ;; 422 | esac 423 | 424 | open_outfile(){ 425 | unset outfile 426 | if (( write_to_stdout )) 427 | then 428 | exec 4>&1 429 | else 430 | case $1 in 431 | ubuntu|debian) outfile=/etc/apt/sources.list.d/mariadb.list ;; 432 | rhel) outfile=/etc/yum.repos.d/mariadb.repo ;; 433 | sles) outfile=/etc/zypp/repos.d/mariadb.repo ;; 434 | *) error "Sorry, your OS is not supported." "$supported" 435 | esac 436 | if [[ -e $outfile ]] 437 | then 438 | local suffix=0 439 | while [[ -e $outfile.old_$((++suffix)) ]]; do :; done 440 | msg warning "Found existing file at $outfile. Moving to $outfile.old_$suffix" 441 | if ! mv "$outfile" "$outfile.old_$suffix" 442 | then 443 | error "Could not move existing '$outfile'. Aborting"\ 444 | "Use the --write-to-stdout option to see its effect without becoming root" 445 | fi 446 | fi 447 | if ! exec 4>"$outfile" 448 | then 449 | error "Could not open file $outfile for writing. Aborting"\ 450 | "Use the --write-to-stdout option to see its effect without becoming root" 451 | fi 452 | fi 453 | } 454 | 455 | identify_os(){ 456 | if [[ ! $arch ]] 457 | then 458 | arch=$(uname -m) 459 | fi 460 | # Check for macOS 461 | if [[ $(uname -s) == Darwin ]] 462 | then 463 | printf '%s\n' \ 464 | 'To install MariaDB Server from a repository on macOS, please use Homebrew:' \ 465 | ' https://mariadb.com/kb/en/mariadb/installing-mariadb-on-macos-using-homebrew/' \ 466 | 'Or use the native PKG installer:' \ 467 | ' https://mariadb.com/kb/en/mariadb/installing-mariadb-server-pkg-packages-on-macos/' 468 | exit 469 | # Check for RHEL/CentOS, Fedora, etc. 470 | elif command -v rpm >/dev/null && [[ -e /etc/redhat-release ]] 471 | then 472 | os_type=rhel 473 | el_version=$(rpm -qa '(oraclelinux|sl|redhat|centos|fedora|rocky|alma)*release(|-server)' --queryformat '%{VERSION}') 474 | case $el_version in 475 | 5*) os_version=5 ; ((skip_os_eol_check)) || error "RHEL/CentOS 5 is no longer supported" "$supported" ;; 476 | 6*) os_version=6 ; ((skip_os_eol_check)) || error "RHEL/CentOS 6 is no longer supported" "$supported" ;; 477 | 7*) os_version=7 ;; 478 | 8*) os_version=8 ; extra_options="module_hotfixes = 1" ;; 479 | 9*) os_version=9 ; extra_options="module_hotfixes = 1" ;; 480 | *) error "Detected RHEL or compatible but version ($el_version) is not supported." "$supported" "$otherplatforms" ;; 481 | esac 482 | elif [[ -e /etc/os-release ]] 483 | then 484 | . /etc/os-release 485 | # Is it Debian? 486 | case $ID in 487 | debian) 488 | os_type=debian 489 | debian_version=$(< /etc/debian_version) 490 | case $debian_version in 491 | 9*) os_version=stretch ; ((skip_os_eol_check)) || error "Debian 9 'stretch' has reached End of Life and is no longer supported" "$supported" ;; 492 | 10*) os_version=buster ;; 493 | 11*) os_version=bullseye ;; 494 | 12*) os_version=bookworm ;; 495 | *) error "Detected Debian but version ($debian_version) is not supported." "$supported" "$otherplatforms" ;; 496 | esac 497 | ;; 498 | ubuntu) 499 | os_type=ubuntu 500 | . /etc/lsb-release 501 | os_version=$DISTRIB_CODENAME 502 | case $os_version in 503 | precise ) ((skip_os_eol_check)) || error 'Ubuntu 12.04 LTS has reached End of Life and is no longer supported.' ;; 504 | trusty ) ((skip_os_eol_check)) || error 'Ubuntu 14.04 LTS has reached End of Life and is no longer supported.' ;; 505 | xenial ) ((skip_os_eol_check)) || error 'Ubuntu 16.04 LTS has reached End of Life and is no longer supported.' ;; 506 | bionic ) extra_options=" lang=none target-=CNF" ; ((skip_os_eol_check)) || error 'Ubuntu 18.04 LTS has reached End of Life and is no longer supported.' ;; 507 | focal|jammy|noble ) ;; 508 | *) error "Detected Ubuntu but version ($os_version) is not supported." "Only Ubuntu LTS releases are supported." "$otherplatforms" ;; 509 | esac 510 | if [[ $arch == aarch64 ]] 511 | then 512 | case $os_version in 513 | xenial ) ;; 514 | bionic ) extra_options=" lang=none target-=CNF" ;; 515 | focal|jammy|noble ) ;; 516 | *) error "Only 18.04/bionic, 20.04/focal, 22.04/jammy, & 24.04/noble are supported for ARM64. Detected version: '$os_version'" ;; 517 | esac 518 | fi 519 | ;; 520 | sles) 521 | os_type=sles 522 | os_version=${VERSION_ID%%.*} 523 | case $os_version in 524 | 12|15) ;; 525 | *) error "Detected SLES but version ($os_version) is not supported." "$otherplatforms" ;; 526 | esac 527 | ;; 528 | esac 529 | fi 530 | if ! [[ $os_type ]] || ! [[ $os_version ]] 531 | then 532 | error "Could not identify OS type or version." "$supported" 533 | fi 534 | } 535 | 536 | check_installed() { 537 | local not_installed 538 | local number_not_installed 539 | local install_message 540 | local need_to_install 541 | not_installed="" 542 | need_to_install=false 543 | for package in "$@" ; do 544 | case ${os_type} in 545 | debian|ubuntu) 546 | if { dpkg -l "${package}" | grep ii; } &>/dev/null ; then 547 | need_to_install=false 548 | else 549 | need_to_install=true 550 | fi 551 | ;; 552 | rhel) 553 | if { yum list installed "${package}" ; } &>/dev/null ; then 554 | need_to_install=false 555 | else 556 | need_to_install=true 557 | fi 558 | ;; 559 | sles) 560 | if { rpm -q "${package}" ; } &>/dev/null ; then 561 | need_to_install=false 562 | else 563 | need_to_install=true 564 | fi 565 | ;; 566 | esac 567 | if ${need_to_install} ; then 568 | if [ "${not_installed}" = "" ] ; then 569 | # number of not installed packages is 1 570 | not_installed="${package}" 571 | number_not_installed=1 572 | else 573 | # number of not installed packages is >1 574 | not_installed="${not_installed} ${package}" 575 | number_not_installed=2 576 | fi 577 | fi 578 | done 579 | if [ "${not_installed}" != "" ] ; then 580 | # One or more packages are not installed 581 | case ${number_not_installed} in 582 | 1) install_message="The following package is needed by the script, but not installed:" ;; 583 | 2) install_message="The following packages are needed by the script, but not installed:" ;; 584 | esac 585 | 586 | error "${install_message} 587 | ${not_installed} 588 | Please install and rerun the script. 589 | To disable this check add the \`--skip-check-installed\` flag" 590 | fi 591 | } 592 | 593 | remove_mdbe_repo(){ 594 | case $os_type in 595 | debian|ubuntu) 596 | # First, remove the MariaDB Enterprise Repository config package, if it's installed 597 | if dpkg -l mariadb-enterprise-repository &>/dev/null 598 | then 599 | msg info 'Removing mariadb-enterprise-repository package...' 600 | dpkg -P mariadb-enterprise-repository 601 | fi 602 | ;; 603 | rhel|sles) 604 | # First, remove the MariaDB Enterprise Repository config package, if it's installed 605 | if rpm -qs mariadb-enterprise-repository &>/dev/null 606 | then 607 | msg info 'Removing mariadb-enterprise-repository package...' 608 | rpm -e mariadb-enterprise-repository 609 | fi 610 | ;; 611 | esac 612 | } 613 | 614 | clean_package_cache(){ 615 | msg info 'Cleaning package cache...' 616 | case $1 in 617 | yum) 618 | microdnf clean all 619 | ;; 620 | dnf) 621 | dnf clean all 622 | ;; 623 | zypper) 624 | zypper clean --all 625 | ;; 626 | esac 627 | } 628 | 629 | # The directory structure of the MariaDB Server repo is such that the directories for each 630 | # version have "mariadb-" prepended to the version number (i.e. mariadb-10.1 instead of 10.1) 631 | # for 10.6 this has changed to just the version number 632 | if [[ $mariadb_server_version = mariadb-* ]] 633 | then 634 | mariadb_server_version_num=${mariadb_server_version#*-} 635 | else 636 | mariadb_server_version_num=$mariadb_server_version 637 | mariadb_server_version=mariadb-$mariadb_server_version 638 | fi 639 | 640 | mariadb_server_version_real=$mariadb_server_version_num 641 | 642 | # If we're writing the repository info to stdout, let's not try to import the signing keys. 643 | ((write_to_stdout)) && skip_key_import=1 644 | 645 | if [[ ! $arch ]] 646 | then 647 | arch=$(uname -m) 648 | case $arch in 649 | amd64|x86_64) 650 | arch='x86_64' 651 | ;; 652 | aarch64|arm64) 653 | arch='aarch64' 654 | ;; 655 | esac 656 | fi 657 | 658 | case $arch in 659 | x86_64) ;; 660 | aarch64) skip_tools=1;; 661 | *) error "The MariaDB Repository only supports x86_64 and aarch64 (detected $arch)." "$supported" "$otherplatforms" ;; 662 | esac 663 | 664 | if [[ $os_type ]] && [[ $os_version ]] 665 | then 666 | # Both were given on the command line, so we'll just try using those. 667 | msg info "Skipping OS detection and using OS type '$os_type' and version '$os_version' as given on the command line" 668 | # We're skipping OS detection, so set extra_options to the correct value 669 | # for RHEL 670 | case $os_version in 671 | 7*|8*|9*) 672 | if [ $os_type = 'rhel' ] ; then 673 | case $os_version in 674 | 7*) os_version=7 ;; 675 | 8*) os_version=8 ; extra_options="module_hotfixes = 1" ;; 676 | 9*) os_version=9 ; extra_options="module_hotfixes = 1" ;; 677 | esac 678 | elif [ $os_type = 'debian' ] ; then 679 | case $os_version in 680 | 7) os_version='wheezy' ; ((skip_os_eol_check)) || msg warning "Debian 7 'wheezy' has reached End of Life and is no longer supported." "$supported" ;; 681 | 8) os_version='jessie' ; ((skip_os_eol_check)) || msg warning "Debian 8 'jessie' has reached End of Life and is no longer supported." "$supported" ;; 682 | 9) os_version='stretch' ; ((skip_os_eol_check)) || msg warning "Debian 9 'stretch' has reached End of Life and is no longer supported" "$supported" ;; 683 | esac 684 | else 685 | error "--os-version='$os_version' is only valid if --os-type='rhel', you gave '$os_type'" "$supported" 686 | fi 687 | ;; 688 | 10|11) 689 | if [ $os_type = 'debian' ] ; then 690 | case $os_version in 691 | 10) os_version='buster' ;; 692 | 11) os_version='bullseye' ;; 693 | esac 694 | else 695 | error "--os-version='$os_version' is only valid if --os-type='debian', you gave '$os_type'" "$supported" 696 | fi 697 | ;; 698 | 12*) 699 | if [ $os_type = 'sles' ] ; then 700 | case $os_version in 701 | 12*) os_version=12 ;; 702 | esac 703 | elif [ $os_type = 'debian' ] ; then 704 | case $os_version in 705 | 12*) os_version='bookworm' ;; 706 | esac 707 | else 708 | error "--os-version='$os_version' is only valid if --os-type='sles' or 'debian', you gave '$os_type'" "$supported" 709 | fi 710 | ;; 711 | 15*) 712 | if [ $os_type = 'sles' ] ; then 713 | case $os_version in 714 | 15*) os_version=15 ;; 715 | esac 716 | else 717 | error "--os-version='$os_version' is only valid if --os-type='sles', you gave '$os_type'" "$supported" 718 | fi 719 | ;; 720 | xenial|bionic|focal|jammy|noble) 721 | if [ $os_type != 'ubuntu' ] ; then 722 | error "--os-version='$os_version' is only valid if --os-type='ubuntu', you gave '$os_type'" "$supported" 723 | fi 724 | ;; 725 | stretch|buster|bullseye|bookworm) 726 | if [ $os_type != 'debian' ] ; then 727 | error "--os-version='$os_version' is only valid if --os-type='debian', you gave '$os_type'" "$supported" 728 | fi 729 | ;; 730 | *) error "--os-type='$os_type' with --os-version='$os_version' is an invalid combination" "$supported" ;; 731 | esac 732 | elif [[ $os_type ]] || [[ $os_version ]] 733 | then 734 | error 'If you give either --os-type or --os-version, you must give both.' 735 | else 736 | identify_os 737 | fi 738 | 739 | # Handle various aarch64 repositories 740 | if [[ "$arch" = 'aarch64' ]] ; then 741 | case $os_version in 742 | 7) 743 | ((skip_maxscale)) || msg info "Skipping MariaDB MaxScale as RHEL 7 does not have aarch64 packages available." 744 | ((skip_maxscale)) || skip_maxscale=1 745 | ;; 746 | 12) 747 | if [ $os_type = 'sles' ] ; then 748 | error "There are no aarch64 packages available for MariaDB Server or MariaDB MaxScale for SLES 12." 749 | fi 750 | ;; 751 | 15) 752 | ((skip_server)) || msg warning "Skipping MariaDB Server as there are no aarch64 packages available." 753 | ((skip_server)) || skip_server=1 754 | ;; 755 | esac 756 | fi 757 | 758 | if (($skip_check_installed)) 759 | then 760 | msg info "Skipping check for script prerequisites." 761 | else 762 | msg info "Checking for script prerequisites." 763 | case $os_version in 764 | stretch) check_installed curl ca-certificates apt-transport-https ;; 765 | *) check_installed curl ca-certificates ;; 766 | esac 767 | fi 768 | 769 | # To support old versions for testing purposes which are not on dlm.mariadb.com 770 | case ${mariadb_server_version} in 771 | *10.1[0-9]*) ;; # everything >= 10.10 is on the new dlm for sure 772 | *10.0*) ;& # 10.0 releases are on the old download server only 773 | *10.1*) ;& # same for 10.1 774 | *10.2*) ;& # same for 10.2 775 | *10.3.[0-2]*|*10.3.[0-9]) ;& # 10.3: old server has <= .32, dlm has >= .29, we switch at .30 776 | *10.4.[0-1]*|*10.4.[0-9]) ;& # 10.4: dlm has >= 10.4.20 777 | *10.5.[0-9]) # 10.5: dlm has >= 10.5.10 778 | url_base="downloads.mariadb.com" 779 | url_mariadb_repo="https://${url_base}/MariaDB" 780 | mariadb_server_version_real=$mariadb_server_version 781 | ;; 782 | esac 783 | 784 | rhel_repo_server=" 785 | [mariadb-main] 786 | name = MariaDB Server 787 | baseurl = ${url_mariadb_repo}/%s/yum/rhel/%s/%s 788 | gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY 789 | gpgcheck = 1 790 | enabled = 1 791 | %s" 792 | rhel_repo_maxscale=' 793 | [mariadb-maxscale] 794 | # To use the latest stable release of MaxScale, use "latest" as the version 795 | # To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version 796 | name = MariaDB MaxScale 797 | baseurl = https://dlm.mariadb.com/repo/maxscale/%s/yum/rhel/%s/%s 798 | gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY 799 | gpgcheck = 1 800 | enabled = 1' 801 | rhel_repo_tools=' 802 | [mariadb-tools] 803 | name = MariaDB Tools 804 | baseurl = https://downloads.mariadb.com/Tools/rhel/%s/x86_64 805 | gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY 806 | gpgcheck = 1 807 | enabled = 1' 808 | 809 | deb_repo_server=" 810 | # MariaDB Server 811 | # To use a different major version of the server, or to pin to a specific minor version, change URI below. 812 | deb [arch=amd64,arm64] ${url_mariadb_repo}/%s/repo/%s %s main" 813 | deb_repo_server_debug="deb [arch=amd64,arm64${extra_options}] ${url_mariadb_repo}/%s/repo/%s %s main/debug" 814 | deb_repo_maxscale=' 815 | # MariaDB MaxScale 816 | # To use the latest stable release of MaxScale, use "latest" as the version 817 | # To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version 818 | deb [arch=amd64,arm64] https://dlm.mariadb.com/repo/maxscale/%s/%s %s main' 819 | deb_repo_tools=' 820 | # MariaDB Tools 821 | deb [arch=amd64] http://downloads.mariadb.com/Tools/%s %s main' 822 | 823 | sles_repo_server=" 824 | [mariadb-server] 825 | name = MariaDB Server 826 | baseurl = ${url_mariadb_repo}/%s/yum/sles/%s/x86_64 827 | gpgkey = file:///etc/pki/trust/MariaDB-Server-GPG-KEY 828 | gpgcheck = 1 829 | type=rpm-md 830 | enabled = 1 831 | autorefresh=1 832 | priority=10" 833 | sles_repo_maxscale=' 834 | [mariadb-maxscale] 835 | # To use the latest stable release of MaxScale, use "latest" as the version 836 | # To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version 837 | name = MariaDB MaxScale 838 | baseurl = https://dlm.mariadb.com/repo/maxscale/%s/yum/sles/%s/%s 839 | gpgkey = file:///etc/pki/trust/MariaDB-MaxScale-GPG-KEY 840 | enabled = 1 841 | autorefresh=1 842 | gpgcheck = 1 843 | type=rpm-md 844 | priority=10' 845 | sles_repo_tools=' 846 | [mariadb-tools] 847 | name = MariaDB Tools 848 | baseurl = https://downloads.mariadb.com/Tools/sles/%s/x86_64 849 | gpgkey = file:///etc/pki/trust/MariaDB-Enterprise-GPG-KEY 850 | enabled = 1 851 | autorefresh=1 852 | gpgcheck = 1 853 | type=rpm-md 854 | priority=10' 855 | 856 | open_outfile "$os_type" 857 | 858 | # If we're not writing to stdout, try to remove the mariadb-enterprise-repository package 859 | ((write_to_stdout)) || remove_mdbe_repo 860 | 861 | 862 | # Before we get into creating the configuration file, check the combination of 863 | # MariaDB version and OS 864 | ((skip_server)) || verify_server_os_combo 865 | 866 | case $os_type in 867 | ubuntu|debian) 868 | # should be a valid version, so verify it is so 869 | ((skip_server)) || ((skip_verify)) || verify_mariadb_server_version $mariadb_server_version_real 870 | # If we are not writing to stdout, create an apt preferences file to give our 871 | # packages the highest possible priority 872 | if ((write_to_stdout)) 873 | then 874 | msg info 'If run without --write-to-stdout, this script will create /etc/apt/preferences.d/mariadb-enterprise.pref to give packages from MariaDB repositories highest priority, in order to avoid conflicts with packages from OS and other repositories.' 875 | else 876 | printf '%s\n' \ 877 | 'Package: *' \ 878 | "Pin: origin ${url_base}" \ 879 | 'Pin-Priority: 1000' \ 880 | > /etc/apt/preferences.d/mariadb-enterprise.pref 881 | fi 882 | { 883 | ((skip_server)) || printf "$deb_repo_server\n\n" "$mariadb_server_version_real" "$os_type" "$os_version" 884 | case $os_type in 885 | ubuntu) 886 | ((skip_server)) || printf "$deb_repo_server_debug\n\n" "$mariadb_server_version_real" "$os_type" "$os_version" 887 | ;; 888 | esac 889 | ((skip_maxscale)) || printf "$deb_repo_maxscale\n\n" "$mariadb_maxscale_version" "apt" "$os_version" 890 | ((skip_tools)) || printf "$deb_repo_tools\n" "$os_type" "$os_version" 891 | } >&4 892 | ((write_to_stdout)) || msg info "Repository file successfully written to $outfile" 893 | if ! ((skip_key_import)) 894 | then 895 | msg info 'Adding trusted package signing keys...' 896 | if curl -LsSO https://supplychain.mariadb.com/mariadb-keyring-2019.gpg 897 | then 898 | if curl -LsS https://supplychain.mariadb.com/mariadb-keyring-2019.gpg.sha256 | sha256sum -c --quiet 899 | then 900 | msg info 'Running apt-get update...' 901 | if mv mariadb-keyring-2019.gpg /etc/apt/trusted.gpg.d/ && 902 | chmod 644 /etc/apt/trusted.gpg.d/mariadb-keyring-2019.gpg && 903 | apt-get -qq update 904 | then 905 | msg info 'Done adding trusted package signing keys' 906 | else 907 | msg error 'Failed to add trusted package signing keys' 908 | fi 909 | else 910 | msg error 'Failed to verify trusted package signing keys keyring file' 911 | fi 912 | else 913 | msg error 'Failed to download trusted package signing keys keyring file' 914 | fi 915 | elif ((write_to_stdout)) 916 | then 917 | msg info 'If run without --skip-key-import/--write-to-stdout, this script will import package signing keys used by MariaDB' 918 | fi 919 | ;; 920 | rhel) 921 | ((skip_server)) || ((skip_verify)) || verify_mariadb_server_version $mariadb_server_version_real 922 | { 923 | ((skip_server)) || printf "$rhel_repo_server\n\n" "$mariadb_server_version_real" "$os_version" "$arch" "$extra_options" 924 | ((skip_maxscale)) || printf "$rhel_repo_maxscale\n\n" "$mariadb_maxscale_version" "$os_version" "$arch" 925 | ((skip_tools)) || printf "$rhel_repo_tools\n" "$os_version" 926 | } >&4 927 | ((write_to_stdout)) || msg info "Repository file successfully written to $outfile" 928 | if ! ((skip_key_import)) 929 | then 930 | msg info 'Adding trusted package signing keys...' 931 | if rpm --import "${key_urls[@]}" 932 | then 933 | pushd /etc/pki/rpm-gpg/ 934 | for key in ${key_urls[@]} ; do curl -LsSO ${key};done 935 | popd 936 | msg info 'Successfully added trusted package signing keys' 937 | else 938 | msg error 'Failed to add trusted package signing keys' 939 | fi 940 | fi 941 | ((write_to_stdout)) || clean_package_cache yum 942 | ;; 943 | sles) 944 | ((skip_server)) || ((skip_verify)) || verify_mariadb_server_version $mariadb_server_version_real 945 | { 946 | ((skip_server)) || printf "$sles_repo_server\n\n" "$mariadb_server_version_real" "$os_version" 947 | ((skip_maxscale)) || printf "$sles_repo_maxscale\n\n" "$mariadb_maxscale_version" "$os_version" "$arch" 948 | ((skip_tools)) || printf "$sles_repo_tools\n" "$os_version" 949 | } >&4 950 | ((write_to_stdout)) || msg info "Repository file successfully written to $outfile" 951 | if ! ((skip_key_import)) 952 | then 953 | if [[ $os_version = 11 ]] 954 | then 955 | # RPM in SLES 11 doesn't support HTTPS, so munge the URLs to use standard HTTP 956 | rpm --import "${key_urls[@]/#https/http}" 957 | else 958 | msg info 'Adding trusted package signing keys...' 959 | if rpm --import "${key_urls[@]}" 960 | then 961 | pushd /etc/pki/trust/ 962 | for key in ${key_urls[@]} ; do curl -LsSO ${key};done 963 | popd 964 | msg info 'Successfully added trusted package signing keys' 965 | else 966 | msg error 'Failed to add trusted package signing keys' 967 | fi 968 | fi 969 | fi 970 | ((write_to_stdout)) || clean_package_cache zypper 971 | ;; 972 | *) 973 | error "Sorry, your OS is not supported." "$supported" 974 | ;; 975 | esac 976 | -------------------------------------------------------------------------------- /maxscale.cnf: -------------------------------------------------------------------------------- 1 | [maxscale] 2 | admin_secure_gui=false 3 | threads=1 4 | 5 | # this enables external access to the REST API outside of localhost 6 | # please review / modify for any public / non development environments 7 | admin_host=0.0.0.0 8 | --------------------------------------------------------------------------------