Bo's Oracle Station

查看: 1853|回复: 0

课程第7次(2016-11-14星期一)

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2016-11-15 10:18:43 | 显示全部楼层 |阅读模式
oraenv的用法:
  1. [root@station90 桌面]# vim /etc/oratab
  2. [root@station90 桌面]# su - oracle
  3. [oracle@station90 ~]$ . oraenv
  4. ORACLE_SID = [orcl] ? rcat
  5. The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
复制代码
监听器和pmon的关系:
  1. [oracle@station90 ~]$ ps aux | grep pmon
  2. oracle    1384  0.0  0.0 103304  2144 pts/3    S+   19:59   0:00 grep pmon
  3. oracle   10691  0.0  0.2 478736 44016 ?        Ss   19:20   0:00 asm_pmon_+ASM
  4. oracle   10858  0.0  0.3 6834040 48984 ?       Ss   19:20   0:00 ora_pmon_orcl
  5. oracle   23180  0.0  0.3 1789856 49948 ?       Ss   19:43   0:00 ora_pmon_rcat
  6. [oracle@station90 ~]$ lsnrctl services

  7. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-NOV-2016 20:01:28

  8. Copyright (c) 1991, 2009, Oracle.  All rights reserved.

  9. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=station90.example.com)(PORT=1521)))
  10. Services Summary...
  11. Service "+ASM" has 1 instance(s).
  12.   Instance "+ASM", status READY, has 1 handler(s) for this service...
  13.     Handler(s):
  14.       "DEDICATED" established:58 refused:0 state:ready
  15.          LOCAL SERVER
  16. Service "orcl.example.com" has 1 instance(s).
  17.   Instance "orcl", status READY, has 1 handler(s) for this service...
  18.     Handler(s):
  19.       "DEDICATED" established:53 refused:0 state:ready
  20.          LOCAL SERVER
  21. Service "orclXDB.example.com" has 1 instance(s).
  22.   Instance "orcl", status READY, has 1 handler(s) for this service...
  23.     Handler(s):
  24.       "D000" established:0 refused:0 current:0 max:1022 state:ready
  25.          DISPATCHER <machine: station90.example.com, pid: 10896>
  26.          (ADDRESS=(PROTOCOL=tcp)(HOST=station90.example.com)(PORT=26631))
  27. Service "rcat.example.com" has 1 instance(s).
  28.   Instance "rcat", status READY, has 1 handler(s) for this service...
  29.     Handler(s):
  30.       "DEDICATED" established:0 refused:0 state:ready
  31.          LOCAL SERVER
  32. Service "rcatXDB.example.com" has 1 instance(s).
  33.   Instance "rcat", status READY, has 1 handler(s) for this service...
  34.     Handler(s):
  35.       "D000" established:0 refused:0 current:0 max:1022 state:ready
  36.          DISPATCHER <machine: station90.example.com, pid: 23212>
  37.          (ADDRESS=(PROTOCOL=tcp)(HOST=station90.example.com)(PORT=2751))
  38. The command completed successfully
