[20190409]pre_page_sga=true与连接缓慢的问题.txt

--//曾经遇到11g下设置pre_page_sga=true启动缓慢的问题(没有使用hugepages).
--//链接:http://blog.itpub.net/267265/viewspace-2295412/
--//实际上这样系统也会遇到连接缓慢的情况,通过测试说明问题.

1.建立pfile:
$ cat initxxxx.ora
db_name=xxxx
instance_name=xxxx
sga_target=20G
#sga_target=0
sga_max_size=20G
pre_page_sga=true

$ export ORACLE_SID=xxxx

SYS@xxxx> startup nomount
ORACLE instance started.
Total System Global Area 2.1379E+10 bytes
Fixed Size                  2262656 bytes
Variable Size            2818574720 bytes
Database Buffers         1.8522E+10 bytes
Redo Buffers               36073472 bytes

$ grep -i page /proc/meminfo
AnonPages:        239336 kB
PageTables:       701008 kB
AnonHugePages:         0 kB
HugePages_Total:     104
HugePages_Free:       48
HugePages_Rsvd:       41
HugePages_Surp:        0
Hugepagesize:       2048 kB

--//才启动没有任何用户连接,PageTables=701008 kB.

2.测试登陆问题:
$ time sqlplus -s -l  / as sysdba <<<quit
real    0m4.944s
user    0m0.024s
sys     0m0.016s
--//单个连接需要5秒.如果多个用户并发呢?
$ cat aa.sql
quit

$ time seq 50 | xargs -I{} -P 50 sqlplus -s -l  / as sysdba @ aa.sql
real    0m13.978s
user    0m1.833s
sys     0m1.017s
--//多个用户同时登录,全部完成需要13秒.

3.分析:
$ strace -f -c sqlplus -s -l  / as sysdba <<<quit
Process 3120 attached
Process 3120 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 99.85    0.419648       69941         6           shmdt
  0.10    0.000434           1       413         2 read
  0.01    0.000046           0       287       127 open
  0.01    0.000045           0       180           mmap
  0.01    0.000037           0       178           close
  0.01    0.000032           0        79           rt_sigaction
  ....
------ ----------- ----------- --------- --------- ----------------
100.00    0.420259                  1970       227 total

$ man shmdt
...
shmdt() detaches the shared memory segment located at the address specified by shmaddr from the address space of the
calling process.  The to-be-detached segment must be currently attached with shmaddr equal to the value returned by the
attaching shmat() call.

On a successful shmdt() call the system updates the members of the shmid_ds structure associated with the shared memory
segment as follows:

shm_dtime is set to the current time.
shm_lpid is set to the process-ID of the calling process.
shm_nattch is decremented by one.  If it becomes 0 and the segment is marked for deletion, the segment is deleted.

--//给人的感觉好像消耗在调用shmdt,实际上消耗的时间0.419648.也就是这样还是无法定位问题在那里.

$ strace -fTtt  -e shmdt sqlplus -s -l  / as sysdba
Process 6046 attached
[pid  6046] 08:41:55.548586 shmdt(0x7f2c41600000) = 0 <0.000036>
quit
08:41:59.992835 shmdt(0x60000000)       = 0 <0.000042>
08:41:59.992983 shmdt(0x68000000)       = 0 <0.000042>
08:41:59.993097 shmdt(0x6c000000)       = 0 <0.360175>
08:42:00.353446 shmdt(0x4ec000000)      = 0 <0.037200>
08:42:00.390737 shmdt(0x560000000)      = 0 <0.000026>
Process 6046 detached
--//我手工执行quit,可以发现shmdt调用发生在退出阶段,也就是不是它导致登陆缓慢.

$ ipcs -smt

------ Shared Memory Attach/Detach/Change Times --------
shmid      owner      attached             detached             changed
352092161  oracle      Apr 10 17:26:09      Apr 10 17:26:17      Apr 10 17:09:55
352124930  oracle      Apr 10 17:26:09      Apr 10 17:26:17      Apr 10 17:09:55
352157699  oracle      Apr 10 17:26:09      Apr 10 17:26:18      Apr 10 17:09:55
352190469  oracle      Apr 10 17:26:09      Apr 10 17:26:18      Apr 10 17:09:55
352223238  oracle      Apr 10 17:26:09      Apr 10 17:26:18      Apr 10 17:09:55

------ Semaphore Operation/Change Times --------
semid    owner      last-op                    last-changed
310738944 oracle      Wed Apr 10 17:11:33 2019   Wed Apr 10 17:11:33 2019
--//从执行时间看4.5秒并不是消耗在这里.

4.继续分析,排除调用shmdt的情况:

