月归档:二月 2012

远程访问ASM

一、动态监听
1.监听文件

[oracle@node1 admin]$ more /u01/oracle/network/admin/listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/oracle)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = node1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

2.监听状态

[oracle@node1 admin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 18-JAN-2012 13:38:42

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                18-JAN-2012 13:32:49
Uptime                    0 days 0 hr. 5 min. 53 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/network/admin/listener.ora
Listener Log File         /u01/oracle/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=node1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "chf" has 1 instance(s).
  Instance "chf", status READY, has 1 handler(s) for this service...
Service "chfXDB" has 1 instance(s).
  Instance "chf", status READY, has 1 handler(s) for this service...
Service "chf_XPT" has 1 instance(s).
  Instance "chf", status READY, has 1 handler(s) for this service...
The command completed successfully

3.客户端tns文件[有部分测试加上了(UR=A)]

vm_asm =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = +ASM)
      (INSTANCE_NAME = +ASM)
      (UR=A)  #分存在和不存在测试
    )
  )

vm_chf =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = chf)
      (INSTANCE_NAME = chf)
    )
  )

4.无测试(UR=A)

C:\Users\XIFENFEI>tnsping vm_asm

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 23-2月 -
2012 22:15:10

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:
e:\oracle\11_2_0\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT =
1521)) (CONNECT_DATA = (SERVICE_NAME = +ASM) (INSTANCE_NAME = +ASM)))
OK (10 毫秒)

C:\Users\XIFENFEI>SQLPLUS sys/xifenfei@vm_asm as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 23 22:15:14 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务


请输入用户名:
ERROR:
ORA-12560: TNS: 协议适配器错误


请输入用户名:
ERROR:
ORA-12560: TNS: 协议适配器错误


SP2-0157: 在 3 次尝试之后无法连接到 ORACLE, 退出 SQL*Plus

--通过下面的数据库实例测试,证明动态监听是正常工作的,可以访问数据库
C:\Users\XIFENFEI>SQLPLUS sys/xifenfei@vm_chf as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 23 21:55:03 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
chf

5.含(UR=A)测试

C:\Users\XIFENFEI>tnsping vm_asm

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 23-2月 -
2012 22:16:49

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:
e:\oracle\11_2_0\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT =
1521)) (CONNECT_DATA = (SERVICE_NAME = +ASM) (INSTANCE_NAME = +ASM) (UR=A)))
OK (20 毫秒)

C:\Users\XIFENFEI>SQLPLUS sys/xifenfei@vm_asm as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 23 22:16:52 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
--------------------------------
+ASM

二、静态监听
1.监听文件

[oracle@node1 admin]$ more listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =  
     (GLOBAL_DBNAME = chf)
     (ORACLE_HOME = /u01/oracle)
     (SID_NAME = chf)
    )
    (SID_DESC =
     (GLOBAL_DBNAME = +ASM)
     (ORACLE_HOME = /u01/oracle)
     (SID_NAME = +ASM)
     )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT = 1521))
    )
  )

2.监听状态

[oracle@node1 admin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 18-JAN-2012 13:53:52

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.30)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                18-JAN-2012 13:51:48
Uptime                    0 days 0 hr. 2 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/network/admin/listener.ora
Listener Log File         /u01/oracle/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.30)(PORT=1521)))
Services Summary...
Service "+ASM" has 2 instance(s).
  Instance "+ASM", status UNKNOWN, has 1 handler(s) for this service...
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
  Instance "+ASM", status BLOCKED, has 1 handler(s) for this service...
Service "chf" has 2 instance(s).
  Instance "chf", status UNKNOWN, has 1 handler(s) for this service...
  Instance "chf", status READY, has 1 handler(s) for this service...
Service "chfXDB" has 1 instance(s).
  Instance "chf", status READY, has 1 handler(s) for this service...
Service "chf_XPT" has 1 instance(s).
  Instance "chf", status READY, has 1 handler(s) for this service...
