TimesTen的守护进程

Posted dingdingfish

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TimesTen的守护进程相关的知识,希望对你有一定的参考价值。

TimesTen的守护进程分为主守护进程和子守护进程。

主守护进程

主守护进程即ttDaemonAdmin启动的进程,也称为Data Manager Daemon。
主守护进程的作用为:

  • Manages shared memory access
  • Coordinates process recovery
  • Keeps management statistics on what databases exist, which are in use, and which application processes are connected to which databases
  • Manages RAM policy
  • Starts replication processes, the TimesTen Server and the cache agent.

每一个TimesTen实例配有一个主守护进程,一个主守护进程下可有多个数据库。

子守护进程

每一个数据库/DataStore都配备相应的子守护进程(subdaemon), 子守护进程父进程即主守护进程。

在OS中可以查看到子守护进程,不过区别不明显,只能看到有两个实例tt1122和ttnew,其它的区别就是-id了:

$ ps -ef|grep timestensubd
oracle    2648  2644  0 Jun29 ?        00:02:35 /home/oracle/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
oracle    2649  2644  0 Jun29 ?        00:05:20 /home/oracle/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000001 -facility user
oracle    2650  2644  0 Jun29 ?        00:00:35 /home/oracle/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
oracle    8775  2644  0 10:33 ?        00:00:13 /home/oracle/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000011 -facility user
oracle    6633  6629  0 03:57 ?        00:00:25 /u01/TimesTen/ttnew/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
oracle    6634  6629  0 03:57 ?        00:00:25 /u01/TimesTen/ttnew/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000001 -facility user
oracle    6635  6629  0 03:57 ?        00:00:25 /u01/TimesTen/ttnew/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
oracle    6636  6629  0 03:57 ?        00:00:25 /u01/TimesTen/ttnew/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000003 -facility user

$ ps -p 2644
  PID TTY          TIME CMD
 2644 ?        00:01:56 timestend

$ ps -p 6629
  PID TTY          TIME CMD
 6629 ?        00:00:51 timestend

从输出还可看出,2644和6629是主守护进程。
每一个timestensubd负责一个数据库。

$ ttstatus
TimesTen status report as of Thu Jun 30 17:56:03 2016

Daemon pid 6629 port 55555 instance ttnew
TimesTen server pid 6638 started on port 55556
------------------------------------------------------------------------
Data store /u01/TimesTen/ttnew/info/DemoDataStore/repdb2_1122
There are no connections to the data store
Replication policy  : Manual
Cache Agent policy  : Manual
PL/SQL enabled.
------------------------------------------------------------------------
Accessible by group oracle
End of report
虽然没有任何数据库,表示之前看到的是idle subdaemon
$ ttstatus
TimesTen status report as of Thu Jun 30 17:48:42 2016

Daemon pid 2644 port 53392 instance tt1122
TimesTen server pid 2653 started on port 53393
------------------------------------------------------------------------
Data store /home/oracle/TimesTen/tt1122/info/DemoDataStore/cachedb2
There are 18 connections to the data store
Shared Memory KEY 0x0e0077ad ID 4718612
PL/SQL Memory KEY 0x0f0077ad ID 4751381 Address 0x7fa0000000
Type            PID     Context             Connection Name              ConnID
Process         10938   0x000000000203dad0  cachedb2                          1
Replication     10955   0x00000000038aa750  LOGFORCE:1092778304             127
Replication     10955   0x0000000003910870  XLA_PARENT:1089628480           129
Replication     10955   0x0000000003925460  REPLISTENER:1101670720          131
Replication     10955   0x00000000039d8750  TRANSMITTER(M):1108805952       126
Replication     10955   0x00007fe9c00008c0  REPHOLD:1098090816              128
Replication     10955   0x00007fe9c80008c0  FAILOVER:1081899328             130
Subdaemon       2648    0x0000000001be0360  Manager                         142
Subdaemon       2648    0x0000000001c57430  Rollback                        141
Subdaemon       2648    0x0000000001debbc0  Checkpoint                      137
Subdaemon       2648    0x0000000001e407f0  Monitor                         136
Subdaemon       2648    0x0000000001e95420  IndexGC                         135
Subdaemon       2648    0x000000000312f8f0  HistGC                          139
Subdaemon       2648    0x0000000003184520  Log Marker                      138
Subdaemon       2648    0x000000000325aa50  AsyncMV                         134
Subdaemon       2648    0x00000000032af680  Aging                           133
Subdaemon       2648    0x00000000033042b0  Deadlock Detector               132
Subdaemon       2648    0x00000000034097c0  Flusher                         140
Replication policy  : Manual
Replication agent is running.
Cache Agent policy  : Manual
PL/SQL enabled.
------------------------------------------------------------------------
Data store /home/oracle/TimesTen/tt1122/info/DemoDataStore/repdb1_1122
There are no connections to the data store
Replication policy  : Manual
Cache Agent policy  : Manual
PL/SQL enabled.
------------------------------------------------------------------------
Data store /home/oracle/TimesTen/tt1122/info/DemoDataStore/cachedb1
There are 18 connections to the data store
Shared Memory KEY 0x4400c901 ID 3997713
PL/SQL Memory KEY 0x4500c901 ID 4030482 Address 0x7fa0000000
Type            PID     Context             Connection Name              ConnID
Process         11076   0x0000000001c84ad0  cachedb1                          1
Replication     10918   0x000000000361f460  LOGFORCE:1101203776             127
Replication     10918   0x000000000368b270  REPHOLD:1108773184              130
Replication     10918   0x00000000036b2350  XLA_PARENT:1098053952           128
Replication     10918   0x00000000036c6f40  REPLISTENER:1093052736          129
Replication     10918   0x00000000038048e0  RECEIVER:1115072832             125
Replication     10918   0x00007fa0880008c0  FAILOVER:1083238720             131
Subdaemon       2649    0x0000000000e82360  Manager                         142
Subdaemon       2649    0x0000000000ef9430  Rollback                        141
Subdaemon       2649    0x0000000001008980  Monitor                         136
Subdaemon       2649    0x000000000108d5e0  IndexGC                         134
Subdaemon       2649    0x00000000010ff8f0  AsyncMV                         133
Subdaemon       2649    0x0000000001134cd0  Flusher                         132
Subdaemon       2649    0x0000000001272b40  Deadlock Detector               140
Subdaemon       2649    0x00000000012d6150  Log Marker                      138
Subdaemon       2649    0x0000000001346c10  Checkpoint                      137
Subdaemon       2649    0x000000000269bb80  HistGC                          135
Subdaemon       2649    0x00000000026b0770  Aging                           139
Replication policy  : Manual
Replication agent is running.
Cache Agent policy  : Manual
PL/SQL enabled.
------------------------------------------------------------------------
Accessible by group oracle
End of report
$ ttstatus|grep -i subdaemon
Subdaemon       2648    0x0000000001be0360  Manager                         142
Subdaemon       2648    0x0000000001c57430  Rollback                        141
Subdaemon       2648    0x0000000001debbc0  Checkpoint                      137
Subdaemon       2648    0x0000000001e407f0  Monitor                         136
Subdaemon       2648    0x0000000001e95420  IndexGC                         135
Subdaemon       2648    0x000000000312f8f0  HistGC                          139
Subdaemon       2648    0x0000000003184520  Log Marker                      138
Subdaemon       2648    0x000000000325aa50  AsyncMV                         134
Subdaemon       2648    0x00000000032af680  Aging                           133
Subdaemon       2648    0x00000000033042b0  Deadlock Detector               132
Subdaemon       2648    0x00000000034097c0  Flusher                         140

