2010년 3월 1일 월요일

[ORACLE] 펌 오라클 관리 명령어 요약

출처 : http://blue1769.tistory.com/104#sess

 

순전히 이기적인 용도로 사용하기 위해 대충 만든 요약본입니다.
필요하신 분은 유용하게 사용하세요.
혹시나 옮겨가실 분은 댓글이라도 달아주세요. ^^

작성자 : mirsya
http://maktub.tistory.com
최종수정 2007년 2월 18일 일요일

※틀린 부분이나 수정이 필요 한 부분은 가차없이 알려주세요.
!! 오렌지색 부분은 환경에 맞게 수정하세요.
Oracle 9i / 10g 관리자 명령어 요약
  1. Startup / Shutdown
  2. Session
  3. Parameter File
  4. Control File
  5. Redo Log
  6. Tablespace
  7. Temporary Tablespace
  8. Undo Tablespace
  9. Database Buffer Cache
  10. Row Migration / Chaining
  11. Partitioned Table
  12. Deferred Constraints
  13. User
  14. Profile
  15. Privileges
  16. Role
  17. Export
  18. Import
  19. Direct Load
  20. Oracle Net - Host Naming
  21. Oracle Net - Local Naming
  22. Create DB - 9i
  23. Create DB - 10g
  24. Archive Log
