Commit fc217d29 authored by QA-甘 盛聪's avatar QA-甘 盛聪
parents f27f841f 56c93bc6
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
database_name=$1 database_name=$1
server_host=$2 server_host=$2
db_sub_backup_folder=$3 db_sub_backup_folder=$3
re_replace_ip=$4
public_ip="139.198.2.95"
ip_last=$5
echo $server_host echo $server_host
cd $db_sub_backup_folder cd $db_sub_backup_folder
...@@ -50,4 +53,13 @@ do ...@@ -50,4 +53,13 @@ do
sed -i "s/https\:\/\/gyxdapi.xyqb.com/http\:\/\/${server_host}:7029/g" $entry sed -i "s/https\:\/\/gyxdapi.xyqb.com/http\:\/\/${server_host}:7029/g" $entry
sed -i "s/http\:\/\/btapi.xyqb.com/http\:\/\/${server_host}:7025/g" $entry sed -i "s/http\:\/\/btapi.xyqb.com/http\:\/\/${server_host}:7025/g" $entry
sed -i "s/https\:\/\/btapi.xyqb.com/http\:\/\/${server_host}:7025/g" $entry sed -i "s/https\:\/\/btapi.xyqb.com/http\:\/\/${server_host}:7025/g" $entry
done done
\ No newline at end of file
if [ "$re_replace_ip" = true ]; then
for entry in ./*
do
echo "is replace public ip for $entry"
sed -i "s/${server_host}/${public_ip}/g" $entry
sed -i "s/\:70/:${ip_last}/g" $entry
done
fi
\ No newline at end of file
...@@ -9,27 +9,28 @@ ...@@ -9,27 +9,28 @@
source ~/.bash_profile source ~/.bash_profile
if [ $# -ne 7 ]; then if [ $# -ne 8 ]; then
echo "---------------" echo "---------------"
echo "source_db_infos:source_db_host: $1, source_db_user: $2" echo "source_db_infos:source_db_host: $1, source_db_user: $2"
echo "target_db_infos:target_db_host: $4, target_db_user: $5" echo "target_db_infos:target_db_host: $4, target_db_user: $5"
echo "sync_db_name: $7" echo "sync_db_name: $7, re_replace_ip: $8"
echo "---参数不正确---" echo "---参数不正确---"
echo "Usage:sh db_schema_sync.sh source_db_host source_db_user source_db_pwd target_db_host target_db_user target_db_pwd sync_db_name" echo "Usage:sh db_schema_sync.sh source_db_host source_db_user source_db_pwd target_db_host target_db_user target_db_pwd sync_db_name"
echo "---------------" echo "---------------"
exit 1 exit 1
fi fi
source_db_host="$1" source_db_host=$1
source_db_user=$2 source_db_user=$2
source_db_pwd='Uiwb@o^fR&nHOa5t' source_db_pwd='Uiwb@o^fR&nHOa5t'
target_db_host="$4" ip_last=$4
target_db_host="192.168.4.$ip_last"
target_db_user=$5 target_db_user=$5
target_db_pwd=$6 target_db_pwd=$6
sync_db_name=$7 sync_db_name=$7
re_replace_ip=$8
work_dir=/home/quant_group/qa-deploy-utils/db-utils work_dir=/home/quant_group/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs sync_config_folder=~/db_sync_configs
...@@ -50,8 +51,9 @@ function db_schema_sync() ...@@ -50,8 +51,9 @@ function db_schema_sync()
sh $work_dir/db_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 $db_backup_sub_folders sh $work_dir/db_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 $db_backup_sub_folders
echo "Step 2: replace domain name in tables: $database $mysql_host $db_backup_sub_folders" echo "Step 2: replace domain name in tables: $database $mysql_host $db_backup_sub_folders"
sh $work_dir/db_replace_ip.sh $database $target_db_host $db_backup_sub_folders echo "Step 2.1: is re_replace_ip: $re_replace_ip"
sh $work_dir/db_replace_ip.sh $database $target_db_host $db_backup_sub_folders $re_replace_ip $ip_last
echo "Step 3: import basic data from backup file: $database $mysql_host $db_backup_sub_folders" echo "Step 3: import basic data from backup file: $database $mysql_host $db_backup_sub_folders"
sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders
......
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