Commit 3cacb892 authored by wentao.suo's avatar wentao.suo
parents 1d32ce97 6166a2c4
database_list=mall xyqb account_center cash_loan_flow clotho contract display dujiangyan financial_system financial_system_api fund_manage gyxd mall_settlement merchant notify offline payment_center qinqiong quartz reconciliation redpacket risk_control score silk_road spider_center traffic_distribution urge_dispatcher user_credit xyqb_app xyqb_btzt xyqb_user database_list=mall xyqb account_center cash_loan_flow clotho contract display dujiangyan financial_system financial_system_api fund_manage gyxd mall_settlement merchant notify offline payment_center qinqiong quartz reconciliation redpacket risk_control score silk_road spider_center traffic_distribution urge_dispatcher user_credit xyqb_app xyqb_btzt xyqb_user
source_db_pwd=Uiwb@o^fR&nHOa5t \ No newline at end of file
\ No newline at end of file
#!/bin/bash #!/bin/bash
set -u set -u
source ~/.profile
work_dir=/home/qa-deploy-utils/db-utils work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=/home/db_sync_configs sync_config_folder=/home/db_sync_configs
db_backup_folder=/home/daily_db_backup db_backup_folder=/home/daily_db_backup
source_db_host=$1 source_db_host=$1
source_db_user=$2 source_db_user=`curl -s http://192.168.4.3:10088/config_server/get_db_config/xyqb/user`
source_db_pwd=`grep source_db_pwd $work_dir/config/db_config | cut -d "=" -f 2` source_db_pwd=`curl -s http://192.168.4.3:10088/config_server/get_db_config/xyqb/pwd`
ip_value=$4 target_db_host=192.168.6.2
target_db_port=3306
target_db_user=$5 target_db_user=$5
target_db_pwd=$6 target_db_pwd=$6
...@@ -25,13 +27,22 @@ function db_schema_sync() ...@@ -25,13 +27,22 @@ function db_schema_sync()
echo "mkdir -p $db_backup_sub_folders" echo "mkdir -p $db_backup_sub_folders"
mkdir -p $db_backup_sub_folders mkdir -p $db_backup_sub_folders
# echo "--- Step 1: generate_config_file: $config_file_name ---" echo "--- Step 1: generate_config_file: $config_file_name ---"
# echo "source infos: $source_db_host $source_db_user" # echo "source infos: $source_db_host $source_db_user"
# 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 192.168.4.12 $target_db_user $target_db_pwd $database $config_file_name $db_backup_sub_folders false 3306" 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 3306"
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 3306 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 3306
echo "--- Step 3: sync schema: $database $target_db_host ---"
#sync_cmd="mss -conf ${config_file_name} -sync"
echo "mss -conf ${config_file_name} -sync > /dev/null"
mss -conf ${config_file_name} -sync > /dev/null
echo "mysql-schema-sync result:$?"
echo "--- Step 4: import basic data from backup file: $database $db_backup_sub_folders ---"
sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders $target_db_port
} }
database_list=`grep database_list $work_dir/config/db_config | cut -d "=" -f 2` database_list=`grep database_list $work_dir/config/db_config | cut -d "=" -f 2`
......
...@@ -10,8 +10,7 @@ source ~/.bash_profile ...@@ -10,8 +10,7 @@ source ~/.bash_profile
work_dir=/home/qa-deploy-utils/db-utils work_dir=/home/qa-deploy-utils/db-utils
source_db_host=$1 source_db_host=$1
source_db_user=$2 # source_db_pwd=`grep source_db_pwd $work_dir/config/db_config | cut -d "=" -f 2`
source_db_pwd=`grep source_db_pwd $work_dir/config/db_config | cut -d "=" -f 2`
target_db_host=$4 target_db_host=$4
target_db_user=$5 target_db_user=$5
...@@ -19,6 +18,8 @@ target_db_pwd=$6 ...@@ -19,6 +18,8 @@ target_db_pwd=$6
sync_db_name=$7 sync_db_name=$7
database_name=$sync_db_name database_name=$sync_db_name
source_db_user=`curl -s http://192.168.4.3:10088/config_server/get_db_config/$database_name/user`
source_db_pwd=`curl -s http://192.168.4.3:10088/config_server/get_db_config/$database_name/pwd`
config_file_name=$8 config_file_name=$8
db_backup_sub_folders=$9 db_backup_sub_folders=$9
...@@ -44,138 +45,142 @@ cache_dir=/home/daily_db_backup ...@@ -44,138 +45,142 @@ cache_dir=/home/daily_db_backup
# fi # fi
echo "prepare to get source_port" echo "prepare to get source_port"
if [[ $database_name = 'xyqb' ]]; then # if [[ $database_name = 'xyqb' ]]; then
# 信用钱包database # # 信用钱包database
sys_table_list='baitiao_merchant baitiao_secure_key channel funding_contract funding_corp loan_product merchant_channel payeco_return_url_info red_packet t_phonenum zmxy_return_url configuration secure_proxy funding_corp_config funding_info_map baitiao_preferential_rule funding_corp_policy' # sys_table_list='baitiao_merchant baitiao_secure_key channel funding_contract funding_corp loan_product merchant_channel payeco_return_url_info red_packet t_phonenum zmxy_return_url configuration secure_proxy funding_corp_config funding_info_map baitiao_preferential_rule funding_corp_policy'
port='3306' # port='3306'
elif [[ $database_name = 'xyqb_app' ]]; then # elif [[ $database_name = 'xyqb_app' ]]; then
# app-backend使用的数据库 # # app-backend使用的数据库
sys_table_list='activities app_banners app_config app_versions banners blanknote_entries credit_questions hot_games loan_banners loan_questions migrations sharings widgets js_patch upgrade_version' # sys_table_list='activities app_banners app_config app_versions banners blanknote_entries credit_questions hot_games loan_banners loan_questions migrations sharings widgets js_patch upgrade_version'
port='3307' # port='3307'
elif [[ $database_name = 'payment_center' ]]; then # elif [[ $database_name = 'payment_center' ]]; then
# 支付中心 # # 支付中心
sys_table_list='card_switcher merchant merchant_config pay_approach_config merchant_pay_approach_relation merchant_bank_config quota' # sys_table_list='card_switcher merchant merchant_config pay_approach_config merchant_pay_approach_relation merchant_bank_config quota'
port='3308' # port='3308'
elif [[ $database_name = 'risk_control' ]]; then # elif [[ $database_name = 'risk_control' ]]; then
# 谛听database # # 谛听database
sys_table_list='company product_strategy_dispatcher quantify_product red_packet_info user' # sys_table_list='company product_strategy_dispatcher quantify_product red_packet_info user'
port='3309' # port='3309'
elif [[ $database_name = 'dujiangyan' ]]; then # elif [[ $database_name = 'dujiangyan' ]]; then
# dujiangyan # # dujiangyan
sys_table_list='external_coopr' # sys_table_list='external_coopr'
port='3310' # port='3310'
elif [[ $database_name = 'mall' ]]; then # elif [[ $database_name = 'mall' ]]; then
# 白条商城 # # 白条商城
sys_table_list='activity_3c_product ad_detail admin_banner advertisement_type album app_channel app_channel_ad app_name app_name_ad category category_banner category_nature commodity_slogan commodity_slogan_product configuration edx_city faster_entrance faster_entrance_image goods_after_sale_config goods_after_sale_step home_config home_page hot_category jd_address jd_after_sale_config jd_brand jd_category jd_product_sku_image jd_property jd_sku jd_sku_detail_image jd_sku_specs life_faster_entrance life_service mall_category mall_config merchant nature_value new_3c_product product product_category product_nature product_nature_value_bak product_sku product_sku_image product_specification product_spu recommend_brand recommend_product sale_product_detail sale_product_theme spu_image supplier tab_navigate title_banner loan_config virtual_brand virtual_category virtual_product_discount virtual_product_hot virtual_product_sku virtual_product_spu virtual_product_template' # sys_table_list='activity_3c_product ad_detail admin_banner advertisement_type album app_channel app_channel_ad app_name app_name_ad category category_banner category_nature commodity_slogan commodity_slogan_product configuration edx_city faster_entrance faster_entrance_image goods_after_sale_config goods_after_sale_step home_config home_page hot_category jd_address jd_after_sale_config jd_brand jd_category jd_product_sku_image jd_property jd_sku jd_sku_detail_image jd_sku_specs life_faster_entrance life_service mall_category mall_config merchant nature_value new_3c_product product product_category product_nature product_nature_value_bak product_sku product_sku_image product_specification product_spu recommend_brand recommend_product sale_product_detail sale_product_theme spu_image supplier tab_navigate title_banner loan_config virtual_brand virtual_category virtual_product_discount virtual_product_hot virtual_product_sku virtual_product_spu virtual_product_template'
source_db_host='192.168.3.19' # source_db_host='192.168.3.19'
port='3306' # port='3306'
elif [[ $database_name = 'qinqiong' ]]; then # elif [[ $database_name = 'qinqiong' ]]; then
# qinqiong # # qinqiong
sys_table_list='secure_key secure_proxy' # sys_table_list='secure_key secure_proxy'
port='3310' # port='3310'
elif [[ $database_name = 'cash_loan_flow' ]]; then # elif [[ $database_name = 'cash_loan_flow' ]]; then
# cash_loan_flow # # cash_loan_flow
sys_table_list='order_callback callback_configuration channel_configuration filter_configuration' # sys_table_list='order_callback callback_configuration channel_configuration filter_configuration'
source_db_host='192.168.4.80' # source_db_host='192.168.4.80'
port='8001' # port='8001'
elif [[ $database_name = 'quartz' ]]; then # elif [[ $database_name = 'quartz' ]]; then
# 定时任务 # # 定时任务
sys_table_list='certain_time_job' # sys_table_list='certain_time_job'
port='3310' # port='3310'
elif [[ $database_name = 'contract' ]]; then # elif [[ $database_name = 'contract' ]]; then
# 合同 # # 合同
sys_table_list='contract_template_new' # sys_table_list='contract_template_new'
port='3311' # port='3311'
elif [[ $database_name = 'fund_manage' ]]; then # elif [[ $database_name = 'fund_manage' ]]; then
# fund_manager # # fund_manager
sys_table_list='business_info email_info fund_info merchant' # sys_table_list='business_info email_info fund_info merchant'
port='3310' # port='3310'
elif [[ $database_name = 'financial_system' ]]; then # elif [[ $database_name = 'financial_system' ]]; then
# 财务系统 # # 财务系统
sys_table_list='collection_user sys_dictionary sys_status_edge sys_status_vertice' # sys_table_list='collection_user sys_dictionary sys_status_edge sys_status_vertice'
port='6603' # port='6603'
elif [[ $database_name = 'financial_system_api' ]]; then # elif [[ $database_name = 'financial_system_api' ]]; then
# 财务系统api # # 财务系统api
sys_table_list='mailinfo' # sys_table_list='mailinfo'
port='6603' # port='6603'
elif [[ $database_name = 'gyxd' ]]; then # elif [[ $database_name = 'gyxd' ]]; then
# 广源小贷系统 # # 广源小贷系统
sys_table_list='administrative_districts templet user' # sys_table_list='administrative_districts templet user'
source_db_host='192.168.4.116' # source_db_host='192.168.4.116'
port='6602' # port='6602'
elif [[ $database_name = 'offline' ]]; then # elif [[ $database_name = 'offline' ]]; then
# 线下白条 # # 线下白条
sys_table_list='goods_detail merchant operator_user' # sys_table_list='goods_detail merchant operator_user'
port='3311' # port='3311'
elif [[ $database_name = 'redpacket' ]]; then # elif [[ $database_name = 'redpacket' ]]; then
# 红包系统 # # 红包系统
sys_table_list='tb_activity_channel tb_dict_channel tb_dict_out_channel' # sys_table_list='tb_activity_channel tb_dict_channel tb_dict_out_channel'
source_db_host='192.168.4.116' # source_db_host='192.168.4.116'
port='6001' # port='6001'
elif [[ $database_name = 'spider_center' ]]; then # elif [[ $database_name = 'spider_center' ]]; then
# 授信中心 # # 授信中心
sys_table_list='merchant merchant_config' # sys_table_list='merchant merchant_config'
source_db_host='192.168.4.253' # source_db_host='192.168.4.253'
port='3317' # port='3317'
elif [[ $database_name = 'silk_road' ]]; then # elif [[ $database_name = 'silk_road' ]]; then
# silk_road # # silk_road
sys_table_list='' # sys_table_list=''
source_db_host='192.168.4.80' # source_db_host='192.168.4.80'
port='9999' # port='9999'
elif [[ $database_name = 'xyqb_user' ]]; then # elif [[ $database_name = 'xyqb_user' ]]; then
# 用户中心 # # 用户中心
sys_table_list='merchant_config merchant' # sys_table_list='merchant_config merchant'
port='3313' # port='3313'
elif [[ $database_name = 'merchant' ]]; then # elif [[ $database_name = 'merchant' ]]; then
# 商户 # # 商户
sys_table_list='authority product_nature role role_authority role_supplier role_user user' # sys_table_list='authority product_nature role role_authority role_supplier role_user user'
port='3314' # port='3314'
elif [[ $database_name = 'xyqb_btzt' ]]; then # elif [[ $database_name = 'xyqb_btzt' ]]; then
# 白条直投 # # 白条直投
sys_table_list='zt_channel zt_fund zt_fund_channel zt_fund_credit zt_fund_term' # sys_table_list='zt_channel zt_fund zt_fund_channel zt_fund_credit zt_fund_term'
port='9002' # port='9002'
elif [[ $database_name = 'user_credit' ]]; then # elif [[ $database_name = 'user_credit' ]]; then
# user_credit # # user_credit
sys_table_list='' # sys_table_list=''
port='9001' # port='9001'
elif [[ $database_name = 'display' ]]; then # elif [[ $database_name = 'display' ]]; then
# display # # display
sys_table_list='discovery_config' # sys_table_list='discovery_config'
source_db_host='192.168.3.19' # source_db_host='192.168.3.19'
port='3307' # port='3307'
elif [[ $database_name = 'clotho' ]]; then # elif [[ $database_name = 'clotho' ]]; then
sys_table_list='' # sys_table_list=''
source_db_host='192.168.3.19' # source_db_host='192.168.3.19'
port='3308' # port='3308'
elif [[ $database_name = 'traffic_distribution' ]]; then # elif [[ $database_name = 'traffic_distribution' ]]; then
sys_table_list='merchant merchant_carousel merchant_credit merchant_detail merchant_section merchant_sort ppdai_exclude_channel t_module t_module_role t_role t_user t_user_role traffic_channel_banner_ids traffic_channel_ids traffic_channel_sort traffic_infos' # sys_table_list='merchant merchant_carousel merchant_credit merchant_detail merchant_section merchant_sort ppdai_exclude_channel t_module t_module_role t_role t_user t_user_role traffic_channel_banner_ids traffic_channel_ids traffic_channel_sort traffic_infos'
source_db_host='192.168.3.36' # source_db_host='192.168.3.36'
port='3313' # port='3313'
elif [[ $database_name = 'notify' ]]; then # elif [[ $database_name = 'notify' ]]; then
sys_table_list='merchant merchant_config' # sys_table_list='merchant merchant_config'
source_db_host='192.168.4.6' # source_db_host='192.168.4.6'
port='7306' # port='7306'
elif [[ $database_name = 'mall_settlement' ]]; then # elif [[ $database_name = 'mall_settlement' ]]; then
sys_table_list='role role_user user' # sys_table_list='role role_user user'
source_db_host='192.168.4.253' # source_db_host='192.168.4.253'
port='3315' # port='3315'
elif [[ $database_name = 'score' ]]; then # elif [[ $database_name = 'score' ]]; then
sys_table_list='' # sys_table_list=''
source_db_host='192.168.4.249' # source_db_host='192.168.4.249'
port='3322' # port='3322'
elif [[ $database_name = 'reconciliation' ]]; then # elif [[ $database_name = 'reconciliation' ]]; then
sys_table_list='' # sys_table_list=''
source_db_host='192.168.3.19' # source_db_host='192.168.3.19'
port='3308' # port='3308'
elif [[ $database_name = 'account_center' ]]; then # elif [[ $database_name = 'account_center' ]]; then
sys_table_list='' # sys_table_list=''
source_db_host='192.168.4.116' # source_db_host='192.168.4.116'
port='6001' # port='6001'
elif [[ $database_name = 'urge_dispatcher' ]]; then # elif [[ $database_name = 'urge_dispatcher' ]]; then
sys_table_list='' # sys_table_list=''
source_db_host='192.168.4.116' # source_db_host='192.168.4.116'
port='9901' # port='9901'
fi # fi
sys_table_list=`curl -s http://192.168.4.3:10088/config_server/get_db_config/$database_name/sys_table_list`
source_db_host=`curl -s http://192.168.4.3:10088/config_server/get_db_config/$database_name/host`
port=`curl -s http://192.168.4.3:10088/config_server/get_db_config/$database_name/port`
echo "source_port is $port" echo "source_port is $port"
echo "copy ${base_config_file} to ${config_file_name}" echo "copy ${base_config_file} to ${config_file_name}"
......
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
database_name=$1 database_name=$1
mysql_host=$2 mysql_host=$2
db_sub_backup_folder=$3 db_sub_backup_folder=$3
delete_business_data=$4 target_db_port=$4
target_db_port=$5
echo "cd $db_sub_backup_folder" echo "cd $db_sub_backup_folder"
cd $db_sub_backup_folder cd $db_sub_backup_folder
......
...@@ -99,21 +99,3 @@ else ...@@ -99,21 +99,3 @@ else
#done #done
fi fi
fi fi
# sed -i "s/\/m.xyqb.com/\/xyqb-ui-$ip_last.q-gp.com/g" $entry
# sed -i "s/\/bt.xyqb.com/\/${server_host}:7050/g" $entry
# sed -i "s/\/api.xyqb.com/\/${server_host}:7003/g" $entry
# sed -i "s/\/r.xyqb.com/\/${server_host}:7004/g" $entry
# sed -i "s/\/rapi.xyqb.com/\/${server_host}:7005/g" $entry
# sed -i "s/\/payapi.xyqb.com/\/${server_host}:7006/g" $entry
# sed -i "s/\/pay.xyqb.com/\/${server_host}:7007/g" $entry
# sed -i "s/\/off.xyqb.com/\/${server_host}:7008/g" $entry
# sed -i "s/\/offapi.xyqb.com/\/${server_host}:7010/g" $entry
# sed -i "s/\/financial.xyqb.com/\/${server_host}:7011/g" $entry
# sed -i "s/\/fsapi.xyqb.com/\/${server_host}:7012/g" $entry
# sed -i "s/\/auth.xyqb.com/\/${server_host}:7013/g" $entry
# sed -i "s/\/qapi.xyqb.com/\/${server_host}:7014/g" $entry
# sed -i "s/\/mallapi.xyqb.com/\/${server_host}:7019/g" $entry
# sed -i "s/\/scapi.xyqb.com/\/${server_host}:7021/g" $entry
# sed -i "s/\/gyxdapi.xyqb.com/\/${server_host}:7029/g" $entry
# sed -i "s/\/btapi.xyqb.com/\/${server_host}:7025/g" $entry
...@@ -30,8 +30,8 @@ sync_config_folder=/home/db_sync_configs ...@@ -30,8 +30,8 @@ sync_config_folder=/home/db_sync_configs
db_backup_folder=/home/db_backups db_backup_folder=/home/db_backups
source_db_host=$1 source_db_host=$1
source_db_user=$2 source_db_user=`curl -s http://192.168.4.3:10088/config_server/get_db_config/xyqb/user`
source_db_pwd=`grep source_db_pwd $work_dir/config/db_config | cut -d "=" -f 2` source_db_pwd=`curl -s http://192.168.4.3:10088/config_server/get_db_config/xyqb/pwd`
ip_value=$4 ip_value=$4
...@@ -106,7 +106,7 @@ function db_schema_sync() ...@@ -106,7 +106,7 @@ function db_schema_sync()
echo "mysql-schema-sync result:$?" echo "mysql-schema-sync result:$?"
echo "--- Step 4: import basic data from backup file: $database $db_backup_sub_folders ---" echo "--- Step 4: import basic data from backup file: $database $db_backup_sub_folders ---"
sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders $delete_business_data $target_db_port sh $work_dir/db_import.sh $database $target_db_host $db_backup_sub_folders $target_db_port
# if [ $? != 0 ];then echo "db_import.sh $database error";exit -1; fi # if [ $? != 0 ];then echo "db_import.sh $database error";exit -1; fi
} }
...@@ -118,7 +118,8 @@ function run_sql_file() ...@@ -118,7 +118,8 @@ function run_sql_file()
sh $work_dir/db_execute_sql.sh $target_db_host $sync_db_name $target_db_port sh $work_dir/db_execute_sql.sh $target_db_host $sync_db_name $target_db_port
} }
database_list=`grep database_list $work_dir/config/db_config | cut -d "=" -f 2` # database_list=`grep database_list $work_dir/config/db_config | cut -d "=" -f 2`
database_list=`curl -s http://192.168.4.3:10088/config_server/get_db_config/all/name`
if [[ "$sync_db_name" = "all" ]];then if [[ "$sync_db_name" = "all" ]];then
echo "sync all database schema" echo "sync all database schema"
......
#!/bin/bash
dbs=`curl http://192.168.4.3:10088/config_server/get_db_config/all/name`
for db in $dbs
do
sql_command=`curl http://192.168.4.3:10088/config_server/get_db_dump_command/${db}/opt`
table_opt="mysqldump --opt $sql_command > /tmp/${db}_opt.sql"
echo "$table_opt"
eval $table_opt
mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}_opt.sql
sql_tables=`curl http://192.168.4.3:10088/config_server/get_db_dump_command/${db}/table`
if [[ sql_tables == '' ]];then
echo "这个数据库没有基础数据需要同步"
else
table_data="mysqldump $sql_command --skip-lock-tables --tables $sql_tables --skip-add-locks --no-create-info --complete-insert > /tmp/${db}_db.sql"
echo "$table_data"
eval $table_data
mysql -h 192.168.6.2 -P 3306 -uqa -pqatest db < /tmp/${db}_db.sql
fi
done
\ No newline at end of file
var db = function( host, port, user, pwd, sys_table_list){
this.sys_table_list = sys_table_list;
this.host = host || '192.168.4.39';
this.port = port || '3306';
this.user = user || 'xyqb_query';
this.pwd = pwd || 'Uiwb@o^fR&nHOa5t';
}
module.exports = {
db_config:function(){
this.dbs = {
mall : new db('192.168.3.19','','','','activity_3c_product ad_detail admin_banner advertisement_type album app_channel app_channel_ad app_name app_name_ad category category_banner category_nature commodity_slogan commodity_slogan_product configuration edx_city faster_entrance faster_entrance_image goods_after_sale_config goods_after_sale_step home_config home_page hot_category jd_address jd_after_sale_config jd_brand jd_category jd_product_sku_image jd_property jd_sku jd_sku_detail_image jd_sku_specs life_faster_entrance life_service mall_category mall_config merchant nature_value new_3c_product product product_category product_nature product_nature_value_bak product_sku product_sku_image product_specification product_spu recommend_brand recommend_product sale_product_detail sale_product_theme spu_image supplier tab_navigate title_banner loan_config virtual_brand virtual_category virtual_product_discount virtual_product_hot virtual_product_sku virtual_product_spu virtual_product_template'),
xyqb : new db('','','','','baitiao_merchant baitiao_secure_key channel funding_contract funding_corp loan_product merchant_channel payeco_return_url_info red_packet t_phonenum zmxy_return_url configuration secure_proxy funding_corp_config funding_info_map baitiao_preferential_rule funding_corp_policy'),
account_center : new db('192.168.4.116','6001','','',''),
cash_loan_flow : new db('192.168.4.80','8001','','','order_callback callback_configuration channel_configuration filter_configuration'),
clotho : new db('192.168.3.19','3308','','',''),
contract : new db('','3311','','','contract_template_new'),
display : new db('192.168.3.19','3307','','','discovery_config'),
dujiangyan : new db('','3310','','','external_coopr'),
financial_system : new db('','6603','','','collection_user sys_dictionary sys_status_edge sys_status_vertice'),
financial_system_api : new db('','6603','','','mailinfo'),
fund_manage : new db('','3310','','','business_info email_info fund_info merchant'),
gyxd : new db('192.168.4.116','6602','','','administrative_districts templet user'),
mall_settlement : new db('192.168.4.253','3315','','','role role_user user'),
merchant : new db('','3314','','','authority product_nature role role_authority role_supplier role_user user'),
notify : new db('192.168.4.6','7306','','','merchant merchant_config'),
offline : new db('','3311','','','goods_detail merchant operator_user'),
payment_center : new db('','3308','','','card_switcher merchant merchant_config pay_approach_config merchant_pay_approach_relation merchant_bank_config quota'),
qinqiong : new db('','3310','','','secure_key secure_proxy'),
quartz : new db('','3310','','','certain_time_job'),
reconciliation : new db('192.168.3.19','3308','','',''),
redpacket : new db('192.168.4.116','6001','','','tb_activity_channel tb_dict_channel tb_dict_out_channel'),
risk_control : new db('','3309','','','company product_strategy_dispatcher quantify_product red_packet_info user'),
score : new db('192.168.4.249','3322','','',''),
silk_road : new db('192.168.4.80','9999','','',''),
spider_center : new db('192.168.4.253','3317','','','merchant merchant_config'),
traffic_distribution : new db('192.168.3.36','3313','','','merchant merchant_carousel merchant_credit merchant_detail merchant_section merchant_sort ppdai_exclude_channel t_module t_module_role t_role t_user t_user_role traffic_channel_banner_ids traffic_channel_ids traffic_channel_sort traffic_infos'),
urge_dispatcher : new db('192.168.4.116','9901','','',''),
user_credit : new db('','9001','','',''),
xyqb_app : new db('','3307','','','activities app_banners app_config app_versions banners blanknote_entries credit_questions hot_games loan_banners loan_questions migrations sharings widgets js_patch upgrade_version'),
xyqb_btzt : new db('','9002','','','zt_channel zt_fund zt_fund_channel zt_fund_credit zt_fund_term'),
xyqb_user : new db('','3313','','','merchant_config merchant'),
}
return this.dbs
},
get_mysql_dump_opt:function(key){
let item = this.dbs[key];
return `--host=${item.host} --port=${item.port} --user=${item.user} --password='${item.pwd}' -d ${key} `
},
get_mysql_dump_table:function(key){
let item = this.dbs[key];
return `${item.sys_table_list}`
},
get_target_mysql_command:function(key){
}
}
\ No newline at end of file
var express = require('express'); var express = require('express');
var cproc = require('child_process'); var cproc = require('child_process');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
var db_config = require('./config/db');
// return
var execSync = cproc.execSync; var execSync = cproc.execSync;
var options = { var options = {
inflate: true, inflate: true,
...@@ -38,7 +40,7 @@ var attrComsArr = []; ...@@ -38,7 +40,7 @@ var attrComsArr = [];
for(let i of attrComs){ for(let i of attrComs){
attrComsArr.push(attrs[i]); attrComsArr.push(attrs[i]);
} }
// ------------UTILS---------- // ------------UTILS------------
function parseStr2Json(str){ function parseStr2Json(str){
var a = {}; var a = {};
var strs = str.split(" "); var strs = str.split(" ");
...@@ -70,8 +72,41 @@ function parseJson2Str(json){ ...@@ -70,8 +72,41 @@ function parseJson2Str(json){
return a.join(" ") return a.join(" ")
} }
// ------------UTILS---------- // ------------UTILS----------
// DB 维护数据
let db_conf = db_config.db_config();
let db_conf_keys = Object.keys(db_conf);
//
admin.get('/get_db_config/:name/:attr', function (req, res) {
let str = ""
if(req.params.name == "all"){
if(req.params.attr == "name"){
res.send(db_conf_keys.join(" "));
}
}else{
if(req.params.attr != "all"){
res.send(db_conf[req.params.name][req.params.attr])
}else{
let item = db_conf[req.params.name]
res.send(`${item.host};${item.port};${item.user};${item.pwd};${item.sys_table_list};`)
}
}
});
admin.get('/get_db_dump_command/:name/:opt', function (req, res) {
if(req.params.opt!="opt"){
res.send(db_config.get_mysql_dump_table(req.params.name));
}else{
res.send(db_config.get_mysql_dump_opt(req.params.name));
}
});
admin.get('/get_db_config/refersh',function(){
res.setHeader("Content-Type","application/json");
db_conf = db_config.db_config();
db_conf_keys = Object.keys(db_conf);
res.send({code:"OK"})
})
// 获取节点命令 // 获取节点命令
admin.get('/get_node_command/:name', function (req, res) { admin.get('/get_node_command/:name', function (req, res) {
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type","application/json");
var str = execSync(`node ./get_project_config.js -name ${req.params.name} -attr config_file/command/gitPathHead`) var str = execSync(`node ./get_project_config.js -name ${req.params.name} -attr config_file/command/gitPathHead`)
...@@ -219,6 +254,35 @@ admin.get('/get_proxy', function (req, res) { ...@@ -219,6 +254,35 @@ admin.get('/get_proxy', function (req, res) {
res.send({namespace:String(str)}); res.send({namespace:String(str)});
}); });
app.use('/config_server', admin) app.use('/config_server', admin)
console.log("http://192.168.4.3:10088/config_server/get_node_command") console.log("http://192.168.4.3:10088/config_server/get_node_command")
app.listen(10088) app.listen(10088)
......
...@@ -28,7 +28,8 @@ function createNginxHttpAndSSLConf() ...@@ -28,7 +28,8 @@ function createNginxHttpAndSSLConf()
echo " listen 80;" >> $file_name echo " listen 80;" >> $file_name
echo " server_name $cus_domain.q-gp.com;" >> $file_name echo " server_name $cus_domain.q-gp.com;" >> $file_name
echo " underscores_in_headers on;" >> $file_name echo " underscores_in_headers on;" >> $file_name
echo " proxy_set_header REMOTE_ADDR \$remote_addr; " >> $file_name
echo " proxy_set_header REMOTE_PORT \$remote_port; " >> $file_name
echo " proxy_set_header Host \$host;" >> $file_name echo " proxy_set_header Host \$host;" >> $file_name
echo " proxy_set_header QT_TOKEN \$http_QT_TOKEN;" >> $file_name echo " proxy_set_header QT_TOKEN \$http_QT_TOKEN;" >> $file_name
...@@ -51,6 +52,8 @@ function createNginxHttpAndSSLConf() ...@@ -51,6 +52,8 @@ function createNginxHttpAndSSLConf()
echo "" >> $file_name echo "" >> $file_name
echo " ssl_ciphers HIGH:!aNULL:!MD5;" >> $file_name echo " ssl_ciphers HIGH:!aNULL:!MD5;" >> $file_name
echo " ssl_prefer_server_ciphers on;" >> $file_name echo " ssl_prefer_server_ciphers on;" >> $file_name
echo " proxy_set_header REMOTE_ADDR \$remote_addr; " >> $file_name
echo " proxy_set_header REMOTE_PORT \$remote_port; " >> $file_name
echo " proxy_set_header Host \$host;" >> $file_name echo " proxy_set_header Host \$host;" >> $file_name
echo "" >> $file_name echo "" >> $file_name
echo " location / {" >> $file_name echo " location / {" >> $file_name
...@@ -76,8 +79,11 @@ createK8sNginxConf(){ ...@@ -76,8 +79,11 @@ createK8sNginxConf(){
echo " listen 80 default; " >> $file_name echo " listen 80 default; " >> $file_name
echo " server_name _; " >> $file_name echo " server_name _; " >> $file_name
echo " underscores_in_headers on; " >> $file_name echo " underscores_in_headers on; " >> $file_name
echo " proxy_set_header Host \$host; " >> $file_name
echo " proxy_set_header QT_TOKEN \$http_QT_TOKEN; " >> $file_name echo " proxy_set_header QT_TOKEN \$http_QT_TOKEN; " >> $file_name
echo " proxy_set_header Host \$host; " >> $file_name
echo " proxy_set_header REMOTE_ADDR \$remote_addr; " >> $file_name
echo " proxy_set_header REMOTE_PORT \$remote_port; " >> $file_name
echo " " >> $file_name echo " " >> $file_name
echo " set \$ip \"\"; " >> $file_name echo " set \$ip \"\"; " >> $file_name
echo " location / { " >> $file_name echo " location / { " >> $file_name
...@@ -97,6 +103,8 @@ createK8sNginxConf(){ ...@@ -97,6 +103,8 @@ createK8sNginxConf(){
echo " ssl_ciphers HIGH:!aNULL:!MD5; " >> $file_name echo " ssl_ciphers HIGH:!aNULL:!MD5; " >> $file_name
echo " ssl_prefer_server_ciphers on; " >> $file_name echo " ssl_prefer_server_ciphers on; " >> $file_name
echo " proxy_set_header Host \$host; " >> $file_name echo " proxy_set_header Host \$host; " >> $file_name
echo " proxy_set_header REMOTE_ADDR \$remote_addr; " >> $file_name
echo " proxy_set_header REMOTE_PORT \$remote_port; " >> $file_name
echo " " >> $file_name echo " " >> $file_name
echo " set \$ip \"\"; " >> $file_name echo " set \$ip \"\"; " >> $file_name
echo " location / { " >> $file_name echo " location / { " >> $file_name
......
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