时间:2021-07-01 10:21:17 帮助过:20人阅读
if [[ -f ~/.profile ]] then . ~/.profile fi
if [[ -f ~/.bash_profile ]] then . ~/.bash_profile fi
USERID=`/usr/bin/id -u -nr` if [ $? -ne 0 ] then echo "ERROR: unable to determine uid" exit 99 fi
echo "current user: ${USERID}"
if [ "${USERID}" != "oracle" ] then echo "ERROR: This script must be run as oracle" exit 98 fi
if [ ! $ORACLE_SID ] then echo "Error: No ORACLE_SID set or provided as an argument" exit 97 else echo "current ORACLE_SID: ${ORACLE_SID}" fi
STTIME=`date "+%Y-%m-%d %H:%M:%S"` echo $STTIME
unset SQLPATH unset ORACLE_PATH
echo "${unlock_user}"
function get_xinxi_sql { sqlplus -S ‘/ as sysdba‘ <<EOF set pagesize 0 feedback off verify off heading off echo off set linesize 2000; select sid,serial,qcinst_id,username from (select pxs.qcsid sid,pxs.qcserial# serial,pxs.qcinst_id,ses.username,count(*) slaves FROM gv\$px_session pxs, gv\$session ses, gv\$px_process p,dba_users us WHERE ses.sid = pxs.sid AND ses.serial# = pxs.serial# AND p.sid = pxs.sid AND pxs.inst_id = ses.inst_id AND ses.inst_id = p.inst_id and ses.username=us.username AND pxs.req_degree IS NOT NULL and us.profile=‘JFZZZ‘ GROUP BY qcsid,qcserial#,pxs.qcinst_id,ses.username ORDER BY pxs.qcinst_id,slaves DESC); insert into dbmt.user_auto_lock(exectime,sid,serial,inst_id,username,sql_id,degree,req_degree,slaves) select sysdate,pxs.qcsid sid,pxs.qcserial# serial,pxs.qcinst_id,ses.username,ses.sql_id,pxs.degree,pxs.req_degree,count(*) slaves FROM gv\$px_session pxs, gv\$session ses, gv\$px_process p,dba_users us WHERE ses.sid = pxs.sid AND ses.serial# = pxs.serial# AND p.sid = pxs.sid AND pxs.inst_id = ses.inst_id AND ses.inst_id = p.inst_id and ses.username=us.username AND pxs.req_degree IS NOT NULL and us.profile=‘JFZZZ‘ GROUP BY qcsid,qcserial#,pxs.qcinst_id,ses.username,ses.sql_id,pxs.degree,pxs.req_degree ORDER BY pxs.qcinst_id,slaves DESC; commit; exit; EOF }
px_xinxi=`get_xinxi_sql` echo "${px_xinxi}"
if [ ! -n "$px_xinxi" ] then echo "personal user no parallel session,exit" exit 88 else echo "discovery parallel session!!! next" fi
echo "${kill_sql}" >> $LOGFILE
kill_parallel_session="sqlplus -S ‘/ as sysdba‘ set sqlblanklines on set pagesize 0 verify off heading off echo off "${kill_sql}" exit; " echo "${kill_parallel_session}" | sh >> $LOGFILE
if [ $? -eq 0 ] then echo "personal user parallel killed" else echo "$kill_parallel_session" fi
lock_user="sqlplus -S ‘/ as sysdba‘ set pagesize 0 verify off heading off echo off "${lock_sql}" exit; " echo "${lock_user}" | sh >> $LOGFILE
--编写不易,且用且珍惜,转载请注明来处
脚本-oracle个人用户并行限制
标签:esc null bsp HERE date session off har number