$ strace -fTr -o /tmp/a2.txt  sqlplus  -s -l / as sysdba <<<quit
$ awk '{print $2}' /tmp/a2.txt | sort -nr | head
5.041521
0.287119
0.064745
0.008298
0.006386
0.004288
0.004272
0.001319
0.000982
0.000978

--//查看a2.txt
3366       0.000067 stat("/u01/app/oracle/product/11.2.0.4/dbhome_1/lib", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0 <0.000025>
3366       0.000112 chdir("/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs") = 0 <0.000027>
3366       5.041521 mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c2c0b3000 <0.000048>
3366       0.000407 mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c2c090000 <0.000015>
3366       0.000127 mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c2c06d000 <0.000013>
3366       0.000218 getcwd("/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs"..., 256) = 46 <0.000016>
3366       0.000087 access("/etc/intchg.ora", F_OK) = -1 ENOENT (No such file or directory) <0.000019>
...
--//也就是在chdir调用与mmap调用之间有5秒不知道在干什么?(chdir 仅仅需要0.000027秒).strace看不出来!!
--//如果你使用top -u oracle观察,你可以发现RES字段不断在增加,接近SGA设置.我的感觉就是在这里建立pagetables的过程.

$ cat aa.sql
host sleep 1
quit

$ cat a.sh
#! /bin/bash
export ORACLE_SID=xxxx
sqlplus  -s -l / as sysdba @ aa.sql &
a=$(($!+2))
top -p $a -d 1 -b

$ . a.sh | tee /tmp/aa.txt
...
--//按ctrl+c中断.

$ grep PID /tmp/aa.txt | head -1; egrep 'oracle' /tmp/aa.txt
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 8498 oracle    20   0 20.2g 1.5g 1.5g R 93.9  1.2   0:00.47 oracle
 8498 oracle    20   0 20.2g 5.8g 5.8g R 99.7  4.6   0:01.47 oracle
 8498 oracle    20   0 20.2g  10g  10g R 99.8  8.4   0:02.47 oracle
 8498 oracle    20   0 20.2g  15g  15g R 99.8 12.2   0:03.47 oracle
--//sleep 1
 8498 oracle    20   0 20.2g  19g  19g S 95.9 15.7   0:04.43 oracle
 8498 oracle    20   0 20.2g  19g  19g S  0.0 15.7   0:04.43 oracle
 8498 oracle    20   0 20.0g  19g  19g R  1.0 15.6   0:04.44 oracle
--//你可以发现RES,SHR都在增加,CPU使用率在9X%,感觉11g版本在设置pre_page_sga=true下有问题.
--//大致定位时间定位在建立pagetables的过程.

5.改用hugepages呢?
$ grep -i page /proc/meminfo
AnonPages:        244144 kB
PageTables:        11508 kB
AnonHugePages:         0 kB
HugePages_Total:   26000
HugePages_Free:    15800
HugePages_Rsvd:       41
HugePages_Surp:        0
Hugepagesize:       2048 kB

$ time  sqlplus -s -l  / as sysdba <<<quit
real    0m0.180s
user    0m0.029s
sys     0m0.011s

$ strace -fTr -o /tmp/a3.txt  sqlplus  -s -l / as sysdba <<<quit
$ awk '{print $2}' /tmp/a3.txt | sort -nr | head
0.121929
0.009182
0.009144
0.009047
0.005081
0.002050
0.001984
0.001932
0.001321
0.001243

--//查看a3.txt
8716       0.000095 chdir("/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs") = 0 <0.000019>
--//这里等待时间很小.
8716       0.121929 mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f552659d000 <0.000029>
8716       0.000143 mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f552657a000 <0.000020>
8716       0.000166 mmap(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5526557000 <0.000020>
8716       0.000260 getcwd("/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs"..., 256) = 46 <0.000023>

--//总之:
如果pre_page_sga=true最好开启hugepages.
很奇怪的是12c 缺省pre_page_sga=true,没有开启hugepages的情况下,没有这个问题.

[20190409]pre_page_sga=true与连接缓慢的问题.txt的更多相关文章

  1. Mysql连接缓慢

    教程所示图片使用的是 github 仓库图片,网速过慢的朋友请移步>>> (原文)Mysql 连接缓慢. 更多讨论或者错误提交,也请移步. 最近在 Node 上进行 Mysql 操作 ...

  2. ssh 连接缓慢解决方法

    ssh 连接缓慢解决方法 摘自:https://blog.csdn.net/qq_14821541/article/details/61915589 2017年03月13日 12:00:38 所以怎样 ...

  3. ssh连接缓慢的问题分析

    之前遇到ssh连接缓慢的问题 一般会检查Server端 /etc/ssh/sshd_config配置文件的两个地方 1.设置UseDNS no 因为我们ssh连接服务器的话 如果UseDNS选项是打开 ...

  4. [20191113]oracle共享连接模式端口2.txt

    [20191113]oracle共享连接模式端口2.txt --//昨天的测试链接:http://blog.itpub.net/267265/viewspace-2663651/=>[20191 ...

  5. mysql远程连接缓慢的问题

    这两天发现服务器程序启动的时候到了mysql初始连接的那一步很耗时,启动缓慢,后来发现,将连接的主机的-h参数改成localhost的时候 瞬间就完成连接了.后来在网上查到,原来是由于mysql服务器 ...

  6. 转 sqlplus/RMAN/lsnrctl 等工具连接缓慢

    AIX上sqlplus /as sysdba    rman target / 或者lsnrctl start时或者通过sqlplus system/oracle@orcl这样通过监听连接等方式来登陆 ...

  7. 轻松解决Github连接缓慢、图裂问题

    1 简介 gayhub(误)github作为全世界最大的开源代码库以及版本控制系统,是用来托管项目以及学习开源技术非常好的平台,是我心中最好的学习网站,我们公众号的众多技术文章对应的数据和代码也都一直 ...

  8. [解决WebClient或HttpWebRequest首次连接缓慢问题]

    [编程环境]Visual Studio 2010, NET4.0 [开发语言]C#, 理论上VB.NET等依赖.NET Framework框架的语言均受此影响 [问题描述] 使用HttpWebRequ ...

  9. 解决Win7中第一次HttpWebRequest连接缓慢、超时等问题

    在使用HttpWebRequest的时候发现,第一次连接需要15S左右,我的系统是win7,很崩溃,除了我那个用户可以等待的了,但是第二次,就没有问题了,于是百度之...... http://www. ...

随机推荐

  1. [Swift]LeetCode1020. 飞地的数量 | Number of Enclaves

    Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land) A move consists of wa ...

  2. Linux 虚拟网络设备详解之 Bridge 网桥

    本文首发于我的公众号 Linux云计算网络(id: cloud_dev),专注于干货分享,号内有 10T 书籍和视频资源,后台回复「1024」即可领取,欢迎大家关注,二维码文末可以扫. 前面几篇文章介 ...

  3. Hadoop源码篇--Reduce篇

    一.前述 Reduce文件会从Mapper任务中拉取很多小文件,小文件内部有序,但是整体是没序的,Reduce会合并小文件,然后套个归并算法,变成一个整体有序的文件. 二.代码 ReduceTask源 ...

  4. 十一之买一台 vps搭建 玩玩

    直接上大家都熟悉的banwangong的网址买一台最便宜的机器,毕竟是试着玩么,买了一个月的,如果直接买还是冲年费的吧. 第一步,注册会员么,结果就出问题了,显示图片不符合标准 ,我就很纳闷,我填几个 ...

  5. Linux 文件权限于目录配置

    用户与用户组 我們以王三毛為例,王三毛這個『檔案』的擁有者為王三毛,他屬於王大毛這個群組, 而張小豬相對於王三毛,則只是一個『其他人(others)』而已. 不過,這裡有個特殊的人物要來介紹的,那就是 ...

  6. .NetCore2.1 WebAPI新增Swagger插件

    说明 Swagger是一个WebAPI在线注解.调试插件,过去我们主要通过手工撰写WebAPI接口的交互文档供前端开发人员或外部开发者, 官网地址:https://swagger.io/. 但是在实际 ...

  7. Spring Boot(六)集成 MyBatis 操作 MySQL 8

    一.简介 1.1 MyBatis介绍 MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射.MyBatis 避免了几乎所有的 JDBC代码和手动设置参数以及获取结果集. ...

  8. 痞子衡嵌入式:第一本Git命令教程(2)- 连接(remote/clone)

    今天是Git系列课程第二课,上一课我们已经学会在本地创建一个空仓库,痞子衡今天要讲的是如何将本地仓库与远程建立联系. 1.将本地仓库挂上远程git remote 本地建好了仓库,我们希望能够挂到远程服 ...

  9. 痞子衡嵌入式:第一本Git命令教程(6)- 日志(log/reflog/gitk)

    今天是Git系列课程第六课,上一课我们学会了Git本地提交,今天痞子衡要讲的是如何查看Git本地历史提交. 当我们在仓库里做了很多次提交之后,免不了需要回看提交记录,看看自己之前的改动.有三种Git命 ...

  10. 用meterpreter实现跳板机

      meterpreter跳板机 背景:渗透测试者A拿到了B主机的控制权,但没有拿到ssh密码(不能打ssh隧道).现需横向移动渗透内网主机C,为了避免动作过大不便直接在B上对C进行渗透,其中C不能出 ...