当设置了resource_limit=true 。通过idle_time限制session idle 时间。session idle超过设置时间,状态为sniped (v$session).,然而OS下的process并不会释放,当session(user process) 再次与server process 通讯,将关闭相应的server process.
sqlnet.expire_time 的原理不一样,Oracle Server 发送包探测dead connection ,如果连接关闭,或者不再用,则关闭相应的server process.
以上两者组合使用,减少server process,防止process超过init$ORACLE_SID极限值。
#查找长时间不用的session.
SELECT s.username,s.status,s.machine,osuser,spid,
'kill -9 '||spid UNIX_level_kill,
'alter system kill session ' ||''''||s.sid||','||s.serial# || ''';' Oracle_level_kill,
TO_CHAR (logon_time, 'dd/mm/yyyy hh24:mi:ss') logon_time,
last_call_et idle_time,
TO_CHAR (TRUNC (last_call_et / 3600, 0))||' '||' HRS '||TO_CHAR (TRUNC ((last_call_et - TRUNC(last_call_et / 3600, 0) * 3600) / 60, 0)) ||' MINS' idle_time_hour_minute,
module
FROM v$session s, v$process p
WHERE TYPE = 'USER'
AND p.addr = s.paddr
AND status = 'SNIPED'
-- AND SUBSTR (machine, 1, 19) NOT IN ('machine')
AND last_call_et > 60 * 60 * 2
-- session idle time more than 1 hour
ORDER BY last_call_et desc;
##写了一个脚本,kill sniped session
##kill_sniped_session.sh
#! /bin/bash
ORACLE_SID=xxxxprod
export ORACLE_SID
ORACLE_HOME=`cat /var/opt/oracle/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
SQLPATH=/apps/oracle/sql
export SQLPATH
#
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba"<<!
@sniped_session.sql
exit
!
if [ -s /apps/oracle/sql/kill_sniped_session.lst ]
then
echo "have a list of sniped_session"
grep kill /apps/oracle/sql/kill_sniped_session.lst
grep kill /apps/oracle/sql/kill_sniped_session.lst | awk '{ print $3 }' | xargs kill -9 2>/backup/oracle/kill_sniped_session.log
fi
if [ $? -ne 0 ]
then
cat /backup/oracle/kill_sniped_session.log | mailx -s "xxxxprod kill sniped session failed" xx@@ss.com
else
sessions_count=`grep kill /apps/oracle/sql/kill_sniped_session.lst | wc -l`
echo "sessions:${sessions_count}" | mailx -s "xxxxprod kill sniped session successful" xx@@ss.com
touch /backup/oracle/kill_sniped_session.sh
fi
oracle@xxxxprod$ more sniped_session.sql
rem sniped_session.sql
rem DESCRIPTION
rem kill sniped session
rem MODIFIED
set pagesize 1000
set heads off
set verify off
set heading off
set termout off
set echo off
set feedback off
spool on
spool /apps/oracle/sql/kill_sniped_session.lst
select 'kill -9 '||spid UNIX_level_kill
FROM v$session s, v$process p
WHERE TYPE = 'USER'
AND p.addr = s.paddr
AND status = 'SNIPED'
AND last_call_et > 60 * 60 * 3
ORDER BY last_call_et desc;
spool off
##btw
What does 'SNIPED' status in v$session mean?
When IDLE_TIME is set in the users' profiles or the default profile. This will kill the sessions in the database (status in v$session now becomes SNIPED) and they will eventually disconnect. It does not always clean up the Unix session (LOCAL=NO sessions). At this time all oracle resources are released but the shadow processes remains and OS resources are not released. This shadow process is still counted towards the parameters of init.ora.
This process is killed and entry from v$session is released only when user again tries to do something. Another way of forcing disconnect (if your users come in via SQL*Net) is to put the file sqlnet.ora on every client machine and include the parameter "SQLNET.EXPIRE_TIME" in it to force the close of the SQL*Net session
sqlnet.expire_time
sqlnet.expire_time actually works on a different principle and is used to detect dead connections as opposed to disconnecting(actually 'sniping') a session based on idle_time which the profile accomplishes.
Sqlnet.expire_time basically instructs the Server to send a probe packet every set minutes to the client , and if it finds a terminated connection or a connection that is no longer in use, causes the associated server process to terminate on the server.
A valid database connection that is idle will respond to the probe packet causing no action on the part of the Server , whereas the resource_limit will snipe the session when idle_time is exceeded. The 'sniped' session will get disconnected when the user(or the user process) tries to communicate with the server again.
But again,as you mentioned, expire_time works globally while idle_time profile works for that user. You can use both of them to make sure that the client not only gets sniped but also gets disconnected if the user process abnormally terminates.
分享到:
相关推荐
设置一个合理的值(如`SQLNET.EXPIRE_TIME = 15`,表示15分钟检查一次)有助于维护数据库性能。 7. **ADR_BASE**: 定义了Oracle诊断目录,所有日志和跟踪文件都将存储在这里。这个目录应该具有足够的空间以容纳...
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更改加密方式 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '自己的密码'; #更新用户密码 (我这里为root )
Microsoft.UI.Xaml.2.7_7.2208.15002.0_x64__8wekyb3d8bbwe
杀毒软件直装版
- 在`$ORACLE_HOME/network/admin/sqlnet.ora`文件中调整`sqlnet.expire_time`参数。该参数用于控制在关闭一个空闲连接前等待的时间长度,默认值通常为0(表示永不超时)。可以将其设置为一个较短的时间值,如10秒...
po.expire_time = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss:ffff"); p.policy = po; p.type = "unicast"; p.production_mode = true; p.device_tokens = "xxxxxxxxx"; PayLoad pay = new ...
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password' PASSWORD EXPIRE NEVER; ``` 最后,记得再次刷新权限以应用所做的更改: ``` flush privileges; ``` 至此,你已经在CentOS 7上成功安装了MySQL ...
1. Expire_logs_days:这个参数确定超过 30 天的 binlog 删除。 2. Binlog_cache_size:这个参数确定一个事务,在没有提交的时候,产生的日志,记录到 Cache 中,默认 binlog_cache_size 大小 32K。 其他参数 1. ...
config.expire_all_remember_me_on_sign_out = true config.password_length = 6..128 config.lock_strategy = :failed_attempts config.unlock_keys = [:email] config.unlock_strategies = [:email] config....
expire 1D ; minimum TTL ) @ IN NS ns1.example.com. @ IN A 192.168.1.1 www IN A 192.168.1.1 ``` 最后,我们来探讨Samba服务,它使得Linux系统能够与Windows网络无缝协作。Samba配置文件`/etc/samba/...
minutesexpire_time == 5 //trueexpire_time === 5 //false+ expire_time === 5 //truetoken = jwt . sign ( user , secret , { expiresInMinutes : expire_time } )key = user . email + '_token'redis . set ( ...
描述中的“Scalper Free Expire”表明这是一款免费的Scalper交易工具或策略,但可能有时间限制,即“Expire”,意味着它可能有一个有效期或者试用期,过了这个期限后可能需要购买或者失去某些功能。 标签“free! ...
4. **缓存失效策略**: 包括LRU(Least Recently Used,最近最少使用)、LFU(Least Frequently Used,最不经常使用)和TTL(Time To Live,生存时间)。Redis提供了EXPIRE命令实现TTL,但实现LRU和LFU通常需要配合...
and you cannot use both "ob_gzhandler" and "zlib.output_compression". ; Note: output_handler must be empty if this is set 'On' !!!! ; Instead you must use zlib.output_handler. ; ...
r.expire('key', 60) # 设置键'key'的过期时间为60秒 ``` 5. **删除数据**: 使用`delete`方法可以删除一个或多个键: ```python r.delete('key') # 删除单个键 r.delete('key1', 'key2') # 删除多个键 ``` ...
然后,可能需要开启`expire_logs_days`以限制旧binlog的保留时间。 4. **从服务器配置**:在从服务器上,同样设置`server-id`,并添加`replicate-do-db`或`replicate-ignore-db`来指定复制的数据库。接着,使用`...
expire 1D ; minimum TTL ) @ IN NS ns1.example.com. @ IN NS ns2.example.com. ns1 IN A 192.168.1.1 ns2 IN A 192.168.1.2 www IN A 192.168.1.3 ``` 2. 在`named.conf.local`中添加区域配置: ...
1. 基本命令:如`SET`、`GET`用于操作字符串,`DEL`删除键,`EXPIRE`设置过期时间。 2. 哈希(Hash):`HSET`、`HGET`操作字段值,`HKEYS`获取所有字段,`HLEN`计算字段数量。 3. 列表(List):`LPUSH`、`RPUSH`...
- `SQLNET.EXPIRE_TIME=10`:设置会话超时时间。 5. **再次配置listener.ora**:在相同目录下,编辑`listener.ora`文件,进一步配置透明网关的监听参数,特别是环境变量`LD_LIBRARY_PATH`。 #### 五、验证配置 ...