复制代码
监听器的管理命令:
  1. [root@station90 桌面]# su - oracle
  2. [oracle@station90 ~]$ cd $TNS_ADMIN
  3. [oracle@station90 admin]$ pwd
  4. /u01/app/oracle/product/11.2.0/grid/network/admin
  5. [oracle@station90 admin]$ ls
  6. listener.ora  listener.ora.bak.station90  samples  shrept.lst
  7. [oracle@station90 admin]$ lsnrctl stop

  8. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-NOV-2016 20:17:35

  9. Copyright (c) 1991, 2009, Oracle.  All rights reserved.

  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=station90.example.com)(PORT=1521)))
  11. The command completed successfully
  12. [oracle@station90 admin]$ crs_stat -t
  13. Name           Type           Target    State     Host        
  14. ------------------------------------------------------------
  15. ora.DATA.dg    ora....up.type ONLINE    ONLINE    station90   
  16. ora.FRA.dg     ora....up.type ONLINE    ONLINE    station90   
  17. ora....ER.lsnr ora....er.type OFFLINE   OFFLINE               
  18. ora.asm        ora.asm.type   ONLINE    ONLINE    station90   
  19. ora.cssd       ora.cssd.type  ONLINE    ONLINE    station90   
  20. ora.diskmon    ora....on.type ONLINE    ONLINE    station90   
  21. ora.orcl.db    ora....se.type ONLINE    ONLINE    station90   
  22. [oracle@station90 admin]$ crs_stat -p | grep lsnr
  23. NAME=ora.LISTENER.lsnr
  24. [oracle@station90 admin]$ crsctl start  res ora.LISTENER.lsnr
  25. CRS-2672: Attempting to start 'ora.LISTENER.lsnr' on 'station90'
  26. CRS-2676: Start of 'ora.LISTENER.lsnr' on 'station90' succeeded
  27. [oracle@station90 admin]$ lsnrctl services

  28. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-NOV-2016 20:19:40

  29. Copyright (c) 1991, 2009, Oracle.  All rights reserved.

  30. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=station90.example.com)(PORT=1521)))
  31. Services Summary...
  32. Service "+ASM" has 1 instance(s).
  33.   Instance "+ASM", status READY, has 1 handler(s) for this service...
  34.     Handler(s):
  35.       "DEDICATED" established:0 refused:0 state:ready
  36.          LOCAL SERVER
  37. Service "orcl.example.com" has 1 instance(s).
  38.   Instance "orcl", status READY, has 1 handler(s) for this service...
  39.     Handler(s):
  40.       "DEDICATED" established:0 refused:0 state:ready
  41.          LOCAL SERVER
  42. Service "orclXDB.example.com" has 1 instance(s).
  43.   Instance "orcl", status READY, has 1 handler(s) for this service...
  44.     Handler(s):
  45.       "D000" established:0 refused:0 current:0 max:1022 state:ready
  46.          DISPATCHER <machine: station90.example.com, pid: 10896>
  47.          (ADDRESS=(PROTOCOL=tcp)(HOST=station90.example.com)(PORT=26631))
  48. Service "rcat.example.com" has 1 instance(s).
  49.   Instance "rcat", status READY, has 1 handler(s) for this service...
  50.     Handler(s):
  51.       "DEDICATED" established:0 refused:0 state:ready
  52.          LOCAL SERVER
  53. Service "rcatXDB.example.com" has 1 instance(s).
  54.   Instance "rcat", status READY, has 1 handler(s) for this service...
  55.     Handler(s):
  56.       "D000" established:0 refused:0 current:0 max:1022 state:ready
  57.          DISPATCHER <machine: station90.example.com, pid: 23212>
  58.          (ADDRESS=(PROTOCOL=tcp)(HOST=station90.example.com)(PORT=2751))
  59. The command completed successfully
  60. [oracle@station90 admin]$ srvctl stop listener
  61. [oracle@station90 admin]$ crs_stat -t
  62. Name           Type           Target    State     Host        
  63. ------------------------------------------------------------
  64. ora.DATA.dg    ora....up.type ONLINE    ONLINE    station90   
  65. ora.FRA.dg     ora....up.type ONLINE    ONLINE    station90   
  66. ora....ER.lsnr ora....er.type OFFLINE   OFFLINE               
  67. ora.asm        ora.asm.type   ONLINE    ONLINE    station90   
  68. ora.cssd       ora.cssd.type  ONLINE    ONLINE    station90   
  69. ora.diskmon    ora....on.type ONLINE    ONLINE    station90   
  70. ora.orcl.db    ora....se.type ONLINE    ONLINE    station90   
  71. [oracle@station90 admin]$ srvctl start listener
  72. [oracle@station90 admin]$ crs_stat -t
  73. Name           Type           Target    State     Host        
  74. ------------------------------------------------------------
  75. ora.DATA.dg    ora....up.type ONLINE    ONLINE    station90   
  76. ora.FRA.dg     ora....up.type ONLINE    ONLINE    station90   
  77. ora....ER.lsnr ora....er.type ONLINE    ONLINE    station90   
  78. ora.asm        ora.asm.type   ONLINE    ONLINE    station90   
  79. ora.cssd       ora.cssd.type  ONLINE    ONLINE    station90   
  80. ora.diskmon    ora....on.type ONLINE    ONLINE    station90   
  81. ora.orcl.db    ora....se.type ONLINE    ONLINE    station90   
  82. [oracle@station90 admin]$ ls
  83. listener.ora  listener.ora.bak.station90  samples  shrept.lst
  84. [oracle@station90 admin]$ vim listener.ora
  85. [oracle@station90 admin]$ ls
  86. listener.ora  listener.ora.bak.station90  samples  shrept.lst
  87. [oracle@station90 admin]$ srvctl status listener
  88. 监听程序 LISTENER 已启用
  89. 监听程序 LISTENER 正在节点上运行: station90
  90. [oracle@station90 admin]$ srvctl stop listener
  91. [oracle@station90 admin]$ ls
  92. listener.ora  listener.ora.bak.station90  samples  shrept.lst
