Commit 2f3a2069 authored by kalvin's avatar kalvin

mysql 5.7

parent 4aa72dc7
FROM mysql:5.7
#定义工作目录
WORKDIR /var/lib/mysql
ENV AUTO_RUN_DIR /docker-entrypoint-initdb.d
COPY my.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
COPY mysqld_charset.cnf /etc/mysql/conf.d/mysqld_charset.cnf
#把要执行的shell文件放到/docker-entrypoint-initdb.d/目录下,容器会自动执行这个shell
COPY ./init_db_data.sh $AUTO_RUN_DIR/
#给执行文件增加可执行权限
RUN chmod a+x $AUTO_RUN_DIR/init_db_data.sh
RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash
# 解决时区问题
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
\ No newline at end of file
# -------------------------------------------------------------------------------
# Filename: init_db_data.sh
# Revision: 1.0
# Date: 2017/08
# Author: dekun.dai
# Description: 执行目录下所有数据库脚本
# -------------------------------------------------------------------------------
# sql_file_folder=$WORK_PATH/sql_to_run
#
# echo "cd $sql_file_folder"
# cd $sql_file_folder
#
# for entry in ./*
# do
# echo "run sql file: $entry"
# mysql -uroot < $entry
# done
#!/bin/bash
export NAMESPACE=`cat /var/run/secrets/kubernetes.io/serviceaccount/namespace`
echo "start replace db domain"
DB_FILE=dump.sql
HOST=$DB_SERVICE_HOST
PORT='3306'
USER='qa'
PASSWORD='qatest'
HTTPS='true'
echo "HOST=$HOST
PORT=$PORT
USER=$USER
PASSWORD=$PASSWORD
HTTPS=$HTTPS
NAMESPACE=$NAMESPACE"
EXCLUDED_TABLES=(
clotho.JOB_EXECUTION_LOG
clotho.JOB_STATUS_TRACE_LOG
notify.JOB_EXECUTION_LOG
notify.JOB_STATUS_TRACE_LOG
xyqb.JOB_EXECUTION_LOG
xyqb.JOB_STATUS_TRACE_LOG
xyqb.channel
xyqb.t_phonenum
mall.jd_address
mall.jd_brand
mall.jd_product_sku_image
mall.jd_property
mall.jd_sku
mall.jd_sku_detail_image
mall.jd_sku_specs
mall.spu_image
mall.sale_product_detail
mall.product_nature_value_bak
mall.product_sku
mall.product_sku_image
mall.product_specification
mall.product_spu
)
IGNORED_TABLES_STRING=''
for TABLE in "${EXCLUDED_TABLES[@]}"
do :
IGNORED_TABLES_STRING+=" --ignore-table=${TABLE}"
done
echo "mysqldump --host=${HOST} --port=${PORT} --user=${USER} --password=${PASSWORD} --all-databases --no-create-info ${IGNORED_TABLES_STRING} >> ${DB_FILE}"
mysqldump --host=${HOST} --port=${PORT} --user=${USER} --password=${PASSWORD} --all-databases ${IGNORED_TABLES_STRING} >> ${DB_FILE}
echo "sed file"
if [[ $HTTPS = true ]];then
sed -i "s#\.xyqb\.com#-${NAMESPACE}\.q-gp\.com#g; s#\.quantgroup\.cn#-${NAMESPACE}\.q-gp\.com#g; s#-base\.q-gp\.com#-${NAMESPACE}\.q-gp\.com#g" ${DB_FILE}
else
sed -i "s#\.xyqb\.com#-${NAMESPACE}\.q-gp\.com#g; s#\.quantgroup\.cn#-${NAMESPACE}\.q-gp\.com#g; s#-base\.q-gp\.com#-${NAMESPACE}\.q-gp\.com#g; s#\https#http#g" ${DB_FILE}
fi
echo "mysql dump file"
mysql --host=${HOST} --port=${PORT} --user=${USER} --password=${PASSWORD} < ${DB_FILE}
\ No newline at end of file
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=/var/lib/mysql/mysql-bin
binlog-format=ROW
server_id=1
innodb_buffer_pool_size = 512M
innodb_buffer_pool_instances = 1
bulk_insert_buffer_size = 32M
query_cache_type = 0
query_cache_size = 0
max_connections = 1024
max_connect_errors = 10
table_open_cache = 4096
max_allowed_packet = 512M
binlog_cache_size = 1M
max_heap_table_size = 64M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
sort_buffer_size = 32K
join_buffer_size = 32K
thread_cache_size = 64
\ No newline at end of file
[mysqld]
character_set_server=utf8
character_set_filesystem=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'
init_connect='SET collation_connection = utf8_general_ci'
skip-character-set-client-handshake
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment