程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> Oracle10g快速手工建庫步驟

Oracle10g快速手工建庫步驟

編輯:Oracle教程

Oracle10g快速手工建庫步驟


0. 修改環境變量
[oracle@ocm1 ~]$ vi .bash_profile

添加以下內容: export ORACLE_SID=PROD
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH

1. 修改登錄標識符和默認編輯器(非必須)
修改$ORACLE_HOME/sqlplus/admin/glogin.sql,在文件末尾添加以下內容:
set sqlprompt '_user''@''_connect_identifier> ' define _editor=vi 2. 創建初始化參數(用於啟動數據庫實例) [oracle@ocm1 dbs]$ cat init.ora|grep -v ^$|grep -v ^# > initPROD.ora [oracle@ocm1 dbs]$ ll total 32 -rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora -rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora -rw-r--r-- 1 oracle oinstall 738 Jan 10 19:18 initPROD.ora [oracle@ocm1 dbs]$ vi initPROD.ora db_name=PROD db_files = 80 # SMALL db_file_multiblock_read_count = 8 # SMALL #db_block_buffers = 100 # SMALL #shared_pool_size = 3500000 # SMALL log_checkpoint_interval = 10000 processes = 50 # SMALL parallel_max_servers = 5 # SMALL log_buffer = 32768 # SMALL max_dump_file_size = 10240 # limit trace file size to 5 Meg each global_names = FALSE control_files = (/u01/app/oacle/oradata/PROD/Disk1/control01.ctl, /u01/app/oacle/oradata/PROD/Disk1/control02.ctl,/u01/app/oacle/oradata/PROD/Disk1/control03.ctl) undo_management=auto sga_max_size=300M sga_target=300M
注意:紅色部分為需要添加或修改的地方
3. 創建密碼文件
[oracle@ocm1 dbs]$ orapwd file=orapwPROD password=oracle entries=5 [oracle@ocm1 dbs]$ ll total 36 -rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora -rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora -rw-r--r-- 1 oracle oinstall 914 Jan 10 19:21 initPROD.ora -rw-r----- 1 oracle oinstall 2048 Jan 10 19:24 orapwPROD
4. 創建相關目錄 [oracle@ocm1 dbs]$ mkdir /u01/app/oracle/admin/PROD/{a,b,c,u}dump -p [oracle@ocm1 dbs]$ cd /u01/app/oracle/admin/PROD [oracle@ocm1 PROD]$ ll total 16 drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 adump drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 bdump drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 cdump drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 udump [oracle@ocm1 PROD]$ cd /u01/app/oracle
[oracle@ocm1 oracle]$ mkdir oradata/PROD/Disk{1,2,3,4,5} -p
[oracle@ocm1 oracle]$ cd oradata/PROD/ [oracle@ocm1 PROD]$ ll total 20 drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk1 drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk2 drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk3 drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk4 drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk5
5. 創建spfile
[oracle@ocm1 PROD]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jan 10 19:25:04 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SYS@PROD> startup nomount ORACLE instance started.
Total System Global Area 314572800 bytes Fixed Size 1219184 bytes Variable Size 96470416 bytes Database Buffers 213909504 bytes Redo Buffers 2973696 bytes SYS@PROD> create spfile from pfile;
File created.
創建spfile並用它啟動後,就可以通過alter sysem set xxx來動態修改所需的參數了,主要是可以利用模糊查找得到不熟悉的參數名
6. 創建建庫腳本crdb.sql
Reffer:Administration->Database Administrator's Guide->2 Creating an Oracle Database->Manually Creating an Oracle Database->Step 7: Issue the CREATE DATABASE Statement CREATE DATABASE PROD USER SYS IDENTIFIED BY oracle USER SYSTEM IDENTIFIED BY oracle GROUP 1 ('/u01/app/oracle/oradata/PROD/Disk1/redo01_a.log') SIZE 100M GROUP 2 ('/u01/app/oracle/oradata/PROD/Disk1/redo02_a.log') SIZE 100M GROUP 3 ('/u01/app/oracle/oradata/PROD/Disk1/redo03_a.log') SIZE 100M MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 CHARACTER SET US7ASCII NATIONAL CHARACTER SET AL16UTF16 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE SIZE 20M REUSE SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
可以用%s替換加速修改,注意修改實例名和相應的路徑,確保目錄都存在
6. 開始跑腳本建庫(約2分鐘) [oracle@ocm1 PROD]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jan 10 19:51:10 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options
SYS@PROD> @/home/oracle/crdb.sql
Database created.
至此,已經基本完成了手工建庫的步驟,但是這個庫目前還用不了,原因是沒有數據字典等系統對象
7. 分別運行catalog.sql和catproc.sql腳本(注意先後順序)
SYS@PROD> @?/rdbms/admin/catalog SYS@PROD> @?/rdbms/admin/catproc

SYS@PROD> select count(*) from dba_objects;
COUNT(*) ---------- 9373
跑完腳本,才能執行對各個系統表和視圖的查詢,可以看到,默認手工建庫跑完腳本後的系統對象是9373個(10g)
還有一種更快的方法,就是設置db_create_file_dest和db_create_online_logfile_dest1,然後直接運行create database xxx; 然後根據需要調整具體的路徑或參數
友情提醒:
建完庫之後,記得關閉數據庫用tar進行冷備份,主要是PROD和dbs這2個目錄,這樣就不怕誤刪除了,用tar的之後千萬注意解壓和壓縮的命令參數不要用錯,否則一不小心將當前目錄不相關的內容變成備份內容,覆蓋了原來的備份內容,那可是非常糟糕的,默認如果生成的tar文件同名,會直接覆蓋掉,而不是追加到原壓縮文件。






  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved