Oracle Study之-Oracle 11g OCM考試(1)

來源:互聯網
上載者:User

標籤:oracle

Oracle Study之-Oracle 11g OCM考試(1)

系統內容:RedHat EL64

Oracle:   Oracle 11gR2

      Oracle 11g OCM考試第一題,手工建庫,參考文檔650) this.width=650;" src="http://img.blog.csdn.net/20160408214710987?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" style="border:none;" />。參考人員必須對文檔非常熟悉,才可以在指定的時間內完成任務。


一、查看系統內容

[[email protected] ~]$ cat .bash_profile

# .bash_profileexport EDITOR=viexport ORACLE_SID=prodexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1export LD_LIBRARY_PATH=$ORACLE_HOME/libexport PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/binumask 022

[[email protected] ~]$ id oracle
uid=300(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
2、建立資料庫pfile檔案
[[email protected] dbs]$ pwd
/u01/app/oracle/product/11.2.0/db_1/dbs

[[email protected] dbs]$ ls
hc_DBUA3908922.dat  init.bk              inittest2.ora  lkTEST2           orapwtest2
hc_prod.dat         initDBUA3908922.ora  inittest.ora   orapwDBUA3908922  snapcf_prod.f
hc_test2.dat        init.ora             lkPROD         orapwprod         spfileprod.ora
hc_test.dat         initprod.ora         lkTEST         orapwtest         spfiletest2.ora
[[email protected] dbs]$ cat init.ora |grep -v "^#"|grep -v "^$" >inittest1.ora

編輯pfile檔案:
[[email protected] dbs]$ cat inittest1.ora

db_name=‘test1‘memory_target=300mprocesses = 150audit_file_dest=‘$ORACLE_BASE/admin/test1/adump‘audit_trail =‘db‘db_block_size=8192db_domain=‘‘diagnostic_dest=$ORACLE_BASEopen_cursors=300 remote_login_passwordfile=‘EXCLUSIVE‘undo_tablespace=‘UNDOTBS1‘control_files =‘/u01/app/oracle/oradata/test1/control01.ctl‘compatible =‘11.2.0‘

建立相應的目錄:
[[email protected] dbs]$ mkdir -p /u01/app/oracle/admin/test1/adump
[[email protected] dbs]$ mkdir -p /u01/app/oracle/oradata/test1
建立 Instance 口令檔案:
[[email protected] dbs]$ orapwd file=orapwtest1 password=oracle entries=3

建立建庫指令碼:

參考:

650) this.width=650;" src="http://img.blog.csdn.net/20160408215342983?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" style="border:none;" />
[[email protected] ~]$ cat cr_db.sql

CREATE DATABASE test1   USER SYS IDENTIFIED BY oracle   USER SYSTEM IDENTIFIED BY oracle   LOGFILE GROUP 1 (‘/u01/app/oracle/oradata/test1/redo01a.log‘) SIZE 100M BLOCKSIZE 512,           GROUP 2 (‘/u01/app/oracle/oradata/test1/redo02a.log‘) SIZE 100M BLOCKSIZE 512   MAXLOGFILES 5   MAXLOGMEMBERS 5   MAXLOGHISTORY 1   MAXDATAFILES 100   CHARACTER SET zhs16gbk   EXTENT MANAGEMENT LOCAL   DATAFILE ‘/u01/app/oracle/oradata/test1/system01.dbf‘ SIZE 325M REUSE   SYSAUX DATAFILE ‘/u01/app/oracle/oradata/test1/sysaux01.dbf‘ SIZE 325M REUSE   DEFAULT TEMPORARY TABLESPACE tempts1      TEMPFILE ‘/u01/app/oracle/oradata/test1/temp01.dbf‘      SIZE 20M REUSE   UNDO TABLESPACE undotbs1      DATAFILE ‘/u01/app/oracle/oradata/test1/undotbs01.dbf‘      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

  3、啟動Instance到nomount,運行建庫指令碼: 
[[email protected] ~]$ export ORACLE_SID=test1

[[email protected] ~]$ sqlplus ‘/as sysdba‘SQL*Plus: Release 11.2.0.3.0 Production on Fri Apr 8 17:09:02 2016Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to an idle instance.17:09:02 [email protected] test1>startup nomount;ORACLE instance started.Total System Global Area  313159680 bytesFixed Size                  2227944 bytesVariable Size             218104088 bytesDatabase Buffers           88080384 bytesRedo Buffers                4747264 bytes17:14:17 [email protected] test1>select status from v$instance;STATUS------------STARTED

17:15:15 [email protected] test1>@/home/oracle/cr_db.sql
Database created.
4、建庫完成後,通過指令碼建立資料字典
[[email protected] ~]$ cat cr_dict.sql 
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
conn system/oracle
@?/sqlplus/admin/pupbld.sql

17:31:44 [email protected] test1>@/home/oracle/cr_dict.sql

5、建庫成功,建立default tablespace
19:24:34 [email protected] test1>create tablespace users
                    datafile ‘/u01/app/oracle/oradata/test1/users01.dbf‘ size 100m;
Tablespace created.
19:25:57 [email protected] test1>alter database default tablespace users;
Database altered.
19:27:52 [email protected] test1>select tablespace_name,file_id,file_name from dba_data_files;

TABLESPACE_NAME                   FILE_ID FILE_NAME------------------------------ ---------- --------------------------------SYSTEM                                  1 /u01/app/oracle/oradata/test1/system01.dbfSYSAUX                                  2 /u01/app/oracle/oradata/test1/sysaux01.dbfUNDOTBS1                                3 /u01/app/oracle/oradata/test1/undotbs01.dbfUSERS                                   4 /u01/app/oracle/oradata/test1/users01.dbf4 rows selected.

6、配置網路(tnsnames)
[[email protected] admin]$ cat tnsnames.ora 

TEST1 =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = rh64)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = test1)    )  )

  [[email protected] admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 08-APR-2016 19:33:50Copyright (c) 1991, 2011, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rh64)(PORT=1521)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date                08-APR-2016 19:32:48Uptime                    0 days 0 hr. 1 min. 2 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log File         /u01/app/oracle/diag/tnslsnr/rh64/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rh64.cuug.cn)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))Services Summary...Service "test1" has 1 instance(s).  Instance "test1", status READY, has 1 handler(s) for this service...The command completed successfully

測試網路連接:
[[email protected] admin]$ sqlplus system/[email protected]

SQL*Plus: Release 11.2.0.3.0 Production on Fri Apr 8 19:34:27 2016Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

19:34:27 [email protected] test1>

-----  至此,手工建庫成功;如果有時間,可以對資料庫做一個冷備 。

---------- OCM考試考點練習,後續繼續推出。。。

本文出自 “天涯客的blog” 部落格,請務必保留此出處http://tiany.blog.51cto.com/513694/1761930

Oracle Study之-Oracle 11g OCM考試(1)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.