The command completed successfully

3.无(UR=A)测试

C:\Users\XIFENFEI>tnsping vm_asm

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 23-2月 -
2012 22:11:34

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:
e:\oracle\11_2_0\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT =
1521)) (CONNECT_DATA = (SERVICE_NAME = +ASM) (INSTANCE_NAME = +ASM)))
OK (20 毫秒)

C:\Users\XIFENFEI>SQLPLUS sys/xifenfei@vm_asm as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 23 22:11:06 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
--------------------------------
+ASM

4.含(UR=A)测试

C:\Users\XIFENFEI>tnsping vm_asm

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 23-2月 -
2012 22:12:49

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:
e:\oracle\11_2_0\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT =
1521)) (CONNECT_DATA = (SERVICE_NAME = +ASM) (INSTANCE_NAME = +ASM) (UR=A)))
OK (10 毫秒)

C:\Users\XIFENFEI>SQLPLUS sys/xifenfei@vm_asm as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 23 22:12:53 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
--------------------------------
+ASM

5.easy connect访问asm实例

C:\Users\XIFENFEI>SQLPLUS sys/xifenfei@192.168.1.30/+asm as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 23 22:27:42 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
--------------------------------
+ASM

三、总结
1.在动态监听中,只有设置了(UR=A)才能够远程访问ASM实例;
2.在静态监听中,无论是否设置(UR=A)均可远程访问ASM实例,甚至可以使用easy connect方法方法ASM实例。

发表在 Oracle ASM | 一条评论

通过netstat+rmsock查找AIX端口对应进程

rmsock除去不包含文件描述符的套接字。它接受 socket、tcpcb、inpcb、ripcb 或 rawcb 地址并将其转换成套接字地址。然后检查每个进程所有打开的文件以查找套接字的匹配。如果没找到匹配,对该套接字执行异常终止操作,而不考虑套接字 linger 选项的存在。套接字保留的端口号释放。如果发现匹配,文件描述符和主进程状态显示给用户。
命令格式:rmsock Address TypeofAddress

[zwq:/]netstat -Aan|grep 6200|grep LISTEN
f1000e0000307bb0 tcp4       0      0  *.6200             *.*                LISTEN
--f1000e0000307bb0 为系统内核地址

[zwq:/]rmsock f1000e0000307bb0 tcpcb
The socket 0x307808 is being held by proccess 5701830 (ons).

[zwq:/]ps -ef|grep 5701830|grep -v grep
oracle10  5701830  5112098   0   Apr 21      -  7:17 /oracle10/app/product/crs/10.2.0/opmn/bin/ons -d 
发表在 AIX | 3 条评论

TimesTen命令—ttBackup

ttBackup使用说明

c:\>ttBackup  -h
Usage:
  ttBackup [-h | -help | -?]
  ttBackup [-V | -version]
  ttBackup -dir <directory> [-type <backupType>] [-fname <fileprefix>]
           [-force] {<DSN> | [-connstr] <connStr>}

options:
  -h | -help | -?      Prints this message and exits.
  -V | -version        Prints the release number and exits.
  -type  <backupType>  The type of backup to be performed.  Supported backup
                       types are given below.  Default is "fileFull".
  -dir   <directory>   The directory in which to store the backup files.
  -fname <fileprefix>  The file prefix for the backup files in the backup
                       directory.  Default is the base filename portion of the
                       DataStore parameter of the data store to be backed up.
  -force               Destroy existing backup files before performing backup
                       (full file-based backups only).
  <DSN>, <connStr>     The DSN or ODBC connection string of the data store to
                       be backed up.

Backup types are:
  fileFull         Full backup to the specified backup directory.  The
                   resulting backup is not enabled for incremental backup.
                   This is the default backup type.
  fileFullEnable   Full backup to the specified backup directory.  The
                   resulting backup is enabled for incremental backup.
  fileIncremental  Incremental backup.  Augments pre-existing backup given
                   by '-dir' and optionally '-fname'.
  fileIncrOrFull   If incremental backup is possible, then behaves like
                   "fileIncremental"; else behaves like "fileFullEnable".