Subdaemon       2649    0x0000000000e82360  Manager                         142
Subdaemon       2649    0x0000000000ef9430  Rollback                        141
Subdaemon       2649    0x0000000001008980  Monitor                         136
Subdaemon       2649    0x000000000108d5e0  IndexGC                         134
Subdaemon       2649    0x00000000010ff8f0  AsyncMV                         133
Subdaemon       2649    0x0000000001134cd0  Flusher                         132
Subdaemon       2649    0x0000000001272b40  Deadlock Detector               140
Subdaemon       2649    0x00000000012d6150  Log Marker                      138
Subdaemon       2649    0x0000000001346c10  Checkpoint                      137
Subdaemon       2649    0x000000000269bb80  HistGC                          135
Subdaemon       2649    0x00000000026b0770  Aging                           139

主守护进程可以按需动态产生subdaemon。当有数据库需要加载到内存时,就会产生新的或使用已有的idle subdaemon来负责这个数据库。

TimesTen总是预留一个idle的subdaemon:
a) 主daemon启动时, 会附带启动4 subdaemon,并且最初的状态为idle
b) 若有数据库需要加载到内存,则会指派一个subdaemon负责一个数据库,但总会预留一个idle的subdaemon。

缺省启动的subdaemon数量可以在ttendaemon.options中通过-minsubs设置。

subdaemon的作用包括:
1. 将数据库从内存中卸载
2. 将Log buffer中的日志写盘
3. 日志的归档和清理
4. 检查和消除死锁
5. 在数据库非正常关闭时,从checkpoint和log文件中恢复
6. 回退交易
7. 实现缓存Aging

常用的subdaemon包括:
Worker: Periodically checks for deadlocks and canceling SQL operations on behalf of other applications in order to break any deadlocks.
Flusher: Flushes contents of Log buffer to disk
Checkpoint: Performs checkpoint operation.
Monitor: Implements lock wait timeout. For more information, please refer connection attribute “LockWait” in “Oracle TimesTen In-Memory Database API Reference Guide”.
HistGC: Purging rows in internal tables SYS.TABLE_HISTORY and SYS.COLUMN_HISTORY periodically when they are no longer needed by XLA readers.
Aging: Implementing the aging policies of various tables.

参考

  • TimesTen subdaemon: Frequently Asked Questions (Doc ID 759437.1)
  • TimesTen recovery from abnormally terminated connections (Doc ID 759443.1)

以上是关于TimesTen的守护进程的主要内容,如果未能解决你的问题,请参考以下文章

守护进程守护进程创建代码实现获取系统时间

20. Gradle编译其他应用代码流程(七) - 守护进程编译

DBUS 代码在放置在守护进程中时崩溃,但在没有守护进程代码的独立独立 main() 函数中运行良好

守护线程与守护进程

守护进程(了解)

关于守护进程和守护线程的区别