mysql+cicd通过tar完成大库部署
dockerfile:
FROM founder/mysql:5.7 RUN apt-get update && apt-get update ; apt-get install -y parallel && chown -R mysql:mysql /docker-entrypoint-initdb.d ADD init.sh /docker-entrypoint-initdb.d/ COPY wisekg.tar.gz /docker-entrypoint-initdb.d/ COPY kb.tar.gz /docker-entrypoint-initdb.d/ ADD mysqld.cnf /etc/mysql/mysql.conf.d/
init.sh:
#!/bin/bash whoami tar zxvf /docker-entrypoint-initdb.d/wisekg.tar.gz -C /docker-entrypoint-initdb.d mkdir /docker-entrypoint-initdb.d/imdb/split cd /docker-entrypoint-initdb.d/imdb/split for i in ../*.txt ; do echo $i ; split -d -a 6 -l 100000 -- $i `basename $i .txt`.; ls|grep `basename $i .txt`|xargs -n1 -i{} mv {} {}.txt; rm -fv $i; done for i in `ls *.*|sed 's/^[^.]+.//'|sort -u` ; do mkdir ../split-$i for j in $i ; do mv $j ../split-$i/$i ; done done cd /docker-entrypoint-initdb.d/imdb/ time ( mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e 'drop database if exists $MYSQL_DATABASE;create database $MYSQL_DATABASE;set global FOREIGN_KEY_CHECKS=0;'; (echo "SET FOREIGN_KEY_CHECKS=0;";cat ./*.sql) | mysql -uroot -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" ; parallel -j32 'mysqlimport --use-threads=32 -uroot -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" /docker-entrypoint-initdb.d/imdb/{}/*.txt' ::: split-* ) whoami tar zxvf /docker-entrypoint-initdb.d/kb.tar.gz -C /docker-entrypoint-initdb.d mkdir /docker-entrypoint-initdb.d/imdbkb/split cd /docker-entrypoint-initdb.d/imdbkb/split for i in ../*.txt ; do echo $i ; split -d -a 6 -l 100000 -- $i `basename $i .txt`.; ls|grep `basename $i .txt`|xargs -n1 -i{} mv {} {}.txt; rm -fv $i; done for i in `ls *.*|sed 's/^[^.]+.//'|sort -u` ; do mkdir ../split-$i for j in $i ; do mv $j ../split-$i/$i ; done done cd /docker-entrypoint-initdb.d/imdbkb/ time ( mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e 'drop database if exists kb;create database kb;set global FOREIGN_KEY_CHECKS=0;'; (echo "SET FOREIGN_KEY_CHECKS=0;";cat ./*.sql) | mysql -uroot -p"$MYSQL_ROOT_PASSWORD" kb ; parallel -j32 'mysqlimport --use-threads=32 -uroot -p"$MYSQL_ROOT_PASSWORD" kb /docker-entrypoint-initdb.d/imdbkb/{}/*.txt' ::: split-* )
mysql.cnf
#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 # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 innodb_buffer_pool_size = 4G innodb_write_io_threads = 64 innodb_read_io_threads = 64 innodb_thread_concurrency=0 innodb_flush_method=O_DIRECT #innodb_io_capacity=2000 #innodb_io_capacity_max=4000 max_allowed_packet=2G skip-log-bin sync_binlog=0 secure_file_priv='' innodb_flush_log_at_trx_commit = 0 innodb_log_buffer_size = 1G innodb_log_file_size = 3G innodb_autoinc_lock_mode=2 innodb_doublewrite=0 innodb_old_blocks_pct=5 skip-innodb_adaptive_hash_index secure_file_priv =
分类:
mysql
, devops CI/CD
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
2019-06-22 apache软件包下载地址
2019-06-22 spark读取文件机制 源码剖析
2019-06-22 zookeeper从入门到放弃(转载学习)