본문 바로가기
스터디북

[09/09] admin 4일차 실습

by 파이어볼러 2015. 9. 10.

[oracle@lnx04 ~]$ emctl status dbconsole

Environment variable ORACLE_UNQNAME not defined. 

Please set ORACLE_UNQNAME to database unique name.


[oracle@lnx04 ~]$ cat /u01/app/oracle/product/11.2.0/db_1/install/portlist.ini

Enterprise Manager Console HTTP Port (orcl) = 1158

Enterprise Manager Agent Port (orcl) = 3938


[oracle@lnx03 ~]$ . oraenv

ORACLE_SID = [orcl] ? prod

The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle

[oracle@lnx03 ~]$ echo $ORACLE_SID

prod

[oracle@lnx03 ~]$ cd $ORACLE_HOME

[oracle@lnx03 db_1]$ ls

apex         emcli                    md           precomp

assistants   EMStagePatches_orcl      mesg         racg

bin          has                      mgw          rdbms

ccr          hs                       network      relnotes

cdata        ide                      nls          root.sh

cfgtoollogs  install                  oc4j         scheduler

clone        install.platform         odbc         slax

config       instantclient            olap         sqldeveloper

crs          inventory                ons          sqlj

csmig        j2ee                     OPatch       sqlplus

css          javavm                   opmn         srvm

ctx          jdbc                     oracore      sysman

cv           jdev                     oraInst.loc  timingframework

dbs          jdk                      ord          ucp

dc_ocm       jlib                     oui          uix

deinstall    ldap                     owb          utl

demo         lib                      owm          wwg

diagnostics  lnx03.ocmkorea.com_orcl  perl         xdk

dv           log                      plsql



[oracle@lnx03 db_1]$ emca -deconfig dbcontrol db -repos drop


STARTED EMCA at Sep 9, 2015 10:03:29 AM

EM Configuration Assistant, Version 11.2.0.0.2 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.


Enter the following information:

Database SID: prod

Listener port number: 1521

Password for SYS user:

Password for SYSMAN user:

Password for SYSMAN user:

Do you wish to continue? [yes(Y)/no(N)]: y

Sep 9, 2015 10:04:51 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/emca_2015_09_09_10_03_29.log.

Sep 9, 2015 10:04:51 AM oracle.sysman.emcp.EMConfig perform

SEVERE: Database instance unavailable.

Refer to the log file at /u01/app/oracle/cfgtoollogs/emca/emca_2015_09_09_10_03_29.log for more details.

Could not complete the configuration. Refer to the log file at /u01/app/oracle/cfgtoollogs/emca/emca_2015_09_09_10_03_29.log for more details.

[oracle@lnx03 db_1]$ emca -deconfig dbcontrol db -repos drop


STARTED EMCA at Sep 9, 2015 10:06:59 AM

EM Configuration Assistant, Version 11.2.0.0.2 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.


Enter the following information:

Database SID: prod

Listener port number: 1521

Password for SYS user:

Password for SYSMAN user:


Do you wish to continue? [yes(Y)/no(N)]: y

Sep 9, 2015 10:07:11 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/prod/emca_2015_09_09_10_06_59.log.

Sep 9, 2015 10:07:11 AM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration

WARNING: EM is not configured for this database. No EM-specific actions can be performed.

Sep 9, 2015 10:07:11 AM oracle.sysman.emcp.ParamsManager checkListenerStatusForDBControl

WARNING: Error initializing SQL connection. SQL operations cannot be performed

Sep 9, 2015 10:07:11 AM oracle.sysman.emcp.EMReposConfig invoke

INFO: Dropping the EM repository (this may take a while) ...

Sep 9, 2015 10:10:08 AM oracle.sysman.emcp.EMReposConfig invoke

INFO: Repository successfully dropped

Enterprise Manager configuration completed successfully

FINISHED EMCA at Sep 9, 2015 10:10:08 AM



[oracle@lnx03 admin]$ vi sqlnet.ora 

[oracle@lnx03 admin]$ emca -config dbcontrol db -repos create


STARTED EMCA at Sep 9, 2015 10:41:22 AM

EM Configuration Assistant, Version 11.2.0.0.2 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.


Enter the following information:

Database SID: prod

Listener port number: 1521

Listener ORACLE_HOME [ /u01/app/oracle/product/11.2.0/db_1 ]: 

Password for SYS user:  

Password for DBSNMP user:  

Password for SYSMAN user:  

Email address for notifications (optional): 

Outgoing Mail (SMTP) server for notifications (optional): 

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


You have specified the following settings


Database ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/db_1


Local hostname ................ lnx03.ocmkorea.com

Listener ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/db_1

Listener port number ................ 1521

Database SID ................ prod

Email address for notifications ............... 

Outgoing Mail (SMTP) server for notifications ............... 


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

Do you wish to continue? [yes(Y)/no(N)]: Y

Sep 9, 2015 10:41:40 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/prod/emca_2015_09_09_10_41_22.log.

Sep 9, 2015 10:41:40 AM oracle.sysman.emcp.EMReposConfig createRepository

