Commit 0953c46d authored by 智勇's avatar 智勇

update

parent dcc9cf11
database_list='mall cash_loan_flow contract dujiangyan financial_system financial_system_api fund_manage gyxd merchant notify offline payment_center qinqiong quartz redpacket risk_control silk_road spider_center traffic_distribution user_credit xyqb xyqb_app xyqb_btzt xyqb_user'
source_db_pwd='Uiwb@o^fR&nHOa5t'
\ No newline at end of file
#!/bin/bash #!/bin/bash
set -u set -u
work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs
db_backup_folder=~/daily_db_backup
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=`grep source_db_pwd $work_dir/config/db_config | cut -d "=" -f 2`
ip_value=$4 ip_value=$4
...@@ -11,29 +15,6 @@ target_db_pwd=$6 ...@@ -11,29 +15,6 @@ target_db_pwd=$6
sync_db_name=$7 sync_db_name=$7
work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs
db_backup_folder=~/daily_db_backup
function valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}
if valid_ip $ip_value; then target_db_host="$ip_value"; else target_db_host="192.168.4.$ip_value"; fi
function db_schema_sync() function db_schema_sync()
{ {
database=$1 database=$1
...@@ -49,11 +30,11 @@ function db_schema_sync() ...@@ -49,11 +30,11 @@ function db_schema_sync()
echo "target infos: $target_db_host $target_db_user" echo "target infos: $target_db_host $target_db_user"
echo "database_name is : $sync_db_name" echo "database_name is : $sync_db_name"
echo "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 false" echo "sh $work_dir/db_gen_config.sh $source_db_host $source_db_user $source_db_pwd 192.168.4.12 $target_db_user $target_db_pwd $database $config_file_name $db_backup_sub_folders false"
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 false sh $work_dir/db_gen_config.sh $source_db_host $source_db_user $source_db_pwd 192.168.4.12 $target_db_user $target_db_pwd $database $config_file_name $db_backup_sub_folders false
} }
database_list='cash_loan_flow contract dujiangyan financial_system financial_system_api fund_manage gyxd mall merchant notify offline payment_center qinqiong quartz redpacket risk_control silk_road spider_center traffic_distribution user_credit xyqb xyqb_app xyqb_btzt xyqb_user' database_list=`grep database_list $work_dir/config/db_config | cut -d "=" -f 2`
echo "database_list:${database_list}" echo "database_list:${database_list}"
for db_name in $database_list for db_name in $database_list
......
...@@ -23,9 +23,13 @@ if [ $# -ne 10 ]; then ...@@ -23,9 +23,13 @@ if [ $# -ne 10 ]; then
exit 1 exit 1
fi fi
work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs
db_backup_folder=~/db_backups
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=`grep source_db_pwd $work_dir/config/db_config | cut -d "=" -f 2`
ip_value=$4 ip_value=$4
...@@ -37,10 +41,6 @@ re_replace_ip=$8 ...@@ -37,10 +41,6 @@ re_replace_ip=$8
delete_business_data=$9 delete_business_data=$9
use_cache=${10} use_cache=${10}
work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs
db_backup_folder=~/db_backups
trap "exec 1000>&-;exec 1000<&-;exit 0" 2 trap "exec 1000>&-;exec 1000<&-;exit 0" 2
tempfifo=$$.fifo tempfifo=$$.fifo
echo "mkfifo /tmp/$tempfifo" echo "mkfifo /tmp/$tempfifo"
...@@ -117,7 +117,7 @@ function run_sql_file() ...@@ -117,7 +117,7 @@ function run_sql_file()
sh $work_dir/db_execute_sql.sh $target_db_host $sync_db_name sh $work_dir/db_execute_sql.sh $target_db_host $sync_db_name
} }
database_list='mall cash_loan_flow contract dujiangyan financial_system financial_system_api fund_manage gyxd merchant notify offline payment_center qinqiong quartz redpacket risk_control silk_road spider_center traffic_distribution user_credit xyqb xyqb_app xyqb_btzt xyqb_user' database_list=`grep database_list $work_dir/config/db_config | cut -d "=" -f 2`
if [[ "$sync_db_name" = "all" ]] if [[ "$sync_db_name" = "all" ]]
then then
......
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