1. 先要关闭数据库(进程和内存关闭)
[Oracle@oracle_2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on TueNov 12 20:34:53 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>exit
2. 设置环境变量
[oracle@oracle_2 ~]$ vi .bash_profile
此时环境变量已经设置好了
3. 创建目录
i. 创建相关文件
此时我们可以看见已经有了相关目录,那是我们之前创建的实例ORCL的相关目录
创建目录是采用了批量创建目录{a,b,c,u}dump
[oracle@oracle_2 ~]$ cd $ORACLE_BASE
[oracle@oracle_2 oracle]$ ls
admin flash_recovery_area oradata oraInventory product
[oracle@oracle_2 oracle]$
[oracle@oracle_2 oracle]$ mkdir -p admin/ORA10G/{a,b,c,u}dump
[oracle@oracle_2 oracle]$ ls
admin flash_recovery_area oradata oraInventory product
[oracle@oracle_2 oracle]$ cd admin/
[oracle@oracle_2 admin]$ ls
ORA10G ORCL
[oracle@oracle_2 admin]$ cd ORA10G/
[oracle@oracle_2 ORA10G]$ ls
adump bdump cdump udump
[oracle@oracle_2 ORA10G]$
[oracle@oracle_2 ORA10G]$ ls
adump bdump cdump udump
[oracle@oracle_2 ORA10G]$ cd ..
[oracle@oracle_2 admin]$ ls
ORA10G ORCL
[oracle@oracle_2 admin]$ cd ..
[oracle@oracle_2 oracle]$ ls
admin flash_recovery_area oradata oraInventory product
[oracle@oracle_2 oracle]$ mkdir -p oradata/ORA10G
[oracle@oracle_2 oracle]$
ii. 创建密码文件
创建密码文件需要到ORACLE_HOME/dbs目录下创建
[oracle@oracle_2 10.2.0]$ cd $ORACLE_HOME/dbs
[oracle@oracle_2 dbs]$ ls
hc_ORCL.dat initdw.ora init.ora lkORCL orapwORCL spfileORCL.ora
[oracle@oracle_2 dbs]$ orapwd
Usage: orapwd file=<fname>password=<password>entries=<users>force=<y/n>
where
file -name of password file (mand),
password- password for SYS (mand),
entries -maximum number of distinct DBA andforce - whether to overwrite existing file (opt),
OPERs (opt),
There areno spaces around the equal-to (=) character.
[oracle@oracle_2 dbs]$ orapwd file=orapwORA10Gpassword=oracle entries=30
[oracle@oracle_2 dbs]$ ls
hc_ORCL.dat init.ora orapwORA10G spfileORCL.ora
initdw.ora lkORCLorapwORCL
[oracle@oracle_2 dbs]$
[oracle@oracle_2 dbs]$ cat init.ora |grep -v^#|grep -v ^$ >initORA10G.ora
[oracle@oracle_2 dbs]$ ls
hc_ORCL.dat init.oralkORCL orapwORCL
initdw.ora initORA10G.ora orapwORA10G spfileORCL.ora
[oracle@oracle_2 dbs]$
[oracle@oracle_2 dbs]$ vi initORA10G.ora
将内容改的和下面的一样
db_name=ORA10G
db_files = 80# SMALL
db_file_multiblock_read_count = 8 #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/oracle/oradata/ORA10G/ora_control1.ctl,/u01/app/oracle/oradata/ORA10G/ora_control2.ctl)
sga_max_size=300m
sga_target=300m
4. 启动实例为ORA10G的数据库
[oracle@oracle_2 dbs]$ export $ORACLE_SID=ORA10G
[oracle@oracle_2 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on TueNov 12 21:08:55 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SYS@ORA10G>
SYS@ORA10G>create spfile from pfile
File created.
SYS@ORA10G>startup nomount
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219184 bytes
Variable Size 96470416 bytes
Database Buffers 213909504 bytes
Redo Buffers2973696 bytes
SYS@ORA10G>
SYS@ORA10G>show parameter undo
NAME TYPEVALUE
------------------------------------ -----------------------------------------
undo_management string MANUAL
undo_retention integer 900
undo_tablespace string
SYS@ORA10G>
修改参数,由于undo_management参数为静态参数,所以需要加上scope=spfile
SYS@ORA10G>alter system set undo_management=autoscope=spfile
System altered.
SYS@ORA10G>show parameter undo
NAME TYPEVALUE
------------------------------------ -----------------------------------------
undo_management string MANUAL
undo_retention integer 900
undo_tablespace string
SYS@ORA10G>shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
此时发现并没有更改,是由于静态参数需要重启才有效
SYS@ORA10G>startup nomount
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219184 bytes
Variable Size 96470416 bytes
Database Buffers 213909504 bytes
Redo Buffers2973696 bytes
SYS@ORA10G>
此时只是改了spfile的参数还需要改pfile的参数
SYS@ORA10G>create pfile from spfile
File created.
SYS@ORA10G>
5. 多个实例的切换
i. 实例为ORCL启动数据库
[oracle@oracle_2 dbs]$ export ORACLE_SID=ORCL
[oracle@oracle_2 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on TueNov 12 21:19:19 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SYS@ORCL>
ii. 实例为ORCL10G启动数据库
SYS@ORCL>exit
Disconnected
[oracle@oracle_2 dbs]$ export ORACLE_SID=ORA10G
[oracle@oracle_2 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on TueNov 12 21:24:54 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SYS@ORA10G>
你可以在安装软件后再创建数据库,这个数量可以是多个。安装ORACLE时,如选择仅安装软件,则安装结束后无数据库。你可以继续创建数据库。实例是一个正在进行时的概念,每当启动一个数据库时,ORACLE会依照初始化参数文件spfile的记录分配内存,启动进程,查找相关文件,而当数据库关闭后,实例的寿命也就终止了,再启动就是一个新的实例,可以简单理解为实例就是内存和进程的集合,与物理文件没有关联,你完全可以删除实例,然后用oradmin来创建一个新实例,然后启动数据库,只要物理文件没有问题。多个实例可对应一个数据库,它们共同 *** 作同一数据文件。但你要说多个数据库,应该是指要创建不同的物理文件,而一个实例不能管理多个数据库。
以下是对新建Oracle数据库的三种方法进行了详细的分析介绍 需要的朋友可以过来参考下通过运行Oracle Database Configuration Assistant 创建 配置 或删除数据库(也可在命令行下输入dbca) 用命令行的方式建立数据库 通过运行自定义的批处理脚本(或create_ORACLE_SID bat(create_ORACLE_SID sql))来创建 配置 或删除数据库
详述 通过运行Oracle Database Configuration Assistant 创建 配置 或删除数据库 建议不熟悉创建过程的DBA使用该方法 只需要根据选项“下一步”进行配置 最后生成数据库的创建脚本(建议保留) 或者直接创建数据库 优点 GUI方法使用方便 缺点 不过创建过程有些慢
用命令行的方式建立数据库
复制代码 代码如下: CONNECT / AS SYSDBA STARTUP PFILE= C:oracleadmininit_testorcl ora NOMOUNT CREATE DATABASE testOrcl DATAFILE /u /oracle/testOrcl/system dbf SIZE M LOGFILE GROUP ( /u /oracle/testOrcl/redo a log /u /oracle/testOrcl/redo b log ) SIZE K GROUP ( /u /oracle/testOrcl/redo a log /u /oracle/testOrcl/redo b log ) SIZE K CHARACTER SET ZHS CGB将数据库直接从未建置状态转换到打开状态 ALTER DATABASE OPEN
删除数据库(Dropping a Database) SPOOL C:DROP_DATABASE BAT SELECT DEL ||NAME 删除数据库相关数据文件 FROM V$DATAFILE SELECT DEL ||MEMBER 删除数据重构日志文件 FROM V$LOGFILE SPOOL OFF
优点 可以熟悉创建指令 创建原理 缺点 配置简单 要求熟记命令行指令 通过运行自定义的批处理或SQL脚本(create_ORACLE_SID bat或create_ORACLE_SID sql)来创建
复制代码 代码如下: create_ORACLE_SID bat set ORACLE_SID= ORACLE_SID del C:ORACLE IdatabasepwdORACLE_SID ora C:ORACLE Ibinoradim new sid ORACLE_SID intpwd oracle startmode manual pfile C:ORACLE IadminORACLE_SIDpfileinit ora C:ORACLE Ibinsvrmgrl @C:WINNTProfilesAdministratorLbORACLE_SIDrun sql C:ORACLE Ibinsvrmgrl @C:WINNTProfilesAdministratorLbORACLE_SIDrun sql C:ORACLE Ibinoradim edit sid ORACLE_SID startmode auto ORACLE_SIDrun sql spool C:ORACLE IadminORACLE_SIDcreatecreatedb set echo on connect INTERNAL/oracle startup nomount pfile=C:ORACLE IadminORACLE_SIDpfileinit ora CREATE DATABASE ORACLE_SID LOGFILE C:ORACLE IoradataORACLE_SIDredo log SIZE K C:ORACLE IoradataORACLE_SIDredo log SIZE K MAXLOGFILES MAXLOGMEMBERS MAXLOGHISTORY DATAFILE C:ORACLE IoradataORACLE_SIDsystem dbf SIZE M REUSE MAXDATAFILES MAXINSTANCES CHARACTER SET ZHT BIG NATIONAL CHARACTER SET ZHT BIG spool off ORACLE_SIDrun sql spool C:ORACLE IadminORACLE_SIDcreatecreatedb set echo on connect INTERNAL/oracle ALTER DATABASE DATAFILE C:ORACLE IoradataORACLE_SIDsystem dbf AUTOEXTEND ON CREATE ROLLBACK SEGMENT SYSROL TABLESPACE "SYSTEM" STORAGE (INITIAL K NEXT K) ALTER ROLLBACK SEGMENT "SYSROL" ONLINELinux平台下Oracle的 *** 作
下面对Oracle的 *** 作都是在Linux平台下进行的! su Oracle sqlplus /logon connect test/test assysdba(test/test是Oracle用户和密码) startup lsnrctl 首选启动数据库 su Oracle sqlplus /nolog conn /as sysdba startup 然后启动监听: 进入/opt/Oracle/product/ /bin/ lsnrctl start 运行shudown命令关闭数据库 [Oracle@wing /Oracle]$ sqlplus" / as sysdba" //以sysdba用户登陆数据库 SQL>shutdown
启动Oracle i 数据库 [Oracle@wing bin]$ sqlplus " /as sysdba" SQL>startup
启动Oracle i监听程序 Oracle的监听程序主要是为客户端的连接提供接口 [Oracle@wing bin]$ lsnrctl LSNRCTL>start
关闭Oracle i监听程序 [Oracle@wing bin]$ lsnrctl LSNRCTL>stop 先看看Oracle_SID 环境变量设置是否正确 i $ sqlplus /nolog SQL>connect / as sysdba SQL>startup $ lsnrctl start i $ svrmgrl SVRMGR>connect internal SVRMGR>startup $ lsnrctl start 在哪里报错?? 一般只要设置这 处就好了~ /etc/oratab ora :/Oracle/app/Oracle/product/ :Y /etc/inittab oralce: :wait:/bin/su Oracle c /Oracle/app/Oracle/product/ /bin/lsnrctl start Oracle: :wait:/bin/su Oracle c /Oracle/app/Oracle/product/ /bin/dbstart
启动步骤 su Oracle [Oracle@websvr Oracle]$ sqlplus /nolog SQL>connect / as sysdba SQL>startup SQL>quit [Oracle@websvr Oracle]$ lsnrctl start 可用 [Oracle@websvr Oracle]$ lsnrctl status 查看监听是否已经启动
lishixinzhi/Article/program/Oracle/201311/19064
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)