STARTUP / SHUTDOWN
STARTUP
startup [ nomount | mount | open [ read only ]]
SHUTDOWN
shutdown [ immediate | transactional | normal | abort ]
상태 변경
alter database [ mount | open [ read only ]];
STARTUP 상태 조회
select status from v$instance;
OPEN 상태 조회
select open_mode from v$database;
>>Index<<
SESSION
제한 상태로 변경
alter system enable restricted session;
제한 상태 조회
select logins from v$instance;
사용자 SESSION 조회
select sid, serial#, username, status from v$session;
사용자 SESSION 강제종료
alter system kill session 'SID,SERIAL#';
RESTRICTED SESSION 권한 조회
select * from dba_sys_privs where privilege like '%RESTRICT%';
>>Index<<
PARAMETER FILE
파일구분
spfile : binaryfile, open 상태에서 수정
pfile : textfile, shutdown 상태에서 수정
파일생성
shutdown 상태에서 수행
create spfile from pfile;
create pfile from spfile;
SPFILE
alter system set parameter_name = 'value' [ comment 'text' ]
[ scope = memory | spfile | both ] [ sid = 'sid' | '*' ];
PFILE
shutdown 상태에서 편집기로 편집
>>Index<<
CONTROL FILE
SPFILE 사용시
open 상태에서 명령수행
alter system set control_files = '경로1', '경로2' scope = spfile;
콘트롤 파일 복사 후 DB 재기동
PFILE 사용시
shutdown 상태에서 pfile 파라미터 수정
콘트롤 파일 복사 후 DB 기동
>>Index<<
REDO LOG
LOGSWITCH
현재 사용하는 로그파일을 변경
alter system switch logfile;
CHECKPOINT
active 상태의 로그파일을 inactive로 변경
alter system checkpoint;
LOG FILE 상태 조회
select a.group#, a.member, b.bytes, b.status
from v$logfile a, v$log b
where a.group# = b.group#;
GROUP 추가
alter database add logfile group 그룹번호 '파일경로' size 크기;
alter database add logfile group 그룹번호 ('파일경로1', '파일경로2') size 크기;
MEMBER 추가
alter database add logfile member '파일경로' to group 그룹번호;
GROUP / MEMBER 삭제
alter database drop logfile group 그룹번호;
alter database drop logfile member '파일경로';
※삭제 명령시 파일은 삭제되지 않음
>>Index<<
TABLESPACE
TABLESPACE 조회
select tablespace_name, status, contents, extent_management, segment_space_management
from dba_tablespaces;
DATAFILE 조회
select tablespace_name, bytes, file_name from dba_data_files;
TEMPFILE 조회
select tablespace_name, bytes, file_name from dba_temp_files;
일반 TABLESPACE 생성
create tablespace 테이블스페이스명 datafile '파일경로' size 크기
[ blocksize 크기] // 해당 블럭 사이즈의 db_nk_cache_size 설정 필요
[ extent management local ] // 8i 이전 필수 옵션
[ segment space management auto ] // 9i 이후 필수 옵션;
UNDO TABLESPACE 생성
create undo tablespace 테이블스페이스명 datafile '파일경로' size 크기;
TEMPORARY TABLESPACE 생성
create temporary tablespace 테이블스페이스명 tempfile '파일경로' size 크기;
TABLESPACE 확장
alter tablespace 테이블스페이스명 add datafile '파일경로' size 크기;
alter database datafile '파일경로' resize 크기;
TABLESPACE 관리
alter tablespace 테이블스페이스명 offline;
alter tablespace 테이블스페이스명 online;
alter tablespace 테이블스페이스명 rename datafile '원본파일경로' to '파일경로';
TABLESPACE 삭제
drop tablespace 테이블스페이스명 including contents and datafile cascade constraints;
문법
CREATE TABLESPACE 테이블스페이스명
DATAFILE '파일경로1' SIZE integer [M/K], '파일경로2' SIZE integer [M/K]
[ MINIMUM EXTENT integer [M/K]]
[ BLOCKSIZE integer [K]] [ DEFAULT STORAGE (
INITIAL integer [M/K]
NEXT integer [M/K]
MAXEXTENTS integer
MINEXTENTS integer
PCTINCREASE integer)]
[ ONLINE | OFFLINE ]
[ PERMANENT | TEMPORARY ]
[ EXTENT MANAGEMENT [ DICTIONARY | LOCAL
[ AUTOALLOCATE | UNIFORM [ SIZE integer [M/K]]]]]
[ SEGMENT SPACE MANAGEMENT [ MANUAL | AUTO]]
OPEN 상태에서 DATAFILE 이동
alter tablespace 테이블스페이스명 offline;
offline 된 T/S에 대해 복사/이동 후
alter tablespace 테이블스페이스명 rename datafile '파일경로' to '파일경로';
alter tablespace 테이블스페이스명 online;
MOUNT 상태에서 DATAFILE 이동
startup mount;
해당 T/S에 대해 복사/이동 후
alter database rename file '파일경로' to '파일경로';
alter database open;
모든 데이타 파일은 mount상태에서 복사/이동 가능
system 파일은 mount상태에서만 복사/이동 가능
>>Index<<
TEMPORARY TABLESPACE
TEMPORARY TABLESPACE 관리
TEMPORARY T/S는 READ ONLY 설정 불가, nologgin 상태이며 rename불가, 복구대상이 아님
READ ONLY DATABASE 에서도 TEMPORARY 파일은 필요
DEFAULT TEMPORARY TABLESPACE 확인
select * from database_properties where property_name like '%TEMP%';
TEMPORARY TABLESPACE 변경
create temporary tablespace 테이블스페이스명_신 tempfile '파일경로' size 크기;
alter database default temporary tablespace 테이블스페이스명_신;
drop tablespace 테이블스페이스명_구;
>>Index<<
UNDO TABLESPACE
PARAMETER 설정 / 9i
UNDO_MANAGEMENT = AUTO [ MANUAL ]
UNDO_TABLESPACE = UNDOTBS1
UNDO_SUPPRESS_ERRORS = TRUE // 10g 에서는 쓰이지 않음
UNDO_RETENTION = integer (초)
PARAMETER 확인 / 9i
show parameter undo;
DEFAULT UNDO TABLESPACE 설정
alter system set undo_tablespace = 테이블스페이스명;
parameter 'UNDO_TABLESPACE' 수정
설정 조회
select segment_name, owner, tablespace_name, status
from dba_rollback_segs;
>>Index<<
DATABASE BUFFER CACHE
DBWR 기동 이벤트
Checkpoint - 일반적인 ckpt는 어디까지 내려썼는지만 확인 immediate ckpt시 즉시 내려씀
Dirty Block 임계값 도달
LRU List 의 Free Block 이 부족할 때
Time out
T/S offline (9i부터는 online시), read only, begin backup
Table Drop, Truncate
RAC ping
STANDARD BLOCK SIZE
System과 Temporary tablespace는 스탠다드 사이즈만 사용 가능
DB생성시 설정되는 표준 사이즈, 수정 불가(system T/S 가 이미 사용중이므로)
show parameter db_block_size
사용 가능한 BLOCK SIZE 조회
show parameter cache_size
db_nk_cache_size / n = '2, 4, 8, 16, 32'
DB_KEEP_CACHE_SIZE, DB_RECYCLE_CACHE_SIZE
hit rate 향상을 위한 parameter
db_keep_cache_size : 자주 호출되는 data를 pinning 할 때 쓰임
db_recycle_cache_size : 차후 호출될 가능성의 희박한 data를 읽을 때 쓰임
SGA 크기 조회
show parameter sga
show parameter sga_max
nk BLOCK SIZE의 TABLESPACE 생성
alter system set db_cache_size = 크기[M]; // SGA영역의 공간 확보를 위해 db_cache_size를 줄임
alter system set db_nk_cache_size = 크기[M]; // 줄여진 db_cache_size 만큼 할당 가능
create tablespace 테이블스페이스명 datafile '파일경로' size 크기 blocksize nk;
nk 블럭의 T/S가 존재하면 해당 db_nk_cache_size 를 0으로 설정 불가
>>Index<<
ROW MIGRATION / CHAINING
migration 은 해소 가능 chaining 은 해소 불가
오라클은 이 두 가지 경우를 구분하지 않음
TABLE 상태 확인
select owner, table_name, tablespace_name from dba_tables
where owner = '유저명' and table_name = '테이블명';
TABLE ANALYZE
analyze table 스키마.테이블명 compute statistics;
dictionary의 통계정보를 갱신시켜 주는 작업
CHAIN COUNT 조회
select num_rows, chain_cnt from dba_tables where table_name = '테이블명';
TABLE 이동
alter table 테이블명 move
[ tablespace 테이블스페이스명]; // 생략시 현재 사용중인 T/S 내에서 옮겨짐
INDEX 조회
select table_name, index_name, status from dba_indexes where table_name = '테이블명'
INDEX REBUILD
alter index 스키마.인덱스명 rebuild;
TABLE MOVE 명령후 ROWID가 변경됐으므로 INDEX를 REBUILD 해주어야 함
TABLE의 공간 사용량 조회
select num_rows, blocks, empty_blocks, avg_space, avg_row_ren from dba_tables
where owner = '유저명' and table_name = '테이블명';
BLOCKS : H/M 왼쪽 블럭 수
EMPTY_BLOCKS : 미사용 블럭 , H/M 오른쪽 블럭 수
AVG_SPACE : 사용중인 블럭의 평균 빈공간
AVG_ROW_LEN : row의 평균 길이
TABLE의 EXTENT설정 조회
select table_name, initial_extent, min_extents from dba_tables
where owner = '유저명' and table_name = '테이블명';
TABLESPACE의 EXTENT설정 조회
select tablespace_name, block_size, initial_extent, min_extents from dba_tablespaces
where tablespace_name = '테이블스페이스명';
>>Index<<
PARTITIONED TABLE
LIST 분할
create table table_name (column_1 type( ), column_2 type( ) ... )
partition by list (column_2) (
partition partition_name values ('value_1') tablespace tablespace_name,
partition partition_name values ('value_2') tablespace tablespace_name);
multi column partition 지원 안함
NULL 값 지정 가능, MAXVALUES 지정 불가
list를 구성하는 문자열은 4k 초과 불가
PARTITIONED TABLE 조회
select table_owner, table_name, partition_name, tablespace_name from dba_tab_partitions where table_owner = '유저명';
TABLE의 PARTITION 여부 조회
select owner, table_name, partitioned from dba_tables where owner = '유저명';
PARTITION 관리
alter table 테이블명 add partition partition_name values ('value') tablespace tablespace_name;
alter table 테이블명 drop partition partition_name;
RANGE 분할
create table table_name (column_1 type( ), column_2 type( ) ... )
partition by range (column_2) (
partition partition_name values less than (value_1),
partition partition_name values less than (value_2),
partition partition_name values less than ( MAXVALUE ) );
HASH 분할
create table table_name (column_1 type( ), column_2 type( ) ... )
partition by hash (column_2)
partitions integer store in (tablespace_name, tablespace_name);
>>Index<<
DEFERRED CONSTRAINTS
문법
CREATE TABLE table_name (column_1 type( ), column_2 type ( ), ...
CONSTRAINT constraint_name constraint_type (column)
[ NOT DEFERRABLE | DEFERRABLE [ INITIALLY [ IMMEDIATE | DEFERRED ]]]);
지연된 제약조건 활성화
ALTER SESSION SET CONSTRAINTS = [ IMMEDIATE | DEFERRED | DEFAULT ]
>>Index<<
USER
USER 생성
create user 유저명 identified by 패스워드
default tablespace 테이블스페이스명
temporary tablespace 임시테이블스페이스명
quota integer [M] on 유저명;
USER 변경
alter user 유저명 identified by 패스워드
default tablespace 테이블스페이스명
temporary tablespace 임시테이블스페이스명
quota integer [M] on 유저명
[ password expire ];
USER 의 TABLESPACE 할당량 조회
select * from dba_ts_quotas;
>>Index<<
PROFILE
PROFILE 조회
select distinct profile from dba_profiles;
USER 의 PROFILE 조회
select username, profile from dba_users;
PROFILE 생성
create profile profile_name limit
제한사항 value 제한사항 value ... ;
PROFILE 적용
alter user 유저명 profile profile_name;
PARAMETER 'resource_limit' 의 값이 TRUE로 설정되어 있어야 함
>>Index<<
PRIVILEGES
권한 부여 / SYSTEM PRIVS
grant 권한 to 유저명
[ with admin option ];
권한 부여 / OBJECT PRIVS
grant 권한 on 개체 to 유저명
[ with grant option ];
권한 조회
select * from dba_sys_privs where grantee like '유저명';
GRANT 조회 / TABLE
select * from all_tab_privs where table_name = '테이블명';
권한 취소 / SYSTEM PRIVS
revoke 권한 from 유저명;
권한 취소 / OBJECT PRIVS
revoke 권한 on 개체 from 유저명;
>>Index<<
ROLE
ROLE 의 PRIVS 조회
select * from dba_sys_privs where grantee = 'role_name';
ROLE 생성
create role role_name;
ROLE 에 SYSTEM PRIVS 부여
grant privs_name to role_name;
ROLE 에 OBJECT PRIVS 부여
grant privs_name on 개체 to role_name;
DEFAULT ROLE 지정
alter user user_name default role role_name;
ROLE 활성화
set role role_name;
set role all;
ROLE 조회
select * from session_roles;
>>Index<<
EXPORT
문법
]$ exp username/passwd option=(value1, value2, ... ) option=value ...
OPTION
  • file
    : 백업 파일명 지정 (default : expdat.dmp)
  • rows
    : 테이블의 row의 포함 여부 지정
  • full
    : 전체 DB에 대한 익스포트 지정
  • owner
    : 익스포트할 사용자 지정 (사용자모드)
  • table
    : 익스포트할 테이블 지정 (테이블모드)
  • tablespace
    : 익스포트할 테이블스페이스 지정 (T/S 모드)
  • inctype
    : 전체 백업 레벨 지정 (8i까지만 사용됨)
  • indexes
    : 인덱스 익스포트 지정
