oracle手动建库

[root@aa ~]# su - oracle
[oracle@aa ~]$ echo $ORACLE_SID
orcl
[oracle@aa ~]$ export ORACLE_SID=axlin
[oracle@aa ~]$ cd /oracle/admin/
[oracle@aa admin]$ ls
orcl
[oracle@aa admin]$ mkdir -pv  axlin/{a,b,c,d,u}dump
mkdir: 已创建目录 “axlin”
mkdir: 已创建目录 “axlin/adump”
mkdir: 已创建目录 “axlin/bdump”
mkdir: 已创建目录 “axlin/cdump”
mkdir: 已创建目录 “axlin/ddump”
mkdir: 已创建目录 “axlin/udump”
[oracle@aa admin]$ cd ..
[oracle@aa oracle]$ cd oradata/
[oracle@aa oradata]$ ls
orcl
[oracle@aa oradata]$ mkdir axlin
[oracle@aa oradata]$ cd $ORACLE_HOME/dbs
[oracle@aa 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 and     force - whether to overwrite existing file (opt),
OPERs (opt),
  There are no spaces around the equal-to (=) character.

[oracle@aa dbs]$ orapwd file=orapwaxlin password=oracle
[oracle@aa dbs]$ ls
hc_orcl.dat  init.ora      lkORCL      orapworcl
initdw.ora   initorcl.ora  orapwaxlin  spfileorcl.ora
[oracle@aa dbs]$ cp init.ora init.ora.bak
[oracle@aa dbs]$ grep -v ^# init.ora.bak|sed '/^$/d'>init.ora
[oracle@aa dbs]$ vim init.ora

db_name=axlin
db_block_size=8192
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','/oracle/ora_control2')

[oracle@aa dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jun 22 14:27:38 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.


SQL> startup nomount pfile='/oracle/db_1/dbs/init.ora'
ORA-00371: not enough shared pool memory, should be atleast 62198988 bytes


vim /oracle/db_1/dbs/init.ora                                                         
db_name=axlin
db_block_size=8192
db_files = 80                                                         # SMALL 
db_file_multiblock_read_count = 8                                     # SMALL 
db_block_buffers = 100                                                 # SMALL 
shared_pool_size = 70000000       这个值必须大于62198988                                      # 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 = ('/oracle/ora_control1','/oracle/ora_control2')


SQL> startup nomount pfile='/oracle/db_1/dbs/init.ora'
ORACLE instance started.

Total System Global Area  109051904 bytes
Fixed Size                  1217932 bytes
Variable Size              96471668 bytes
Database Buffers            8388608 bytes
Redo Buffers                2973696 bytes


SQL> create spfile from pfile='/oracle/db_1/dbs/init.ora';

File created.


SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  109051904 bytes
Fixed Size                  1217932 bytes
Variable Size              96471668 bytes
Database Buffers            8388608 bytes
Redo Buffers                2973696 bytes

SQL> alter system set undo_management=auto scope=spfile;        可以先在PFILE中加上undo_management=auto,再create spfile from pfile

System altered.

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  109051904 bytes
Fixed Size                  1217932 bytes
Variable Size              96471668 bytes
Database Buffers            8388608 bytes
Redo Buffers                2973696 bytes

 

SQL>CREATE DATABASE axlin
    USER SYS IDENTIFIED BY oracle
   USER SYSTEM IDENTIFIED BY oracle
   LOGFILE GROUP 1 ('/oracle/oradata/axlin/redo01.log') SIZE 100M,
           GROUP 2 ('/oracle/oradata/axlin/redo02.log') SIZE 100M,
           GROUP 3 ('/oracle/oradata/axlin/redo03.log') SIZE 100M
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   MAXINSTANCES 1
   CHARACTER SET US7ASCII
   NATIONAL CHARACTER SET AL16UTF16
   DATAFILE '/oracle/oradata/axlin/system01.dbf' SIZE 325M REUSE
   EXTENT MANAGEMENT LOCAL
   SYSAUX DATAFILE '/oracle/oradata/axlin/sysaux01.dbf' SIZE 325M REUSE
   --DEFAULT TABLESPACE tbs_1
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE '/oracle/oradata/axlin/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs
      DATAFILE '/oracle/oradata/axlin/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

 

SQL>CREATE TABLESPACE users LOGGING
     DATAFILE '/oracle/oradata/axlin/users01.dbf'
     SIZE 25M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
     EXTENT MANAGEMENT LOCAL;


SQL>@?/rdbms/admin/catalog.sql
SQL>@?/rdbms/admin/catproc.sql

 


========================================================================================================================

========================================================================================================================

 

====================================================================================================================================
*****************************************************************************************************************************************************************************************
====================================================================================================================================
$ORACLE_BASE=/oracle    $ORACLE_HOME=/oracle/db


建立pfile ,
vim /oracle/db/dbs/initBILL.ora
compatible=10.2.0.1
db_name=bill
INSTANCE_NAME=BILL
sga_max_size=500m
sga_target=300m
undo_management=AUTO
undo_tablespace=undo1
job_queue_processes=10
background_dump_dest=/oracle/admin/BILL/bdump
core_dump_dest=/oracle/admin/BILL/cdump
user_dump_dest=/oracle/admin/BILL/udump
control_files='/oracle/admin/BILL/control01.ctl','/oracle/admin/BILL/control02.ctl'


建立在参数文件中相应的目录
$mkdir /oracle/admin/BILL
$mkdir /oracle/admin/BILL/{a,b,c,d,u}dump


$export ORACLE_SID=BILL

[oracle@aa ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 23 19:27:05 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile='/oracle/db/dbs/initBILL.ora';
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size                  1220384 bytes
Variable Size             306184416 bytes
Database Buffers          209715200 bytes
Redo Buffers                7168000 bytes
SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION           STARTUP_T STATUS       PAR    THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- --------- ------------ --- ---------- ------- ---------------
LOGINS     SHU DATABASE_STATUS   INSTANCE_ROLE      ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
              1 BILL
aa.ly.com
10.2.0.1.0        23-JUN-11 STARTED      NO           0 STOPPED
ALLOWED    NO  ACTIVE            UNKNOWN            NORMAL    NO

SQL> create spfile from pfile='/oracle/db/dbs/initBILL.ora';

File created.

[oracle@aa dbs]$ ls
hc_BILL.dat  initBILL.ora  init.ora  orapworcl       spfileorcl.ora
hc_orcl.dat  initdw.ora    lkORCL    spfileBILL.ora


SQL> startup force nomount

SQL> ho vim createdb.sql

create database bill
maxinstances 2
maxdatafiles 200
maxlogfiles 32
maxlogmembers 5
maxloghistory 290
user sys identified by admin123
user system identified by admin123
character set utf8
national character set al16utf16
datafile '/oracle/oradata/bill/system01.dbf' size 200m
sysaux datafile '/oracle/oradata/bill/sysaux01.dbf' size 200m
undo tablespace undo1 datafile '/oracle/oradata/bill/undo01.dbf' size 100m
default temporary tablespace temp tempfile '/oracle/oradata/bill/temp01.dbf' size 100m
logfile
group 1 '/oracle/oradata/bill/redo101.log' size 100m,
group 2 '/oracle/oradata/bill/redo102.log' size 100m;


[oracle@aa ~]$ mkdir /oracle/oradata/bill

SQL> @ createdb.sql

Database created.

SQL> ho vim sql.sql
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
conn system/admin123
@?/sqlplus/admin/pupbld.sql

SQL> @ sql.sql

====================================================================================================================================================

SQL> select status from v$instance;

STATUS
------------
OPEN

1 row selected.

SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted


SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01531: a database already open by the instance


SQL> show user;
USER is "SYSTEM"

SQL> show user;
USER is "SYSTEM"
SQL>
SQL> shutdown immediate
ORA-01031: insufficient privileges
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

==================================================================================================================================================

[oracle@aa ~]$ echo $ORACLE_SID
BILL
[oracle@aa ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 23 20:03:19 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size                  1220384 bytes
Variable Size             310378720 bytes
Database Buffers          205520896 bytes
Redo Buffers                7168000 bytes
Database mounted.
Database opened.
SQL> select instance_name from v$instance
  2  ;

INSTANCE_NAME
----------------
BILL

SQL> select name from v$databases;
select name from v$databases
                 *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select name from v$database;

NAME
---------
BILL

==========================================================================================================================================================
[oracle@aa ~]$ export ORACLE_SID=orcl
[oracle@aa ~]$ echo $ORACLE_SID=orcl
orcl=orcl
[oracle@aa ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 23 20:06:36 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  603979776 bytes
Fixed Size                  1220796 bytes
Variable Size             171970372 bytes
Database Buffers          423624704 bytes
Redo Buffers                7163904 bytes
Database mounted.
Database opened.
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
orcl


SQL> select name from v$database;

NAME
---------
ORCL

 

你可能感兴趣的:(oracle,手动建库)