复制代码
交互式使用lsnrctl命令:
  1. LSNRCTL> help
  2. The following operations are available
  3. An asterisk (*) denotes a modifier or extended command:

  4. start               stop                status              
  5. services            version             reload              
  6. save_config         trace               spawn               
  7. change_password     quit                exit               
  8. set*                show*               

  9. LSNRCTL> set -h
  10. NL-00853: undefined set command "-h".  Try "help set"
  11. LSNRCTL> help set
  12. The following operations are available after set
  13. An asterisk (*) denotes a modifier or extended command:

  14. password                           rawmode                           
  15. displaymode                        trc_file                           
  16. trc_directory                      trc_level                          
  17. log_file                           log_directory                     
  18. log_status                         current_listener                  
  19. inbound_connect_timeout            startup_waittime                  
  20. save_config_on_stop                dynamic_registration               
  21. enable_global_dynamic_endpoint     

  22. LSNRCTL> set current_listener l2
  23. Current Listener is l2
  24. LSNRCTL> status
  25. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.90)(PORT=1522)))
  26. STATUS of the LISTENER
  27. ------------------------
  28. Alias                     L2
  29. Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  30. Start Date                14-NOV-2016 21:16:17
  31. Uptime                    0 days 0 hr. 12 min. 57 sec
  32. Trace Level               off
  33. Security                  ON: Local OS Authentication
  34. SNMP                      OFF
  35. Listener Parameter File   /u01/app/oracle/product/11.2.0/grid/network/admin/listener.ora
  36. Listener Log File         /u01/app/oracle/diag/tnslsnr/station90/l2/alert/log.xml
  37. Listening Endpoints Summary...
  38.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.90)(PORT=1522)))
  39. Services Summary...
  40. Service "+ASM" has 1 instance(s).
  41.   Instance "+ASM", status READY, has 1 handler(s) for this service...
  42. Service "orcl.example.com" has 2 instance(s).
  43.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  44.   Instance "orcl", status READY, has 1 handler(s) for this service...
  45. Service "orclXDB.example.com" has 1 instance(s).
  46.   Instance "orcl", status READY, has 1 handler(s) for this service...
  47. Service "rcat.example.com" has 2 instance(s).
  48.   Instance "rcat", status UNKNOWN, has 1 handler(s) for this service...
  49.   Instance "rcat", status READY, has 1 handler(s) for this service...
  50. Service "rcatXDB.example.com" has 1 instance(s).
  51.   Instance "rcat", status READY, has 1 handler(s) for this service...
  52. The command completed successfully
  53. LSNRCTL> exit
复制代码
在演示环境中的网络配置文件:
listener.ora:
  1. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/grid/network/admin/listener.ora
  2. # Generated by Oracle configuration tools.

  3. L2 =
  4.   (DESCRIPTION =
  5.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522))
  6.   )

  7. SID_LIST_LISTENER =
  8.   (SID_LIST =
  9.     (SID_DESC =
  10.       (GLOBAL_DBNAME = orcl.example.com)
  11.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  12.       (SID_NAME = orcl)
  13.     )
  14.     (SID_DESC =
  15.       (GLOBAL_DBNAME = rcat.example.com)
  16.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  17.       (SID_NAME = rcat)
  18.     )
  19.   )

  20. ADR_BASE_L2 = /u01/app/oracle

  21. ENABLE_GLOBAL_DYNAMIC_ENDPOINT_L2 = ON

  22. LISTENER =
  23.   (DESCRIPTION_LIST =
  24.     (DESCRIPTION =
  25.       (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
  26.     )
  27.     (DESCRIPTION =
  28.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))
  29.     )
  30.   )

  31. ADR_BASE_LISTENER = /u01/app/oracle

  32. ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

  33. SID_LIST_L2 =
  34.   (SID_LIST =
  35.     (SID_DESC =
  36.       (GLOBAL_DBNAME = orcl.example.com)
  37.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  38.       (SID_NAME = orcl)
  39.     )
  40.     (SID_DESC =
  41.       (GLOBAL_DBNAME = rcat.example.com)
  42.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  43.       (SID_NAME = rcat)
  44.     )
  45.   )
