diff --git a/proxysql/dockerdir/entrypoint.sh b/proxysql/dockerdir/entrypoint.sh index c66ddc3cb..81233bf57 100755 --- a/proxysql/dockerdir/entrypoint.sh +++ b/proxysql/dockerdir/entrypoint.sh @@ -3,25 +3,23 @@ set -o xtrace PROXY_CFG=/etc/proxysql/proxysql.cnf -if [ "${SCHEDULER}" == "percona" ]; then - PROXY_SCHEDULER_CFG=/etc/config.toml - temp_proxy_scheduler_cfg=$(mktemp) -else - PROXY_SCHEDULER_CFG=/etc/proxysql-admin.cnf -fi +# Percona scheduler +PERCONA_SCHEDULER_CFG=/etc/config.toml +temp_proxy_scheduler_cfg=$(mktemp) +# proxysql-admin scheduler +PROXY_SCHEDULER_CFG=/etc/proxysql-admin.cnf if [ -n ${PROXYSQL_SERVICE} ]; then MYSQL_INTERFACES='0.0.0.0:3306;0.0.0.0:33062' CLUSTER_PORT='33062' - if [ "${SCHEDULER}" == "percona" ]; then - sed "s/^writerIsAlsoReader.*=.*$/writerIsAlsoReader = 1/" ${PROXY_SCHEDULER_CFG} | \ - sed "s/^hgW.*=.*$/hgW = 11/" | \ - sed "s/^hgR.*=.*$/hgR = 10/" | \ - sed "s/^clustered.*=.*false$/clustered = true/" > ${temp_proxy_scheduler_cfg} - cp ${temp_proxy_scheduler_cfg} ${PROXY_SCHEDULER_CFG} - else - sed "s/#export WRITERS_ARE_READERS=.*$/export WRITERS_ARE_READERS='yes'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - fi + # Percona scheduler + sed "s/^writerIsAlsoReader.*=.*$/writerIsAlsoReader = 1/" ${PROXY_SCHEDULER_CFG} | \ + sed "s/^hgW.*=.*$/hgW = 11/" | \ + sed "s/^hgR.*=.*$/hgR = 10/" | \ + sed "s/^clustered.*=.*false$/clustered = true/" > ${temp_proxy_scheduler_cfg} + cp ${temp_proxy_scheduler_cfg} ${PROXY_SCHEDULER_CFG} + # proxysql-admin scheduler + sed "s/#export WRITERS_ARE_READERS=.*$/export WRITERS_ARE_READERS='yes'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} fi sed "s/interfaces=\"0.0.0.0:3306\"/interfaces=\"${MYSQL_INTERFACES:-0.0.0.0:3306}\"/g" ${PROXY_CFG} 1<> ${PROXY_CFG} @@ -38,24 +36,23 @@ sed "s/cluster_username=\"admin\"/cluster_username=\"${PROXY_ADMIN_USER:-admin}\ sed "s/cluster_password=\"admin\"/cluster_password=\"${PROXY_ADMIN_PASSWORD:-admin}\"/g" ${PROXY_CFG} 1<> ${PROXY_CFG} sed "s/monitor_password=\"monitor\"/monitor_password=\"${MONITOR_PASSWORD:-monitor}\"/g" ${PROXY_CFG} 1<> ${PROXY_CFG} -if [ "${SCHEDULER}" == "percona" ]; then - sed "s/^user.*=.*\"$/user = '${PROXY_ADMIN_USER:-admin}'/" ${PROXY_SCHEDULER_CFG} | \ - sed "s/^password.*=.*\"$/password = '${PROXY_ADMIN_PASSWORD_ESCAPED:-admin}'/" | \ - sed "s/^clusterUserPassword.*=.*\"$/clusterUserPassword='${OPERATOR_PASSWORD_ESCAPED:-operator}'/" | \ - sed "s/^clusterUser.*=.*\"$/clusterUser = 'operator'/" | \ - sed "s/^clusterPort.*=.*\"$/clusterPort='${CLUSTER_PORT:-3306}'/" | \ - sed "s/^monitorUserPassword.*=.*\"$/monitorUserPassword='${MONITOR_PASSWORD_ESCAPED:-monitor}'/" | \ - sed "s/^monitorUser.*=.*\"$/monitorUser='monitor'/" > ${temp_proxy_scheduler_cfg} - cp ${temp_proxy_scheduler_cfg} ${PROXY_SCHEDULER_CFG} -else - sed "s/PROXYSQL_USERNAME='admin'/PROXYSQL_USERNAME='${PROXY_ADMIN_USER:-admin}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - sed "s/PROXYSQL_PASSWORD='admin'/PROXYSQL_PASSWORD='${PROXY_ADMIN_PASSWORD_ESCAPED:-admin}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - sed "s/CLUSTER_USERNAME='admin'/CLUSTER_USERNAME='operator'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - sed "s/CLUSTER_PASSWORD='admin'/CLUSTER_PASSWORD='${OPERATOR_PASSWORD_ESCAPED:-operator}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - sed "s/CLUSTER_PORT='3306'/CLUSTER_PORT='${CLUSTER_PORT:-3306}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - sed "s/MONITOR_USERNAME='monitor'/MONITOR_USERNAME='monitor'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} - sed "s/MONITOR_PASSWORD='monitor'/MONITOR_PASSWORD='${MONITOR_PASSWORD_ESCAPED:-monitor}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} -fi +# Percona scheduler +sed "s/^user.*=.*\"$/user = '${PROXY_ADMIN_USER:-admin}'/" ${PERCONA_SCHEDULER_CFG} | \ +sed "s/^password.*=.*\"$/password = '${PROXY_ADMIN_PASSWORD_ESCAPED:-admin}'/" | \ +sed "s/^clusterUserPassword.*=.*\"$/clusterUserPassword='${OPERATOR_PASSWORD_ESCAPED:-operator}'/" | \ +sed "s/^clusterUser.*=.*\"$/clusterUser = 'operator'/" | \ +sed "s/^clusterPort.*=.*\"$/clusterPort='${CLUSTER_PORT:-3306}'/" | \ +sed "s/^monitorUserPassword.*=.*\"$/monitorUserPassword='${MONITOR_PASSWORD_ESCAPED:-monitor}'/" | \ +sed "s/^monitorUser.*=.*\"$/monitorUser='monitor'/" > ${temp_proxy_scheduler_cfg} +cp ${temp_proxy_scheduler_cfg} ${PERCONA_SCHEDULER_CFG} +# proxysql-admin scheduler +sed "s/PROXYSQL_USERNAME='admin'/PROXYSQL_USERNAME='${PROXY_ADMIN_USER:-admin}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} +sed "s/PROXYSQL_PASSWORD='admin'/PROXYSQL_PASSWORD='${PROXY_ADMIN_PASSWORD_ESCAPED:-admin}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} +sed "s/CLUSTER_USERNAME='admin'/CLUSTER_USERNAME='operator'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} +sed "s/CLUSTER_PASSWORD='admin'/CLUSTER_PASSWORD='${OPERATOR_PASSWORD_ESCAPED:-operator}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} +sed "s/CLUSTER_PORT='3306'/CLUSTER_PORT='${CLUSTER_PORT:-3306}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} +sed "s/MONITOR_USERNAME='monitor'/MONITOR_USERNAME='monitor'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} +sed "s/MONITOR_PASSWORD='monitor'/MONITOR_PASSWORD='${MONITOR_PASSWORD_ESCAPED:-monitor}'/g" ${PROXY_SCHEDULER_CFG} 1<> ${PROXY_SCHEDULER_CFG} set -o xtrace @@ -67,18 +64,14 @@ fi SSL_DIR=${SSL_DIR:-/etc/proxysql/ssl} if [ -f "${SSL_DIR}/ca.crt" ]; then CA=${SSL_DIR}/ca.crt - if [ "${SCHEDULER}" == "percona" ]; then - sed "s:^sslCertificatePath.*= .*\"$:sslCertificatePath = \"${SSL_DIR}\":" ${PROXY_SCHEDULER_CFG} > ${temp_proxy_scheduler_cfg} - cp ${temp_proxy_scheduler_cfg} ${PROXY_SCHEDULER_CFG} - fi + sed "s:^sslCertificatePath.*= .*\"$:sslCertificatePath = \"${SSL_DIR}\":" ${PERCONA_SCHEDULER_CFG} > ${temp_proxy_scheduler_cfg} + cp ${temp_proxy_scheduler_cfg} ${PERCONA_SCHEDULER_CFG} fi SSL_INTERNAL_DIR=${SSL_INTERNAL_DIR:-/etc/proxysql/ssl-internal} if [ -f "${SSL_INTERNAL_DIR}/ca.crt" ]; then CA=${SSL_INTERNAL_DIR}/ca.crt - if [ "${SCHEDULER}" == "percona" ]; then - sed "s:^sslCertificatePath.*= .*\"$:sslCertificatePath = \"${SSL_INTERNAL_DIR}\":" ${PROXY_SCHEDULER_CFG} > ${temp_proxy_scheduler_cfg} - cp ${temp_proxy_scheduler_cfg} ${PROXY_SCHEDULER_CFG} - fi + sed "s:^sslCertificatePath.*= .*\"$:sslCertificatePath = \"${SSL_INTERNAL_DIR}\":" ${PERCONA_SCHEDULER_CFG} > ${temp_proxy_scheduler_cfg} + cp ${temp_proxy_scheduler_cfg} ${PERCONA_SCHEDULER_CFG} fi KEY=${SSL_DIR}/tls.key @@ -94,13 +87,12 @@ if [ -f "$CA" ] && [ -f "$KEY" ] && [ -f "$CERT" ] && [ -n "$PXC_SERVICE" ]; the sed "s^ssl_p2s_ca=\"\"^ssl_p2s_ca=\"$CA\"^" ${PROXY_CFG} 1<> ${PROXY_CFG} sed "s^ssl_p2s_key=\"\"^ssl_p2s_key=\"$KEY\"^" ${PROXY_CFG} 1<> ${PROXY_CFG} sed "s^ssl_p2s_cert=\"\"^ssl_p2s_cert=\"$CERT\"^" ${PROXY_CFG} 1<> ${PROXY_CFG} - if [ "${SCHEDULER}" == "percona" ]; then - sed "s:^sslCa.*=.*\"$:sslCa = \"${CA##*/}\":" ${PROXY_SCHEDULER_CFG} | \ - sed "s:^sslKey.*=.*\"$:sslKey = \"${KEY##*/}\":" | \ - sed "s:^sslClient.*=.*\"$:sslClient = \"${CERT##*/}\":" > ${temp_proxy_scheduler_cfg} - cp ${temp_proxy_scheduler_cfg} ${PROXY_SCHEDULER_CFG} - rm ${temp_proxy_scheduler_cfg} - fi + # Percona scheduler + sed "s:^sslCa.*=.*\"$:sslCa = \"${CA##*/}\":" ${PERCONA_SCHEDULER_CFG} | \ + sed "s:^sslKey.*=.*\"$:sslKey = \"${KEY##*/}\":" | \ + sed "s:^sslClient.*=.*\"$:sslClient = \"${CERT##*/}\":" > ${temp_proxy_scheduler_cfg} + cp ${temp_proxy_scheduler_cfg} ${PERCONA_SCHEDULER_CFG} + rm ${temp_proxy_scheduler_cfg} fi if [ -f "${SSL_DIR}/tls.key" ] && [ -f "${SSL_DIR}/tls.crt" ]; then diff --git a/proxysql/dockerdir/usr/bin/add_pxc_nodes.sh b/proxysql/dockerdir/usr/bin/add_pxc_nodes.sh index 1ad1334b6..75ffae768 100755 --- a/proxysql/dockerdir/usr/bin/add_pxc_nodes.sh +++ b/proxysql/dockerdir/usr/bin/add_pxc_nodes.sh @@ -68,6 +68,8 @@ function main() { sed "s/^clusterHost.*=.*\"$/clusterHost=\"$first_host\"/" /etc/config.toml > ${temp} && cp ${temp} /etc/config.toml rm ${temp} + proxysql-admin --config-file=/etc/proxysql-admin.cnf --disable || true + percona-scheduler-admin \ --config-file=/etc/config.toml \ --write-node="$pod_zero.$service:3306" \ @@ -89,6 +91,8 @@ function main() { --config-file=/etc/config.toml \ --update-mysql-version else + percona-scheduler-admin --config-file=/etc/config.toml --disable || true + proxysql-admin \ --config-file=/etc/proxysql-admin.cnf \ --cluster-hostname="$first_host" \