1.安装数据库软件
2. 设置环境变量
[oracle@zengyike ~]$ vi .bash_profile
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=/opt/app/oracle/product/11.2.0.4/db_1
export ORACLE_SID=yico
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export PATH
3. 创建zengyike目录
[root@zengyike ~]# chmod -R 775 /opt
[root@zengyike ~]# chown -R oracle:dba /opt/
rm -rf $ORACLE_BASE/admin/$ORACLE_SID
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/dpdump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/pfile
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/scripts
chmod -R 750 $ORACLE_BASE/admin
rm -rf $ORACLE_BASE/diag/rdbms/$ORACLE_SID
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/alert
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/cdump
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/hm
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/incident
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/incpkg
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/ir
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/lck
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/metadata
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/stage
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/sweep
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace
chmod -R 750 $ORACLE_BASE/diag/rdbms/$ORACLE_SID
4. 创建密码文件
[oracle@zengyike oracle]$ mkdir -p /opt/app/oracle/product/11.2.0.4/db_1/dbs/
[oracle@ogg04 dbs]$ pwd
/u01/app/oracle/product/11.2.0.3/db_1/dbs
[oracle@ogg04 dbs]$ orapwd file=orapwyico password=oracle entries=5
5.建初始化参数文件
[oracle@yico dbs]$ vi inityico.ora
yico.__db_cache_size=348127232
yico.__java_pool_size=4194304
yico.__large_pool_size=4194304
yico.__oracle_base='/opt/app/oracle'
yico.__pga_aggregate_target=343932928
yico.__sga_target=515899392
yico.__shared_io_pool_size=0
yico.__shared_pool_size=150994944
yico.__streams_pool_size=0
*.audit_file_dest='/opt/app/oracle/admin/yico/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/opt/oradata/yico/control01.ctl','/opt/oradata/yico/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yico'
*.diagnostic_dest='/opt/app/oracle'
*.memory_target=858783744
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
6. 启动实例到nomount状态
SQL> startup nomount pfile='$ORACLE_HOME/dbs/inityico.ora'
ORACLE instance started.
Total System Global Area 855982080 bytes
Fixed Size 2258040 bytes
Variable Size 503319432 bytes
Database Buffers 348127232 bytes
Redo Buffers 2277376 bytes
7.创建spfile
SQL> create spfile from pfile='$ORACLE_HOME/dbs/inityico.ora';
File created.
8.建库脚本
SQL> create database yico CONTROLFILE REUSE
MAXINSTANCES 8
MAXDATAFILES 2000
MAXLOGHISTORY 1024
MAXLOGFILES 64
MAXLOGMEMBERS 4
character set ZHS16GBK national character set AL16UTF16
logfile
group 1 ('/opt/oradata/yico/redo01.log') size 50M reuse,
group 2 ('/opt/oradata/yico/redo02.log') size 50M reuse,
group 3 ('/opt/oradata/yico/redo03.log') size 50M reuse
datafile '/opt/oradata/yico/system01.dbf' size 1000M reuse extent management local
sysaux datafile '/opt/oradata/yico/sysaux01.dbf' size 800M
default temporary tablespace temp tempfile '/opt/oradata/yico/temp01.dbf' size 500M reuse
undo tablespace undotbs1 datafile '/opt/oradata/yico/undotbs01.dbf' size 126M reuse
USER SYS IDENTIFIED BY "oracle" USER SYSTEM IDENTIFIED BY "oracle";
Database created.
9. 运行数据字典脚本,其中catalog和catproc是必需的,其它可选:
SQL> spool /home/oracle/cat_yico.log
SQL> @?/rdbms/admin/catalog.sql; (建数据字典视图)
SQL> @?/rdbms/admin/catproc.sql; (建存储过程包) --时间较长
SQL> @?/rdbms/admin/catblock.sql; (建锁相关的几个视图)
SQL> @?/rdbms/admin/catoctk.sql; (建密码工具包dbms_crypto_toolkit)
SQL> @?/rdbms/admin/owminst.plb; (建工作空间管理相关对象,如dmbs_wm)
SQL> spool off
执行完后检查/orahome/cat.log看看有什么不可接受的错误没有。
10. 新建sqlplus属性和帮助、USERS表空间
SQL> connect system/oracle
SQL> @?/sqlplus/admin/pupbld.sql
SQL> @?/sqlplus/admin/help/hlpbld.sql helpus.sql
SQL> connect /as sysdba
SQL> CREATE TABLESPACE USERS LOGGING DATAFILE '/opt/oradata/yico/user01.dbf' SIZE 100M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
SQL> ALTER DATABASE DEFAULT TABLESPACE USERS;
11. 最后修改为归档模式并重启(省略此步骤)
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /oracle/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence 1
Current log sequence 2
SQL> shutdown immediate
SQL> connect /as sysdba
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
至此 数据库安装完毕 监听也安装完毕