NOTE: For above types, '-dir' is required; '-fname' and '-force' are optional.

  streamFull       Full backup to the standard output.  '-dir', '-fname' and
                   '-force' are ignored.
  incrementalStop  Does not perform a backup. Disables an incremental-enabled
                   backup.  '-dir' is required; '-fname' is optional; '-force'
                   is ignored.

ttBackupStatus函数说

全备和增量备份

--全备并启动增量备份功能
c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileFullEnable    -fname xifenfei01_ -force my_ttdb
Backup started ...
Backup complete

Command> call ttBackupStatus ();
< 2, 0, 1, 2012-02-22 23:13:18.125000, 2012-02-22 23:13:18.505000, 0, 11821056,0, 5896 >
1 row found.

--增量备份
c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileIncremental  -fname xifenfei01_  -force my_ttdb
Backup started ...
Backup complete

Command> call ttBackupStatus ();
< 2, 0, 0, 2012-02-22 23:19:24.453000, 2012-02-22 23:19:24.702000, 0, 11825152,0, 3960 >
1 row found.

--执行结果
E:\oracle\timesten\tt_back\full>dir
 驱动器 E 中的卷没有标签。
 卷的序列号是 38D0-2A35

 E:\oracle\timesten\tt_back\full 的目录

2012/02/22  23:19    <DIR>          .
2012/02/22  23:19    <DIR>          ..
2012/02/22  23:13        21,119,936 xifenfei01_.0.bac
2012/02/22  23:19        11,943,936 xifenfei01_.0.bac0
2012/02/22  23:19               696 xifenfei01_.sta
               3 个文件     33,064,568 字节
               2 个目录  9,432,420,352 可用字节


--补充说明
1.需要使用fileFullEnable启动增量备份
2.增量备份需要指定dir和fname和全备时一致

fileIncrOrFull测试

c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileIncrOrFull    -force  -fname xifenfei01_  my_ttdb
Backup started ...
Backup complete

Command> call ttBackupStatus ();
< 2, 0, 0, 2012-02-22 23:47:57.997000, 2012-02-22 23:47:58.174000, 0, 11880448,0, 5740 >
1 row found.

c:\>ttbackup -dir E:\oracle\timesten\tt_back\full  -type fileIncrOrFull    -force  -fname xifenfei00_  my_ttdb
Backup started ...
Backup complete

Command> call ttBackupStatus ();
< 2, 0, 1, 2012-02-22 23:53:37.364000, 2012-02-22 23:53:37.753000, 0, 11886592,0, 5076 >
1 row found.

--补充说明
在有启用增量备份(启用增量的全备或者增量备份本身)的基础上,会自动进行增量备份;
在无启用增量备份(没有备份或者备份没有启用增量备份)的基础上,如果无则会进行全备

streamFull测试

c:\>ttBackup -type streamFull my_ttdb>E:\oracle\timesten\tt_back\full\xifenfei.tream
Backup started ...
Backup complete

Command> call ttBackupStatus ();
< 2, 1, 1, 2012-02-22 23:38:52.480000, 2012-02-22 23:38:52.606000, 0, 11874304,0, 4384 >
1 row found.

c:\>dir E:\oracle\timesten\tt_back\full\xifenfei.*
 驱动器 E 中的卷没有标签。
 卷的序列号是 38D0-2A35

 E:\oracle\timesten\tt_back\full 的目录

2012/02/22  23:38        33,064,596 xifenfei.tream
               1 个文件     33,064,596 字节
               0 个目录  9,399,287,808 可用字节

--补充说明
在linux/unix环境中,执行流备份可以结合dd命令
如:ttBackup -type streamFull FastIns | dd bs=64k of=/dev/rmt0
发表在 TimesTen | 评论关闭