full, owner, table, tablespace 는 동시 사용 불가
익스포트시 sys로 작업은 지양 (dictionary data까지 포함되므로)
>>Index<<
IMPORT
문법
]$ imp username/passwd option=(value1, value2, ... ) option=value ...
OPTION
  • file
    : 입력 파일명 지정
  • ignore
    : 임포트 실행중 입력 오류 무시
  • rows
    : 테이블의 row의 포함 여부 지정
  • full
    : 전체 DB에 대한 임포트트 지정
  • fromuser
    : 익스포트된 객체를 소유한 사용자중 임포트 대상이 되는 사용자
  • touser
    : 임포트할 대상이 되는 사용자
  • table
    : 임포트할 테이블 지정
  • tablespace
    : 임포트할 테이블스페이스 지정
임포트 작업시 실행 순서 : 새로운 테이블생성 / 데이터 입력, 인덱스 리빌드 / 제약조건 활성화
>>Index<<
DIRECT LOAD
DIRECT LOAD SAMPLE
sample.ctl
LOAD DATA INFILE * INTO TABLE table_name
FIELDS TERMINATED BY ',' (column1, column2, column3)
BEGINDATA
111,aa,95
112,ab,86
...
...

]$ sqlldr username/passwd sample.ctl
>>Index<<
ORACLE NET / HOST NAMING
HOST NAMING
port 번호등의 정보를 Client에게 제공하지 않음
다수의 DB를 운용하는 경우는 사용할 수 없음
GLOBAL_DBNAME은 되도록이면 도메인 형식을 사용
(호스트명만 기입시 Windows Client 에서만 이용가능)
SERVER 설정 / LINUX
$ORACLE_HOME/network/admin/listener.ora
  • ora10g =
  • (ADDRESS_LIST =
  • (ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1521))
  • )
  • SID_LIST_ora10g =
  • (SID_LIST =
  • (SID_DESC = (GLOBAL_DBNAME = ora10g.xxx.xxx)
  • (ORACLE_HOME = /app/ora10g/10g)
  • (SID_NAME = DB09)
  • )
  • )
LISTENER 구동
]$ lsnrctl start ora10g
CLIENT 설정 / WINDOWS
GLOBAL_DBNAME 으로 ping이 되는지 확인, 필요시 hosts나 DNS에 등록
%ORACLE_HOME%\network\admin\sqlnet.ora
  • SQLNET.AUTHENTICATION_SERVICES= (NTS)
  • NAMES.DIRECTORY_PATH= (HOSTNAME)
