diff --git a/docker-deploy/docker_deploy.sh b/docker-deploy/docker_deploy.sh index a98e58743..12749313a 100644 --- a/docker-deploy/docker_deploy.sh +++ b/docker-deploy/docker_deploy.sh @@ -1,5 +1,5 @@ # Copyright 2019-2020 VMware, Inc. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # you may obtain a copy of the License at @@ -14,7 +14,7 @@ BASEDIR=$(dirname "$0") cd $BASEDIR -WORKINGDIR=`pwd` +WORKINGDIR=$(pwd) # fetch fate-python image source ${WORKINGDIR}/.env @@ -23,137 +23,134 @@ source ${WORKINGDIR}/parties.conf cd ${WORKINGDIR} Deploy() { - if [ "$1" = "" ];then - echo "No party id was provided, please check your arguments " - exit 1 - fi + if [ "$1" = "" ]; then + echo "No party id was provided, please check your arguments " + exit 1 + fi - while [ "$1" != "" ]; do - case $1 in - splitting_proxy) - shift - DeployPartyInternal $@ - break - ;; - all) - for party in ${partylist[*]} - do - if [ "$2" != "" ]; then - case $2 in - --training) - DeployPartyInternal $party - if [ "${exchangeip}" != "" ]; then - DeployPartyInternal exchange - fi - ;; - --serving) - DeployPartyServing $party - ;; - esac - else - DeployPartyInternal $party - DeployPartyServing $party - if [ "${exchangeip}" != "" ]; then - DeployPartyInternal exchange - fi - fi - done - break - ;; - *) - if [ "$2" != "" ]; then - case $2 in - --training) - DeployPartyInternal $1 - break - ;; - --serving) - DeployPartyServing $1 - break - ;; - esac - else - DeployPartyInternal $1 - DeployPartyServing $1 - fi - ;; - esac - shift + while [ "$1" != "" ]; do + case $1 in + splitting_proxy) + shift + DeployPartyInternal $@ + break + ;; + all) + for party in ${partylist[*]}; do + if [ "$2" != "" ]; then + case $2 in + --training) + DeployPartyInternal $party + if [ "${exchangeip}" != "" ]; then + DeployPartyInternal exchange + fi + ;; + --serving) + DeployPartyServing $party + ;; + esac + else + DeployPartyInternal $party + DeployPartyServing $party + if [ "${exchangeip}" != "" ]; then + DeployPartyInternal exchange + fi + fi + done + break + ;; + *) + if [ "$2" != "" ]; then + case $2 in + --training) + DeployPartyInternal $1 + break + ;; + --serving) + DeployPartyServing $1 + break + ;; + esac + else + DeployPartyInternal $1 + DeployPartyServing $1 + fi + ;; + esac + shift - done + done } Delete() { - if [ "$1" = "" ];then - echo "No party id was provided, please check your arguments " - exit 1 - fi + if [ "$1" = "" ]; then + echo "No party id was provided, please check your arguments " + exit 1 + fi - while [ "$1" != "" ]; do - case $1 in - all) - for party in ${partylist[*]} - do - if [ "$2" != "" ]; then - DeleteCluster $party $2 - else - DeleteCluster $party - fi - done - if [ "${exchangeip}" != "" ]; then - DeleteCluster exchange - fi - break - ;; - *) - DeleteCluster $@ - break - ;; - esac - done + while [ "$1" != "" ]; do + case $1 in + all) + for party in ${partylist[*]}; do + if [ "$2" != "" ]; then + DeleteCluster $party $2 + else + DeleteCluster $party + fi + done + if [ "${exchangeip}" != "" ]; then + DeleteCluster exchange + fi + break + ;; + *) + DeleteCluster $@ + break + ;; + esac + done } DeployPartyInternal() { - target_party_id=$1 - # should not use localhost at any case - target_party_ip="127.0.0.1" - - # check configuration files - if [ ! -d ${WORKINGDIR}/outputs ];then - echo "Unable to find outputs dir, please generate config files first." - exit 1 - fi - if [ ! -f ${WORKINGDIR}/outputs/confs-${target_party_id}.tar ];then - echo "Unable to find deployment file for party $target_party_id, please generate it first." - exit 1 - fi - # extract the ip address of the target party - if [ "$target_party_id" = "exchange" ];then - target_party_ip=${exchangeip} - elif [ "$2" != "" ]; then - target_party_ip="$2" - else - for ((i=0;i<${#partylist[*]};i++)) - do - if [ "${partylist[$i]}" = "$target_party_id" ];then - target_party_ip=${partyiplist[$i]} - fi - done - fi - # verify the target_party_ip - if [ "$target_party_ip" = "127.0.0.1" ]; then - echo "Unable to find Party: $target_party_id, please check you input." - exit 1 - fi + target_party_id=$1 + # should not use localhost at any case + target_party_ip="127.0.0.1" - if [ "$3" != "" ]; then - user=$3 - fi + # check configuration files + if [ ! -d ${WORKINGDIR}/outputs ]; then + echo "Unable to find outputs dir, please generate config files first." + exit 1 + fi + if [ ! -f ${WORKINGDIR}/outputs/confs-${target_party_id}.tar ]; then + echo "Unable to find deployment file for party $target_party_id, please generate it first." + exit 1 + fi + # extract the ip address of the target party + if [ "$target_party_id" = "exchange" ]; then + target_party_ip=${exchangeip} + elif [ "$2" != "" ]; then + target_party_ip="$2" + else + for ((i = 0; i < ${#partylist[*]}; i++)); do + if [ "${partylist[$i]}" = "$target_party_id" ]; then + target_party_ip=${partyiplist[$i]} + fi + done + fi + # verify the target_party_ip + if [ "$target_party_ip" = "127.0.0.1" ]; then + echo "Unable to find Party: $target_party_id, please check you input." + exit 1 + fi - scp ${WORKINGDIR}/outputs/confs-$target_party_id.tar $user@$target_party_ip:~/ - #rm -f ${WORKINGDIR}/outputs/confs-$target_party_id.tar - echo "$target_party_ip training cluster copy is ok!" - ssh -tt $user@$target_party_ip<< eeooff + if [ "$3" != "" ]; then + user=$3 + fi + + scp ${WORKINGDIR}/outputs/confs-$target_party_id.tar $user@$target_party_ip:~/ + #rm -f ${WORKINGDIR}/outputs/confs-$target_party_id.tar + echo "$target_party_ip training cluster copy is ok!" + ssh -tt $user@$target_party_ip <#jdbc:mysql://${db_ip}:3306/eggroll_meta?useSSL=false\&serverTimezone=UTC\&characterEncoding=utf8\&allowPublicKeyRetrieval=true#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##${db_user}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##${db_password}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - - #clustermanager & nodemanager - sed -i "s##${clustermanager_ip}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##${clustermanager_port}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##${nodemanager_port}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##${party_id}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - - #python env - sed -i "s##${venv_dir}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - #pythonpath, very import, do not modify." - sed -i "s##/data/projects/fate/python:/data/projects/fate/eggroll/python#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - - #javahome - sed -i "s##/usr/lib/jvm/java-1.8.0-openjdk#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##conf/:lib/*#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - - sed -i "s##${proxy_ip}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - sed -i "s##${proxy_port}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties - - # fateboard - sed -i "s#^server.port=.*#server.port=${fateboard_port}#g" ./confs-$party_id/confs/fateboard/conf/application.properties - sed -i "s#^fateflow.url=.*#fateflow.url=http://${fate_flow_ip}:${fate_flow_http_port}#g" ./confs-$party_id/confs/fateboard/conf/application.properties - sed -i "s##${db_user}#g" ./confs-$party_id/confs/fateboard/conf/application.properties - sed -i "s##${db_password}#g" ./confs-$party_id/confs/fateboard/conf/application.properties - sed -i "s##jdbc:mysql://${db_ip}:3306/${db_name}?characterEncoding=utf8\&characterSetResults=utf8\&autoReconnect=true\&failOverReadOnly=false\&serverTimezone=GMT%2B8#g" ./confs-$party_id/confs/fateboard/conf/application.properties - echo fateboard module of $party_id done! - - # mysql - # sed -i "s/eggroll_meta/${db_name}/g" ./confs-$party_id/confs/mysql/init/create-eggroll-meta-tables.sql - echo > ./confs-$party_id/confs/mysql/init/insert-node.sql - echo "CREATE DATABASE IF NOT EXISTS ${db_name};" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - echo "CREATE USER '${db_user}'@'%' IDENTIFIED BY '${db_password}';" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - echo "GRANT ALL ON *.* TO '${db_user}'@'%';" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - echo 'USE `eggroll_meta`;' >> ./confs-$party_id/confs/mysql/init/insert-node.sql - echo "INSERT INTO server_node (host, port, node_type, status) values ('${clustermanager_ip}', '${clustermanager_port_db}', 'CLUSTER_MANAGER', 'HEALTHY');" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - for ((j=0;j<${#nodemanager_ip[*]};j++)) - do - echo "INSERT INTO server_node (host, port, node_type, status) values ('${nodemanager_ip[j]}', '${nodemanager_port_db}', 'NODE_MANAGER', 'HEALTHY');" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - done - echo "show tables;" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - echo "select * from server_node;" >> ./confs-$party_id/confs/mysql/init/insert-node.sql - echo mysql module of $party_id done! - - # fate_flow - sed -i "s/WORK_MODE =.*/WORK_MODE = 1/g" ./confs-$party_id/confs/fate_flow/conf/settings.py - sed -i "s/user:.*/user: '${db_user}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml - sed -i "s/passwd:.*/passwd: '${db_password}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml - sed -i "s/host: 192.168.0.1*/host: '${db_ip}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml - sed -i "s/name:.*/name: '${db_name}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml - - cat > ./confs-$party_id/confs/fate_flow/conf/server_conf.json <#jdbc:mysql://${db_ip}:3306/eggroll_meta?useSSL=false\&serverTimezone=UTC\&characterEncoding=utf8\&allowPublicKeyRetrieval=true#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##${db_user}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##${db_password}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + + #clustermanager & nodemanager + sed -i "s##${clustermanager_ip}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##${clustermanager_port}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##${nodemanager_port}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##${party_id}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + + #python env + sed -i "s##${venv_dir}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + #pythonpath, very import, do not modify." + sed -i "s##/data/projects/fate/python:/data/projects/fate/eggroll/python#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + + #javahome + sed -i "s##/usr/lib/jvm/java-1.8.0-openjdk#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##conf/:lib/*#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + + sed -i "s##${proxy_ip}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + sed -i "s##${proxy_port}#g" ./confs-$party_id/confs/eggroll/conf/eggroll.properties + + # fateboard + sed -i "s#^server.port=.*#server.port=${fateboard_port}#g" ./confs-$party_id/confs/fateboard/conf/application.properties + sed -i "s#^fateflow.url=.*#fateflow.url=http://${fate_flow_ip}:${fate_flow_http_port}#g" ./confs-$party_id/confs/fateboard/conf/application.properties + sed -i "s##${db_user}#g" ./confs-$party_id/confs/fateboard/conf/application.properties + sed -i "s##${db_password}#g" ./confs-$party_id/confs/fateboard/conf/application.properties + sed -i "s##jdbc:mysql://${db_ip}:3306/${db_name}?characterEncoding=utf8\&characterSetResults=utf8\&autoReconnect=true\&failOverReadOnly=false\&serverTimezone=GMT%2B8#g" ./confs-$party_id/confs/fateboard/conf/application.properties + echo fateboard module of $party_id done! + + # mysql + # sed -i "s/eggroll_meta/${db_name}/g" ./confs-$party_id/confs/mysql/init/create-eggroll-meta-tables.sql + echo >./confs-$party_id/confs/mysql/init/insert-node.sql + echo "CREATE DATABASE IF NOT EXISTS ${db_name};" >>./confs-$party_id/confs/mysql/init/insert-node.sql + echo "CREATE USER '${db_user}'@'%' IDENTIFIED BY '${db_password}';" >>./confs-$party_id/confs/mysql/init/insert-node.sql + echo "GRANT ALL ON *.* TO '${db_user}'@'%';" >>./confs-$party_id/confs/mysql/init/insert-node.sql + echo 'USE `eggroll_meta`;' >>./confs-$party_id/confs/mysql/init/insert-node.sql + echo "INSERT INTO server_node (host, port, node_type, status) values ('${clustermanager_ip}', '${clustermanager_port_db}', 'CLUSTER_MANAGER', 'HEALTHY');" >>./confs-$party_id/confs/mysql/init/insert-node.sql + for ((j = 0; j < ${#nodemanager_ip[*]}; j++)); do + echo "INSERT INTO server_node (host, port, node_type, status) values ('${nodemanager_ip[j]}', '${nodemanager_port_db}', 'NODE_MANAGER', 'HEALTHY');" >>./confs-$party_id/confs/mysql/init/insert-node.sql + done + echo "show tables;" >>./confs-$party_id/confs/mysql/init/insert-node.sql + echo "select * from server_node;" >>./confs-$party_id/confs/mysql/init/insert-node.sql + echo mysql module of $party_id done! + + # fate_flow + sed -i "s/WORK_MODE =.*/WORK_MODE = 1/g" ./confs-$party_id/confs/fate_flow/conf/settings.py + sed -i "s/user:.*/user: '${db_user}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml + sed -i "s/passwd:.*/passwd: '${db_password}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml + sed -i "s/host: 192.168.0.1*/host: '${db_ip}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml + sed -i "s/name:.*/name: '${db_name}'/g" ./confs-$party_id/confs/fate_flow/conf/base_conf.yaml + + cat >./confs-$party_id/confs/fate_flow/conf/server_conf.json < ./confs-$party_id/confs/eggroll/conf/route_table.json <./confs-$party_id/confs/eggroll/conf/route_table.json <#${proxy_ip}#g" ./confs-exchange/conf/eggroll.properties - sed -i "s##${proxy_port}#g" ./confs-exchange/conf/eggroll.properties - sed -i "s##exchange#g" ./confs-exchange/conf/eggroll.properties - sed -i "s/coordinator=.*/coordinator=exchange/g" ./confs-exchange/conf/eggroll.properties - sed -i "s/ip=.*/ip=0.0.0.0/g" ./confs-exchange/conf/eggroll.properties - - cat > ./confs-exchange/conf/route_table.json <#${proxy_ip}#g" ./confs-exchange/conf/eggroll.properties + sed -i "s##${proxy_port}#g" ./confs-exchange/conf/eggroll.properties + sed -i "s##exchange#g" ./confs-exchange/conf/eggroll.properties + sed -i "s/coordinator=.*/coordinator=exchange/g" ./confs-exchange/conf/eggroll.properties + sed -i "s/ip=.*/ip=0.0.0.0/g" ./confs-exchange/conf/eggroll.properties + + cat >./confs-exchange/conf/route_table.json </${redis_ip}/g" ./serving-$party_id/confs/serving-server/conf/serving-server.properties - sed -i "s//${redis_port}/g" ./serving-$party_id/confs/serving-server/conf/serving-server.properties - sed -i "s//${redis_password}/g" ./serving-$party_id/confs/serving-server/conf/serving-server.properties - sed -i "s//${redis_password}/g" ./serving-$party_id/docker-compose.yml - - # serving proxy - sed -i "s/coordinator=partyid/coordinator=${party_id}/g" ./serving-$party_id/confs/serving-proxy/conf/application.properties - cat > ./serving-$party_id/confs/serving-proxy/conf/route_table.json </${redis_ip}/g" ./serving-$party_id/confs/serving-server/conf/serving-server.properties + sed -i "s//${redis_port}/g" ./serving-$party_id/confs/serving-server/conf/serving-server.properties + sed -i "s//${redis_password}/g" ./serving-$party_id/confs/serving-server/conf/serving-server.properties + sed -i "s//${redis_password}/g" ./serving-$party_id/docker-compose.yml + + # serving proxy + sed -i "s/coordinator=partyid/coordinator=${party_id}/g" ./serving-$party_id/confs/serving-proxy/conf/application.properties + cat >./serving-$party_id/confs/serving-proxy/conf/route_table.json < ./confs-${party_id}/conf/route_table.json <./confs-${party_id}/conf/route_table.json <