INFO: Creating the EM repository (this may take a while) ...

Sep 9, 2015 10:46:50 AM oracle.sysman.emcp.EMReposConfig invoke

INFO: Repository successfully created

Sep 9, 2015 10:46:55 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository

INFO: Uploading configuration data to EM repository (this may take a while) ...

INFO: Database Control secured successfully.

Sep 9, 2015 10:48:53 AM oracle.sysman.emcp.util.DBControlUtil startOMS

INFO: Starting Database Control (this may take a while) ...

Sep 9, 2015 10:49:42 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration

INFO: Database Control started successfully

Sep 9, 2015 10:49:42 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration

INFO: >>>>>>>>>>> The Database Control URL is https://lnx03.ocmkorea.com:5500/em <<<<<<<<<<<

Sep 9, 2015 10:49:45 AM oracle.sysman.emcp.EMDBPostConfig invoke

WARNING: 

************************  WARNING  ************************


Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /u01/app/oracle/product/11.2.0/db_1/lnx03.ocmkorea.com_prod/sysman/config/emkey.ora.   Please ensure this file is backed up as the encrypted data will become unusable if this file is lost. 


***********************************************************

Enterprise Manager configuration completed successfully

FINISHED EMCA at Sep 9, 2015 10:49:45 AM


[oracle@lnx03 admin]$ emca -reconfig ports -DBCONTROL_HTTP_PORT 9462


STARTED EMCA at Sep 9, 2015 10:50:43 AM

EM Configuration Assistant, Version 11.2.0.0.2 Production

Copyright (c) 2003, 2005, Oracle.  All rights reserved.


Enter the following information:

Database SID: prod

Password for SYS user:  

Password for SYS user:  

Do you wish to continue? [yes(Y)/no(N)]: Y 

Sep 9, 2015 10:50:52 AM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/prod/emca_2015_09_09_10_50_42.log.

Sep 9, 2015 10:50:52 AM oracle.sysman.emcp.util.DBControlUtil stopOMS

INFO: Stopping Database Control (this may take a while) ...

Sep 9, 2015 10:51:12 AM oracle.sysman.emcp.util.DBControlUtil startOMS

INFO: Starting Database Control (this may take a while) ...

Sep 9, 2015 10:51:45 AM oracle.sysman.emcp.EMDBPostConfig performReconfiguration

INFO: Database Control started successfully

Sep 9, 2015 10:51:45 AM oracle.sysman.emcp.EMDBPostConfig performReconfiguration

INFO: >>>>>>>>>>> The Database Control URL is https://lnx03.ocmkorea.com:9462/em <<<<<<<<<<<

Enterprise Manager configuration completed successfully

FINISHED EMCA at Sep 9, 2015 10:51:45 AM

[oracle@lnx03 admin]$ emctl start dbconsole

Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0 

Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.

https://lnx03.ocmkorea.com:9462/em/console/aboutApplication

 - An instance of Oracle Enterprise Manager 11g Database Control is already running. 

[oracle@lnx03 admin]$ 


orcl@SYS> select username, server from v$session;


USERNAME                       SERVER

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

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

                               DEDICATED

SYS                            DEDICATED

                               DEDICATED

                               DEDICATED

SYSMAN                         DEDICATED

SYSMAN                         DEDICATED

SYSMAN                         DEDICATED

SYS                            DEDICATED

SYSMAN                         DEDICATED

SYSMAN                         DEDICATED

                               DEDICATED

DBSNMP                         DEDICATED

SYS                            DEDICATED

SYSMAN                         DEDICATED

SYSMAN                         DEDICATED

SYSMAN                         DEDICATED

DBSNMP                         DEDICATED

                               DEDICATED

SYS                            DEDICATED

DBSNMP                         DEDICATED


orcl@SYS> show parameter spfile


NAME                                 TYPE        VALUE

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

spfile                               string      /u01/app/oracle/product/11.2.0

                                                 /db_1/dbs/spfileorcl.ora

orcl@SYS> create pfile from spfile;


File created.




[oracle@lnx03 dbs]$ cd /u01/app/oracle/admin/orcl/pfile/

[oracle@lnx03 pfile]$ ls

init.ora.772015175949



orcl@SYS> create pfile='/BACKUP/pfile/initorcl.bak' from spfile;


File created.


파라메터가 바뀔때마다 백업하는 습관 필요



orcl@SYS> startup pfile=/BACKUP/pfile/initorcl.bak

ORACLE instance started.


Total System Global Area  619360256 bytes

Fixed Size                  1338280 bytes

Variable Size             461374552 bytes

Database Buffers          150994944 bytes

Redo Buffers                5652480 bytes

Database mounted.

Database opened.

orcl@SYS> show parameter spfile


NAME                                 TYPE        VALUE

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

spfile                               string

orcl@SYS>


orcl@SYS> show parameter workarea


NAME                                 TYPE        VALUE

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

workarea_size_policy                 string      AUTO


orcl@SYS> select logins from v$instance;