C:\>sqlplus username/passwd@ora10g.xxx.xxx
CLIENT 설정 / LINUX
GLOBAL_DBNAME 으로 ping이 되는지 확인, 필요시 hosts나 DNS에 등록
$ORACLE_HOME/network/admin/sqlnet.ora
  • NAMES.DIRECTORY_PATH= (HOSTNAME)
]$ sqlplus username/passwd@ora10g.xxx.xxx
>>Index<<
ORACLE NET / LOCAL NAMING
LOCAL NAMING
port 번호등 서버정보를 Client가 가지고 있음
SERVER 설정 / LINUX
$ORACLE_HOME/network/admin/listener.ora
  • ora10g =
  • (ADDRESS_LIST =
  • (ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1521))
  • )
  • SID_LIST_ora10g =
  • (SID_LIST =
  • (SID_DESC = (ORACLE_HOME = /app/ora10g/10g)
  • (SID_NAME = DB09)
  • )
  • )
다수의 DB가 존재 할 경우 각 DB의 listner port번호는 다르게 설정한다
LISTENER 구동
]$ lsnrctl start ora10g
각각의 DB에 해당하는 listener.ora 파일을 생성하고 listener를 각각 구동한다
CLIENT 설정 / NAMES.DEFAULT_DOMAIN 미설정 시
sqlnet.ora
  • NAMES.DIRECTORY_PATH= (TNSNAMES)
tnsnames.ora
  • ora9i =
  • (DESCRIPTION =
  • (ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1529))
  • (CONNECT_DATA = (SID = DB09))
  • )
  • ora10g =
  • (DESCRIPTION =
  • (ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1521))
  • (CONNECT_DATA = (SID = DB10))
  • )
]$ sqlplus username/passwd@ora10g
]$ sqlplus username/passwd@ora9i
CLIENT 설정 / NAMES.DEFAULT_DOMAIN 설정 시
TCP/IP 에서의 DOMAIN과 관계 없음
sqlnet.ora
  • NAMES.DEFAULT_DOMAIN= webdb.co.kr
  • NAMES.DIRECTORY_PATH= (TNSNAMES)
tnsnames.ora
  • ora9i.webdb.co.kr =
  • (DESCRIPTION =
  • (ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1529))
  • (CONNECT_DATA = (SID = DB09))
  • )
  • ora10g.webdb.co.kr =
  • (DESCRIPTION =
  • (ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1521))
  • (CONNECT_DATA = (SID = DB10))
  • )
]$ sqlplus username/passwd@ora10g
]$ sqlplus username/passwd@ora9i
]$ sqlplus username/passwd@ora10g.webdb.co.kr
>>Index<<
DATABASE 생성 / 9i
ENV CHECK
]$ env | grep ORACLE
기존 파일 삭제
$ORACLE_BASE/oradata/
$ORACLE_BASE/admin/$ORACLE_SID/
PARAMETER FILE 편집
$ORACLE_HOME/dbs/initSID_name.ora
DB 생성
createdb.sql
  • CREATE DATABASE $ORACLE_SID
  • LOGFILE
  • GROUP 1 ('$ORACLE_BASE/oradata/disk4/redo01.log') size 1M,
  • GROUP 2 ('$ORACLE_BASE/oradata/disk4/redo02.log') size 1M,
  • GROUP 3 ('$ORACLE_BASE/oradata/disk4/redo03.log') size 1M
  • MAXLOGFILES 5
  • MAXLOGMEMBERS 5
  • MAXDATAFILES 100
  • DATAFILE
  • '$ORACLE_BASE/oradata/disk3/system01.dbf' size 300M
  • EXTENT MANAGEMENT LOCAL
  • UNDO TABLESPACE undo DATAFILE
  • '$ORACLE_BASE/oradata/disk3/undo01.dbf' size 10M
  • DEFAULT TEMPORARY TABLESPACE temp TEMPFILE
  • '$ORACLE_BASE/oradata/disk3/temp01.dbf' size 10M
  • CHARACTER SET KO16KSC5601
  • ;
  • @$ORACLE_HOME/rdbms/admin/catalog.sql
  • @$ORACLE_HOME/rdbms/admin/catproc.sql
  • conn system/manager;
  • @$ORACLE_HOME/sqlplus/admin/pupbld.sql
]$ sqlplus '/as sysdba'
SQL> startup nomount
SQL> @createdb.sql
>>Index<<
DATABASE 생성 / 10g
ENV CHECK
]$ env | grep ORACLE
기존 파일 삭제
$ORACLE_BASE/oradata/
$ORACLE_BASE/admin/$ORACLE_SID/
PARAMETER FILE 편집
$ORACLE_HOME/dbs/initSID_name.ora
DB 생성
createdb.sql
  • CREATE DATABASE $ORACLE_SID
  • LOGFILE
  • GROUP 1 ('$ORACLE_BASE/oradata/disk4/redo01.log') size 4M,
  • GROUP 2 ('$ORACLE_BASE/oradata/disk4/redo02.log') size 4M,
  • GROUP 3 ('$ORACLE_BASE/oradata/disk4/redo03.log') size 4M
  • MAXLOGFILES 5
  • MAXLOGMEMBERS 5
  • MAXDATAFILES 100
  • DATAFILE
  • '$ORACLE_BASE/oradata/disk3/system01.dbf' size 300M
  • EXTENT MANAGEMENT LOCAL
  • SYSAUX DATAFILE
  • '$ORACLE_BASE/oradata/disk3/sysaux01.dbf' size 200M
  • UNDO TABLESPACE undo DATAFILE
  • '$ORACLE_BASE/oradata/disk3/undo01.dbf' size 10M
  • DEFAULT TEMPORARY TABLESPACE temp TEMPFILE
  • '$ORACLE_BASE/oradata/disk3/temp01.dbf' size 10M
  • CHARACTER SET KO16KSC5601
  • ;
  • @$ORACLE_HOME/rdbms/admin/catalog.sql
  • @$ORACLE_HOME/rdbms/admin/catproc.sql
  • conn system/manager;
  • @$ORACLE_HOME/sqlplus/admin/pupbld.sql
]$ sqlplus '/as sysdba'
SQL> startup nomount
SQL> @createdb.sql
>>Index<<
ARCHIVE LOG MODE
DB 종료
SQL> shutown immediate
Parameter File 수정
  • log_archive_start = true
  • log_archive_dest = destination
  • log_archive_format = %S.arc
