Oracle10G手動建立例項

2jfly發表於2008-01-15
前幾天有臺伺服器的oracle10g資料庫的一張系統表損壞了(可能是因為不正常shutdown所致),但在在BDUMP下的alert日誌裡卻不斷報ora-00600錯誤,並且在BDUMP資料夾內產生大量的trc跟蹤檔案,導致該分割槽下沒兩三天硬碟空間就不夠用了。因此決定重新建一個例項,並將舊例項的資料導進新例項中,再刪除舊的例項。參考了網上一些高手文章,終於順利完成。具體步驟如下:

首先先將舊資料庫啟動起來,sartup force;

再匯出使用者資料:exp FILE=/***.DMP LOG=***.LOG OWNER=USERNAME FEEDBACK=10000.

導完或再建庫。
建庫步驟:
1、手工建立相關目錄
/oraclepro/admin/dxora
/oraclepro/admin/dxora/adump
/oraclepro/admin/dxora/bdump
/oraclepro/admin/dxora/cdump
/oraclepro/admin/dxora/dpump
/oraclepro/admin/dxora/pfile
/oraclepro/admin/dxora/udump

2、手工建立初始化啟動引數檔案:/oraclepro/admin/dxora/pfile/initdSID.ora,內容:我是從舊例項的PFILE裡複製出來的的,再修改一下SID。
內容如下:
#########################################################
# SGA Memory
###########################################
sga_target=2146435072

###########################################
# Job Queues
###########################################
job_queue_processes=10

###########################################
# Shared Server
###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=dxptoraXDB)"

###########################################
# Miscellaneous
###########################################
compatible=10.2.0.1.0

###########################################
# Security and Auditing
###########################################
audit_file_dest=/oraclepro//admin/dxora/adump
remote_login_passwordfile=EXCLUSIVE

###########################################
# Sort, Hash Joins, Bitmap Indexes
###########################################
pga_aggregate_target=839909376

###########################################
# Database Identification
###########################################
db_domain=""
db_name=dxora

###########################################
# File Configuration
###########################################
control_files=("/oracleapp/oradata/dxora/control01.ctl", "/oracleapp/oradata/dxora/control02.ctl", "/oracleapp/oradata/dxora/control03.ctl")
db_recovery_file_dest=/oracleapp/flash_recovery_area
db_recovery_file_dest_size=2147483648

###########################################
# Cursors and Library Cache
###########################################
open_cursors=300

###########################################
# System Managed Undo and Rollback Segments
###########################################
undo_management=AUTO
undo_tablespace=UNDOTBS1

###########################################
# Diagnostics and Statistics
###########################################
background_dump_dest=/oraclepro//admin/dxora/bdump
core_dump_dest=/oraclepro//admin/dxora/cdump
user_dump_dest=/oraclepro//admin/dxora/udump

###########################################
# Processes and Sessions
###########################################
processes=150

###########################################
# Cache and I/O
###########################################
db_block_size=8192
db_file_multiblock_read_count=16
############################################################


3、手工建立/oraclepro/product/10.2.0/db_1/dbs/initdxora.ora檔案,
內容為:IFILE='/oraclepro/admin/dxora/pfile/initdxora.ora'

4、使用orapwd.exe命令,建立/oraclepro/product/10.2.0/db_1/dbs/PWDdxora.ora

命令:orapwd file=/oraclepro/product/10.2.0/db_1/dbs/PWDdxora.ora password=dxpt123 entries=5

5、透過oradism.exe命令(在10G以下版本的是oradim.exe),在服務裡生成一個新的例項管理服務,啟動方式為手工
set ORACLE_SID=dxora
oradism -new -sid dxora -startmode manual -pfile "/oraclepro/admin/dxora/pfile/initdxora.ora"
6.修改ORACLE環境變數 vi /home/oracle/.bash_profile
將SID=舊例項名更改為SID=新例項名
7.退出遠端,用ORACLE重新登陸,可使用env命令檢視環境變數是否已經更改。更改後

8.sqlplus /nolog
conn / as sysdba (會提示已連線到一個空的例項)

9.startup nomount pfile="/oraclepro/admin/dxora/pfile/initdxora.ora"

10,建立資料庫

一、
create database dxora
MAXINSTANCES 2
MAXLOGHISTORY 32
MAXLOGFILES 32
MAXLOGMEMBERS 3
MAXDATAFILES 2048
character set ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/oracleapp/oradata/dxora/system01.dbf' size 500M autoextend on next 64K maxsize unlimited
sysaux DATAFILE '/oracleapp/oradata/dxora/sysaux01.dbf' size 500M autoextend on next 64K maxsize unlimited
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/oracleapp/oradata/dxora/temp01.dbf' size 50M autoextend on MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K
UNDO TABLESPACE UNDOTBS1 datafile '/oracleapp/oradata/dxora/undotbs01.dbf' SIZE 1024M autoextend on next 64K maxsize unlimited
LOGFILE
GROUP 1 ('/oracleapp/oradata/dxora/redo01.log') SIZE 50M REUSE,
GROUP 2 ('/oracleapp/oradata/dxora/redo02.log') SIZE 50M REUSE,
GROUP 3 ('/oracleapp/oradata/dxora/redo03.log') SIZE 50M REUSE;
二、建立使用者表空間

CREATE TABLESPACE USERS DATAFILE '/oracleapp/oradata/dxora/users01.dbf' SIZE 2048M REUSE
AUTOEXTEND ON NEXT 1280K
MINIMUM EXTENT 128K
DEFAULT STORAGE ( INITIAL 128K NEXT 128K MINEXTENTS 1 MAXEXTENTS 4096 PCTINCREASE 0);

三、建立資料字典

@/oraclepro/product/10.2.0/db_1/rdbms/admin/catalog.sql;
@/oraclepro/product/10.2.0/db_1/rdbms/admin/catproc.sql;
@/oraclepro/product/10.2.0/db_1/rdbms/admin/catblock.sql;
@/oraclepro/product/10.2.0/db_1/rdbms/admin/catoctk.sql;

conn system/manager

@/oraclepro/product/10.2.0/db_1/sqlplus/admin/pupbld.sql;

11、建立spfile並重啟db
create spfile from pfile='/oraclepro/admin/dxora/pfile/initdxora.ora'
startup force

12.刪除舊的例項
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
wmsdev

SQL> shutdown immediate;
Database closed.
Database dismounted.
orACLE instance shut down.

SQL> startup mount exclusive
orACLE instance started.

Total System Global Area 939524096 bytes
Fixed Size 781984 bytes
Variable Size 245633376 bytes
Database Buffers 692060160 bytes
Redo Buffers 1048576 bytes
Database mounted.
SQL> alter system enable restricted session;

System altered.

SQL> drop database;

Database dropped.

建立使用者

create user USERNAME identified by PSW;

許可權:

Grant DBA,CONNECT ,RESOURCE TO USERNAME;

建立後有可能需要解鎖才能進行遠端連線。下面是解鎖命令,如果不需解鎖則可跳過

#####################################################################
alter profile default limit FAILED_LOGIN_ATTEMPTS unlimited;
改完後再
alter user USERNAME account unlock;
#####################################################################
以上是因為遠端登陸報ora-2800使用者被鎖,須用以上方法解開。

下面就可以導進使用者資料。

imp FILE=/***.DMP LOG=/imp***.LOG FROMUSER=USERNAME,TOUSER=USERNAME.FEEDBACK=10000

由於我們那臺伺服器做了群集,因此在備機上也需要建立例項服務與引數。

須先shutdown normal 資料庫,再切換到備機上執行。

1、手工建立相關目錄
/oraclepro/admin/dxora
/oraclepro/admin/dxora/adump
/oraclepro/admin/dxora/bdump
/oraclepro/admin/dxora/cdump
/oraclepro/admin/dxora/dpump
/oraclepro/admin/dxora/pfile
/oraclepro/admin/dxora/udump
2.手工建立初始化啟動引數檔案:/oraclepro/admin/dxora/pfile/initdxora.ora
scp initdxora.ora node2:/oraclepro/admin/dxora/pfile/initdxora.ora
3、手工建立/oraclepro/product/10.2.0/db_1/dbs/initdxora.ora檔案,
內容為:IFILE='/oraclepro/admin/dxora/pfile/initdxora.ora'

4、使用orapwd.exe命令,建立/oraclepro/product/10.2.0/db_1/dbs/PWDdxora.ora

命令:orapwd file=/oraclepro/product/10.2.0/db_1/dbs/PWDdxora.ora password=dxpt123 entries=5

5、透過oradism.exe命令,在服務裡生成一個新的例項管理服務,啟動方式為手工
set ORACLE_SID=dxora
oradism -new -sid dxora -startmode manual -pfile "/oraclepro/admin/dxora/pfile/initdxora.ora"
6.修改ORACLE環境變數 vi .bash_profile

7.修改TNSNAME.ORA

8.startup nomount pfile="/oraclepro/admin/dxora/pfile/initdxora.ora"

9.conn / as sysdba;
建立spfile並重啟db
create spfile from pfile='/oraclepro/admin/dxora/pfile/initdxora.ora';
alter database mount;
alter database open;


(完)

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21100044/viewspace-1018627/,如需轉載,請註明出處,否則將追究法律責任。

相關文章