日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

【Clickhouse】Dockerfile 文件,加入 mysql

發布時間:2025/3/20 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Clickhouse】Dockerfile 文件,加入 mysql 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

    • Dockerfile
    • docker_related_config.xml 內容
    • entrypoint.sh 內容
    • docker-compose.yml
    • mysql/conf/my.cnf

Dockerfile

FROM ubuntu:18.04ARG repository="deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" ARG version=19.1.13 ARG gosu_ver=1.10RUN apt-get update \&& apt-get install --yes --no-install-recommends \apt-transport-https \dirmngr \gnupg \&& mkdir -p /etc/apt/sources.list.d \&& apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 \&& echo $repository > /etc/apt/sources.list.d/clickhouse.list \&& apt-get update \&& env DEBIAN_FRONTEND=noninteractive \apt-get install --allow-unauthenticated --yes --no-install-recommends \clickhouse-common-static=$version \clickhouse-client=$version \clickhouse-server=$version \libgcc-7-dev \locales \tzdata \wget \vim \libmariadbclient-dev \mariadb-client \mariadb-server \&& rm -rf \/var/lib/apt/lists/* \/var/cache/debconf \/tmp/* \&& apt-get cleanADD https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 /bin/gosuRUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 ENV TZ Asia/ShanghaiRUN mkdir /docker-entrypoint-initdb.dCOPY ./docker_related_config.xml /etc/clickhouse-server/config.d/ COPY ./entrypoint.sh /entrypoint.shRUN chmod +x \/entrypoint.sh \/bin/gosuEXPOSE 9000 8123 9009 VOLUME /var/lib/clickhouseENV CLICKHOUSE_CONFIG /etc/clickhouse-server/config.xmlENTRYPOINT ["/entrypoint.sh"]

docker_related_config.xml 內容

<yandex><!-- Listen wildcard address to allow accepting connections from other containers and host network. --><listen_host>::</listen_host><listen_host>0.0.0.0</listen_host><listen_try>1</listen_try><!--<logger><console>1</console></logger>--> </yandex>

entrypoint.sh 內容

#!/bin/bash# set some vars CLICKHOUSE_CONFIG="${CLICKHOUSE_CONFIG:-/etc/clickhouse-server/config.xml}" USER="$(id -u clickhouse)" GROUP="$(id -g clickhouse)"# port is needed to check if clickhouse-server is ready for connections HTTP_PORT="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=http_port)"# get CH directories locations DATA_DIR="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=path || true)" TMP_DIR="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=tmp_path || true)" USER_PATH="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=user_files_path || true)" LOG_PATH="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=logger.log || true)" LOG_DIR="$(dirname $LOG_PATH || true)" ERROR_LOG_PATH="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=logger.errorlog || true)" ERROR_LOG_DIR="$(dirname $ERROR_LOG_PATH || true)" FORMAT_SCHEMA_PATH="$(clickhouse extract-from-config --config-file $CLICKHOUSE_CONFIG --key=format_schema_path || true)"# ensure directories exist mkdir -p \"$DATA_DIR" \"$ERROR_LOG_DIR" \"$LOG_DIR" \"$TMP_DIR" \"$USER_PATH" \"$FORMAT_SCHEMA_PATH"if [ "$CLICKHOUSE_DO_NOT_CHOWN" != "1" ]; then# ensure proper directories permissionschown -R $USER:$GROUP \"$DATA_DIR" \"$ERROR_LOG_DIR" \"$LOG_DIR" \"$TMP_DIR" \"$USER_PATH" \"$FORMAT_SCHEMA_PATH" fiif [ -n "$(ls /docker-entrypoint-initdb.d/)" ]; thengosu clickhouse /usr/bin/clickhouse-server --config-file=$CLICKHOUSE_CONFIG &pid="$!"# check if clickhouse is ready to accept connections# will try to send ping clickhouse via http_port (max 12 retries, with 1 sec delay)if ! wget --spider --quiet --tries=12 --waitretry=1 --retry-connrefused "http://localhost:$HTTP_PORT/ping" ; thenecho >&2 'ClickHouse init process failed.'exit 1ficlickhouseclient=( clickhouse-client --multiquery )echofor f in /docker-entrypoint-initdb.d/*; docase "$f" in*.sh)if [ -x "$f" ]; thenecho "$0: running $f""$f"elseecho "$0: sourcing $f". "$f"fi;;*.sql) echo "$0: running $f"; cat "$f" | "${clickhouseclient[@]}" ; echo ;;*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${clickhouseclient[@]}"; echo ;;*) echo "$0: ignoring $f" ;;esacechodoneif ! kill -s TERM "$pid" || ! wait "$pid"; thenecho >&2 'Finishing of ClickHouse init process failed.'exit 1fi fi# if no args passed to `docker run` or first argument start with `--`, then the user is passing clickhouse-server arguments if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; thenexec gosu clickhouse /usr/bin/clickhouse-server --config-file=$CLICKHOUSE_CONFIG "$@" fi# Otherwise, we assume the user want to run his own process, for example a `bash` shell to explore this image exec "$@"

docker-compose.yml

version: "3.7" services:logserver:build: context: ./clickhousedockerfile: Dockerfilecontainer_name: logservernetwork_mode: "logserver_net"privileged: truerestart: alwaysports:- 8123:8123- 9000:9000- 3306:3306volumes:- /etc/localtime:/etc/localtime- $PWD/clickhouse/clickhouse-server/config.xml:/etc/clickhouse-server/config.xml- $PWD/clickhouse/clickhouse-server/users.xml:/etc/clickhouse-server/users.xml- $PWD/clickhouse/clickhouse-server/data:/var/lib/clickhouse- $PWD/clickhouse/clickhouse-server/log/clickhouse-server.log:/var/log/clickhouse-server/clickhouse-server.log- $PWD/clickhouse/clickhouse-server/log/clickhouse-server.err.log:/var/log/clickhouse-server/clickhouse-server.err.log- $PWD/clickhouse/docker_related_config.xml:/etc/clickhouse-server/config.d/docker_related_config.xml- $PWD/clickhouse/entrypoint.sh:/entrypoint.sh- $PWD/mysql/init.sql:/init.sql- $PWD/mysql/conf/my.cnf:/etc/mysql/my.cnf- mysql_data:/var/lib/mysql networks:logserver_net:external:name: logserver_net volumes: mysql_data:name: mysql_datadriver: local

mysql/conf/my.cnf

[client-server]# Import all .cnf files from configuration directory !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mariadb.conf.d/[mysqld] #sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION general_log = 1 general_log_file = /var/log/mysql/general.log#pid-file = /var/run/mysqld/mysqld.pid #socket = /var/run/mysqld/mysqld.sockdatadir = /var/lib/mysql log-error = /var/log/mysql/error.logexplicit_defaults_for_timestamp=true# By default we only accept connections from localhost #bind-address = :: bind-address = 0.0.0.0# Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake#skip-grant-tables [client] default-character-set=utf8[mysql] default-character-set=utf8[mysqldump] user=xxx password=xxxx

總結

以上是生活随笔為你收集整理的【Clickhouse】Dockerfile 文件,加入 mysql的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。