다수의 아카이빙
  • log_archive_duplex_dest = destination
  • log_archive_min_succed_dest = [ 1 | 2 ]
  • log_archive_dest_# = "location = destination"
  • log_archive_dest_# = "service = tnsname"
DB 기동 / 아카이브 모드 변경
SQL> startup mount
SQL> alter database archivelog; SQL> startup open
아카이브 모드 확인 후 Close Backup
SQL> archive log list
>>Index<<

 

[아파치] httpd.conf 설정 환경

출처 : httpd.conf 설정 환경 (아파치)

 

ServerType standalone

아파치데몬의 실행방법을 결정한다.
inetd / standalone 두가지 구동방식이 있으며, 아파치 데몬은 standalone 방식으로 구동되는게 좋다.
standalone 방식은 독립적으로 데몬을 실행시킨다는 의미이며,커널에서 웹 데몬이 프로세스로 작동중이어서 외보로부터의 요청에 즉각적으로 응답을 할수있다.반면 항상 프로세스가 떠있으므로 시스템 자원의 낭비를 가져올수도있다.
inetd 방식은 inetd라는 슈퍼데몬에 의해서 모든 서비스가 관리된다.
만약 외부로부터 ftp 요청이 들어오면 inetd 데몬은 이 서비스의 성격을 파악하고이에 맞는 ftp 데몬을 호출하여 응답하도록한다.telnet,named,sendmail 등이 inetd데몬에 속하며 웹데몬을 inetd 방식을 사용할경우 반응속도의 저하밑 하나의 데몬을 제시작하기위해서 inetd 전체의 데몬에 영향을 주는것이 단점이다.

Server Root "/usr/local/apach"

웹서버에 관련된 환경설정 파일,에러 파일,로그 파일들이 존재하는 디렉토리 위치를 지정한다. 경로의 마지막에 / 를 절대로 붙여서는 안됀다.

#LockFile /usr/local/apache/logs/httpd.lock

아파치를 컴파일할때USE_FCNTL_SERIALIZED_ACCEPT or USE_FLOCK_SERIALIZED_ACCEPT
로 컴파일했을경우 사용되는 잠금파일의 위치를 지정한다.
default는 비 활성화이다.

PidFile /usr/local/apache/logs/httpd.pid

서버가 실행될때 프로세스의 ID,즉 PID 값이 기록되는 위치를 지정한다.

ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard

이 지시자는 특정 플랫폼에서 아파치서버 프로세스간에 서로 통신하기 위해 특정한파일을 매개로 해야할 경우 사용된다.여러분의 서버가 이 파이을 사용하는지여 여부는 아파치 데몬을 실행시킬때 이 파일이 생기는지 확인하면된다.
만약 이 파일이 생긴다면, 각각의 아파치프로세스가 이 파일에 동시에 접근하여 이파일을 개방하는 일이없도록해야한다.

Timeout 300

클라이언트에게 타임아웃 신호를 보낼때까지의 기다리는 시간으로 단위는 초이다.

KeepAlive on

지속적인 접속 즉 한번 연결에 대하여 한번이상의 요청을 허용할것인가 아닌가를 결정한다.
어떤 유저가 서버에 접속하여 웹서핑을하다가 다른 페이지를 요청할때가 많다.이때처음부터 다시 connection이 이루어져야한다면 불필요한 일이 반복될것이다.
이것을 보완하기위해서 지속적인 connection을 유지할수있게한다.하지만 이 유지가무한정 유지되는것은 아니다.keepalive timeout에 설정된 시간만큼만의 유지만해준다.이 설정을 취소할려면 off 옵션을 사용하면된다.

MaxKeepAliveRequests 100

지속적인 접속동안에 허용할 최대 요청의 횟수를지정한다.
0 은 요청 횟수의 제한을 두지않는다는 말이다. 이 값이 높으면 웹서버의 성능에좋은 결과를 가져올것이다.

KeepAliveTimeout 15

지속저인 접속을 허용한 상태에서 15 초 동안 다음 요청이 없을경우 이접속을 해제한다.

MinSpareServers 5

아파치가 여기에 설정된 개수의 프로세스는 항상 남겨두도록한다.

MaxSpareServer 10

여기에 지정된 자식프로세스의 이상은 만들지 않는다.

StartServers 5

child 아파치 시작시 생성되는 서버의 프로세스의 수를 결정한다.
여러분이 아피치데몬을 시작하고 나서 ps aux | grep apache 하면 6 개의 프로세스가떠있는것을 확인할수있다. 이는 이 자식프로세스가 5개이고 최상위 아파치데몬이하나가 있다는것이다.

MaxClients 150

동시에 처리할수있는 클라이언트부터의 요청횟수를 제한한다.

MaxRequestPerChild 0

아파치서버에서 생성된 각각의 자식 프로세스는 여기에 설정된 횟수만큼 요청을 처리하고 자동으로 사라진다. 0 은 시스템이 재부팅될 때까지 계속 동작한다.

#Listen 3000

아파치에게 하나 이상의 IP 혹은 포트에 주의를 기울이라고 지정하는 것이다.
기본설정은 아파치가 모든 IP 주소의 PORT로 지정한 포트로부터의 모든 요청에 응답하도록 되어있다.그러므로 이 지시자는 아파치가 감시해야할 IP주소와 PORT의 쌍을한정하는 역활을한다.Listen 지시자는 여러번 사용할수있다.

Listen 80
Listen 8080

이렇게 설정하면 포트 80 번과 포트 8080 에서의 접속에 응답을할것이다.

Listen 192.168.0.1:80
Listen 192.168.0.2:8080

이렇게 설정하면 두개의 아이피와 포트에서 접속을 허용한다.

#BindAddress *

아파치가 해당시스템에 할당된 모든 IP 주소를 감시하지않고 위에 설정된 IP 주소만감시 하도록한다.

Port 80

bindaddress 혹은 listen이 없으면서 가 설정이되어있지 않을경우 아파치가 감시해야될 port 를 정의한다.

User nobody
Group nobody

아파치 요청에 대해 응답을할때 어떤 UID,GID를 가질것인지 규정한다.

