Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qg-dockerfiles
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qg-dockerfiles
Commits
7d6aeec5
Commit
7d6aeec5
authored
Feb 11, 2018
by
daidekun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整db启动脚本
parent
67521d6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
65 deletions
+65
-65
init_db_data.sh
baseimg/tools/db/init_db_data.sh
+65
-13
replace.sh
baseimg/tools/db/replace.sh
+0
-52
No files found.
baseimg/tools/db/init_db_data.sh
View file @
7d6aeec5
...
...
@@ -6,21 +6,73 @@
# Description: 执行目录下所有数据库脚本
# -------------------------------------------------------------------------------
sql_file_folder
=
$WORK_PATH
/sql_to_run
# 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
echo
"cd
$sql_file_folder
"
cd
$sql_file_folder
export
NAMESPACE
=
`
cat
/var/run/secrets/kubernetes.io/serviceaccount/namespace
`
for
entry
in
./
*
do
echo
"run sql file:
$entry
"
mysql
-uroot
<
$entry
done
echo
"start replace db domain"
DB_FILE
=
dump.sql
HOST
=
'127.0.0.1'
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
)
export
NAMESPACE
=
`
cat
/var/run/secrets/kubernetes.io/serviceaccount/namespace
`
echo
"cd /docker-entrypoint-initdb.d"
cd
/docker-entrypoint-initdb.d
echo
"replace DB string"
sh replace.sh 127.0.0.1 3306 qa qatest
true
$NAMESPACE
\ No newline at end of file
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#
\h
ttps#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
baseimg/tools/db/replace.sh
View file @
7d6aeec5
...
...
@@ -12,57 +12,5 @@ NAMESPACE=$6
# HTTPS=true
# NAMESPACE=tianyawei
DB_FILE
=
dump.sql
echo
"HOST=
$1
PORT=
$2
USER=
$3
PASSWORD=
$4
HTTPS=
$5
NAMESPACE=
$6
"
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 "Dump structure"
# mysqldump --host=${HOST} --user=${USER} --password=${PASSWORD} --single-transaction --no-data ${DATABASE} > ${DB_FILE}
echo
"Dump content"
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#
\h
ttps#http#g"
${
DB_FILE
}
fi
echo
"mysql dump file"
mysql
--host
=
${
HOST
}
--port
=
${
PORT
}
--user
=
${
USER
}
--password
=
${
PASSWORD
}
<
${
DB_FILE
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment