在Linux上安裝Oracle11gR2-手工建庫

1、修改oracle用戶環境變量html

[oracle@oracle ~]$ su - oracle
[oracle@oracle ~]$ vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi
# User specific environment and startup programs
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1
export ORACLE_SID=ORACLEDB
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin
export PATH
[oracle@oracle ~]$ source .bash_profile

2、啓動監聽sql

[oracle@oracle ~]$ lsnrctl start

3、手工建庫數據庫

一、建立Oracle數據目錄:vim

  1: [oracle@oracle ~]$ mkdir -p $ORACLE_BASE/oradata/ORACLEDB
  2: [oracle@oracle ~]$ mkdir -p $ORACLE_BASE/admin/ORACLEDB
  3: [oracle@oracle ~]$ mkdir -p $ORACLE_BASE/flash_recovery_area

二、建立Oracle的口令認證bash

  1: [oracle@oracle ~]$ cd $ORACLE_HOME/dbs
  2: [oracle@oracle dbs]$ orapwd file=orapwORACLEDB password=oracle entries=30

三、建立初始化參數文件oracle

a、以官方參數文件爲模板建立初始化參數文件app

  1: [oracle@oracle ~]cd $ORACLE_HOME/dbs
  2: [oracle@oracle ~]cat init.ora |grep -v ^#|grep -v ^$> initORACLEDB.ora

b、修改初始化參數文件dom

修改前:ide

db_name='ORCL'
  memory_target=1G
  processes = 150
  audit_file_dest='<ORACLE_BASE>/admin/orcl/adump'
  audit_trail ='db'
  db_block_size=8192
  db_domain=''
  db_recovery_file_dest='<ORACLE_BASE>/flash_recovery_area'
  db_recovery_file_dest_size=2G
  diagnostic_dest='<ORACLE_BASE>'
  dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
  open_cursors=300
  remote_login_passwordfile='EXCLUSIVE'
  undo_tablespace='UNDOTBS1'
  # You may want to ensure that control files are created on separate physical
  # devices
  control_files = (ora_control1, ora_control2)
  compatible ='11.2.0'

在vim末行命令的編輯狀態中輸入spa

  1: :%s#orcl#ORACLEDB#gi裏面替換的orcl的字符串。其中i命令不區分大小寫。
  2: :%s#ora_control1#/u01/app/oracle/oradata/ORACLEDB/control01.ctl#g替換ora_control1的字符串。
  3: :%s#ora_control2#/u01/app/oracle/oradata/ORACLEDB/control02.ctl#g替換ora_control2的字符串。
  4: :%s#<ORACLE_BASE>#/u01/app/oracle#g替換<ORACLE_BASE>的字符串。
  5: :wq命令保存配置

修改後:

db_name='ORACLEDB'
  memory_target=1G
  processes = 150
  audit_file_dest='/u01/app/oracle/admin/ORACLEDB/adump'
  audit_trail ='db'
  db_block_size=8192
  db_domain=''
  db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
  db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORACLEDBXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (/u01/app/oracle/oradata/ORACLEDB/control01.ctl, /u01/app/oracle/oradata/ORACLEDB/control02.ctl)
compatible ='11.2.0'

四、鏈接數據庫實例

  1: 命令文件鏈接:
  2: [oracle@oracle ~]sqlplus sys/oracle as sysdba
  3: SYS@>create spfile from pfile;

五、啓動實例

  1: SYS@>startup nomount

六、在當前目錄建立create database語句建立數據庫

CREATE DATABASE ORACLEDB
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/ORACLEDB/redo01a.log','/u01/app/oracle/oradata/ORACLEDB/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/ORACLEDB/redo02a.log','/u01/app/oracle/oradata/ORACLEDB/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/ORACLEDB/redo03a.log','/u01/app/oracle/oradata/ORACLEDB/redo03b.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/ORACLEDB/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/ORACLEDB/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/ORACLEDB/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/ORACLEDB/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/ORACLEDB/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

給文件授予權限,並執行腳本:

  1: [oracle@oracle dbs]chmod 755 create_database.sql
  2: [oracle@oracle dbs]sqlplus / as sysdba
  3: SYS@>@create_database.sql
  4: Database created.

七、執行腳本並構建數據字典視圖

  1: [oracle@oracle ~] sqlplus / as sysdba
  2: SYS@>@?/rdbms/admin/catalog.sql
  3: SYS@>@?/rdbms/admin/catproc.sql
  4: SYS@>@?/rdbms/admin/utlrp.sql

八、使用system用戶登陸,執行腳本

  1: [oracle@oracle ~]sqlplus system/oracle
  2: SYSTEM@> @?/sqlplus/admin/pupbld.sql

4、驗證數據庫,是否正常:

1:[oracle@oracle ~]sqlplus / as sysdba
2:SYS@>select INSTANCE_NAME,STATUS from v$instance;
  INSTANCE_NAME    STATUS
  ---------------- ------------
  OEACLEDB         OPEN
相關文章
相關標籤/搜索