ServerAdmin root@server

서버에 문제가 있을시 여기에 지정된 email로 메일을 보낸다.

ServerName server

서버의 호스트 이름을 지정한다. 이 지시자가 사용되지 않았을때 아파치는 시작시DNS 요청에 의해 호스트 이름을 정한다.

DocumentRoot "/usr/local/apache/htdocs"

아파치의 기본 웹문서 디렉토리를 지정한다.

AccessFileName .htaccess

이 지시자는 per-directory 접속 제어 파일의 이름을 지정한다.
아파치는 기본 설정에 의해 클라이언트 시스템에 의한 접속 요청을 받을때 마다 .htaccess 파일을 찾는다. 예를 들어 www.angelsoma.com 이라는 아파치 웹서버가 구축되어있다고 가정하면 클라이언트에서 www.angelsoma.com 이라는 도메인을 요청하게 되면 아파치는 아래의 순서로 기본 페이지를 찾는다.

/.htaccess
/usr/.htaccess
/usr/local/.htaccess
/usr/local/apache/.htaccess
/usr/local/apache/htdocs/.htaccess

아파치가 이모든 검사하며 제어 파일을 찾는다.만약 아파치 서버가이검사 과정을 거치지 않기를 원한다면 지시자에 AllowOverride None 옵션 설정을하면된다.

UserCanonicalName on

아파치가 자신을 가리키는 URL을 구성할것인지 제어한다.
예를 들어 http://angelsoma.com/~soma/index.html 에대한 요청을 http://angelsoma.com/~soma/index.html/ 로 리다이렉션을 할때 사용된다.
리다이렉션할때 사용되는 호스트 네임과 포트는 만약 UserCanonicalName 이 on 으로셋팅이 되어있아면 ServerName 과 port에 지정된 내용이적용되며, off 로 설정되어있다면 원래 요청에서 사용된 호스트네임과 포트가 적용된다.

Default Type text/plain

웹서버의 기본 컨텐츠를 정하는데 사용된다.

HostnameLookups off

만약 이 설정이 on 으로 되어있다면 아파치 웹서버는 요청이들어오는 모든 클라이언트의 hostname을 찾게되고, 이정보를 log 파일에 hostname을 남기게된다.
이 작업은 오랜시간이 걸릴수있으므로 웹서버에 부하는 줄수가있다. 그러므로 off로설정하는게 웹서버의 속도 향상에 도움을 줄것이다. 이 기능이 off 로되어있다면log 파일에는 ip 정보가 남게된다.

ErrorLog /usr/local/apache/logs/error_log

접속이 실패하였을경우 이 로그정보를 남길 위치를 지정한다.

CustomLog /usr/local/apache/logs/access_log common

웹서버에대한 요청이 정상적으로 처리되었을경우 남길 로그의 위치를 지정한다.

ServerSignature On

클라이언트가 프록시 환경에서 사용될때 자기 요청을 실제로 처리한서버가 어느서버인지 알아낼수있게한다. ServerSignature 는 서버가 생성한 문서의 끝부분에 서버의 버전과 버추얼 호스트에서 지정된 servername 등을 나타낸다.


   Options FollowSymLinks
   AllowOverride None


이 설정은 시스템의 전체 파일시스템에 적용되는 내용이다.


   Order allow,deny
   Deny from all


이 설정은 특정파일에 대해서 다른 지시자의 내용을 적용할때 사용한다.

#
#   SetHandler server-status
#   Order deny,allow
#   Deny from all
#   Allow from .your domain name


이 지시자는 특정 URL에 대해서 다른 지시자의 내용을 적용할때 사용된다.

Options 에 대한 설명

 All - MultiViews,IncludesNOEXEC,SymLinksIfOwnerMatch 를 제외한 모든옵션을
       활성화.
 ExecCGI - CGI스크립트를 사용할수 있도록 한다.
 FollowSymLinks - 심볼릭 링크 사용을 할수있게 한다.
 Includes - 서버측 포함기능(SSI)을 사용할수있으며 SSI를 사용하려면 이 옵션
       을 활성화 해야한다.
 IncludesNOEXEC - 서버측 포함 기능은 사용할수있으나 #exec,#include를 이용한
       CGI스크립트는 사용할수없다.
 Indexes - 고객의 디렉토리를 지정하는 URL로 접속했을때 index.html 파일이없
       으면 디렉토리 내용을 브라우저에서 출력한다.
 MultiViews - 컨텐츠 협상기능을 사용할수 있게한다.
 SymLinksIfOwnerMatch - 동일한 사용자의 소유로 설정된 심볼릭 링크만 허가함.

AllowOverride none  

 이 지시자를 통해 .htaccess 파일에 있는 지시자가 그 이전에 설정된 여러 지시
 자들을 무시하고 사용되도록 한다.
 
 Limit - 호스트명이나 IP 주소로 나타난 호스트들에 대한 접속제한을 재설정
 Options - Options 지시자에 대한 재설정을 허용한다.
 All - 위의 모든 것을 포함한다.
 None - 위에서 나열한 모든것도 포함하지 않는다.


AddHandler  cgi-script .cgi .pl

 이 지시자는 어떠한 파일이든 cgi,pl 확장자를가진다면 아파치 입장에서는 실행
 파일로 간주한다.

ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

 이 지시자는 지정한 URL 경로로의 요청을 디렉토리에 있는 CGI가 실행되게해준
 다.디렉토리는 절대 경로로 설정해야된다.

[리눅스] 즐겨찾기

리눅스 관련

http://blog.daum.net/warmfeel/105
http://www.linux.co.kr/  리눅스 포탈

 

아파치 참고 자료 즐겨찾기 WEB/WAS

[ORACLE] 11g RAC startup policy 변경(crs start시 instance자동 start 설정)

 

오랜만에 공부를 하려고 검색을 하니

무쟈게 잘된글이 많다.

 

항상 자연스럽게 여기고 그냥 넘어갔던것.

RAC 를 기본옵션으로 설치하면 항상 CRS가 올라오고 instance도 자동으로 올라온다.