LOGINS

----------

ALLOWED


orcl@SYS> alter system enable restricted session;


System altered.


orcl@SYS> select logins from v$instance;


LOGINS

----------

RESTRICTED


orcl@SYS> alter system disable restricted session;


System altered.


Elapsed: 00:00:00.00

orcl@SYS> select logins from v$instance;


LOGINS

----------

ALLOWED


orcl@SYS> startup nomount

ORACLE instance started.


Total System Global Area  619360256 bytes

Fixed Size                  1338280 bytes

Variable Size             461374552 bytes

Database Buffers          150994944 bytes

Redo Buffers                5652480 bytes

orcl@SYS> select status from v$instance;


STATUS

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

STARTED


Elapsed: 00:00:00.12

orcl@SYS> alter database mount;


Database altered.


Elapsed: 00:00:04.22

orcl@SYS> select status from v$instance;


STATUS

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

MOUNTED


Elapsed: 00:00:00.00

orcl@SYS> alter database open;


Database altered.


Elapsed: 00:00:00.97

orcl@SYS> select status from v$instance;


STATUS

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

OPEN


orcl@SYS> help startup


 STARTUP

 -------


 Starts an Oracle instance with several options, including mounting,

 and opening a database.


 STARTUP options | upgrade_options


 where options has the following syntax:

    [FORCE]abort후startup

    [RESTRICT] 제한모드 접속

    [PFILE=filename] pfile접속 

    [QUIET] 

    [ MOUNT [dbname] |

    [ OPEN [open_options] 

    [dbname] ] |

    NOMOUNT ]


 where open_options has the following syntax:

    READ {ONLY | WRITE [RECOVER]} | RECOVER


startup open read write 기본값


 and where upgrade_options has the following syntax:

    [PFILE=filename] {UPGRADE | DOWNGRADE} [QUIET]



orcl@SYS> help shutdown


 SHUTDOWN

 --------


 Shuts down a currently running Oracle Database instance, optionally

 closing and dismounting a database.


 SHUTDOWN [ABORT|IMMEDIATE|NORMAL|TRANSACTIONAL [LOCAL]]



[oracle@lnx03 ~]$ adrci


ADRCI: Release 11.2.0.1.0 - Production on Wed Sep 9 12:42:09 2015


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


ADR base = "/u01/app/oracle"


alert과 trace를 통합해서 관리

DB  SID

cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace/



 

sid = testdb


[oracle@exp04 dbs]$ vi initorcl.ora


db_name=orcl

control_files='/u01/app/oracle/oradata/orcl/control01.ctl'

#memory_target = 800M

sga_max_size=400M

sga_target=400M

processes = 250

db_block_size=8192

db_domain=''

open_cursors=300

remote_login_passwordfile='EXCLUSIVE'

undo_tablespace='UNDOTBS1'

undo_management='AUTO'

compatible='11.2.0.1.0'



[oracle@exp04 ~]$ vi credb.sql

create database orcl

user sys identified by oracle

user system identified by oracle

logfile group 1 ('/u01/app/oracle/oradata/orcl/redo01a.log') size 100M reuse,

        group 2 ('/u01/app/oracle/oradata/orcl/redo02a.log') size 100M reuse,

        group 3 ('/u01/app/oracle/oradata/orcl/redo03a.log') size 100M reuse

MAXLOGFILES 5

MAXLOGMEMBERS 5

MAXLOGHISTORY 1

MAXDATAFILES 100

MAXINSTANCES 1

CHARACTER SET AL32UTF8

NATIONAL CHARACTER SET AL16UTF16

EXTENT MANAGEMENT LOCAL

DATAFILE '/u01/app/oracle/oradata/orcl/system01.dbf' size 50M reuse autoextend on

sysaux datafile '/u01/app/oracle/oradata/orcl/sysaux01.dbf' size 50M reuse autoextend on

default tablespace users

datafile '/u01/app/oracle/oradata/orcl/users01.dbf' size 50M reuse autoextend on

default TEMPORARY TABLESPACE TEMP

TEMPFILE '/u01/app/oracle/oradata/orcl/temp01.dbf' size 20M reuse

undo tablespace UNDOTBS1

datafile '/u01/app/oracle/oradata/orcl/undotbs01.dbf' size 200M reuse autoextend on maxsize unlimited;


SQL> select instance_name, status from v$instance;

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

TESTDB open


-- 내부 dictionary 및 package 설치 script 실행

-- vi dbinstall.sql

@@$ORACLE_HOME/rdbms/admin/catalog.sql  

@@$ORACLE_HOME/rdbms/admin/catproc.sql

@@conn system/oracle

@@$ORACLE_HOME/sqlplus/admin/pupbld.sql


SQL> @dbinstall.sql


SYS@testdb>select tablespace_name,extent_management from dba_tablespaces;


TABLESPACE_NAME                EXTENT_MAN

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

SYSTEM                         DICTIONARY

SYSAUX                         LOCAL

UNDOTBS1                       LOCAL

TEMP                           LOCAL


4 rows selected.