ORACLE/TUNING2008. 2. 1. 19:28
반응형

1. 대량의 데이터 로드 작업 수행후에는 DBA가 작업 후 바로 통계작업을 실시해야 최신의 통계정보를 유지할 수 있다.

(바로 통계작업을 해도 바로 적용되지 않으니 안심해도 된다. http://blog.naver.com/ukja/120045329315 참조하삼)

 

2. 당연하겠지만.. external table은 통계정보 대상이 아니다.

 

3. 시스템 통계는 DBA가 직접 수행해야 한다.

   exec dbms_stats.gather_system_stats;

 

4. fixed object에 대한 통계수집도 자동화되지 않는다.

   (v$view와 같은 dynamic performance view는 자동화 대상이 아니다.)

 

5. 대량의 데이터를  insert하고 delete하는 등등 항상 full table scan이 필요한 테이블 등에 대해서는..

   자동으로 table통계를 수집하는것이 오히려 악영향을 끼친다. 때문에 이러한 테이블들은..

   exec dbms_stats.lock_table_stats('SCOTT','EMP'); 이런 프로시져로... locking을 하여..

   자동 통계수집 대상 테이블에서 제외 할 수 있다.

 

6. 10g부터 데이터 변동을 추정하는 table 모니터링은 자동화 되었다.

    alter table과 같은 명령어로 table 모니터링을 제어 할 수 있지만.. 이것은 명령만 유효할뿐..

    실제 내부적으로는 아무런 영향을 주지 않는다.

    Note:295249.1 <--- 참조하세요^^

 

7. 10g의 자동화된 통계수집 기능을 완전히 끄고 싶으면...

    gather_stats_job을 disable 시키고..

    statistics_level 파라메터 값을 basic으로 바꾸면 완벽하게 자동통계 기능을 끄는것이다.

 

8. 통계정보를 수집할때 dbms_stats로 수집을 하면 오라클은 그 정보들의 미래의 사용 가능성을 염두해두고

   old_version으로 관리를 한다. 이런것들은 나중에 필요하면 dbms_stats.restore_*_stats로 과거 통계를 복원 할 수 있다.

   그러나 analyze command로 통계를 수집하면 old version으로 보존되지 않는다.

   통계정보 유지기간 확인및 설정은 다음과 같이 한다.

 

   유지기간 확인

   select dbms_stats.get_stats_history_retention from dual;

   유지기간 변경

   exec dbms_stats.alter_stats_history_retention(61);

Note:236935.1 <--- analyze와 dbms_stats의 차이점 참조하세요^^

9. 자동화된 통계정보는 AWR에 저장되며 AWR은 SYSAUX에 위치한다.

 

10. undo와 관련하여 AWR에 저장된 통계정보를 통해 오라클 스스로 얼마나 많은 수의 undo segment를 온라인 할것인지

     바로 결정할 수 있기때문에 Fast Ramp-Up이 가능하다.

 

11. 오라클 10g가 취합한 통계들은 SGA에 저장되어 v$view로 접근할 수 있으며 이 통계들은 주기적으로

     10g의 새로운 background processes인 MMON에 의해 스냅샷 형태로 AWR에 저장된다.

     기본 주기는 60분마다 스냅샷이 생성된다.

 

12. AWR 리포트가 보고 싶으면 $ORACLE_HOME/rdbms/admin/awrrpt.sql 을 돌리면 된다.

 

13. ASH (Active Session History)는 AWR과 ADDM의 한계를 극복하기 위해 나왔다.

     기본적으로 database를 분석하는 시간이 1시간 이기때문에 문제가 생겼을때 최신의 정보분석이 어렵다.

     이런 문제점을 극복하기 위해 만들어진 ASH는 매 초마다 "active session"에 한해 샘플링을 실시하여 저장한다.

     이 정보들은 historical하게 볼 수 있으므로 이미 발생하거나 지금 발생하고 있는 문제들에 대해

     실시간으로 historical하게 접근 할 수 있다.

     메모리상에 위치하는 rolling buffer로 만들어지고 SGA에 존재하며

     shared pool의 5%를 넘지 않도록 구성되며 평균적으로 CPU 1개당 2MB의 크기를 점유한다.

     ASH는 주기적으로 MMON에 의해 60분마다 디스크로 쓰이게 되며 정보가 워낙 많아서 그 많은 정보를 디스크에 모두

     저장할 수 없기 때문에 MMNL에 의해 필터링되서 저장된다.

     ASH는 v$active_session_history를 통해 접급 할 수 있다.   

    

반응형
Posted by [PineTree]
ORACLE/Backup & Recovery2008. 1. 28. 23:17
반응형

#####################################################################
### Character Set 조회
#####################################################################

SQL> select * from nls_database_parameters;

PARAMETER                      VALUE
------------------------------ -------------------------------------------------------
NLS_LANGUAGE                   AMERICAN
NLS_TERRITORY                  AMERICA
NLS_CURRENCY                   $
NLS_ISO_CURRENCY               AMERICA
NLS_NUMERIC_CHARACTERS         .,
NLS_CHARACTERSET               KO16KSC5601
NLS_CALENDAR                   GREGORIAN
NLS_DATE_FORMAT                DD-MON-RR
NLS_DATE_LANGUAGE              AMERICAN
NLS_SORT                       BINARY
NLS_TIME_FORMAT                HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZH:TZM
NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZH:TZM
NLS_DUAL_CURRENCY              $
NLS_COMP                       BINARY
NLS_NCHAR_CHARACTERSET         KO16KSC5601
NLS_RDBMS_VERSION              8.1.6.3.0


#####################################################################
### Control File 조회
#####################################################################

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/oracle/app/oracle/oradata/WWW/control01.ctl
/oracle/app/oracle/oradata/WWW/control02.ctl
/oracle/app/oracle/oradata/WWW/control03.ctl


#####################################################################
### user별 object 조회
#####################################################################

SQL> select owner, object_type, count(*) from dba_objects
     where object_type in ('TABLE', 'INDEX', 'VIEW', 'PROCEDURE', 'FUNCTION')
     group by owner, object_type
     order by 1, 2;

OWNER                          OBJECT_TYPE          COUNT(*)
------------------------------ ------------------ ----------
ADMIT                          INDEX                      72
ADMIT                          TABLE                      73
BIZMAX                         INDEX                       2
BIZMAX                         TABLE                       2
CDL                            INDEX                      90
CDL                            TABLE                      73
CDL                            VIEW                       10
CTXSYS                         INDEX                      38
CTXSYS                         PROCEDURE                   1
CTXSYS                         TABLE                      29
CTXSYS                         VIEW                       35
EDUGRAD                        INDEX                       7
EDUGRAD                        TABLE                       7
FRIEND                         TABLE                       1
IAS                            INDEX                       9
IAS                            TABLE                       9
IPSI                           INDEX                      69
IPSI                           TABLE                      56
KOREA                          INDEX                      15
KOREA                          TABLE                      55
KRBIZ                          INDEX                     348
KRBIZ                          TABLE                     229
KRBIZ                          VIEW                        1
KUPR                           INDEX                       7
KUPR                           TABLE                       6
NOTICE                         INDEX                      23
NOTICE                         TABLE                      31
ORANGE                         FUNCTION                    9
ORANGE                         INDEX                       4
ORANGE                         TABLE                       6
ORANGE                         VIEW                       39
ORS                            FUNCTION                    7
ORS                            INDEX                      57
ORS                            PROCEDURE                   2
ORS                            TABLE                      49
ORS                            VIEW                        1
OUTLN                          INDEX                       3
OUTLN                          TABLE                       2
PERSON                         INDEX                       6
PERSON                         TABLE                       6
RNDCARD                        TABLE                       1
RNDCARD                        VIEW                        1
SCOTT                          INDEX                       2
SCOTT                          TABLE                       4
SYS                            FUNCTION                   23
SYS                            INDEX                     218
SYS                            PROCEDURE                  10
SYS                            TABLE                     197
SYS                            VIEW                     1420
SYSTEM                         INDEX                      23
SYSTEM                         TABLE                      23
SYSTEM                         VIEW                        3
WIZARD                         INDEX                      47
WIZARD                         TABLE                      53

54 rows selected.


#####################################################################
### Datafile Size 조회
#####################################################################

SQL> select sum(bytes)/1024/1024 from dba_data_files;

SUM(BYTES)/1024/1024
--------------------
               20146


SQL> select sum(bytes)/1024/1024 from dba_segments;

SUM(BYTES)/1024/1024
--------------------
          6561.64453


#####################################################################
### user별 tablespace 조회
#####################################################################

SQL> select username, default_tablespace, temporary_tablespace from dba_users
     where username not in ('SYS', 'SYSTEM');

 

USERNAME                       DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
TRACESVR                       SYSTEM                         SYSTEM
OUTLN                          SYSTEM                         SYSTEM
ORS                            TS_ORS01                       TS_ORSTEMP01
AURORA$ORB$UNAUTHENTICATED     SYSTEM                         SYSTEM
NOTICE                         TS_NOT01                       TS_NOTTEMP01
FRIEND                         TS_FRI01                       TS_FRITEMP01
ORANGE                         TOOLS                          TEMP
IPSI                           TS_EEX01                       TS_EEXTEMP01
KOREA                          TS_FRI01                       TS_FRITEMP01
RNDCARD                        TS_FRI01                       TS_FRITEMP01
SMBSUPP                        TS_FRI01                       TS_FRITEMP01
ADMIT                          TS_EEX02                       TS_EEXTEMP02
KRBIZ                          TS_KRB01                       TS_NOTTEMP01
CTXSYS                         TS_CTX01                       TS_NOTTEMP01
JONES                          SYSTEM                         SYSTEM
BIZMAX                         TOOLS                          TEMP
DBSNMP                         SYSTEM                         SYSTEM
PERSON                         TS_PER01                       TS_NOTTEMP01
SCOTT                          SYSTEM                         SYSTEM
ADAMS                          SYSTEM                         SYSTEM
CLARK                          SYSTEM                         SYSTEM
BLAKE                          SYSTEM                         SYSTEM
CDL                            TS_CDL01                       TS_CDLTEMP01
EDUGRAD                        TS_EDU01                       TS_EDUTEMP01
KUPR                           TS_KUPR01                      TS_NOTTEMP01
WIZARD                         TS_WIZ01                       TS_NOTTEMP01
IAS                            TS_IAS01                       TS_NOTTEMP01
IACF                           TS_KRB01                       TS_NOTTEMP01

28 rows selected.


#####################################################################
### user 및 user priviedge 조회, 생성
#####################################################################

select 'CREATE USER ' || username || ' IDENTIFIED BY ' || username ||
' DEFAULT TABLESPACE ' || default_tablespace ||
' TEMPORARY TABLESPACE ' || temporary_tablespace ||';'
from dba_users
where username not in ('SYS','SYSTEM');

'CREATEUSER'||USERNAME||'IDENTIFIEDBY'||USERNAME||'DEFAULTTABLESPACE'||DEFAULT_TABLESPACE||'TEMPORARYTABLESPACE'||TEMPORARY_TABLESPACE||';'
-------------------------------------------------------------------------------------------------------------------------------------------
 create user TRACESVR identified by TRACESVR default tablespace SYSTEM temporary tablespace SYSTEM;
 create user OUTLN identified by OUTLN default tablespace SYSTEM temporary tablespace SYSTEM;
 create user ORS identified by ORS default tablespace TS_ORS01 temporary tablespace TS_ORSTEMP01;
 create user AURORA$ORB$UNAUTHENTICATED identified by AURORA$ORB$UNAUTHENTICATED default tablespace SYSTEM temporary tablespace SYSTEM;
 create user NOTICE identified by NOTICE default tablespace TS_NOT01 temporary tablespace TS_NOTTEMP01;
 create user FRIEND identified by FRIEND default tablespace TS_FRI01 temporary tablespace TS_FRITEMP01;
 create user ORANGE identified by ORANGE default tablespace TOOLS temporary tablespace TEMP;
 create user IPSI identified by IPSI default tablespace TS_EEX01 temporary tablespace TS_EEXTEMP01;
 create user KOREA identified by KOREA default tablespace TS_FRI01 temporary tablespace TS_FRITEMP01;
 create user RNDCARD identified by RNDCARD default tablespace TS_FRI01 temporary tablespace TS_FRITEMP01;
 create user SMBSUPP identified by SMBSUPP default tablespace TS_FRI01 temporary tablespace TS_FRITEMP01;
 create user ADMIT identified by ADMIT default tablespace TS_EEX02 temporary tablespace TS_EEXTEMP02;
 create user KRBIZ identified by KRBIZ default tablespace TS_KRB01 temporary tablespace TS_NOTTEMP01;
 create user CTXSYS identified by CTXSYS default tablespace TS_CTX01 temporary tablespace TS_NOTTEMP01;
 create user JONES identified by JONES default tablespace SYSTEM temporary tablespace SYSTEM;
 create user BIZMAX identified by BIZMAX default tablespace TOOLS temporary tablespace TEMP;
 create user DBSNMP identified by DBSNMP default tablespace SYSTEM temporary tablespace SYSTEM;
 create user PERSON identified by PERSON default tablespace TS_PER01 temporary tablespace TS_NOTTEMP01;
 create user SCOTT identified by SCOTT default tablespace SYSTEM temporary tablespace SYSTEM;
 create user ADAMS identified by ADAMS default tablespace SYSTEM temporary tablespace SYSTEM;
 create user CLARK identified by CLARK default tablespace SYSTEM temporary tablespace SYSTEM;
 create user BLAKE identified by BLAKE default tablespace SYSTEM temporary tablespace SYSTEM;
 create user CDL identified by CDL default tablespace TS_CDL01 temporary tablespace TS_CDLTEMP01;
 create user EDUGRAD identified by EDUGRAD default tablespace TS_EDU01 temporary tablespace TS_EDUTEMP01;
 create user KUPR identified by KUPR default tablespace TS_KUPR01 temporary tablespace TS_NOTTEMP01;
 create user WIZARD identified by WIZARD default tablespace TS_WIZ01 temporary tablespace TS_NOTTEMP01;
 create user IAS identified by IAS default tablespace TS_IAS01 temporary tablespace TS_NOTTEMP01;
 create user IACF identified by IACF default tablespace TS_KRB01 temporary tablespace TS_NOTTEMP01;

28 rows selected.


SQL> select ' grant connect, resource to ' || username ||';'
     from dba_users
     where username not in ('SYS', 'SYSTEM');

 
''GRANTCONNECT,RESOURCETO'||USERNAME||';'
-----------------------------------------------------------
 grant connect, resource to TRACESVR;
 grant connect, resource to OUTLN;
 grant connect, resource to ORS;
 grant connect, resource to AURORA$ORB$UNAUTHENTICATED;
 grant connect, resource to NOTICE;
 grant connect, resource to FRIEND;
 grant connect, resource to ORANGE;
 grant connect, resource to IPSI;
 grant connect, resource to KOREA;
 grant connect, resource to RNDCARD;
 grant connect, resource to SMBSUPP;
 grant connect, resource to ADMIT;
 grant connect, resource to KRBIZ;
 grant connect, resource to CTXSYS;
 grant connect, resource to JONES;
 grant connect, resource to BIZMAX;
 grant connect, resource to DBSNMP;
 grant connect, resource to PERSON;
 grant connect, resource to SCOTT;
 grant connect, resource to ADAMS;
 grant connect, resource to CLARK;
 grant connect, resource to BLAKE;
 grant connect, resource to CDL;
 grant connect, resource to EDUGRAD;
 grant connect, resource to KUPR;
 grant connect, resource to WIZARD;
 grant connect, resource to IAS;
 grant connect, resource to IACF;

28 rows selected.


#####################################################################
### Tablespace Size 조회
#####################################################################

SQL> select tablespace_name, sum(bytes)/1024/1024  || 'M' as MBYTES
     from dba_data_files
     group by tablespace_name
     order by 1;


TABLESPACE_NAME                MBYTES
------------------------------ -----------------------------------------
INDX                           100M
IX_CDL01                       300M
IX_EDU01                       100M
IX_EEX01                       500M
IX_EEX02                       100M
IX_FRI01                       100M
IX_IAS01                       50M
IX_KRB01                       500M
IX_KUPR01                      100M
IX_NOT01                       100M
IX_ORS01                       500M
IX_PER01                       200M
IX_WIZ01                       30M
RBS                            2516M
SYSTEM                         300M
TEMP                           500M
TOOLS                          50M
TS_CDL01                       1000M
TS_CTX01                       50M
TS_EDU01                       200M
TS_EEX01                       1500M
TS_EEX02                       1500M
TS_EEXTEMP01                   500M
TS_EEXTEMP02                   500M
TS_FRI01                       300M
TS_FRITEMP01                   1000M
TS_IAS01                       100M
TS_KRB01                       3200M
TS_KUPR01                      200M
TS_NOT01                       300M
TS_NOTTEMP01                   1500M
TS_ORS01                       1000M
TS_ORSTEMP01                   500M
TS_PER01                       500M
TS_WIZ01                       100M
USERS                          150M

36 rows selected.


#####################################################################
### Temporary Tablespace의 Tempfile 조회
#####################################################################

 

#####################################################################
### datafile이 두개 이상인 Tablespace 조회
#####################################################################

SQL> select tablespace_name , count(*)
     from dba_data_files
     having count(*)>1
     group by tablespace_name
     order by 1;


TABLESPACE_NAME                  COUNT(*)
------------------------------ ----------
RBS                                     3
TS_KRB01                                3

 

SQL> select tablespace_name, file_name, bytes/1024/1024 || 'M' as MBYTES
     from dba_data_files
     where tablespace_name in ('RBS')
     order by 1;

 

TABLESPACE_NAME  FILE_NAME                                     MBYTES
---------------- --------------------------------------------- -----------------------------------------
RBS              /oracle/app/oracle/oradata/WWW/rbs01.dbf      516M
RBS              /WWW/Data/rbs2.dbf                            1000M
RBS              /WWW/Index/rbs3.dbf                           1000M


SQL> select tablespace_name, file_name, bytes/1024/1024 || 'M' as MBYTES
     from dba_data_files
     where tablespace_name in ('TS_KRB01')
     order by 1;

 

TABLESPACE_NAME  FILE_NAME                                     MBYTES
---------------- --------------------------------------------- -----------------------------------------
TS_KRB01         /WWW/Data/ts_krb01.dbf                        1200M
TS_KRB01         /WWW/Data/ts_krb02.dbf                        1500M
TS_KRB01         /WWW/Data/ts_krb03.dbf                        500M


#####################################################################
### Create Tablespace SQL Query Statement 작성
#####################################################################

SQL> set lines 200
SQL> set pages 200
SQL> col file_name for a50
SQL> col tablespace_name for a20
SQL> col Mbytes for a20
SQL> spool create_tablespace.sql
SQL> set echo off;
SQL> set heading off;
SQL> select ' create tablespace ' || tablespace_name ||
     ' datafile ''' || file_name || ''' size ' || bytes/1024/1024 || 'M autoextend off; '
     from dba_data_files
     where tablespace_name not in ('SYSTEM', 'USER', 'RBS', 'TOOLS', 'TEMP')
     and tablespace_name not like '%TMP%'
     and tablespace_name not like '%TEMP%';

 
'CREATETABLESPACE'||TABLESPACE_NAME||'DATAFILE'''||FILE_NAME||'''SIZE'||BYTES/1024/1024||'MAUTOEXTENDOFF;'
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 create tablespace USERS datafile '/oracle/app/oracle/oradata/WWW/users01.dbf' size 150M autoextend off;
 create tablespace INDX datafile '/oracle/app/oracle/oradata/WWW/indx01.dbf' size 100M autoextend off;
 create tablespace TS_NOT01 datafile '/WWW/Data/ts_not02.dbf' size 300M autoextend off;
 create tablespace IX_NOT01 datafile '/WWW/Index/ix_not01.dbf' size 100M autoextend off;
 create tablespace TS_FRI01 datafile '/WWW/Data/ts_fri02.dbf' size 300M autoextend off;
 create tablespace IX_FRI01 datafile '/WWW/Index/ix_fri01.dbf' size 100M autoextend off;
 create tablespace TS_ORS01 datafile '/WWW/Data/ts_ors01.dbf' size 1000M autoextend off;
 create tablespace IX_ORS01 datafile '/WWW/Index/ix_ors01.dbf' size 500M autoextend off;
 create tablespace IX_EEX01 datafile '/WWW/Index/ix_eex01.dbf' size 500M autoextend off;
 create tablespace TS_EEX01 datafile '/WWW/Data/ts_eex02.dbf' size 1500M autoextend off;
 create tablespace TS_EEX02 datafile '/WWW/Data/ts_eex04.dbf' size 1500M autoextend off;
 create tablespace IX_EEX02 datafile '/WWW/Index/ix_eex02.dbf' size 100M autoextend off;
 create tablespace TS_KRB01 datafile '/WWW/Data/ts_krb01.dbf' size 1200M autoextend off;
 create tablespace IX_KRB01 datafile '/WWW/Index/ix_krb01.dbf' size 500M autoextend off;
 create tablespace TS_CTX01 datafile '/WWW/Data/ts_ctx01.dbf' size 50M autoextend off;
 create tablespace TS_PER01 datafile '/WWW/Data/ts_per01.dbf' size 500M autoextend off;
 create tablespace IX_PER01 datafile '/WWW/Index/ix_per01.dbf' size 200M autoextend off;
 create tablespace TS_KRB01 datafile '/WWW/Data/ts_krb02.dbf' size 1500M autoextend off;
 create tablespace TS_CDL01 datafile '/WWW/Data/ts_cdl01.dbf' size 1000M autoextend off;
 create tablespace IX_CDL01 datafile '/WWW/Index/ix_cdl01.dbf' size 300M autoextend off;
 create tablespace TS_EDU01 datafile '/WWW/Data/ts_edu01.dbf' size 200M autoextend off;
 create tablespace IX_EDU01 datafile '/WWW/Index/ix_edu01.dbf' size 100M autoextend off;
 create tablespace TS_KUPR01 datafile '/WWW/Data/ts_kupr01.dbf' size 200M autoextend off;
 create tablespace IX_KUPR01 datafile '/WWW/Index/ix_kupr01.dbf' size 100M autoextend off;
 create tablespace TS_WIZ01 datafile '/WWW/Data/ts_wiz01.dbf' size 100M autoextend off;
 create tablespace IX_WIZ01 datafile '/WWW/Index/ix_wiz01.dbf' size 30M autoextend off;
 create tablespace TS_IAS01 datafile '/WWW/Data/ts_ias01.dbf' size 100M autoextend off;
 create tablespace IX_IAS01 datafile '/WWW/Index/ix_ias01.dbf' size 50M autoextend off;
 create tablespace TS_KRB01 datafile '/WWW/Data/ts_krb03.dbf' size 500M autoextend off;

29 rows selected.

SQL> spool off;


#####################################################################
###  Create Temporary Tablespace SQL Query Statement 작성
#####################################################################

SQL> set pages 200
SQL> set lines 200
SQL> col file_name for a50
SQL> col tablespace_name for a20
SQL> col Mbytes for a20
SQL> spool create_temp_tablespace.sql
SQL> set echo off;
SQL> set heading off;
SQL> select ' create temporary tablespace ' || tablespace_name ||
     ' tempfile ''' || file_name || ''' size ' || bytes/1024/1024 || 'M autoextensible off; '
     from dba_data_files
     where tablespace_name like '%TMP%'
     or tablespace_name like '%TEMP%';

 create temporary tablespace TEMP tempfile '/oracle/app/oracle/oradata/WWW/temp01.dbf' size 500M autoextensible off;
 create temporary tablespace TS_NOTTEMP01 tempfile '/WWW/Data/ts_not01.dbf' size 1500M autoextensible off;
 create temporary tablespace TS_FRITEMP01 tempfile '/WWW/Data/ts_fri01.dbf' size 1000M autoextensible off;
 create temporary tablespace TS_ORSTEMP01 tempfile '/WWW/Data/ts_orstemp01.dbf' size 500M autoextensible off;
 create temporary tablespace TS_EEXTEMP01 tempfile '/WWW/Data/ts_eex01.dbf' size 500M autoextensible off;
 create temporary tablespace TS_EEXTEMP02 tempfile '/WWW/Data/ts_eex03.dbf' size 500M autoextensible off;


6 rows selected.

SQL> spool off;


#####################################################################
### Import Script 작성
#####################################################################

SQL> set pages 200
SQL> set lines 200
SQL> col file_name for a50
SQL> col tablespace_name for a20
SQL> col Mbytes for a20
SQL> spool import_user.sh
SQL> set echo off;
SQL> set heading off;
SQL> select 'imp system/manager file= filesize=6000m rows=y fromuser=' || username ||
  2  ' touser=' || username || ' log=' || username || '.log'
  3  from dba_users
  4  where username not in ('SYS', 'SYSTEM');

imp system/manager file= filesize=6000m rows=y fromuser=TRACESVR touser=TRACESVR log=TRACESVR.log
imp system/manager file= filesize=6000m rows=y fromuser=OUTLN touser=OUTLN log=OUTLN.log
imp system/manager file= filesize=6000m rows=y fromuser=ORS touser=ORS log=ORS.log
imp system/manager file= filesize=6000m rows=y fromuser=AURORA$ORB$UNAUTHENTICATED touser=AURORA$ORB$UNAUTHENTICATED log=AURORA$ORB$UNAUTHENTICATED.log
imp system/manager file= filesize=6000m rows=y fromuser=NOTICE touser=NOTICE log=NOTICE.log
imp system/manager file= filesize=6000m rows=y fromuser=FRIEND touser=FRIEND log=FRIEND.log
imp system/manager file= filesize=6000m rows=y fromuser=ORANGE touser=ORANGE log=ORANGE.log
imp system/manager file= filesize=6000m rows=y fromuser=IPSI touser=IPSI log=IPSI.log
imp system/manager file= filesize=6000m rows=y fromuser=KOREA touser=KOREA log=KOREA.log
imp system/manager file= filesize=6000m rows=y fromuser=RNDCARD touser=RNDCARD log=RNDCARD.log
imp system/manager file= filesize=6000m rows=y fromuser=SMBSUPP touser=SMBSUPP log=SMBSUPP.log
imp system/manager file= filesize=6000m rows=y fromuser=ADMIT touser=ADMIT log=ADMIT.log
imp system/manager file= filesize=6000m rows=y fromuser=KRBIZ touser=KRBIZ log=KRBIZ.log
imp system/manager file= filesize=6000m rows=y fromuser=CTXSYS touser=CTXSYS log=CTXSYS.log
imp system/manager file= filesize=6000m rows=y fromuser=JONES touser=JONES log=JONES.log
imp system/manager file= filesize=6000m rows=y fromuser=BIZMAX touser=BIZMAX log=BIZMAX.log
imp system/manager file= filesize=6000m rows=y fromuser=DBSNMP touser=DBSNMP log=DBSNMP.log
imp system/manager file= filesize=6000m rows=y fromuser=PERSON touser=PERSON log=PERSON.log
imp system/manager file= filesize=6000m rows=y fromuser=SCOTT touser=SCOTT log=SCOTT.log
imp system/manager file= filesize=6000m rows=y fromuser=ADAMS touser=ADAMS log=ADAMS.log
imp system/manager file= filesize=6000m rows=y fromuser=CLARK touser=CLARK log=CLARK.log
imp system/manager file= filesize=6000m rows=y fromuser=BLAKE touser=BLAKE log=BLAKE.log
imp system/manager file= filesize=6000m rows=y fromuser=CDL touser=CDL log=CDL.log
imp system/manager file= filesize=6000m rows=y fromuser=EDUGRAD touser=EDUGRAD log=EDUGRAD.log
imp system/manager file= filesize=6000m rows=y fromuser=KUPR touser=KUPR log=KUPR.log
imp system/manager file= filesize=6000m rows=y fromuser=WIZARD touser=WIZARD log=WIZARD.log
imp system/manager file= filesize=6000m rows=y fromuser=IAS touser=IAS log=IAS.log
imp system/manager file= filesize=6000m rows=y fromuser=IACF touser=IACF log=IACF.log

28 rows selected.

SQL> spool off;


#####################################################################
### user별 object 조회
#####################################################################

 


IMP-00017: following statement failed with ORACLE error 2264:
 "ALTER TABLE "VRLOGO" ADD  CONSTRAINT "SYS_C002772" PRIMARY KEY ("SEQ_NO") U"
 "SING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 102400 NEXT 5"
 "3248 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST "
 "GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TS_KRB01" ENABLE "
IMP-00003: ORACLE error 2264 encountered
ORA-02264: name already used by an existing constraint
. . importing table                     "VRMEMBER"          0 rows imported
. . importing table               "VRUSED_SERVICE"          8 rows imported
About to enable constraints...
IMP-00017: following statement failed with ORACLE error 2430:
 "ALTER TABLE "VRLOGO" ENABLE CONSTRAINT "SYS_C002772""
Import terminated successfully with warnings.

반응형
Posted by [PineTree]
ORACLE/SQL2008. 1. 28. 21:46
반응형

▶ DB에 있는 모든 Table 이름보기

    select table_name from user_tables

   ▶ Table의 Primary Key 찾기

    select * from user_ind_columns where table_name = 'CodeTable'

   ▶ 인수전달

 

    select * from user_ind_columns where table_name = '&1' 

   →; save key 

      SQL> start key CodeTable

   ▶ 서로 연결되는 Key를 찾는 방법 

   select constraint_name, constraint_type, r_constraint_name  

    from user_constraints

       where table_name = 'TABLE_NAME

  ▶ TABLE 구조 보기

    DESC TABLE_NAME

   ▶ Constraint 확인

    select table_name, constraint_name, constraint_type

      from user_constraints

    where table_name in ('DEPARTMENT','EMPLOYEE');

   ▶ 테이블 COPY 하기

    create table emp_41

    as

    select id, last_name, userid, start_date from s_emp

    where dept_id = 41;

    → where절에 엉뚱한 조건을 주면 emp_41이란 이름으로 테이블이 만들어진다.   

   ▶ 선택한 Row만큼만 보여주기

    select * from tmp_table

    where rownum <= 100

    → 이렇게 하면 데이터가 10000건이 있더라도, 1~100건만 보여주게 된다.

   ▶ 오라클의 모든 유저 보기

    select * from all_users

    KO16KSC5601 이면 한글...

    US7ASCII 이면 영문이다. → regedit에서 편집하면 간단히 해결.

   ▶ Space 있는 값을 Null로 비교

    RTRIM(a.ymd_myun) IS NULL

   ▶ Desc명령으로 Table구조 보는 효과와 같은 방법

    SELECT column_name, data_type, data_length, nullable FROM cols

    WHERE table_name = 'YTB_CARCOM'

    → 반드시 테이블명은 대문자 이어야 한다.

   ▶ Function Script 보는 방법.

    select text from user_source where name = 'FUNCTION_NAME'

   ▶ 요일 찾는 방법.

    select TO_CHAR(sysdate,'D') from dual

   ▶ 사용하지 않는 컬럼의 표시 

   alter table [tbl명] set unused column [column명];

  ▶ 사용하지 않는 컬럼 제거

   alter table [table명]  drop column [column명] cascade constraints;

  --> 사용하지 않는 컬럼을 삭제 (제약조건이 있으면 제약조건을 같이 삭제)

  alter table [table명]  drop column [column명];

  --> 사용하지 않는 컬럼으로 표시된 컬럼을 삭제

 

 

반응형

'ORACLE > SQL' 카테고리의 다른 글

&lt;25가지 SQL작성법&gt;  (0) 2008.02.19
oracle에서 hint의 사용  (0) 2008.02.14
Materialized View 설명  (0) 2008.02.14
유용한 DB 쿼리  (0) 2007.11.17
demobld.sql  (0) 2007.09.17
Posted by [PineTree]
ORACLE/Backup & Recovery2008. 1. 28. 20:25
반응형
[ RMAN 환경 정보 검색]

    RMAN> SHOW ALL;

    RMAN configuration parameters are:
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;
    CONFIGURE BACKUP OPTIMIZATION OFF; # default
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default ...

[ 디스크 백업 설정 ]

    RMAN>CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/tmp/ora_df%t_s%s_s%p';

[ 테이프 백업 설정 ]

    RMAN>CONFIGURE DEFAULT DEVICE TYPE TO sbt;

[  백업 유지 정책 설정 - 30일간의 백업만 유지 ]

    RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;

[ Controlfile의 자동 백업 ]

    RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '?/tmp/cf%F';

[ 환경 설정 초기화 ]

    RMAN>CONFIGURE CHANNEL DEVICE TYPE sbt CLEAR;
    RMAN>CONFIGURE RETENTION POLICY CLEAR;
    RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;

[ 데이타베이스와 모든 아카이브파일 백업 ]

    RMAN>BACKUP DATABASE PLUS ARCHIVELOG;

[ 다양한 파일 백업 예제 ]

    RMAN>BACKUP ARCHIVELOG TIME BETWEEN 'SYSDATE-31' AND 'SYSDATE-7';
    RMAN>BACKUP TABLESPACE system, users, tools, undotbs;
    RMAN>BACKUP DATAFILE '?/oradata/trgt/users01.dbf', '?/oradata/trgt/tools01.dbf';
    RMAN>BACKUP CURRENT CONTROLFILE TO '/backup/curr_cf.copy';
    RMAN>BACKUP SPFILE;
   
[ RMAN 백업 옵션 ]

  1. FORMAT --- FORMAT '/tmp/%U'

      Specifies a nondefault location and name for backup pieces.

  2. FILESPERSET --- FILESPERSET 20

      Limits the number of database files or archived logs placed in a backup set.

  3. MAXSETSIZE --- MAXSETSIZE 5G

      Specifies the maximum byte size of the backup set.

  4. COPIES --- COPIES 2

      Specifies the number of identical copies of each backup piece.

  5. TAG --- TAG 'monday_bak'

      Specifies a user-defined string as a label for the backup.

    RMAN>BACKUP TABLESPACE tools, indx, undotbs FORMAT '?/oradata/%U';
    RMAN>BACKUP FILESPERSET 20 FORMAT='AL_%d/%t/%s/%p' ARCHIVELOG LIKE '%arc_dest%';
    RMAN>BACKUP TAG 'weekly_full_db_bkup' DATABASE MAXSETSIZE 10M;
    RMAN>BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;

[ Incremental 백업 - LEVEL 0 (데이타베이스 전체 백업) ]

    RMAN>BACKUP INCREMENTAL LEVEL 0 DATABASE;

[ 가장 최근의 Incremental 백업 이후의 변경된 블럭 정보 백업 ]

    RMAN>BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

[ RMAN 백업 테스트 ]

    실 백업에 앞서 데이타파일의 존재 유무,물리적,논리적 Corruption 상태를 체크

    RMAN>BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

[ RMAN의 Format이 아닌 Image Copy 방법 ]

    RMAN>COPY DATAFILE 1 TO '/tmp/df1.cpy', CURRENT CONTROLFILE TO '/tmp/cf.cpy';

[ 전체 데이타베이스 복구 ]

    RMAN>STARTUP FORCE MOUNT;
    RMAN>RESTORE DATABASE;
    RMAN>RECOVER DATABASE;
    RMAN>ALTER DATABASE OPEN;

[ 개별 테이블스페이스 복구 ]

    RMAN>RUN
            {
                SQL 'ALTER TABLESPACE users OFFLINE';
                #To restore to a different location, uncomment the following commands.
                # SET NEWNAME FOR DATAFILE 8 TO '/newdir/new_filename_for_8.f';
                RESTORE TABLESPACE users;
                # If you restored to different locations, uncomment the following line.
                # SWITCH DATAFILE ALL;
                RECOVER TABLESPACE users;
                SQL 'ALTER TABLESPACE users ONLINE';
              }

[ 개별 데이타파일 복구 ]

    RMAN>RUN
              {
                SQL 'ALTER DATABASE DATAFILE 7 OFFLINE';
                # To restore to a different location, uncomment the following command.
                # SET NEWNAME FOR DATAFILE 7 TO '/newdir/new_filename.f';
                RESTORE DATAFILE 7;
                # If you restored to different locations, uncomment the following line.
                # SWITCH DATAFILE ALL;
                RECOVER DATAFILE 7;
                SQL 'ALTER DATABASE DATAFILE 7 ONLINE';
              }

[ 손상된 데이타 블럭의 복구 ]

  1. Alert.log / Trace Files / SQL Qeury 로 나타난  손상된 블럭의 복구 방법

    RMAN>BLOCKRECOVER DATAFILE 7 BLOCK 233, 235 DATAFILE 4 BLOCK 101;

  2. RMAN을 사용하여 백업하는 동안에 발견된 손상된 블럭정보는 다음의 뷰에 쌓이게 된다. 
      이 뷰를 이용한 복구 방법 ( V$BACKUP_CORRUPTION 와 V$COPY_CORRUPTION)

    RMAN>BLOCKRECOVER CORRUPTION LIST;

[ RMAN 백업 정보 검색 ]

    RMAN>SHOW ALL;
    RMAN>LIST BACKUP OF DATABASE;
    RMAN>LIST COPY OF DATAFILE 1, 2, 3;
    RMAN>LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 1437;
    RMAN>LIST CONTROLFILECOPY "/tmp/cf.cpy";
    RMAN>LIST BACKUPSET 193, 207, 242;
반응형
Posted by [PineTree]
MS-SQL2008. 1. 15. 19:51
반응형

1. 시작화면

설치 CD를 넣으면 자동으로 설치가 시작되면서 다음과 같은 첫 화면을 표시됩니다. (평가판 다운로드 방법은 자료실에 있으니 참고하시기 바랍니다)


[화면 1]

그리고 잠시 후 다음과 같은 화면이 표시됩니다.


[화면 2]

이 화면에서 설치전 다양한 정보를 확인할 수 있습니다. 설치를 위해서는 [설치] 부분의 [서버 구성 요소, 도구, 온라인 설명서 및 예제(C)] 를 선택하시면 됩니다.

2. 최종 사용자 사용권 계약

이 단계의 화면에서는 아래의 [화면3] 처럼 소프트웨어 사용권에 대한 동의를 얻는 단계가 수행됩니다. 내용을 확인하시고 [동의함]을 선택하여 다음 단계로 진행하시면 됩니다.


[화면 3]

3. 필수 구성 요소 설치

이 단계의 화면에서는 아래의 [화면 4] 처럼 MS SQL Server 2005를 설치하기 전에 필수적으로 설치되어야 하는 구성 요소를 설치 하겠다는 안내를 해주게 됩니다. 이중에서 생소하게 보일 수 있는 것이 닷넷 프레임워크 2.0과 MS SQL Native Client입니다. 우선 이런게 설치되어야 하는구나 생각하시고 [설치] 버튼을 눌러 다음 단계로 진행하시기 바랍니다.


[화면 4]

4. 필수 구성 요소 설치 (계속)

이 단계 에서는 아래의 [화면 5] 처럼 MS SQL Server 2005를 설치하기 전에 필수적으로 설치되어야 하는 구성 요소가 설치 되고 있는 상황을 보여 줍니다. 약간의 시간이 소요 되므로 완료되기를 기다리 신 후 단계를 진행하시기 바랍니다.


[화면 5]

5. 설치 마법사 시작

필수적인 구성 요소 설치가 완료 되었으므로 이제부터 본격적인 MS SQL Server 2005 설치가 시작됨을 알려주는 화면입니다. [다음] 버튼을 눌러 설치를 시작하시면 됩니다.


[화면 6]

6. 시스템 구성 검사

MS SQL Server 2005를 설치 하는 과정에서 발생할 수 있는 문제점을 사전에 확인하기 위해 필요한 요구사항을 현재의 시스템이 충족하고 있는지 점검하는 단계입니다. 아래의 [화면 7]에서는 모든 요구사항이 충족되고 있음을 표시하고 있습니다. 만일 충족하지 못한 요구 사항이 발견되는 경우 그 요구 사항을 충족 시킨 후 다시 설치를 진행하시거나, 설치 후 해당 요구 사항이 충족 되도록 조치를 취하셔도 되는데 전자를 권해드리고 싶습니다. 예를 들어 IIS 기능 요구 사항은 Reporting Service를 위해 필요한 내용입니다. 일반적으로 IIS 서비스를 설치하지 않는 경우가 많으므로 이 부분에 경고가 표시되는 경우가 많습니다. 이런 경우 IIS를 설치 한 후 MS SQL Server 2005 설치를 다시 진행하시면 됩니다.


[화면 7]

7. 등록 정보

이 단계는 이름과 회사명 그리고 제품 키를 입력하는 화면입니다. 특히 제품 키값이 제대로 입력되지 않으면 설치를 진행 할 수 없습니다. 아래 [화면 8]에서는 현재 제가 설치하고 있는 에디션이 평가판이기에 제품 키값을 요구하지 않고 있지 않음을 숙지 하사기 바랍니다. 다시 말하면 평가판은 아무나 설치 할 수 있다는 것입니다.


[화면 8]

8. 등록 정보

이 단계에서는 설치 또는 업그레이드 할 구성 요소를 선택하게 됩니다. 만일 데이터베이스 서비스만 사용하실거라면 첫번째의 [SQL Server Database Services(S)]만 선택하시면 됩니다. 그리고 온라인 설명서나 기타 개발 도구를 사용하기 위해서는 맨 마지막의 [워크스테이션 구성 요소, 온라인 설명서 및 개발 도구(W)] 를 선택하시면 됩니다. 이 두가지가 가장 일반적으로 사용되는 항목입니다. 어떤 것을 선택 하는가에 따라 이후에 진행되는 설치 과정이 다를 수 있으므로 저는 아래 모든 항목을 선택해 설치를 진행할 예정입니다.

Analysis Services는 OLAP릉 이용하기 위해 설치하는 항목이며, Reporting Services는 보고서관련 서비스를 사용하기 위한 항목입니다(이를 위해서는 IIS 설치 필수). 그리고 Notification Services는 경고 및 알림 서비스를 위한 것이며, Integration Services는 BI를 위한 것으로 이전 버젼의 DTS의 새로운 형태라 보시면 됩니다.


[화면 9]

9. 등록 정보 - 고급

위 [화면 9]에서 [고급(D)] 버튼을 누르면 아래 [화면 10] 처럼 상세 설치 화면이 표시됩니다. 각각의 구성 요소에 대해 세부적으로 설치 여부를 설정할 수 있습니다. 아래 화면에서 보면 [설명서, 예제 및 예제 데이터베이스] 부분 앞의 디스크 모양의 아이콘이 회색입니다. 이는 세부적으로 볼때 설치를 위해 선택되지 않은 항목이 있음을 알려주는 것입니다.


[화면 10]

필요하다면 아래 [화면 11]처럼 디스크 모양의 아이콘을 틀릭해 표시되면 단축 메뉴에서 [모든 기능을 로컬 하드 드라이브에 설치합니다]를 선택하여 모든 항목이 설치되게 할 수 있습니다. 학습을 위한 목적이라면 모든 항목을 선택해 설치하기를 권해 드립니다.


[화면 11]

10. 인스턴스 이름

인스턴스는 이전 버젼부터 접해 왔던 개념입니다. 한 서버에 여러개의 MS SQL Server 서비스를 설치 할 수 있습니다. 그러면 이들은 서로 다른 MS SQL Server 처럼 운영이 되는데 이 하나 하나를 인스턴스라 이야기 합니다. 처음에 성치 되는것이 기본 인스턴스 입니다. 이후에 설치되는 것이 명명된 인스턴스 입니다.

이번 강좌에서는 첫 설치 이므로 [기본 인스턴스]로 설치 하도록 할 예정입니다.


[화면 12]

실제적으로 여러 인스턴스를 설치해 업무에 활용하는 경우는 별로 없습니다. 여러 인스턴스를 설치하는 경우는 개발 및 운영 테스트 또는 개인 학습을 위한 경우입니다. 이전 MS SQL Server 2000이 설치된 서버에 2005 버젼을 설치 하고자 하는 경우 새로운 인스턴스로 설치하셔도 됩니다. 이렇게 되면 한 서버에 2000 과 2005 버젼을 동시에 운영 할 수 있습니다. 학습 및 테스트로는 권장하지만 실제 업무에는 그리 권하고 싶지는 않습니다.

11. 서비스 계정

이 단계는 MS SQL Server 2005 관련 서비스를 어떤 계정을 통해 실행되게 할 것인지 설정하는 화면입니다.


[화면 13]

기본적으로는 관련된 서비스 전체를 하나의 계정을 통해 실행되게 할 수 있지만 [화면 14] 처럼 각 서비스에 대해 개별 계정을 설정 할 수도 있습니다.


[화면 14]

다른 서버들과의 상호 연관된 작업이 필요하다면 도메인 계정을 사용하시기 바랍니다. [설치 완료 후 서비스 시작] 부분에는 MS SQL Server 2005가 설치 된 후 자동으로 시작되게 할 서비스를 선택하는 부분입니다.

12. 인증 모드

이 단계는 MS SQL Server 2005에서 사용할 인증 모드를 선택하게 됩니다. 이전 버젼과 같이 Windows 인증 모드와 혼합 모드가 있습니다. 윈도우즈 계정만을 가지고 인증을 받게 할 것이라면 [WIndows 인증 모드]를 선택하시면 됩니다. 그렇지 않을 경우라면 [혼합 모드]를 선택하시면 됩니다.


[화면 15]

[혼합 모드]를 선택하게 되면 아래 [화면 16] 처럼 sa 계정의 암호를 설정하도록 요청됩니다. 이 경우 암호를 되도록 복잡하게 구성하여 설정해주셔야 합니다. 그렇지 않으면 보안에 취약성을 드러내게 됩니다.


[화면 16]

13. 데이터 정렬 설정

이 단계는 MS SQL Server 2005에서 사용할 데이터 정렬 방식을 선택하게 됩니다. 이전 버젼과 같으므로 특별한 설명은 생략하도록 하겠습니다.


[화면 17]

14. 보고서 서버 설치 옵션

Reporting Services 설치를 선택한 경우 이 단계가 수행됩니다.


[화면 18]

위 [화면 18]에서 [자세히(E)...] 버튼을 누르면 다음과 같이 상세 정보가 표시됩니다.


[화면 19]

15. 오류 및 사용 보고서 설정

MS SQL Server 2005에서 오류가 발생하면 그 내용을 MS에 자동으로 보고 할 지 설정하는 화면입니다. 오류가 발생하면 그 해결책을 제시해 주지는 않을 것입니다. 단지 향후 기능 개선에 활용될 것입니다.


[화면 20]

16. 설치 준비 완료

지금 까지의 과정을 통해 MS SQL Server 2005를 설치할 준비가 된 것입니다. 아래 [화면 21] 처럼 설치될 항목이 표시됩니다. [설치] 버튼을 누르게 되면 이제 설치 과정이 진행이 됩니다.


[화면 21]

17. 설치 진행률

아래 [화면 22] 처럼 설치되는 과정이 표시됩니다. 실제 설치 과정이므로 이 부분이 가장 많은 시간이 소요되게 됩니다. 저의 경우는 40분 정도 소요 되었던 것으로 기억됩니다. 설치가 진행되게 놔 두고 잠시 쉬면 될것으로 보입니다. 따스한 커피 한잔?^^


[화면 22]

설치가 완료되면 다음과 같이 모든 과정이 완료 되었음을 표시해 줍니다. [다음] 버튼을 눌러 다음 단계로 진행하시면 됩니다.


[화면 23]

18. 설치 완료

드디어 설치가 완료 되었습니다. 물론 이후에 관련 서비스에 대한 구성 설정을 해야 안전한 서비스 운영을 할 수 있습니다. 아래 [화면 24] 처럼 이후에 진행되어야 하는 내용이 안내되어 집니다. 우선 표시되는 내용을 확인해 보시기 바랍니다.


[화면 24]

[요약 로그]를 선택하시면 다음과 같이 상세한 정보를 확인 할 수 있는 로그 폴더를 보여줍니다.


[화면 25]

[노출 영역 구성 도구를 사용하십시오]를 선택하시면 다음과 같이 관리 효율 및 보안을 위한 설정 화면이 표시됩니다. 이 부분은 다음에 별도 강좌로 다루도록 하겠습니다.


[화면 26]

19. 정리

지금까지 MS SQL Server 2005를 설치하는 과정을 살펴 보았습니다. 이번 강좌를 통해서 MS SQL Server 2005 설치 과정이 그리 복잡하지 않음을 확인할 수 있었기를 바랍니다. 실제 설치를 하는 과정에서 의문이 있는 부분은 각 화면의 [도움말]을 참고하시기 바랍니다. 설치 이후에도 수행해야 할 내용들이 있습니다. 앞에서 본 노출 영역 설정 또는 서비스 팩(현재 서비스팩 1까지 나와 있습니다) 설치 등입니다. 이 부분도 이후에 강좌로 다루어 볼 예정입니다. 물론 쉽게 할 수 있을 내용이지만 강좌를 통해 미리 진행 내용을 점검하면 도움이 될것이라 생각하기 때문입니다.

반응형
Posted by [PineTree]
ORACLE/ADMIN2007. 12. 13. 19:11
반응형
1. 파라미터 명칭과 설명이 잘 정리되어 있습니다
http://www.orafaq.com/parms/index.htm
2. 9i 와 10g 의 차이점에 대해 정리되어 있습니다
http://www.ss64.com/orasyntax/initora.html
반응형

'ORACLE > ADMIN' 카테고리의 다른 글

오라클에서 유니코드의 사용  (0) 2008.04.26
오라클 캐릭터 셋 변경(CHARACTER SET)  (0) 2008.04.02
DATABASE LINK 사용법  (0) 2007.12.07
oracle lock  (0) 2007.08.14
ORACLE relink  (0) 2007.08.07
Posted by [PineTree]
ORACLE/Backup & Recovery2007. 12. 11. 20:01
반응형
: Configuration of Load Balancing and Transparent Application Failover
  문서 ID: 공지:226880.1 유형: BULLETIN
  마지막 갱신 날짜: 15-NOV-2007 상태: PUBLISHED

Configuration of Load Balancing and Transparent Application Failover


This note was created to provide a guideline to the configuration of:

1) client side connect time load balance only
2) server side listener connection load balance with client side connect
   time load balance
3) server side listener connection load balance only
3) transparent application failover

Before you configure the Net Services features, here is a definition of the
these features that can be implemented either singly or in combination with
each other.

 Client Side Connect-Time Failover
The connect-time failover enables clients to connect to another listener if
the initial connection to the first listener fails. The number of listener 
protocol addresses determines how many listeners are tried. Without 
connect-time failover, Oracle Net attempts a connection with only one listener.  
The default is on.

 Transparent Application Failover
The Transparent Application Failover (TAF) feature is a runtime failover for
high-availability environments, such as Oracle9i Real Application Clusters and
Oracle9i Real Application Clusters Guard. TAF fails over and reestablishes 
application-to-service connections. It enables client applications to 
automatically reconnect to the database if the connection fails and, 
optionally, resume a SELECT statement that was in progress. The reconnection 
happens automatically from within the Oracle Call Interface (OCI) library.

 Client Side Connect Time Load Balancing
The client load balancing feature enables clients to randomize connection 
requests among the listeners. Oracle Net progresses through the list of 
protocol addresses in a random sequence, balancing the load on the various 
listeners. Without client load balancing, Oracle Net progresses through the 
list of protocol addresses sequentially until one succeeds.  This normally is 
referred to connect-time load balance.  

 Server Side Listener Connection Load Balancing
The listener connection load balancing feature improves connection performance
by balancing the number of active connections among multiple dispatchers and 
instances. In a single-instance environment, the listener selects the least 
loaded dispatcher to handle the incoming client requests. In an Oracle9i Real 
Application Clusters environment, connection load balancing also has the 
capability to balance the number of active connections among multiple instances.

Due to dynamic service registration, a listener is always aware of all 
instances and dispatchers regardless of their locations. Depending on the load
information, a listener decides which instance and, if shared server is 
configured, which dispatcher to send the incoming client request to. In a 
shared server configuration, a listener selects a dispatcher in the following 
order:
1. Least-loaded node
2. Least-loaded instance
3. Least-loaded dispatcher for that instance

In a dedicated server configuration, a listener selects an instance in the 
following order:
1. Least loaded node
2. Least loaded instance

If a database service has multiple instances on multiple nodes, the listener 
chooses the least loaded instance on the least loaded node. If shared server 
is configured, then the least loaded dispatcher of the selected instance is 
chosen.


Included is server side node1's init.ora, listener.ora, and tnsnames.ora files 
as well as client side tnanames.ora file.

This is a four nodes cluster setup.  The configuration is as follows.  If you 
replace your hostname, service_name, sid_name, instance_name and $ORACLE_HOME
in the example files, you should be able to configure a successful setup.  

       hostname  service name  sid name  instance_name  ORACLE_HOME
       ========  ============  ========  =============  =====================
node1   hprac-22      rac         rac1         rac1     /oracle/9iship/rac901
node2   hprac-23      rac         rac2         rac2     /oracle/9iship/rac901
node3   hprac-24      rac         rac3         rac3     /oracle/9iship/rac901
node4   hprac-25      rac         rac4         rac4     /oracle/9iship/rac901


All 4 nodes init.ora file have the following parameters:
remote_listener='LISTENERS_RAC'
rac1.local_listener="LISTENER_rac1”
rac2.local_listener="LISTENER_rac2"
rac3.local_listener="LISTENER_rac3"
rac4.local_listener="LISTENER_rac4"
# dispatchers="(pro=ipc)(dis=0)"
db_name='rac'
rac1.instance_name='rac1'
rac2.instance_name='rac2'
rac3.instance_name='rac3'
rac4.instance_name='rac4'

Since service_names is not specified in the init.ora file, it defaults to 
db_name.db_domain.  Each node should list it's own host name and instance_name.  
With the above setup, after you start the instance, when checking the sql 
session from node1, you will find the following info.  


SQL> show parameter db_name
NAME                        TYPE      VALUE
--------------------------- --------- -----------------------------------------
db_name                     string    rac

SQL> show parameter db_domain
NAME                        TYPE      VALUE
--------------------------- --------- -----------------------------------------
db_domain                   string

SQL> show parameter service_names
NAME                        TYPE      VALUE
--------------------------- --------- -----------------------------------------
service_names               string    rac

SQL> show parameter instance_name
NAME                        TYPE      VALUE
--------------------------- --------- -----------------------------------------
instance_name               string    rac1

SQL> show parameter listener
NAME                    TYPE      VALUE
---------------------- -----     ----------------------------------------------
local_listener         string    LISTENER_rac1
mts_listener_address   string
mts_multiple_listeners boolean   FALSE
remote_listener        string    LISTENERS_RAC


hprac-22 listener.ora file
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
      )
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /oracle/9iship/rac901)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (ORACLE_HOME = /oracle/9iship/rac901)
      (SID_NAME = rac1)
    )
  )


hprac-22 ~ hprac-25 tnsnames.ora file

LISTENERS_RAC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
    )
  )

# For hprac-22 only
LISTENER_rac1 =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
  )

# For hprac-23 only
LISTENER_rac2 =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
  )

# For hprac-24 only
LISTENER_rac3 =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
  )

# For hprac-25 only
LISTENER_rac4 =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
  )


Client side Tnsnames.ora file
RAC1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
      (INSTANCE_NAME = rac1)
    )
  )

RAC2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
      (INSTANCE_NAME = rac2)
    )
  )

RAC3 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
      (INSTANCE_NAME = rac3)
    )
  )

RAC4 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
      (INSTANCE_NAME = rac4)
    )
  )

RAC =
  (DESCRIPTION =
    (LOAD_BALANCE = yes)
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
    )
  )

failover =
  (DESCRIPTION =
    (enable=broken)
    (LOAD_BALANCE = yes)
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
      (failover_mode=(type=select)(method=basic))
    )
  )



Remarks:
1) LISTENERS_RAC, LISTENER_rac1, LISTENER_rac2, LISTENER_rac3, LISTENER_rac4, 
is the net_service_name (connect descriptor) for remote_listener and 
local_listener.  On the client side, you do not need these net_service_name.
2) failover is the net_service_name for transparent application failover (TAF)
testing.
3) RAC is the net_service_name for client side load balance, if you do not 
need to configure TAF.

There are few different ways to set up client side connect time load balance.  
Here is another alternative:

4) RAC_alternative =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (LOAD_BALANCE = yes)
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
    )
  )
Note:  The (load_balance=yes) instructs Net to progress through the list of 
listener addresses in a random sequence, balancing the load on the various 
listeners.  When set to OFF, instructs Net to try the addresses sequentially 
until one succeeds.  This parameter must be correctly coded in your net 
service name (connect descriptor).  By default, this parameter is set to ON 
for DESCRIPTION_LISTs.  Load balancing can be specified for an ADDRESS_LIST or 
associated with a set of ADDRESSes or set DESCRIPTIONs. If you use ADDRESS_LIST,
(load_balance=yes) should be within the (ADDRESS_LIST=) portion.  If you do 
not use ADDRESS_LIST, (load_balance=yes) should be within the (description=)
portion.  We recommend not to use this (ADDRESS_LIST=) clause.

5) (failover=on) is default for ADDRESS_LISTs, DESCRIPTION_LISTs, and a set of
DESCRIPTIONs., therefore, you do not have to specify.  This is for 
connect-time-failover, please do not confuse it with transparent application 
failover (TAF).  
6) (failover_mode=): The FAILOVER_MODE parameter must be included in the 
CONNECT_DATA portion of a net_service_name.  
7) There is no (backup=failover) in (failover_mode=), this implies 
(failover_mode=(type=select)(method=basic)(backup=failover)), which means 
whenever failover occurs, the connected session will failover to the 
net_service_name failover again.  A backup should be specified when using 
PRECONNECT to pre-establish connections.  For details of TAF, please refer to 
Oracle official documentations.


Methodology for the testing
1. You should always start with a simple setup and then move towards 
more complicated one.
2. After you start the listener and instance, verify the output from 
'lsnrctl services' first.  'lsnrctl status' alone does not provide you with 
sufficient info whether or not you have the correct setup.  If ‘lsnrctl 
services’ output is incorrect.  STOP!  Correct the listener.ora or init.ora 
before you continue.  
3. Test the connections from the server for the client-side-load-balancing, 
verify it with the verify.sql provided here.  You can comment out the sql 
you do not need.
4. Test the connections from the server for the server side listerener 
connection load balance, verify it.
5. Test the TAF connections from the server, verify the failover_type and
failover_mothod before shutting down the instance or rebooting the server. 


===============================================================================
Before you start the testing, you can create a loop.sh file with the following
lines repeated as many times as you like.  In my testing, I repeat 512 times 
connection.  Please replace username, password and net_service_name accordingly.

loop.sh
nohup sqlplus su/su@failover @verify.sql &
   sleep 1
nohup sqlplus su/su@failover @verify.sql &
   sleep 1
nohup sqlplus su/su@failover @verify.sql &
   sleep 1
nohup sqlplus su/su@failover @verify.sql &
   sleep 1


verify.sql (to verify the connection)
REM  set pagesize 1000
REM  the following query is for TAF connection verification
col sid format 999
col serial# format 9999999
col failover_type format a13
col failover_method format a15
col failed_over format a11
select sid, serial#, failover_type, failover_method, failed_over
  from v$session where username = 'SU';

REM  the following query is for load balancing verification
select instance_name from v$instance;
exit

REM you can also combine two queries:
col inst_id format 999
col sid format 999
col serial# format 9999999
col failover_type format a13
col failover_method format a15
col failed_over format a11

select inst_id, sid, serial#, failover_type, failover_method, failed_over
  from gv$session where username = 'SU';

REM  a simple select to see the distribution of users when testing connection 
REM  load balancing

select inst_id, count(*) from gv$session group by inst_id;

To run the test, simply type './loop.sh', the output will go to nohup.out.

===============================================================================

Client Side Connect Time Load Balancing



Testing
For client side connect time load balancing testing only, without server side 
listener connection load balancing, please remove the remote_listener in the 
init.ora file and restart all instances.  There will be no remote instances 
registered to the listener.  You will only find the local server for each 
instance.  

hprac-22 'lsnrctl service' 
Service "rac" has 1 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-23 'lsnrctl service' 
Service "rac" has 1 instance(s).
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "rac2" has 1 instance(s).
  Instance "rac2", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-24 'lsnrctl service' 
Service "rac" has 1 instance(s).
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "rac3" has 1 instance(s).
  Instance "rac3", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-25 'lsnrctl service' 
Service "rac" has 1 instance(s).
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "rac4" has 1 instance(s).
  Instance "rac4", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


Simply run the './loop.sh' script, and check the output periodically.

> grep rac1 nohup.out | wc -l
28
> grep rac2 nohup.out | wc -l
28
> grep rac3 nohup.out | wc -l
22
> grep rac4 nohup.out | wc -l
17


> grep rac1 nohup.out | wc -l
87
> grep rac2 nohup.out | wc -l
72
> grep rac3 nohup.out | wc -l
73
> grep rac4 nohup.out | wc -l
63


> grep rac1 nohup.out | wc -l
147
> grep rac2 nohup.out | wc -l
126
> grep rac3 nohup.out | wc -l
133
> grep rac4 nohup.out | wc -l
106


After the testing completes, in this particular test, there were 147 
connections go to rac1, 126 connections go to rac2, 133 connections go to 
rac3 and 106 connections go to rac4.  This gives you a rough idea about 
the distribution of client side randomly selection among all 4 nodes.  

==============================================================================

Server Side Listener Connection Load Balancing Testing (combined with client 
side connect time load balancing)

Server side listener connection load balancing is where the listener routes 
the connections to the least-loaded instance.  Please add back remote_listener 
parameter in the init.ora file and restart all 4 instances.  Remember to 
verify the output of ‘lsnrctl services’.  The node1 'lsnrctl services' output 
looks like (I have eliminiated "MODOSE" and "PLSExtProc" service output to 
make it easier to read):

hprac-22 $ lsnrctl services

LSNRCTL for HPUX: Version 9.0.1.3.0 - Production on 06-JUN-2002 19:44:17

Copyright (c) 1991, 2001, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
Services Summary...
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
      "D002" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-22, pid: 27840>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-22)(PORT=62235))
         (PRESENTATION=oracle.aurora.server.SGiopServer)(SESSION=RAW))
      "D001" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-22, pid: 27838>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-22)(PORT=62234))
         (PRESENTATION=oracle.aurora.server.GiopServer)(SESSION=RAW))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
      "D002" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-23, pid: 16911>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-23)(PORT=51212))
         (PRESENTATION=oracle.aurora.server.SGiopServer)(SESSION=RAW))
      "D001" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-23, pid: 16909>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-23)(PORT=51211))
         (PRESENTATION=oracle.aurora.server.GiopServer)(SESSION=RAW))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
      "D002" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-24, pid: 27815>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-24)(PORT=52409))
         (PRESENTATION=oracle.aurora.server.SGiopServer)(SESSION=RAW))
      "D001" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-24, pid: 27813>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-24)(PORT=52408))
         (PRESENTATION=oracle.aurora.server.GiopServer)(SESSION=RAW))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
      "D002" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-25, pid: 5081>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-25)(PORT=53755))
         (PRESENTATION=oracle.aurora.server.SGiopServer)(SESSION=RAW))
      "D001" established:0 refused:0 current:0 max:2026 state:ready
         DISPATCHER <machine: hprac-25, pid: 5079>
         (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-25)(PORT=53754))
         (PRESENTATION=oracle.aurora.server.GiopServer)(SESSION=RAW))
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully
$

Note: Comparing this to the 'lsnrctl status' output below, you will find the
above provides much more information.  Please note that for an instance on its
own node, i.e. rac1 on node1 (hprac-22), you should have both local server and
remote server.  For all other remote instances, i.e. rac2, rac3 and rac4 on 
node1 (hprac-22), you will only find the remote server.  Under the remote 
server, please make sure the address listed is correct, no null hostname.
(ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
                        ^^^^^^^^^^^^^

hprac-22 $ lsnrctl status

LSNRCTL for HPUX: Version 9.0.1.3.0 - Production on 06-JUN-2002 19:45:14

Copyright (c) 1991, 2001, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for HPUX: Version 9.0.1.3.0 - Production
Start Date                15-MAY-2002 15:33:41
Uptime                    22 days 4 hr. 11 min. 33 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /oracle/9iship/rac901/network/admin/listener.ora
Listener Log File         /oracle/9iship/rac901/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hprac-22)(PORT=1521)))
Services Summary...
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 4 handler(s) for this service...
  Instance "rac2", status READY, has 3 handler(s) for this service...
  Instance "rac3", status READY, has 3 handler(s) for this service...
  Instance "rac4", status READY, has 3 handler(s) for this service...
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


Example of 'lsnrctl services' output from hprac-23, hprac-24, hprac-25.  
To make it easier to read, I have eliminated the aurora dispatchers info.  


hprac-23 $ lsnrctl services

LSNRCTL for HPUX: Version 9.0.1.3.0 - Production on 06-JUN-2002 19:44:15
Copyright (c) 1991, 2001, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
Services Summary...
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
   Instance "rac2", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SER   (ADc-25)(PORT=1521))
Service "rac2" has 1 instance(s).
  Instance "rac2", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully
$

hprac-24 $ lsnrctl services

LSNRCTL for HPUX: Version 9.0.1.3.0 - Production on 06-JUN-2002 19:44:14
Copyright (c) 1991, 2001, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
Services Summary...
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
   Instance "rac3", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac3" has 1 instance(s).
  Instance "rac3", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully
$


hprac-25  $ lsnrctl services

LSNRCTL for HPUX: Version 9.0.1.3.0 - Production on 06-JUN-2002 19:43:20
Copyright (c) 1991, 2001, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
Services Summary...
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac4" has 1 instance(s).
  Instance "rac4", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


===============================================================================
Simply run the './loop.sh' script again.  You can also periodically check the 
results.

After the testing completes, in this particular test, there were 182 
connections go to rac1, 109 connections go to rac2, 153 connections go to 
rac3 and 68 connections go to rac4.  This output combines both client side 
load balancing (randomly selected) and the server side listener connection 
load balancing.
  
> grep rac1 nohup.out | wc -l
182
> grep rac2 nohup.out | wc -l
109
> grep rac3 nohup.out | wc -l
153
> grep rac4 nohup.out | wc -l
68

You can safely assume that node1 had the least CPU load, therefore, most 
connections went to rac1.  Node4 had the heaviest CPU load, therefore, least 
connections went to rac4.  

After the testing, you can check 'lsnrctl services' from all 4 nodes again:
hprac-22 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:182 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
   Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:47 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
   Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:23 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-23 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:58 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:109 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
   Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:50 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
   Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:22 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac2" has 1 instance(s).
  Instance "rac2", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-24 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:65 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
   Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:39 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:153 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:23 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac3" has 1 instance(s).
  Instance "rac3", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully



hprac-25 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:55 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:32 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:48 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:68 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac4" has 1 instance(s).
  Instance "rac4", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

===============================================================================

Server Side Listener Connection Load Balancing Only Testing
If you prefer, you can eliminate the client side connect time load balance by 
removing or commenting out (LOAD_BALANCE = yes) and check the distribution of 
the server side listener connection load balance only.

RAC_no_client_side_load_balance =
  (DESCRIPTION =
#      (LOAD_BALANCE = yes)
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-22)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-23)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-24)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hprac-25)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = rac)
    )
  )

In this case, all connections will go to hprac-22 listener and hprac-22 
listener will route to the other instances based on the last updated load 
information updated by PMON.  

The result is 
> grep rac1 nohup.out | wc -l
189
> grep rac2 nohup.out | wc -l
106
> grep rac3 nohup.out | wc -l
105
> grep rac4 nohup.out | wc -l
112

After the testing completes, in this particular test, there were 189 
connections go to rac1, 106 connections go to rac2, 105 connections go to 
rac3 and 112 connections go to rac4.  This gives you a rough idea about 
the distribution of server side listener connection load balancing among 
all 4 nodes.  You can compare it with the previous two tests.  


hprac-22 ‘lsnrctl services’
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:189 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:106 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:105 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:112 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-23 ‘lsnrctl services’
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
      "DEDICATED" established:106 refused:0 state:ready
         LOCAL SERVER
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac2" has 1 instance(s).
  Instance "rac2", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-24 ‘lsnrctl services’
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
      "DEDICATED" established:105 refused:0 state:ready
         LOCAL SERVER
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
Service "rac3" has 1 instance(s).
  Instance "rac3", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


hprac-25 ‘lsnrctl services’
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-22)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-23)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-24)(PORT=1521))
  Instance "rac4", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))
      "DEDICATED" established:112 refused:0 state:ready
         LOCAL SERVER
Service "rac4" has 1 instance(s).
  Instance "rac4", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

You will also notice that from hprac-22 ‘lsnrctl service’ output, it has all 4
instances established connection count info.  However, the other 3 nodes only 
have it’s own instance established connection count info.  It’s due to no 
client side load balancing (load_balance=on), all connections go to hprac-22 
listener (first one in the address_list) and hprac-22 listener routes to the 
other instances.  

===============================================================================

Common misconception

If you want to have remote instances registered with the listener, even if 
your listener is using port 1521, you still need to have local_listener in 
your init.ora file.  Otherwise, with remote_listener="LISTENERS_RAC" alone, 
you will not get the remote instances registered with the listener and no 
server side listener connection load balancing.  This is due to Bug 2194549, 
fixed at 10i.  Let’s remove all local_listener parameters from the init.ora 
file and restart all 4 nodes, to see what will happen.  Please note the (HOST=)
under REMOTE SERVER.  

If you are not using the default port 1521, it’s required that you have 
local_listener in the init.ora file.  If your hostname output is your 
interconnect ip address as opposed to the public ethernet ip address, PMON 
process will register the service and instance with the hostname’s listener.  
In this case, you should also specify the local_listener parameter to 
instruct the PMON to register the service and instance with the public 
ethernet ip address listener. 

hprac-22 'lsnrctl service'
 (Similar output will be found for hprac-23, hprac-24, hprac-25)
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
                                ^^^^^^^
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
                                ^^^^^^^
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
                                ^^^^^^^
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
                                ^^^^^^^
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


Since the remote instances registered with NULL hostname, only 1 out of 4 
connections (4 nodes configuration) will go thru (via local server) and the 
others will fail with ORA-12502.  The following test was using the 
net_service_name RAC with (load_balance = yes).  

> grep rac1 nohup.out | wc -l
30
> grep rac2 nohup.out | wc -l
33
> grep rac3 nohup.out | wc -l
32
> grep rac4 nohup.out | wc -l
33
> grep 12502 sqlnet.log | wc -l
384

In this particular testing, 384 output 512 connections failed. Among the 
successful connections, 30 connections go to rac1, 33 connections go to rac2, 
32 connections go to rac3, and 33 connections go to rac4.  On the client 
side sqlnet.log file you will find the following error messages:

***********************************************************************
Fatal NI connect error 12502, connecting to:
 (DESCRIPTION=(enable=broken)(ADDRESS=(PROTOCOL=TCP)(HOST=hprac-25)(PORT=1521))(
CONNECT_DATA=(service_name=rac)(failover_mode=(type=select)(method=basic))(CID=(
PROGRAM=)(HOST=opcbhp1)(USER=usupport))))

  VERSION INFORMATION:
        TNS for HPUX: Version 9.0.1.3.0 - Production
        TCP/IP NT Protocol Adapter for HPUX: Version 9.0.1.3.0 - Production
  Time: 06-JUN-2002 19:27:25
  Tracing not turned on.
  Tns error struct:
    nr err code: 0
    ns main err code: 12564
    TNS-12564: TNS:connection refused
    ns secondary err code: 0
    nt main err code: 0
    nt secondary err code: 0
    nt OS err code: 0

The ora-12502 error is due to every connection going to node1 listener and 
it would try to route 3 out of 4 connections (4 nodes configuration) to the 
remote server with (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521)).  It does not 
know where, or which host to connect to.  

In this particular testing, for the failing 384 connections, 89 went to 
hprac-22 listener, 98 went to hprac-23 listener, 97 went to hprac-24 listener 
and 100 went to hprac-25 listener. Here was the statistics: 

> grep HOST=hprac-22 sqlnet.log | wc -l
89
> grep HOST=hprac-23 sqlnet.log | wc -l
98
> grep HOST=hprac-24 sqlnet.log | wc -l
97
>  grep HOST=hprac-25 sqlnet.log | wc -l
100

hprac-22 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:30 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac2", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:29 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:29 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:31 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
Service "rac1" has 1 instance(s).
  Instance "rac1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

hprac-23 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac2", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:32 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
Service "rac2" has 1 instance(s).
  Instance "rac2", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

hprac-24 'lsnrctl service'
Service "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:32 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac3", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:32 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac4", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:32 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
Service "rac3" has 1 instance(s).
  Instance "rac3", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s)d:0 refusecommice "rac" has 4 instance(s).
  Instance "rac1", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:34 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac2", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac3", status READY, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
  Instance "rac4", status READY, has 4 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:33 refused:0 state:ready
         LOCAL SERVER
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
Service "rac4" has 1 instance(s).
  Instance "rac4", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully


Caution:  If you are not running 9.0.1.3, for dedicated connection, server 
side load balancing will route most connections to one node, this is due to 
Bug 2134254.  The workaround is to add dispatchers="(pro=ipc)(dis=0)" in 
init.ora file.  

===============================================================================

Transparent Application Failover (TAF) testing

Please familiar yourself with WebIV Note 97926.1 - Failover Issues and 
Limitations [Connect-time failover and TAF] by Richard Powell for detailed 
explanation about TAF.  The following only demonstrate the transparent 
application failover testing.  

> sqlplus su/su@failover

SQL*Plus: Release 9.0.1.3.0 - Production on Thu Jun 6 19:44:57 2002
(c) Copyright 2001 Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.0.1.3.0 - 64bit Production
With the Partitioning and Real Application Clusters options
JServer Release 9.0.1.3.0 - Production

SQL> col sid format 999
SQL> col serial# format 9999999
SQL> col failover_type format a13
SQL> col failover_method format a15
SQL> col failed_over format a11
SQL> select sid, serial#, failover_type, failover_method, failed_over
     from v$session where username = 'SU';

       SID    SERIAL# FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
---------- ---------- ------------- --------------- -----------
        13          8 SELECT        BASIC           NO

If you see NONE under failover_type and failover_method, STOP!!  You need
to fix your tnsnames.ora file, it does not make sense to continue to test 
'shutdown abort' or reboot server.

SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
rac4

*** Due to the load balancing, we need to find out which instance it 
currently connects to.  Now, we can continue our TAF testing.  

SQL> select count(*) from
(select * from dba_source
union
select *  from dba_source
union
select *   from dba_source
union
select *    from dba_source
union
select *     from dba_source)
/

*** At this point, I ‘shutdown abort’ rac4 from another window.  The query
did not stop and the result should be back.  

COUNT(*)
----------
     60221

*** The query results is back without any error.  

SQL> col sid format 999
SQL> col serial# format 9999999
SQL> col failover_type format a13
SQL> col failover_method format a15
SQL> col failed_over format a11
SQL> select sid, serial#, failover_type, failover_method, failed_over
     from v$session where username = 'SU';

       SID    SERIAL# FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
---------- ---------- ------------- --------------- -----------
        13          5 SELECT        BASIC           YES

SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
rac1

*** Note here, it failed over to rac1 with different serial# and 
failed_over flag was set.
 
Restarted rac4, make this database back to 4 instances database.

SQL> select count(*) from
(select * from dba_source
union
select *  from dba_source
union
select *   from dba_source
union
select *    from dba_source
union
select *     from dba_source)
/

*** At this point, I ‘shutdown abort’ rac1 from another window.  The query 
did not stop and the result should be back.  


  COUNT(*)
----------
     60221
The query results is back without any error.  

SQL>          
    SID    SERIAL#    FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
---------- ---------- ------------- --------------- -----------
        14         20 SELECT        BASIC           YES

SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
rac2

*** Note here, it failed over to rac2 with different sid, serial# and 
failed_over flag was set.


Troubleshooting:

If there still is a problem, you should send the screen print out together 
with the following into to the support:

1. listener.ora, tnsnames.ora, sqlnet.ora files from all server nodes
2. 'lsnrctl services' output from all server nodes, please note: 
'lsnrctl status' output is not sufficient. 
3. init.ora, common.ora, and spfile converted init.ora if any, from all 
server nodes
4. in sql session, spool out the following info:
show parameter db_name
show parameter db_domain
show parameter service_name
show parameter instance_name
show parameter listener

5. ‘hostname’ output and /etc/hosts file or nslookup `hostname` output.
6. tnsnames.ora, sqlnet.ora files from the client side
7. sqlnet.log files from both client and server, listener.log file from the 
server
8. In sqlnet.ora files on both client and server, please set up the tracing 
parameters as follows and send us the sqlnet client/server trace files from 
both client and server sides.
trace_level_client = 16
trace_unique_client = on
# please provide a valid directory with write permission for the following 
parameter
trace_directory_client = /oracle/9iship/rac901/network/trace 
trace_level_server = 16
# please provide a valid directory with write permission for the following 
parameter
trace_directory_server = /oracle/9iship/rac901/network/trace  
trace_timestamp_client = on
trace_timestamp_server = on

9.  When you finish the testing, please make sure that you comment out the 
following two lines.  
# trace_level_client = 16
# trace_level

반응형
Posted by [PineTree]
OS/SOLARIS2007. 12. 7. 20:19
반응형

[sol9:root:/]# vmstat 1 2

 kthr      memory            page            disk          faults      cpu

 r b w   swap  free  re  mf pi po fr de sr f0 s0 s1 s2   in   sy   cs us sy id

 0 0 0 1795144 840456 4   9  0  1  0  0  0  0  2  0  0  515  152  167  0  0 100

 0 0 0 1790624 827744 1   9  0  8  0  0  0  0  1  0  0  511  272  170  0  0 100

kthr(proc)

프로세스 수와 그에 해당하는 데이터를 나타낸다.

r:           실행 가능한 상태로 대기 큐에 쌓인 프로세스 수 이 숫자가 크다는 것은 현재 cpu가 작업을 원활히 소화하지 못하고 있다는 의미이다.

             r=0                      white (cpu idle)

             0<r<3                  green (no problem)

             3<=r<=5 amber (cpu busy)

             5<r                     red (cpu busy)

b:          i/o 자원을 할당 받지 못해 블록된 프로세스

w:          swap-out 된 프로세스 수, 실행 가능한 대기 큐에는 쌓이지 않고 swap-out

             대기큐가 많다는 것은 physical 메모리 부족을 의미

memory

가상 메모리와 physical 메모리의 사용 가능량

swap:    현재 사용 가능한 스왑 크기

free:      현재 사용가능한 free 메모리 크기, free 메모리가 인스톨된 메모리의

             6% 보다 계속적으로 적으면 가용 메모리가 부족한 경우이고 잠재적 병목현상이다.

page

초당 발생하는 fault page 수와 실행중인 페이징 표시

Solaris에서 여유 있는 물리적 메모리를 화일 시스템의 캐쉬로 사용한다.

디폴트로 프리 메모리(free physical memory)가 전체 물리적 메모리 양의 1/64(lotsfree)보다 크면, 화일 시스템을 통한 디스크 I/O는 모두 메모리에 남겨두어 화일 시스템의 캐쉬로 사용한다. 프리 메모리가 물리적 메모리 양의 1/64보다 적으면, Solaris는 프리 메모리를 1/64로 채우기 위하여 시스템에 있는 페이지를 조사하여, 최근에 사용되지 않은 페이지를 찾아서 프리 시킨다.

 

re:         page reclaim 프리 메모리가 부족할 경우, paging이 발생하여 최근에 사용되지

않은 페이지를 찾아서 프리시켜 부족한 메모리를 보충하게 되는데, 이렇게 프리

되는 페이지의 내용은 훼손되지 않고 프리 메모리 영역에서 관리된다.

             이렇게 프리된 페이지가 프로세스의 요청에 따라 다시 사용될 수 있다.

             이렇게 다시 사용된 페이지 수를 re(reclaim)에 보여준다.

 

mf:         minor fault 프로그램을 실행할 경우에 운영체제는 프로세스에 대한 어드레스 맵핑

테이블을 만들고, 프로세스를 실행한다. 프로세스가 실행되다가 필요한 페이지가 자신의 어드레스 맵핑 테이블에 연결되어 있지 않으면, 페이지 폴트가 발생하는데, 그 페이지가 메모리에 있으면(minor page fault라고 함), 그 페이지를 자신의 어드레스 맵핑 테이블에 등록한다. vmstat mf(minor fault) minor page fault 횟수를 나타낸다.

pi:          page in(kb) Solaris에서 파일 시스템은 페이지 서브 시스템을 통하여 이루어 진다.

, 화일 시스템의 입출력은 모두 page I/O로 이루어 진다. 화일 시스템을 통하여 화일을 읽을 때, 읽은 양은 KB로 환산되어 pi(page in)에 보여준다.

po:        page out(kb)페이지를 프리시킬 페이지의 내용이 변경되었을 경우, 그 페이지를 disk에 저장한다. (변경된 페이지가 프로그램의 데이타일 경우, 스왑 파티션에 저장되고, 화일 시스템의 케쉬이면 해당 디스크 파티션에 저장된다.) 이때, 디스크에 저장된 페이지를 KB 환산하여 보여준다.

fr:          free(kb) 프리시킨 페이지 수는 KB 단위로 환산되어 fr(free)에 보여준다.

de:        short_term 메모리 부족분 즉 swap-in을 막기위해 swap-out 시에 설정된

             인공적인 메모리의 부족분이다.

sr:         clock 알고리즘에 의한 페이지 scanned. sr은 가용메모리 부족 시에 활성화된

페이지 데몬의 수를 나타낸다. sr이 크다는 것은 사용 가능 메모리가 부족하다는 것이다.

             sr=0                    white

             0<sr<200            green

             200<=sr<300       amber

             400<sr                red

disk

초당 디스크 조작 수

faults

초당 trap/interrupt 비율

in:          device interrupt(non clock)

sy:         초당 system fault

cs:        cpu context switch

cpu

cpu 사용 시간에 대한 백분율(%)

us:         사용자 사용 시간

sy:         시스템 사용 시간

id:          idle 시간

 

[sol9:root:/]# vmstat -s

       0 swap ins

       0 swap outs

       0 pages swapped in

       0 pages swapped out

  7377342 total address trans. faults taken

시스템 부팅 이후 현재까지 이벤트 출력

 

[sol9:root:/]# vmstat -S 1 2

 kthr      memory            page            disk          faults      cpu

 r b w   swap  free  si  so pi po fr de sr f0 s0 s1 s2   in   sy   cs us sy id

 0 0 0 1795136 840440 0   0  0  1  0  0  0  0  2  0  0  515  152  167  0  0 100

 0 0 0 1790616 827704 0   0  0  0  0  0  0  0  0  0  0  507   97  164  0  0 100

 

페이징 내용에 si so 추가 출력

 

si:          초당 swap-in된 페이지

so:        swap-out된 전체 프로세서 수

swap-in:             주기억 장치에서 어떤 작업을 실행하고 있는 동안 그 작업 보다 순위가 높은 작업수행이 필요하여 끼어들기 형태로 일을 해야 할 때 이미 실행 중인 프로그램과 데이터를 일시적으로 보조기억 장치에 옮기는 것

swap-out:           작업 종료 후 보조기억 장치에서 주기억 장치로 다시 프로그램과 데이터를 옮기는 것

 

[sol9:root:/]# vmstat -c 1 2

flush statistics: (interval based)

     usr     ctx     rgn     seg     pag     par

       0       0       0       0       0       0

       0       0       0       0       0       0

cache flushing 상태를 나타내는 것

시스템 부팅 후 현재까지 flush 캐시의 수를 나타낸다

 

usr:       user

ctx:        context

rgn:       region

seg:      segment

pag:       page

par:       partial-page

 

[sol9:root:/]# vmstat -i

interrupt         total     rate

--------------------------------

clock          83489951      100

hmec0            242802        0

fdc0                  9        0

--------------------------------

Total          83732762      100

 

각 디바이스의 인터럽트된 사항을 나타낸다.

반응형

'OS > SOLARIS' 카테고리의 다른 글

미러 디스크 장애시 디스크 교체하기  (0) 2009.05.07
samba  (0) 2008.02.28
솔라리스에서 xmanager 접속을 차단하거나, 통제하기  (0) 2007.11.17
sun ipmp 관련 정보 사이트들  (0) 2007.08.28
IPMP  (0) 2007.08.28
Posted by [PineTree]
ORACLE/ADMIN2007. 12. 7. 00:16
반응형


DATABASE LINK 사용 방법
=======================


먼저 한글 data간의 전달을 위해 두 db간의 character set이 같아야 합니다.
character set을 확인하는 방법은

sqlplus system/manager
select * from v$nls_parameters;
하여 보면 nls_characterset에 대한 값이 나옵니다.

 
  예를 위해 다음과 같은 환경을 가정하겠습니다.
    
           HOST NAME    :      HP7     -       SUN7      
      
           ORACLE_SID   :      ORA7   -    ORATEST 
    
  이라 할 때

  1)  HP7 에서 SUN7로 DB LINK 생성하기. 

 

      scott/tiger 로 Login

    SQL*NET V1의 경우
      SQL> create public database link  HP7TOSUN6
                connect to scott identified by tiger
                using 't:SUN7:ORATEST';

    (rdbms 7.3 이상은 SQL*NET v2 를 사용하십시오)


    SQL*NET V2의 경우

 

create [public |private] DATABASE LINK {사용할 링크 명}
 CONNECT TO {접속 아이디} IDENTIFIED BY {접속암호}using'연결문자열';   

 

 public 일 경우 모든 사용자가 사용할 수 있으며 pribate일 경우에는 생성한 사용자만 사용할 수있다.
 
 링크 이름을 지정하는 데 숫자가 먼저 올 수 없다.


      SQL> create public database link HP7TOSUN7
           connect to scott identified by tiger
           using 'ORATEST';

      로 하면 된다.

      이 때 V2인 경우의 ORATEST는 $ORACLE_HOME/network/admin/ directory의
      tnsnames.ora file 내에 지정된 service name이다.
      tnsnames.ora의 service name이 잘 setting 되어 있는지 확인하는 방법
      : SQL*Plus scott/tiger@service name했을 때, SQL*Plus에 log-in되어야
      합니다.
    

  2> SUN7 에 있는 TABLE의 select 및 view(view는 필요에 따라 생성) 작성,
     HP에서 작업
   
      SQL> select * from emp@HP7TOSUN7;

      SQL> create view emp_view as select *
           from emp@HP7TOSUN7 a
           where a.deptno = 10;
                   
  3> HP7 에서 SYNONYM을 생성하여 사용하는 경우

 

         SQL> create synonym emp for emp@HP7TOSUN7;
         SQL> select * from emp;

 

   로 한다면 간단히 분산 DB의 환경에서 사용할 수 있습니다.

  select를 제외한 DML(insert, update, delete)을 하려면,
  sql*plus log-in 시에 다음과 같은 option이 display 되어야 합니다.

  SQL*Plus: Release 3.3.3.0.0 - Production on Mon Jan 19 14:18:47 1998
  Copyright (c) Oracle Corporation 1979, 1996.  All rights reserved.

  Connected to:
  Oracle7 Server Release 7.3.3.4.0 with the 64-bit option - Production
  Release With the distributed, ......
  ------------------------------------

  remote 작업의 예

  select * from table_name@HP7TOSUN7;
  insert into table_name@HP7TOSUN7;
  delete table_name@HP7TOSUN7;
  ...

  (단 SERVER TO SERVER로 NETWORK 환경이 구축되어 있어야 하고,
  listener 가 반드시 떠 있어야 합니다.)

 

DATABASE LINK 삭제하기

 
 DROP [public|private\ database link {삭제할링크 명};

 

==db links 조회

 

==USER ACCOUNT

SELECT * FROM USER_DB_LINKS

 

--DBA ACCOUNT

SELECT * FROM DBA_DB_LINKS

 

/* NEW 오라클 테이블 비우기 */
select 'truncate table '||table_name||';' from user_tables;


 

/* NEW 오라클 노로깅 */
select 'alter table '||table_name||' nologging;' from user_tables ;


 

/* NEW 오라클 index drop */
select 'drop index '||object_name||';' from user_objects
where object_type = 'INDEX';


 

/* NEW 오라클 인서트  */
select 'insert /*+ append */ into '||table_name||' select * from '||table_name||'@dblinkname;'
from user_tables
where owner = 'KVDBA';


 


/* NEW 오라클 테이블 로깅으로 변경 */
select 'alter table '||table_name||' logging;' from user_tables;


덧글. 오라클이 CBO이면 analyze 를 수행할것을 권장...

반응형

'ORACLE > ADMIN' 카테고리의 다른 글

오라클 캐릭터 셋 변경(CHARACTER SET)  (0) 2008.04.02
오라클 파라미터 관련 사이트 링크  (0) 2007.12.13
oracle lock  (0) 2007.08.14
ORACLE relink  (0) 2007.08.07
Oradebug Command  (0) 2007.08.04
Posted by [PineTree]
OS/LINUX2007. 11. 21. 02:10
반응형

원본출처링크:

http://www.mojily.com/bbs/view.php?id=linux&no=189

 

 - iptables

 

iptables 명령어 실행시 시스템에 적용되는 시기

- iptables 명령어를 실행하면 재부팅하지 않더라도 즉시 시스템에 적용된다.

- iptables -A INPUT -s 0/0 -j DROP를 하면 그 즉시 모든 접속이 차단된다.

- iptables -D INPUT -s 0/0 -j DROP를 하면 그 즉시 접속 차단 명령이 삭제된다.

- iptables -L로 명령어가 시스템에 적용중인지 확인 가능



재부팅시 iptables 내용 보존하여 실행하기

1. 스크립트 파일 만들어서 실행

   1) cd /etc/sysconfig

      - 스크립트파일 만들어질 디렉토리로 이동 (다른 디렉토리에 만들어도 됨)

   2) touch iptablesscript

      - /etc/sysconfig디렉토리에 iptablesscript라는 파일이 생성됨

        (다른 파일명으로 만들어도 됨)

   3) vi /etc/sysconfig/iptablesscript

      - 만들어진 파일을 open

   4) /sbin/iptables -A INPUT -s 100.100.100.100 -j DROP

      /sbin/iptables -A OUTPUT -s 200.200.200.200 -j ACCEPT

      - 실행하고자 하는 내용을 입력

      - 맨 윗줄에 #! /bin/bash나 맨 아랫줄에 exit 0는 입력할 필요 없음

   5) chmod 700 iptablesscript

      - 실행가능한 파일로 속성을 변경

   6) vi /etc/rc.d/rc.local

      - 재부팅시 자동으로 실행되는 내용이 들어가도록 하는 rc.local파일을 open

   7) /etc/sysconfig/iptablesscript

      - rc.local파일의 맨 아랫줄에 입력

   8) 재부팅

2. /etc/rc.d/rc.local 파일에 직접 기록

   /sbin/iptables -A INPUT -s 100.100.100.100 -j DROP

   /sbin/iptables -A OUTPUT -s 200.200.200.200 -j ACCEPT

   위 두줄을 /etc/rc.d/rc.local파일 맨 아랫줄에 직접 입력

   (파일에 직접 기록하는 방식은 다른 자동 실행 파일이 있는 경우 혼동

    가능성이 있으므로 스크립트 파일로 만드는 것이 좋음)



iptables -A INPUT -s 200.200.200.1 -j DROP

200.200.200.1 이라는 source IP(-s)로부터 오는(INPUT) 모든 패킷을

막는(DROP) 규칙을 추가(A)한다.

* ACCEPT  : 패킷을 허용

* DENY    : 패킷을 허용하지 않는다는 메시지를 패킷을 보낸 PC에 돌려보냄

* DROP    : 패킷을 허용하지 않으며, 허용하지 않는다는 메시지 자체도 안보냄

* REJECT  : match된 경우 -------- 거절한다는 에러 메시지를 돌려보냄

            match되지 않은 경우 - DROP과 동일한 작동을 함

* INPUT   : 내가 외부의 패킷을 받을지 결정

          : INPUT을 막을 경우 외부에서 나한테 패킷을 보낼 수 없음

* OUTPUT  : 내가 외부에 패킷을 보낼지 결정

          : OUTPUT을 막을 경우 내가 외부에 패킷을 보낼 수 없음

* FORWARD : 내가 받을 패킷을 어디로 RELAY할지 결정



iptables -A INPUT -p tcp --sport 25 -j ACCEPT

25번이라는 source포트(--sport)에서 오는(INPUT) protocol이(-p) tcp인 모든 접속을

허락하는(ACCEPT) 규칙을 추가(A)한다.



iptables –A INPUT –s 200.200.200.1 –p tcp --destination-port telnet –j DROP
200.200.200.1 이라는 source IP(-s)로부터 오는(INPUT) protocol이(-p) tcp이고

목적지 port(--destination-port)가 telnet인 패킷의 접속을 막는(DROP) 규칙을

추가(A)한다.



iptables -A INPUT -i eth1 -s 192.168.1.0/24 -d 0/0 -j ACCEPT
192.168.1.0/24라는 source IP(-s)로부터 오는(INPUT)

서버안으로 들어오는 인터페이스(-i)가 eth1이고 destination IP(-d)가

어떤 IP라도(0/0) 접속을 허락하는(ACCEPT) 규칙을 추가(A)한다.

(서버자체에 대한 접속이 아니라 마스커레이딩등을 이용하여 랜카드 두 개를

장착한 경우 eth1에 연결된 내부 PC에서 외부로의 접속 허용)

* 0/0 : 모든 IP가 해당 (/뒤의 숫자는 서브넷마스크를 의미함)

  /8  = /255.0.0.0  (/8이나 /255.0.0.0 중 어느 것을 입력해도 같음)

  /9  = /255.128.0.0

  /18 = /255.192.0.0

  /24 = /255.255.255.0

  /27 = /255.255.255.224

  /28 = /255.255.255.240

  /29 = /255.255.255.248

  /30 = /255.255.255.252

* '/'다음에 숫자가 올 경우 비트가 1로 채워진 갯수를 의미하는데 /24인 경우

  왼쪽에서 24개의 비트가 1이다.

(11111111.11111111.11111111.00000000 = 255.255.255.0)

  따라서 192.168.1.0/24 는 192.168.1.0/255.255.255.0과 같다



iptables -A INPUT –p tcp --destination-port telnet –i ppp0 –j DROP

protocol이(-p) tcp이고 목적지 port(--destination-port)가 telnet이며,

서버안으로 들어오는 인터페이스(-i)가 ppp0인 패킷의 접속을 막는(DROP) 규칙을

추가(A)한다.



iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT

iptables -A INPUT -p icmp --icmp-type 8 -j REJECT

protocol이(-p) icmp이고 icmp 의 type이 echo-request인 패킷이 오는(INPUT) 것을

거절하는(REJECT) 규칙을 추가(A)한다.

(외부에서의 ping을 거절하는 방법임 / echo-request대신에 8을 해도 됨)

* icmp type

  number    name                        icmp 보낸 program

    0       echo-reply                  ping

    3       destination-unreachable     Any TCP/UDP traffic

    5       redirect                    routing if not running routing daemon

    8       echo-request                ping

   11       time-exceeded               traceroute

* echo-request : ping프로그램으로 사용자가 목적지 서버에 보내는 패킷

* echo-reply : echo-request에 대하여 목적지시스템이 사용자에게 회신하는 패킷



iptables -A INPUT -p tcp --dport 20:30 -j DROP
protocol이(-p) tcp이고 목적지 port(--dport)가 20번부터 30번까지인 패킷이

오는(INPUT) 것을 막는(DROP) 규칙을 추가(A)한다.



iptables -A INPUT -m state --state INVALID -j DROP
network상태가(state --state)가 INVALID인 패킷이 오는(INPUT) 것을

막는(DROP) 규칙을 추가(A)한다.

* -m : -match로 해도 됨 (match 여부로 패킷의 방향을 결정하는 옵션임)

* state --state INVALID     : 패킷이 network연결되어 있는지 모르는 상태

* state --state ESTABLISHED : 패킷이 network 연결되어 있는 상태

* state --state NEW         : 패킷이 network 새로 연결되어 있는 상태

* state --state RELATED     : 패킷이 network새로 연결되어 있으나 이미 연결되어

                              있는 network와 연관성이 있는 상태



iptables -A INPUT -p tcp --tcp-flags ACK ACK --dport 80

-m string --string "/default.ida?"

-j REJECT --reject-with tcp-reset

protocol이(-p) tcp이고 목적지가 80번 포트(--dport 80)로 오는(INPUT)

신호가 ACK이고 /default.ida?라는 문자열이 들어있는 패킷은

연결을 해제하고(tcp-reset) 거절하는(REJECT) 규칙을 추가(A)한다.

* tcp프로토콜의 접속 제어 flag

  - SYN (SYNchronize Sequence Numbers) : 연결을 요청하는 flag(신호)

  - ACK (Acknowledgement) : 알았다는 신호

  - RST (Reset) : 연결을 해제하는 신호

  - FIN (Finish) : 접속을 종료하고 전송을 끝내는 신호

* HOST A > (SYN) > HOST B > (SYN ACK) > HOST A > (ACK) > HOST B

  1) HOST A는 HOST B에 SYN을 보내 연결을 요청

  2) HOST B는 HOST A에 SYS ACK를 보내 연결을 허락한다고 회신

  3) HOST A는 HOST B에 ACK를 보냄으로써 연결이 이루어짐

* SYN,ACK,FIN,RST SYN : 앞의 네 개 FLAG인 SYN,ACK,FIN,RST를 검사하여

  맨뒤의 SYN의 방향을 결정함 (위의 명령어의 경우는 앞의 ACK만 검사하여

  뒤의 ACK의 방향을 결정함)

* 는 명령어가 길어 아랫줄로 계속 이어서 입력할 경우 사용

  는 backspace왼쪽의 기호 key임

  80과 사이에 하나의 공백이 있어야 함 공백이 없을 경우 80 -m이

  안되고 80-m으로 계속 이어지는 형태로 error발생

* --reject-with tcp-reset : RST 패킷을 돌려보내서 연결을 해제토록 함

* --reject-with icmp-net-unreachable   : error 메시지를 돌려보냄

* --reject-with icmp-host-unreachable  : error 메시지를 돌려보냄

* --reject-with icmp-port-unreachable  : error 메시지를 돌려보냄

* --reject-with icmp-proto-unreachable : error 메시지를 돌려보냄

* --reject-with icmp-net-prohibitedor  : error 메시지를 돌려보냄

* --reject-with icmp-host-prohibited   : error 메시지를 돌려보냄



iptables -A input -i eth0 -s 10.0.0.0/8 -d 0/0 -j DENY

iptables -A input -i eth0 -s 127.0.0.0/8 -d 0/0 -j DENY

iptables -A input -i eth0 -s 172.16.0.0/16 -d 0/0 -j DENY

iptables -A input -i eth0 -s 192.168.0.0/24 -d 0/0 -j DENY

외부에서 내부 네트워크 IP자격으로 접근하여 ip spoofing하는 것 방지



iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

IP 주소를 할당 받은후 (POSTROUTING) NAT 테이블에 (-t nat)

서버밖으로 나가는 인터페이스(-o)가 ppp0인 모든 패킷들이

마스쿼레이드 되도록 (-j MASQUERADE) 규칙을 추가(-A) 한다.

* ppp0는 활성화된 외부 디바이스(External Interface)가 유동IP인 경우이며,

  고정IP인 경우 ppp0대신에 eth0사용

  (/sbin/ifconfig를 이용하여 활성화된 외부 디바이스 확인 가능)



마스커레이딩

                                               ┌---- PC1 (192.168.0.6)

* 인터넷망 - SERVER LAN1 - SERVER LAN2 - HUB - |----- PC2 (192.168.0.7)

                                               └---- PC3 (195.168.0.8)

* 패킷 발송 절차

  - 패킷에는 발신지, 수신지 IP주소와 포트번호가 포함되어 있습니다.

  1) PC1에서 서버로 패킷 보냄

  2) 서버는 수신된 패킷의 원래 IP(192.168.0.6)와 포트번호를 내부에 저장

  3) 서버는 수신된 패킷에 외부연결된 IP 및 새로운 발신포트번호를 부여

     <일반적인 web은 80번 포트를 사용하지만 80이 아닌 새로운 발신포트를

      사용해도 일반적으로는 접속 가능합니다. 목적지 서버에서 웹서버만

      운영하기 위해 80포트만 열어놓는 것은 패킷의 발신포트(source port)가

      아닌 목적지 포트(destination port)를 80만 열어놓는 것이므로

      발신포트가 예를들면 100이라도 접속 가능>

  4) 패킷은 새로받은 IP와 포트번호로 외부로 나감

* 패킷 수신 절차

  1) 외부에서 서버로 패킷이 들어옴

  2) 서버는 패킷의 포트번호를 검사하여 PC1의 포트인지 확인후

     패킷에 원래 IP(192.168.0.6)와 포트번호를 부여

  3) 패킷은 PC1로 전달됨

* 유동(또는 고정) IP 한개인 서버를 통해 IP가 없는 PC에 인터넷 연결하는 방식

  /etc/rc.d/rc.local 의 하단에 아래 두줄 추가하여 구축 가능

  iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

  echo 1 > /proc/sys/net/ipv4/ip_forward  (ip_forward 파일의 내용을 1로

    바꿈으로써 ipforwarding이 가능하게 한다. vi /proc/sys/net/ipv4/ip_forward로

    보면 바꾸기 전에 기본으로는 0으로 되어 있음)

* PREROUTING  : 서버안으로 들어오는 패킷에 해당되며, 들어오는 인터페이서(-i)만

                선택 가능

  POSTROUTING : 서버밖으로 나가는 패킷에 해당되면, 나가는 인터페이서(-o)만

                선택 가능

* nat (Network Address Translation)

  - 패킷의 목적지나 시작점을 바꾸는 방법

  - 시작점 NAT(Source NAT) (SNAT) : 패킷의 시작점을 바꾸는 방법

    iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4

    (외부로 나가는 패킷의 출발지를 현재 내 PC의 IP주소인 200.200.200.200이

     아닌 1.2.3.4로 변경)

  - 목적지 NAT(Destination NAT) (DNAT) : 패킷의 목적지를 바꾸는 방법

    iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 51210 -j DNAT

    --to 192.168.0.2

    (외부에서 내부로 들어오는 패킷의 목적지를 내부 서브네트워크중 하나인

     192.168.0.2로 변경)

반응형

'OS > LINUX' 카테고리의 다른 글

yum  (0) 2008.02.11
[LINUX] bonding  (0) 2008.02.11
iptables  (0) 2007.11.21
리눅스 & 유닉스에서 화일 갯수 세기  (0) 2007.10.29
텔넷 putty ssh-keygen으로 자동 로그인하기  (0) 2007.10.26
Posted by [PineTree]