요 설정을 어딘가에서 해주겠지,하며 그냥 넘어갔었는데, 관련글이 있어 첨부한다.

 

출처 : http://cafe.naver.com/dbknowlege/16

 

   

-- 현재 설정 확인

rac1@orcl1 : /home/oracle/script/sql> srvctl config database -d orcl -a
rac1 orcl1 /u01/app/oracle/product/11.1.0/db_1
rac2 orcl2 /u01/app/oracle/product/11.1.0/db_1
DB_UNIQUE_NAME: orcl
DB_NAME: null
ORACLE_HOME: /u01/app/oracle/product/11.1.0/db_1
SPFILE: null
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY:  AUTOMATIC
ENABLE FLAG: DB ENABLED
rac1@orcl1 : /home/oracle/script/sql>


-- 현재 지정되어 있는 POLICY를 변경

rac1@orcl1 : /home/oracle/script/sql> srvctl modify database -d orcl -y manual
rac1@orcl1 : /home/oracle/script/sql> srvctl config database -d orcl -a
rac1 orcl1 /u01/app/oracle/product/11.1.0/db_1
rac2 orcl2 /u01/app/oracle/product/11.1.0/db_1
DB_UNIQUE_NAME: orcl
DB_NAME: null
ORACLE_HOME: /u01/app/oracle/product/11.1.0/db_1
SPFILE: null
DOMAIN: null
DB_ROLE: null
START_OPTIONS: null
POLICY:  manual
ENABLE FLAG: DB ENABLED

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

policy에 manual , automatic이  대/소문자를 구분할까요??

자세한 내용은 http://cafe.naver.com/dbknowlege/에서 확인하세요.

 

 

[ORACLE] Using srvctl to Manage your 10g RAC Database

SRVCTL 운영상에서 실제로 써본적은 한번도 없다.

 

왜 안쓰는지는. ..ㅠㅠ 글쎄...

 

sqlplus에서 shutdown을 직접 쳐줘야 느낄수 있는 희열감?

내지는 눈으로 직접 close, dismount 단계별로 내려가는걸 봐야 하는 안도감? 이랄까?

 

잘 정리된 글이 있어 퍼온다.

 

 

출처 : http://www.orafaq.com/node/70

Using srvctl to Manage your 10g RAC Database

Natalka Roshak's picture

Oracle recommends that RAC databases be managed with srvctl, an Oracle-supplied tool that was first introduced with 9i RAC. The 10g version of srvctl is slightly different from the 9i implementation. In this article, we will look at how -- and why -- to manage your 10g databases with srvctl.

RAC Architecture Overview

Let's begin with a brief overview of RAC architecture.

  • A cluster is a set of 2 or more machines (nodes) that share or coordinate resources to perform the same task.
  • A RAC database is 2 or more instances running on a set of clustered nodes, with all instances accessing a shared set of database files.
  • Depending on the O/S platform, a RAC database may be deployed on a cluster that uses vendor clusterware plus Oracle's own clusterware (Cluster Ready Services), or on a cluster that solely uses Oracle's own clusterware.

Thus, every RAC sits on a cluster that is running Cluster Ready Services. srvctl is the primary tool DBAs use to configure CRS for their RAC database and processes.

Cluster Ready Services and the OCR

Cluster Ready Services, or CRS, is a new feature for 10g RAC. Essentially, it is Oracle's own clusterware. On most platforms, Oracle supports vendor clusterware; in these cases, CRS interoperates with the vendor clusterware, providing high availability support and service and workload management. On Linux and Windows clusters, CRS serves as the sole clusterware. In all cases, CRS provides a standard cluster interface that is consistent across all
platforms.

CRS consists of four processes (crsd, occsd, evmd, and evmlogger) and two disks: the Oracle Cluster Registry (OCR), and the voting disk.

CRS manages the following resources:

  • The ASM instances on each node
  • Databases
  • The instances on each node
  • Oracle Services on each node
  • The cluster nodes themselves, including the following processes, or "nodeapps":
    • VIP
    • GSD
    • The listener
    • The ONS daemon

CRS stores information about these resources in the OCR. If the information in the OCR for one of these resources becomes damaged or inconsistent, then CRS is no longer able to manage that resource. Fortunately, the OCR automatically backs itself up regularly and frequently.

Interacting with CRS and the OCR: srvctl

srvctl is the tool Oracle recommends that DBAs use to interact with CRS and the cluster registry. Oracle does provide several tools to interface with the cluster registry and CRS more directly, at a lower level, but these tools are deliberately undocumented and intended only for use by Oracle Support. srvctl, in contrast, is well documented and easy to use. Using other tools to modify the OCR or manage CRS without the assistance of Oracle Support runs the risk of damaging the OCR.

Using srvctl

Even if you are experienced with 9i srvctl, it's worth taking a look at this section; 9i and 10g srvctl commands are slightly different.

srvctl must be run from the $ORACLE_HOME of the RAC you are administering. The basic format of a srvctl command is

srvctl <command> <target> [options]

where command is one of

enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config

and the target, or object, can be a database, instance, service, ASM instance, or the nodeapps.

The srvctl commands are summarized in this table:

Table 1. Summary of srvctl commands.
Command Targets Description
srvctl add
srvctl modify
srvctl remove
database
instance
service
nodeapps
srvctl add / remove adds/removes target's configuration information to/from the OCR.

srvctl modify allows you to change some of target's configuration information in the OCR without wiping out the rest.

srvctl relocate service Allows you to reallocate a service from one named instance to another named instance.
srvctl config database
service
nodeapps
asm
Lists configuration information for target from the OCR.
srvctl disable
srvctl enable
database
instance
service
asm
srvctl disable disables target, meaning CRS will not consider it for automatic startup, failover, or restart. This option is useful to ensure an object that is down for maintenance is not accidentally automatically restarted.

srvctl enable reenables the specified object.

srvctl getenv
srvctl setenv
srvctl unsetenv
database
instance
service
nodeapps
srvctl getenv displays the environment variables stored in the OCR for target.

srvctl setenv allows these variables to be set, and unsetenv unsets them.

srvctl start
srvctl status
srvctl stop
database
instance
service
nodeapps
asm
Start, stop, or display status (started or stopped) of target.

As you can see, srvctl is a powerful utility with a lot of syntax to remember. Fortunately, there are only really two commands to memorize: srvctl -help displays a basic usage message, and srvctl -h displays full usage information for every possible srvctl command.

Examples

Example 1. Bring up the MYSID1 instance of the MYSID database.

[oracle@myserver oracle]$ srvctl start instance -d MYSID -i MYSID1

Example 2. Stop the MYSID database: all its instances and all its services, on all nodes.

[oracle@myserver oracle]$ srvctl stop database -d MYSID

Example 3. Stop the nodeapps on the myserver node. NB: Instances and services also stop.

[oracle@myserver oracle]$ srvctl stop nodeapps -n myserver

Example 4. Add the MYSID3 instance, which runs on the myserver node, to the MYSID
clustered database.

[oracle@myserver oracle]$ srvctl add instance -d MYSID -i MYSID3 -n myserver

Example 4. Add a new node, the mynewserver node, to a cluster.

[oracle@myserver oracle]$ srvctl add nodeapps -n mynewserver -o $ORACLE_HOME -A 
149.181.201.1/255.255.255.0/eth1

(The -A flag precedes an address specification.)

Example 5. To change the VIP (virtual IP) on a RAC node, use the command

[oracle@myserver oracle]$ srvctl modify nodeapps -A new_address

Example 6. Find out whether the nodeapps on mynewserver are up.

[oracle@myserver oracle]$ srvctl status nodeapps -n mynewserver
VIP is running on node: mynewserver
GSD is running on node: mynewserver
Listener is not running on node: mynewserver
ONS daemon is running on node: mynewserver

Example 7. Disable the ASM instance on myserver for maintenance.

[oracle@myserver oracle]$ srvctl disable asm -n myserver

Debugging srvctl

Debugging srvctl in 10g couldn't be easier. Simply set the SRVM_TRACE environment variable.

[oracle@myserver bin]$ export SRVM_TRACE=true

Let's repeat Example 6 with SRVM_TRACE set to true:

[oracle@myserver oracle]$ srvctl status nodeapps -n mynewserver
/u01/app/oracle/product/10.1.0/jdk/jre//bin/java -classpath 
/u01/app/oracle/product/10.1.0/jlib/netcfg.jar:/u01/app/oracle/product/10.1.0/jdk/jre//lib/rt.jar:
/u01/app/oracle/product/10.1.0/jdk/jre//lib/i18n.jar:/u01/app/oracle/product/10.1.0/jlib/srvm.jar:
/u01/app/oracle/product/10.1.0/jlib/srvmhas.jar:/u01/app/oracle/product/10.1.0/jlib/srvmasm.jar:
/u01/app/oracle/product/10.1.0/srvm/jlib/srvctl.jar 
-DTRACING.ENABLED=true -DTRACING.LEVEL=2 oracle.ops.opsctl.OPSCTLDriver status nodeapps -n 
mynewserver
[main] [19:53:31:778] [OPSCTLDriver.setInternalDebugLevel:165]  tracing is true at level 2 to 
file null
[main] [19:53:31:825] [OPSCTLDriver.<init>:94]  Security manager is set
[main] [19:53:31:843] [CommandLineParser.parse:157]  parsing cmdline args
[main] [19:53:31:844] [CommandLineParser.parse2WordCommandOptions:900]  parsing 2-word 
cmdline
[main] [19:53:31:866] [GetActiveNodes.create:212]  Going into GetActiveNodes constructor...
[main] [19:53:31:875] [HASContext.getInstance:191]  Module init : 16
[main] [19:53:31:875] [HASContext.getInstance:216]  Local Module init : 19
...
[main] [19:53:32:285] [ONS.isRunning:186]  Status of ora.ganges.ons on mynewserver is true
ONS daemon is running on node: mynewserver
[oracle@myserver oracle]$

Pitfalls

A little impatience when dealing with srvctl can corrupt your OCR, ie, put it into a state where the information for a given object is inconsistent or partially missing. Specifically, the srvctl remove command provides the -f option, to allow you to force removal of an object from the OCR. Use this option judiciously, as it can easily put the OCR into an inconsistent state.

Restoring the OCR from an inconsistent state is best done with the assistance of Oracle Support, who will guide you in using the undocumented $CRS_HOME/bin/crs_* tools to repair it. The OCR can also be restored from backup.

Error messages

srvctl errors are PRK% errors, which are not documented in the 10gR1 error messages manual. However, for those with a Metalink account, they are documented on Metalink here.

Conclusion

srvctl is a powerful tool that will allow you to administer your RAC easily and effectively. In addition, it provides a valuable buffer between the DBA and the OCR, making it more difficult to corrupt the OCR.

 

[oracle] Oracle NLS 정리 문서

 Oracle DBMS를 사용하면서 수 많은 개발자들이 한번쯤은 접하게되는 문제가 "지금 운영중인 DB의 캐릭터셋 설정때문에 한자, 혹은 특정 한글 문자의 입력이 안되는게 당연합니다. 지금 캐릭터셋을 바꾸면 Data가 깨질수도 있어요."라는 DBA의 답변...이다.
 이런말 하기는 참 싫지만 내가 설치한 DB도 아니고... 새로 구축하는 DB면 이렇게 설치 안 하겠는데... 암튼...
(사실 이렇게 말해놓고는 지난번에 설치한 DB는 이 회사 왕고참 과장님의 의견(기존에 사용하던 DB와 캐릭터셋이 같아야 한다는...)에 따라서 KSC5601로 설치했다. 아~ 소신대로 살기 참 힘들죠~잉~)

OTN에 NLS관련 내용을 정리한 문서가 있어서 소개합니다. 언젠간 저도 이런 곳에 문서를 올릴 수 있는 능력자가 될 수 있기를...

보러가기
오라클과 NLS의 찰떡궁합 들여다보기(1)
오라클과 NLS의 찰떡궁합 들여다보기(2)

출처 : http://www.hyungjun.kr/256

[아이폰] 설치할 어플들

RSS (http://www.voiceportal.co.kr/894)

ikorway 3.0

smartSMS