這篇文章將為大家詳細(xì)講解有關(guān)怎樣手工方式建立 ORACLE數(shù)據(jù)庫,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
站在用戶的角度思考問題,與客戶深入溝通,找到永康網(wǎng)站設(shè)計(jì)與永康網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名申請(qǐng)、虛擬主機(jī)、企業(yè)郵箱。業(yè)務(wù)覆蓋永康地區(qū)。
通過dbca方式創(chuàng)建Oracle數(shù)據(jù)庫是最常見的方法,除此之外如果對(duì)數(shù)據(jù)庫的創(chuàng)建過程了解的話,亦可一步一步的通過命令行的方式完成數(shù)據(jù)庫的創(chuàng)建。
現(xiàn)將在OEL4.8操作系統(tǒng)上手工創(chuàng)建Oracle數(shù)據(jù)庫實(shí)例的方法記錄在此,供參考。
1.手工建庫前提條件
既然已經(jīng)到了創(chuàng)建數(shù)據(jù)庫實(shí)例的階段,因此主機(jī)上的數(shù)據(jù)庫軟件需要事先創(chuàng)建完畢。
2.準(zhǔn)備.bash_profile配置文件并確認(rèn)環(huán)境變量
1)編輯.bash_profile文件
[oracle@secDB ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/sbin:/usr/local/bin
export PATH
unset USERNAME
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export ORACLE_SID=secooler
export PATH=$ORACLE_HOME/bin:$PATH
需要設(shè)置的環(huán)境變量主要就是這三個(gè):ORACLE_BASE、ORACLE_HOME、ORACLE_SID和PATH
需要說明的是PATH變量的設(shè)置,需要將“$ORACLE_HOME/bin”寫在“$PATH”之前,這樣設(shè)置主要目的是:Oracle命令優(yōu)先被選擇。
2)使.bash_profile配置文件生效
[oracle@secDB ~]$ . ./.bash_profile
或
[oracle@secDB ~]$ source ./.bash_profile
3)確認(rèn)ORACLE_SID等環(huán)境變量被正確設(shè)置
[oracle@secDB ~]$ env | grep -i sid
ORACLE_SID=secooler
[oracle@secDB ~]$ env | grep ORACLE_BASE
ORACLE_BASE=/u01/app/oracle
[oracle@secDB ~]$ env | grep ORACLE_HOME
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
3.在$ORACLE_BASE下創(chuàng)建所需的目錄
1)創(chuàng)建四個(gè)轉(zhuǎn)儲(chǔ)目錄
[oracle@secDB ~]$ cd $ORACLE_BASE
[oracle@secDB oracle]$ mkdir -p admin/secooler/adump
[oracle@secDB oracle]$ mkdir -p admin/secooler/bdump
[oracle@secDB oracle]$ mkdir -p admin/secooler/cdump
[oracle@secDB oracle]$ mkdir -p admin/secooler/udump
2)創(chuàng)建存放數(shù)據(jù)文件、日志文件和控制文件的目錄
[oracle@secDB oracle]$ mkdir -p oradata/secooler/dfile
[oracle@secDB oracle]$ mkdir -p oradata/secooler/lfile
[oracle@secDB oracle]$ mkdir -p oradata/secooler/cfile
3)創(chuàng)建備份介質(zhì)存放的目錄
[oracle@secDB oracle]$ mkdir -p rmanbak
4.生成密碼文件
[oracle@secDB ~]$ cd $ORACLE_HOME/dbs
[oracle@secDB dbs]$ orapwd file=orapwsecooler password=change_on_install entries=10
5.創(chuàng)建所需的pfile和spfile
1)創(chuàng)建pfile文件并調(diào)整
我們根據(jù)Oracle安裝軟件$ORACLE_HOME/dbs目錄下自帶的init.ora來定制我們需要的pfile。
(1)進(jìn)入到$ORACLE_HOME/dbs目錄
[oracle@secDB ~]$ cd $ORACLE_HOME/dbs
(2)去掉默認(rèn)init.ora文件中雜亂的內(nèi)容,僅保留參數(shù)本身信息
[oracle@secDB dbs]$ cat init.ora |grep -v ^# |grep -v ^$ > initsecooler.ora
(3)調(diào)整initsecooler.ora參數(shù)內(nèi)容
調(diào)整后的內(nèi)容如下:
[oracle@secDB dbs]$ vi initsecooler.ora
db_name=secooler
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 = TRUE
#control_files = (ora_control1, ora_control2)
control_files = (/u01/app/oracle/oradata/secooler/cfile/ora_control1,/u01/app/oracle/oradata/secooler/cfile/ora_control2,/u01/app/oracle/oradata/secooler/cfile/control3)
sga_max_size=300M
sga_target=300M
~
~
較之系統(tǒng)自帶的參數(shù)文件做了如下修改動(dòng)作:
a.修改db_name參數(shù)為
b.注銷掉參數(shù)db_block_buffers、shared_pool_size
c.修改controlfile參數(shù)
c.增加sga_max_size和sga_target參數(shù),大小設(shè)置為300M。
2)創(chuàng)建spfile并調(diào)整
(1)使用sqlplus命令登陸創(chuàng)建spfile
[oracle@secDB dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jul 7 22:44:55 2010
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
SQL> create spfile from pfile;
(2)啟動(dòng)數(shù)據(jù)庫到nomount狀態(tài),調(diào)整spfile參數(shù)
a.啟動(dòng)數(shù)據(jù)庫到nomount狀態(tài)
SQL> 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
b.需要修改的spfile參數(shù)如下
SQL> alter system set undo_management=auto scope=spfile;
SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata/secooler/dfile' scope=spfile;
SQL> alter system set db_create_online_log_dest_1='/u01/app/oracle/oradata/secooler/lfile' scope=spfile;
SQL> alter system set job_queue_processes =5 scope=spfile;
SQL> alter system set background_dump_dest='/u01/app/oracle/admin/secooler/bdump' scope=spfile;
SQL> alter system set core_dump_dest= '/u01/app/oracle/admin/secooler/cdump' scope=spfile;
SQL> alter system set user_dump_dest='/u01/app/oracle/admin/secooler/udump' scope=spfile;
SQL> alter system set audit_file_dest='/u01/app/oracle/admin/secooler/adump' scope=spfile;
c.停起數(shù)據(jù)庫到nomount狀態(tài)使spfile調(diào)整生效
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> 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
6.創(chuàng)建數(shù)據(jù)庫
1)編寫create database腳本
(1)獲取create database的參考腳本
在Oracle文檔中中有一個(gè)供參考的創(chuàng)建語句
(1)進(jìn)入到Oracle官方文檔的首頁:http://www.oracle.com/pls/db102/homepage;
(2)點(diǎn)擊“Books”;
(3)在列出來的參考書目中的找到第5本書“Administrator's Guide”,點(diǎn)擊“HTML”進(jìn)入;
(4)搜索關(guān)鍵字“create database statement”,位到“Step 7: Issue the CREATE DATABASE Statement”,點(diǎn)擊進(jìn)入便可以得到創(chuàng)建數(shù)據(jù)庫的參考腳本;
2)調(diào)整參考腳本中的內(nèi)容為我所用
(1)需要調(diào)整的內(nèi)容
數(shù)據(jù)庫名字
SYS和SYSTEM密碼
路徑名修改,注意一定要準(zhǔn)確全面
表空間tbs_1后面給出具體數(shù)據(jù)文件信息
(2)調(diào)整后的腳本如下
CREATE DATABASE secooler
USER SYS IDENTIFIED BY change_on_install
USER SYSTEM IDENTIFIED BY manager
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/secooler/lfile/redo01.log') SIZE 100M,
GROUP 2 ('/u01/app/oracle/oradata/secooler/lfile/redo02.log') SIZE 100M,
GROUP 3 ('/u01/app/oracle/oradata/secooler/lfile/redo03.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/secooler/dfile/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/secooler/dfile/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1 datafile '/u01/app/oracle/oradata/secooler/dfile/tbs_1.dbf' size 50m
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/secooler/dfile/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u01/app/oracle/oradata/secooler/dfile/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
3)使用上面的create database腳本創(chuàng)建數(shù)據(jù)庫
腳本執(zhí)行之后,此時(shí)數(shù)據(jù)庫狀態(tài)已經(jīng)為OPEN狀態(tài)。
SQL> select status from v$instance;
STATUS
------------
OPEN
4)設(shè)置數(shù)據(jù)文件和臨時(shí)文件為自動(dòng)擴(kuò)展
(1)獲得所有數(shù)據(jù)文件和臨時(shí)文件信息
SQL> col name for a60
SQL> select file#,name from v$datafile union select file#,name from v$tempfile;
FILE# NAME
---------- ------------------------------------------------------------
1 /u01/app/oracle/oradata/secooler/dfile/system01.dbf
1 /u01/app/oracle/oradata/secooler/dfile/temp01.dbf
2 /u01/app/oracle/oradata/secooler/dfile/undotbs01.dbf
3 /u01/app/oracle/oradata/secooler/dfile/sysaux01.dbf
4 /u01/app/oracle/oradata/secooler/dfile/tbs_1.dbf
(2)將其調(diào)整為自動(dòng)擴(kuò)展
SQL> alter database datafile 1 autoextend on;
SQL> alter database datafile 2 autoextend on;
SQL> alter database datafile 3 autoextend on;
SQL> alter database datafile 4 autoextend on;
SQL> alter database tempfile 1 autoextend on;
7.執(zhí)行catalog.sql和catproc.sql腳本創(chuàng)建數(shù)據(jù)字典視圖并配置
注意這兩個(gè)腳本需要以SYSDBA身份來執(zhí)行
[oracle@secDB ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jul 7 22:17:18 2010
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
SQL> @?/rdbms/admin/catalog.sql
大約需要5分鐘
SQL> @?/rdbms/admin/catproc.sql
大約需要10分鐘
8.小結(jié)
手工創(chuàng)建數(shù)據(jù)庫相比dbca來說繁瑣了很多,不過整個(gè)安裝過程體現(xiàn)的是Oracle的運(yùn)行原理,對(duì)于理解數(shù)據(jù)庫細(xì)節(jié)來說有很大的裨益。
關(guān)于怎樣手工方式建立 ORACLE數(shù)據(jù)庫就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
當(dāng)前名稱:怎樣手工方式建立ORACLE數(shù)據(jù)庫
本文來源:http://jinyejixie.com/article40/pdsdho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、ChatGPT、網(wǎng)站排名、面包屑導(dǎo)航、用戶體驗(yàn)、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)