Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-deploy-utils
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
qa-deploy-utils
Commits
34f4aa7e
Commit
34f4aa7e
authored
Jan 24, 2017
by
daidekun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步test-utils代码
parent
c88f95ee
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
12 deletions
+49
-12
db_schema_sync.sh
db-utils/db_schema_sync.sh
+15
-11
gen_config.sh
db-utils/gen_config.sh
+7
-1
publish_db_schema_to_all_env.sh
db-utils/publish_db_schema_to_all_env.sh
+27
-0
No files found.
db-utils/db_schema_sync.sh
View file @
34f4aa7e
...
...
@@ -29,19 +29,23 @@ target_db_user=$5
target_db_pwd
=
$6
sync_db_name
=
$7
date_str
=
`
date
"+%Y-%m-%d-%H-%M-%S"
`
work_dir
=
/home/quant_group/test-utils/db-utils
sync_config_folder
=
~/db_sync_configs
config_file_name
=
"
$sync_config_folder
/
${
sync_db_name
}
_
${
date_str
}
_db_schema_sync_config.json"
function
db_schema_sync
()
{
database
=
$1
uuid
=
$(
uuidgen
)
config_file_name
=
"
$sync_config_folder
/
${
database
}
_
${
uuid
}
_db_schema_sync_config.json"
echo
"Step 1: generate_config_file:
$config_file_name
"
echo
"source infos:
$source_db_host
$source_db_user
"
echo
"target infos:
$target_db_host
$target_db_user
"
echo
"database_name is :
$sync_db_name
"
sh
$work_dir
/gen_config.sh
$source_db_host
$source_db_user
$source_db_pwd
$target_db_host
$target_db_user
$target_db_pwd
$sync_db_name
$config_file_name
sh
$work_dir
/gen_config.sh
$source_db_host
$source_db_user
$source_db_pwd
$target_db_host
$target_db_user
$target_db_pwd
$database
$config_file_name
echo
"Step 2: sync schema:
$database
$mysql_host
"
sync_cmd
=
"mysql-schema-sync -conf
${
config_file_name
}
-sync"
...
...
@@ -49,15 +53,15 @@ function db_schema_sync()
$sync_cmd
}
database_list
=
'xyqb xyqb_app payment_center risk_control dujiangyan mall qinqiong quartz contract financial_system gyxd offline sms-center spider_center'
if
[[
"
$
{
database_name
}
"
=
"all"
]]
database_list
=
'xyqb xyqb_app payment_center risk_control dujiangyan mall qinqiong quartz contract financial_system gyxd offline sms-center spider_center
xyqb_user merchant
'
if
[[
"
$
sync_db_name
"
=
"all"
]]
then
echo
"
all database
"
for
d
atabas
e
in
$database_list
echo
"
sync all database schema
"
for
d
b_nam
e
in
$database_list
do
db_schema_sync
$d
atabas
e
echo
$d
atabas
e
db_schema_sync
$d
b_nam
e
echo
$d
b_nam
e
done
else
db_schema_sync
$
database
_name
db_schema_sync
$
sync_db
_name
fi
\ No newline at end of file
db-utils/gen_config.sh
View file @
34f4aa7e
...
...
@@ -91,11 +91,17 @@ elif [[ $sync_db_name = 'spider_center' ]]; then
# 授信中心
sys_table_list
=
'merchant merchant_config'
port
=
'3312'
elif
[[
$sync_db_name
=
'xyqb_user'
]]
;
then
# xyqb_user
port
=
'3313'
elif
[[
$sync_db_name
=
'merchant'
]]
;
then
# merchant
port
=
'3314'
fi
echo
"port is
$port
"
echo
"copy
${
base_config_file
}
to
${
config_file_name
}
"
cp
$base_config_file
$config_file_name
cp
-f
$base_config_file
$config_file_name
echo
"sed -i s/source_db_host/
${
source_db_host
}
/g
$config_file_name
"
sed
-i
"s/source_db_host/
${
source_db_host
}
/g"
$config_file_name
...
...
db-utils/publish_db_schema_to_all_env.sh
0 → 100755
View file @
34f4aa7e
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: publish_db_schema_to_all_env.sh
# Revision: 1.0
# Date: 2017/01
# Author: dekun.dai
# Description: 向所有测试环境下发最新表结构
# -------------------------------------------------------------------------------
source
~/.bash_profile
work_dir
=
/home/quant_group/test-utils/db-utils
if
[
$#
-gt
0
]
;
then
echo
"---------------"
echo
"ip_list:
$*
"
echo
"共有:
$#
个需同步"
else
echo
"---参数不正确---"
echo
"Usage:sh publish_db_schema_to_all_env.sh 192.168.x.x"
echo
"---------------"
exit
1
fi
for
host
in
"
$@
"
do
sh
$work_dir
/db_schema_sync.sh 192.168.4.253 xyqb_query default
${
host
}
qa qatest all
done
\ No newline at end of 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