#依次导入用户数据
arr_user=(${user_list//,/ })
for user_name in ${arr_user[@]}
do
sed -i "s#@cur_path#$INSTALL_HOME/dbscript/impdp#g" $INSTALL_HOME/dbscript/impdp/get_fk_disable.sql
su - oracle -c "sqlplus ${user_name}/${DB_APP_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} @$INSTALL_HOME/dbscript/impdp/get_fk_disable.sql;"
while read fk_low_line ; do
if [ "x${fk_low_line}" != "x" ] ; then
fk_low=`echo $fk_low_line | grep [a-z] | awk '{print $NF }' `
if [ "x${fk_low}" != "x" ] ; then
fk_low=`echo ${fk_low%;*}`
fk_low_replace=\"$fk_low\"
sed -i "s#${fk_low}#${fk_low_replace}#g" $INSTALL_HOME/dbscript/impdp/set_fk_disable.sql
fi
fi
done < $INSTALL_HOME/dbscript/impdp/set_fk_disable.sql
su - oracle -c "sqlplus ${user_name}/${DB_APP_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} <<EOF
@$INSTALL_HOME/dbscript/impdp/set_fk_disable.sql;
quit;
EOF";
if [ "$user_name" == "inoc_sdm_servicedesk_${sdm_number}" ]
then
if [ "$except_flag" == "min" ] ; then
su - oracle -c "impdp ${DB_System_username}/${DB_System_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} DIRECTORY=dumpdir parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} logfile=impdp_${user_name}_min_exclude.log DUMPFILE=${user_name}_%u.dump SCHEMAS=$user_name EXCLUDE=TABLE:\"IN\($table_list\)\" content=data_only;"
RESULT=`cat ${dump_directory}/impdp_${user_name}_min_exclude.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import ${user_name}.dump Faild, please check impdp_${user_name}_min_exclude.log" $log_path
exit 1;
fi
else
su - oracle -c "impdp ${DB_System_username}/${DB_System_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} DIRECTORY=dumpdir parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} logfile=impdp_${user_name}.log DUMPFILE=${user_name}_%u.dump SCHEMAS=$user_name content=data_only;"
RESULT=`cat ${dump_directory}/impdp_${user_name}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import ${user_name}.dump Faild, please check impdp_${user_name}.log" $log_path
exit 1;
fi
fi
else
su - oracle -c "impdp ${DB_System_username}/${DB_System_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} DIRECTORY=dumpdir parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} logfile=impdp_${user_name}.log DUMPFILE=${user_name}_%u.dump SCHEMAS=$user_name content=data_only;"
RESULT=`cat ${dump_directory}/impdp_${user_name}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import ${user_name}.dump Faild, please check impdp_${user_name}.log" $log_path
exit 1;
fi
fi
sed -i "s#@cur_path#$INSTALL_HOME/dbscript/impdp#g" $INSTALL_HOME/dbscript/impdp/get_fk_enable.sql
su - oracle -c "sqlplus ${user_name}/${DB_APP_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} @$INSTALL_HOME/dbscript/impdp/get_fk_enable.sql;"
while read fk_low_line ; do
if [ "x${fk_low_line}" != "x" ] ; then
fk_low=`echo $fk_low_line | grep [a-z] | awk '{print $NF }' `
if [ "x${fk_low}" != "x" ] ; then
fk_low=`echo ${fk_low%;*}`
fk_low_replace=\"$fk_low\"
sed -i "s#${fk_low}#${fk_low_replace}#g" $INSTALL_HOME/dbscript/impdp/set_fk_enable.sql
fi
fi
done < $INSTALL_HOME/dbscript/impdp/set_fk_enable.sql
su - oracle -c "sqlplus ${user_name}/${DB_APP_password}@//${DB_server_ip}:${DB_Port}/${DB_instance} <<EOF
@$INSTALL_HOME/dbscript/impdp/set_fk_enable.sql;
quit;
EOF";
done
#MOSTCMDB用户
if [ -f ${dump_directory}/full_most.dump ]
then
sed -i "s#@cur_path#$INSTALL_HOME/dbscript/impdp#g" $INSTALL_HOME/dbscript/impdp/get_fk_disable.sql
su - oracle -c "sqlplus mostcmdb_${sdm_number}/${MOSTCMDB_password}@//${DB_server_ip}:${MOST_DB_listen_port}/${MOST_instance_name} @$INSTALL_HOME/dbscript/impdp/get_fk_disable.sql;"
while read fk_low_line ; do
if [ "x${fk_low_line}" != "x" ] ; then
fk_low=`echo $fk_low_line | grep [a-z] | awk '{print $NF }' `
if [ "x${fk_low}" != "x" ] ; then
fk_low=`echo ${fk_low%;*}`
fk_low_replace=\"$fk_low\"
sed -i "s#${fk_low}#${fk_low_replace}#g" $INSTALL_HOME/dbscript/impdp/set_fk_disable.sql
fi
fi
done < $INSTALL_HOME/dbscript/impdp/set_fk_disable.sql
su - oracle -c "sqlplus mostcmdb_${sdm_number}/${MOSTCMDB_password}@//${DB_server_ip}:${MOST_DB_listen_port}/${MOST_instance_name} <<EOF
@$INSTALL_HOME/dbscript/impdp/set_fk_disable.sql;
quit;
EOF";
su - oracle -c "impdp ${DB_System_username}/${DB_System_password}@//${DB_server_ip}:${MOST_DB_listen_port}/${MOST_instance_name} DIRECTORY=dumpdir parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} logfile=impdp_mostcmdb_${sdm_number}.log DUMPFILE=mostcmdb_${sdm_number}_%u.dump SCHEMAS=mostcmdb_${sdm_number} content=data_only;"
#TABLE_EXISTS_ACTION=REPLACE; "
sed -i "s#@cur_path#$INSTALL_HOME/dbscript/impdp#g" $INSTALL_HOME/dbscript/impdp/get_fk_enable.sql
su - oracle -c "sqlplus mostcmdb_${sdm_number}/${MOSTCMDB_password}@//${DB_server_ip}:${MOST_DB_listen_port}/${MOST_instance_name} @$INSTALL_HOME/dbscript/impdp/get_fk_enable.sql;"
while read fk_low_line ; do
if [ "x${fk_low_line}" != "x" ] ; then
fk_low=`echo $fk_low_line | grep [a-z] | awk '{print $NF }' `
if [ "x${fk_low}" != "x" ] ; then
fk_low=`echo ${fk_low%;*}`
fk_low_replace=\"$fk_low\"
sed -i "s#${fk_low}#${fk_low_replace}#g" $INSTALL_HOME/dbscript/impdp/set_fk_enable.sql
fi
fi
done < $INSTALL_HOME/dbscript/impdp/set_fk_enable.sql
su - oracle -c "sqlplus mostcmdb_${sdm_number}/${MOSTCMDB_password}@//${DB_server_ip}:${MOST_DB_listen_port}/${MOST_instance_name} <<EOF
@$INSTALL_HOME/dbscript/impdp/set_fk_enable.sql;
quit;
EOF";
RESULT=`cat ${dump_directory}/impdp_mostcmdb_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import mostcmdb_${sdm_number}.dump Faild, please check impdp_mostcmdb_${sdm_number}.log" $log_path
exit 1;
fi
fi
else
#mv ${DBBACKUP_DIR}/* /opt/oracle/autobackup_20150210103527/
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
echo "------------"
echo "sdm_number is $sdm_number......"
echo "------------"
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_message.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_message.sql
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_si.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_si.sql
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
#add mostcmdb by gufan
sed -i "s/@{ProjectID}/${project}/g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
sed -i "s#@{systempassword}#${DB_SYSTEM_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
sed -i "s#@{dbserverip}#${DB_server_ip}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
sed -i "s#@{listenport}#${DB_listen_port}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
sed -i "s#@{SDMUserName}#${DB_APP_username}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
sed -i "s#@{DBUSERSDMPASSWORD}#${DB_APP_password}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
#end add mostcmdb by gufan
chmod -R 777 $INSTALL_HOME/dbscript/impdp/grant_archive.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/grant_mostcbb.sql
chmod -R 777 $INSTALL_HOME/dbscript/impdp/grant_servicedesk.sql
echo "------------"
echo "sdm_number is $sdm_number......"
echo "------------"
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/grant_archive.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/grant_mostcbb.sql
sed -i "s#@{sdm_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/grant_servicedesk.sql
writeLog $log_file_name "DB_instance is ${DB_instance}......" $log_path
sed -i "s#@{DB_instance}#${DB_instance}#g" $INSTALL_HOME/dbscript/impdp/createTableSpace_inoc.sql
sed -i "s#@{inoc_number}#${sdm_number}#g" $INSTALL_HOME/dbscript/impdp/createTableSpace_inoc.sql
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createTableSpace_inoc.sql
exit;
END"
sleep 20s
#begin create mostcbb user and import dump and grant mostcbb
writeLog $log_file_name "Starting to importdata ...inoc_sdm_mostcbb_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_mostcbb.sql
exit;
END"
sleep 20s
su - oracle -c "impdp inoc_sdm_mostcbb_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_mostcbb_${sdm_number}.dump LOGFILE=import_inoc_sdm_mostcbb_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE"
RESULT=`cat ${dump_directory}/import_inoc_sdm_mostcbb_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import inoc_sdm_mostcbb_${sdm_number}.dump Faild, please check import_mostcbb" $log_path
exit 1;
fi
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/grant_mostcbb.sql
exit;
END"
writeLog $log_file_name "end to importdata ...inoc_sdm_mostcbb_${sdm_number}" $log_path
#end create mostcbb user and import dump and grant mostcbb
#begin create archive user and import dump and grant archive
writeLog $log_file_name "Starting to importdata ...inoc_sdm_archive_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_archive.sql
exit;
END"
sleep 20s
su - oracle -c "impdp inoc_sdm_archive_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_archive_${sdm_number}.dump LOGFILE=import_inoc_sdm_archive_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE"
RESULT=`cat ${dump_directory}/import_inoc_sdm_archive_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import inoc_sdm_archive_${sdm_number}.dump Faild, please check import_inoc_sdm_archive_${sdm_number}.log" $log_path
exit 1;
fi
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/grant_archive.sql
exit;
END"
writeLog $log_file_name "end to importdata ...inoc_sdm_archive_${sdm_number}" $log_path
#end create archive user and import dump and grant archive
#begin create servicedesk user and import dump and grant servicedesk
writeLog $log_file_name "Starting to importdata ...inoc_sdm_servicedesk_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_servicedesk.sql
exit;
END"
sleep 20s
if [ "$except_flag" == "min" ] ; then
su - oracle -c "impdp inoc_sdm_servicedesk_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_servicedesk_${sdm_number}.dump LOGFILE=import_inoc_sdm_servicedesk_${sdm_number}_exclude.log EXCLUDE=TABLE:\"IN\($table_list\)\" parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE "
su - oracle -c "impdp inoc_sdm_servicedesk_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_servicedesk_${sdm_number}.dump LOGFILE=import_inoc_sdm_servicedesk_${sdm_number}_include.log INCLUDE=TABLE:\"IN\($table_list\)\" parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE rows=n"
else
su - oracle -c "impdp inoc_sdm_servicedesk_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_servicedesk_${sdm_number}.dump LOGFILE=import_inoc_sdm_servicedesk_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE "
fi
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/grant_servicedesk.sql
exit;
END"
writeLog $log_file_name "end to importdata ...inoc_sdm_servicedesk_${sdm_number}" $log_path
#end create servicedesk user and import dump and grant servicedesk
#begin create message user and import dump and grant message
writeLog $log_file_name "Starting to importdata ...inoc_sdm_message_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_message.sql
exit;
END"
sleep 20s
su - oracle -c "impdp inoc_sdm_message_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=noc_sdm_message_${sdm_number}.dump LOGFILE=import_noc_sdm_message_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} EXCLUDE=STATISTICS TABLE_EXISTS_ACTION=REPLACE "
RESULT=`cat ${dump_directory}/import_noc_sdm_message_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import noc_sdm_message_${sdm_number}.dump Faild, please check import_noc_sdm_message_${sdm_number}" $log_path
exit 1;
fi
writeLog $log_file_name "end to importdata ...inoc_sdm_message_${sdm_number}" $log_path
#end create message user and import dump and grant message
#begin create studio user and import dump and grant studio
writeLog $log_file_name "Starting to importdata ...inoc_sdm_studio_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_studio.sql
exit;
END"
sleep 20s
su - oracle -c "impdp inoc_sdm_studio_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_studio_${sdm_number}.dump LOGFILE=import_inoc_sdm_studio_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} EXCLUDE=STATISTICS TABLE_EXISTS_ACTION=REPLACE "
RESULT=`cat ${dump_directory}/import_inoc_sdm_studio_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import inoc_sdm_studio_${sdm_number}.dump Faild, please check import_inoc_sdm_studio_${sdm_number}" $log_path
exit 1;
fi
writeLog $log_file_name "end to importdata ...inoc_sdm_studio_${sdm_number}" $log_path
#end create studio user and import dump and grant studio
#begin create si user and import dump and grant si
writeLog $log_file_name "Starting to importdata ...inoc_sdm_si_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${DB_instance} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_si.sql
exit;
END"
sleep 20s
su - oracle -c "impdp inoc_sdm_si_${sdm_number}/${DB_APP_password}@//${DB_server_ip}:${DB_listen_port}/${DB_instance} DIRECTORY=dumpdir DUMPFILE=inoc_sdm_si_${sdm_number}.dump LOGFILE=import_inoc_sdm_si_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE "
RESULT=`cat ${dump_directory}/import_inoc_sdm_si_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import inoc_sdm_si_${sdm_number}.dump Faild, please check import_inoc_sdm_si_${sdm_number}" $log_path
exit 1;
fi
writeLog $log_file_name "end to importdata ...inoc_sdm_si_${sdm_number}" $log_path
#end create si user and import dump and grant si
#begin create mostcmdb user and import dump and grant mostcmdb
writeLog $log_file_name "Starting to importdata ...mostcmdb_${sdm_number}" $log_path
su - oracle -c "export ORACLE_SID=${MOST_instance_name} ; sqlplus / as sysdba <<END
start $INSTALL_HOME/dbscript/impdp/createUser_mostcmdb.sql
exit;
END"
sleep 20s
su - oracle -c "impdp system/iNOC_oper_001@//${DB_server_ip}:${MOST_DB_listen_port}/${MOST_instance_name} DIRECTORY=dumpdir DUMPFILE=mostcmdb_${sdm_number}.dump LOGFILE=import_mostcmdb_${sdm_number}.log parallel=4 ENCRYPTION_PASSWORD=${DB_wallet_password} TABLE_EXISTS_ACTION=REPLACE "
RESULT=`cat ${dump_directory}/import_mostcmdb_${sdm_number}.log | grep ERROR | grep -i ORA- | grep -v -E ${except_ora_err}`
if [ "$RESULT" ];
then
writeLog $log_file_name "import mostcmdb_${sdm_number}.dump Faild, please check import_mostcmdb_${sdm_number}" $log_path
exit 1;
fi
writeLog $log_file_name "end to importdata ...mostcmdb_${sdm_number}" $log_path
#end create mostcmdb user and import dump and grant mostcmdb
fi
#add sequence for all user schema
sh $current_path/db_modify_sequence.sh ${sdm_number}
#mv /opt/oracle/autobackup_20150210103527/* ${DBBACKUP_DIR}/
writeLog $log_file_name "import all dump successfully..." $log_path
}