复制代码
服务器上的tnsnames.ora:
  1. # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/grid/network/admin/tnsnames.ora
  2. # Generated by Oracle configuration tools.

  3. RCAT =
  4.   (DESCRIPTION =
  5.     (ADDRESS_LIST =
  6.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))
  7.     )
  8.     (CONNECT_DATA =
  9.       (SERVICE_NAME = rcat.example.com)
  10.     )
  11.   )

  12. ORCL =
  13.   (DESCRIPTION =
  14.     (ADDRESS_LIST =
  15.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))
  16.     )
  17.     (CONNECT_DATA =
  18.       (SERVICE_NAME = orcl.example.com)
  19.     )
  20.   )


  21. fordb =
  22.    (DESCRIPTION =
  23.     (ADDRESS_LIST =
  24.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))
  25.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522))
  26.     )
  27.   )
复制代码
windows上的tnsnames.ora:
  1. # tnsnames.ora Network Configuration File: C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
  2. # Generated by Oracle configuration tools.

  3. ORACLR_CONNECTION_DATA =
  4.   (DESCRIPTION =
  5.     (ADDRESS_LIST =
  6.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  7.     )
  8.     (CONNECT_DATA =
  9.       (SID = CLRExtProc)
  10.       (PRESENTATION = RO)
  11.     )
  12.   )

  13. DOG =
  14.   (DESCRIPTION =
  15.     (ADDRESS_LIST =
  16.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))
  17.     )
  18.     (CONNECT_DATA =
  19.       (SERVICE_NAME = rcat.example.com)
  20.     )
  21.   )

  22. CAT =
  23.   (DESCRIPTION =
  24.     (ADDRESS_LIST =
  25.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522))
  26.     )
  27.     (CONNECT_DATA =
  28.       (SERVICE_NAME = orcl.example.com)
  29.     )
  30.   )

  31. WOLF =
  32.   (DESCRIPTION =
  33.     (ADDRESS_LIST =
  34.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))
  35.     )
  36.     (CONNECT_DATA =
  37.       (SERVICE_NAME = orcl.example.com)
  38.     )
  39.   )

  40. TIGER =
  41.   (DESCRIPTION =
  42.     (ADDRESS_LIST =
  43.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522))
  44.     )
  45.     (CONNECT_DATA =
  46.       (SERVICE_NAME = rcat.example.com)
  47.     )
  48.   )


  49. UTFORCL =
  50.   (DESCRIPTION =
  51.     (ADDRESS_LIST =
  52.       (ADDRESS = (PROTOCOL = TCP)(HOST = station199)(PORT = 1521))
  53.     )
  54.     (CONNECT_DATA =
  55.       (SERVER = DEDICATED)
  56.       (SERVICE_NAME = utforcl.example.com)
  57.     )
  58.   )

  59. ORCL =
  60.   (DESCRIPTION =
  61.     (ADDRESS_LIST =
  62.       (ADDRESS = (PROTOCOL = TCP)(HOST = station199)(PORT = 1521))
  63.     )
  64.     (CONNECT_DATA =
  65.       (SERVER = DEDICATED)
  66.       (SERVICE_NAME = orcl.example.com)
  67.     )
  68.   )

复制代码
注册监听器到集群件:
  1. [oracle@station90 admin]$ srvctl add listener -l l2 -p TCP:1522
复制代码
注册数据库服务器到集群件:
  1. [oracle@station90 admin]$ srvctl add database -d rcat -o /u01/app/oracle/product/11.2.0/dbhome_1
复制代码
在演示环境中的实例参数设置:
rcat.example.com:
  1. SQL> alter system set local_listener=fordb;

  2. System altered.
复制代码
注册监听器到集群件:
  1. [oracle@station90 admin]$ srvctl add listener -l l2 -p TCP:1522
复制代码
注册数据库服务器到集群件:
  1. [oracle@station90 admin]$ srvctl add database -d rcat -o /u01/app/oracle/product/11.2.0/dbhome_1
复制代码
在演示环境中的实例参数设置:
rcat.example.com:
  1. SQL> alter system set local_listener=fordb;

  2. System altered.
复制代码
orcl.example.com:
  1. SQL> alter system set local_listener=fordb;

  2. System altered.
复制代码










回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-4-26 07:08 , Processed in 0.039707 second(s), 24 queries .

快速回复 返回顶部 返回列表