Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问radondb需要怎么执行需要初始化的sql文件? #122

Closed
Ary0075 opened this issue Jun 23, 2021 · 2 comments · Fixed by #123 or #124
Closed

请问radondb需要怎么执行需要初始化的sql文件? #122

Ary0075 opened this issue Jun 23, 2021 · 2 comments · Fixed by #123 or #124
Assignees
Labels
question Further information is requested

Comments

@Ary0075
Copy link

Ary0075 commented Jun 23, 2021

General Question

我尝试了按照原生mysql镜像的方法,修改了chart中statefulset.yaml文件,把configmap挂载到了mysql容器的/docker-entrypoint-initdb.d目录,但是没有生效。于是我对比了一下mysql和xenondb/percona:5.7.33的docker-entrypoint.sh,发现相关逻辑有一些差异:

mysql:5.7:
https://github.com/docker-library/mysql/blob/master/5.7/docker-entrypoint.sh

# usage: docker_process_init_files [file [file [...]]]
#    ie: docker_process_init_files /always-initdb.d/*
# process initializer files, based on file extensions
docker_process_init_files() {
	# mysql here for backwards compatibility "${mysql[@]}"
	mysql=( docker_process_sql )

	echo
	local f
	for f; do
		case "$f" in
			*.sh)
				# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
				# https://github.com/docker-library/postgres/pull/452
				if [ -x "$f" ]; then
					mysql_note "$0: running $f"
					"$f"
				else
					mysql_note "$0: sourcing $f"
					. "$f"
				fi
				;;
			*.sql)    mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
			*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
			*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;
			*)        mysql_warn "$0: ignoring $f" ;;
		esac
		echo
	done
}

xenondb/percona:5.7.33:
https://github.com/radondb/radondb-mysql-kubernetes/blob/main/charts/helm/dockerfiles/mysql/mysql-entry.sh

# usage: process_init_file FILENAME MYSQLCOMMAND...
#       ie: process_init_file foo.sh mysql -uroot
# (process a single initializer file, based on its extension. we define this
# function here, so that initializer scripts (*.sh) can use the same logic,
# potentially recursively, or override the logic used in subsequent calls)
process_init_file() {
        local f="$1"; shift
        local mysql=( "$@" )

        case "$f" in
                *.sh)    echo "$0: running $f"; . "$f" ;;
                *.sql)  echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
                *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
                *)              echo "$0: ignoring $f" ;;
        esac
        echo
}

我想请教一下这些改动的目的是什么,以及radondb-mysql需要怎么初始化sql文件?

@Ary0075 Ary0075 added the question Further information is requested label Jun 23, 2021
@zhyass
Copy link
Contributor

zhyass commented Jun 24, 2021

你好,因为radondb-mysql设计时没有考虑有初始化sql的场景,所以在dockerfile中相关的逻辑没有添加。
我们会考虑将初始化逻辑加上去。

@zhyass
Copy link
Contributor

zhyass commented Jun 24, 2021

初始化sql文件功能已经支持。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
4 participants