Centos 下oracle 11g 安装部署及手动建库过程

时间:2022-05-02 10:31:36

Oracle 11g 手动建库,在虚拟环境中,不使用DBCA工具进行创建数据库

1.Linux环境的基本配置

2.ip  10.11.30.60

3.Oracle 11g安装过程


------------------------------------Linux环境配置---------------------------------------

1.硬件配置


[root@gzxbi01 ~]# free -g
total used free shared buffers cached
Mem:
-/+ buffers/cache:
Swap:
[root@gzxbi01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 34G .2G 24G % /
tmpfs .9G 84K .9G % /dev/shm
/dev/sda1 477M 33M 419M % /boot
/dev/sda5 15G 37M 14G % /u01
/dev/sda6 33G 48M 32G % /u01/oradata

[root@gzxbi01 ~]# grep "model name" /proc/cpuinfo
model name : QEMU Virtual CPU version (cpu64-rhel6)
model name : QEMU Virtual CPU version (cpu64-rhel6)
model name : QEMU Virtual CPU version (cpu64-rhel6)
model name : QEMU Virtual CPU version (cpu64-rhel6)


2.软件

[root@gzxbi01 ~]# ll /data/download/
total
drwxr-xr-x root root Aug database
-rw-rw-r-- eson eson Nov : linux.x64_11gR2_database_1of2.zip
-rw-rw-r-- eson eson Nov : linux.x64_11gR2_database_2of2.zip

3.配置过程

[root@gzxbi01 ~]# yum -y install epel-release

[root@gzxbi01 ~]# yum -y install binutils compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat compat-libstdc*

[root@gzxbi01 ~]# groupadd dba

[root@gzxbi01 ~]# groupadd oinstall
[root@gzxbi01 ~]# useradd -g oinstall -G dba oracle
[root@gzxbi01 ~]# passwd oracle

[root@gzxbi01 ~]# mkdir -p /u01/app/oracle

[root@gzxbi01 ~]# chown -R oracle:oinstall /u01/app/oracle
[root@gzxbi01 ~]# chmod -R 775 /u01/app/oracle

[root@gzxbi01 ~]# sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

#在sysctl.conf中添加对应的内核参数

net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmall = 2097152
kernel.shmmni=4096
net.core.rmem_default = 262144
net.core.wmem_default = 4194304
kernel.shmmax = 536870912
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576

[root@gzxbi01 ~]# sysctl -p

[root@gzxbi01 ~]# vim /etc/security/limits.conf

oracle soft nproc
oracle hard nproc
oracle soft nofile
oracle hard nofile

[root@gzxbi01 ~]# vim /etc/pam.d/login

session required /lib64/security/pam_limits.so

[root@gzxbi01 ~]# vim /etc/profile

if [ $USER = "oracle" ]; then
ulimit -u
ulimit -n
else
ulimit -u -n
fi

[root@gzxbi01 ~]# source /etc/profile

[root@gzxbi01 ~]# su - oracle

[oracle@gzxbi01 ~]$ vim .bash_profile

TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2./db_1; export ORACLE_HOME
ORACLE_SID=orcl11; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p ulimit -n
else
ulimit -u -n
fi
fi

[oracle@gzxbi01 ~]$ source .bash_profile

安装过程省略,手工建库过程

[root@gzxbi01 ~]# mkdir -p /u02/app/oracle/flash_recovery_area

[root@gzxbi01 ~]# mkdir -p /u02/app/oracle/arch/

[root@gzxbi01 ~]# chown -R oracle:oinstall /u02
[root@gzxbi01 ~]# chmod -R 775 /u02

[oracle@gzxbi01 oradata]$ cd $ORACLE_HOME/dbs

[oracle@gzxbi01 dbs]$ vim initnina.ora

instance_type='RDBMS'
db_domain='world'
db_name='nina'
compatible ='11.2.0'

statistics_level='typical'
audit_trail='none'
remote_login_passwordfile='none'

sga_target=300M
memory_target=1G
open_cursors=300
db_files=1000
processes=600
db_block_size=8192
cursor_sharing='force'

background_dump_dest='/u01/app/oracle/admin/nina/'
user_dump_dest='/u01/app/oracle/admin/nina/'
core_dump_dest='/u01/app/oracle/admin/nina/'
control_files = ('/u01/oradata/cont1.ctl','/u01/oradata/cont2.ctl')

db_file_multiblock_read_count=16
db_flashback_retention_target=7200
db_recovery_file_dest=('/u02/app/oracle/flash_recovery_area')
db_recovery_file_dest_size=1000M

log_archive_dest_1='LOCATION=/u02/app/oracle/arch/'
log_archive_format='log%t_%s_%r.arc'
optimizer_mode='all_rows'

undo_management='auto'
undo_retention=7200
undo_tablespace='undotbs_01'

连接启动

SQL> startup nomount
ORA-: insufficient privileges
SQL> exit
[oracle@gzxbi01 dbs]$ sqlplus /nolog SQL*Plus: Release 11.2.0.1. Production on Thu Dec :: Copyright (c) , , Oracle. All rights reserved. SQL> conn sys as sysdba
Enter password:
Connected to an idle instance.
SQL> startup nomount

编写SQL脚本

[root@gzxbi01 oradata]# mkdir -pv /u01/oradata/nina

[root@gzxbi01 oradata]# chown -R oracle:oinstall /u01/oradata
[root@gzxbi01 oradata]# chmod -R 755 /u01/oradata

CREATE DATABASE nina
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_passwordd
LOGFILE
GROUP 1 ('/u01/oradata/nina/redo01.log') SIZE 100M,
GROUP 2 ('/u01/oradata/nina/redo02.log') SIZE 100M,
GROUP 3 ('/u01/oradata/nina/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 300
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/oradata/nina/system01.dbf' SIZE 500M REUSE
SYSAUX DATAFILE '/u01/oradata/nina/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/oradata/nina/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oradata/nina/temp01.dbf'
SIZE 200M REUSE
UNDO TABLESPACE undotbs_01
DATAFILE '/u01/oradata/nina/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

执行SQL语句

SQL> @/u02/app/oracle/a.sql

可以同时观察对应的预警日志

[oracle@gzxbi01 trace]$ pwd
/u01/app/oracle/diag/rdbms/nina/nina/trace

[oracle@gzxbi01 trace]$ cat alert_nina.log

CREATE DATABASE nina
USER SYS IDENTIFIED BY *USER SYSTEM IDENTIFIED BY *MAXLOGFILES
MAXLOGMEMBERS
MAXLOGHISTORY
MAXDATAFILES
LOGFILE
GROUP ('/u01/oradata/nina/redo01.log') SIZE 100M,
GROUP ('/u01/oradata/nina/redo02.log') SIZE 100M,
GROUP ('/u01/oradata/nina/redo03.log') SIZE 100M
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/oradata/nina/system01.dbf' SIZE 500M REUSE
SYSAUX DATAFILE '/u01/oradata/nina/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/oradata/nina/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oradata/nina/temp01.dbf'
SIZE 200M REUSE
UNDO TABLESPACE undotbs_01
DATAFILE '/u01/oradata/nina/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
Database mounted in Exclusive Mode #表示Oracle已经打开initnina.ora文件中指定的控制文件
Lost write protection disabled
Thu Dec ::
Successful mount of redo thread , with mount id 1284923831 #指出第一个重做日志已经成功创建,并为恢复的目的打开
Assigning activation ID (0x4c9661b7)
Thread opened at log sequence
Current log# seq# mem# : /u01/oradata/nina/redo01.log
Successful open of redo thread
Thu Dec ::
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Dec ::
SMON: enabling cache recovery
processing ?/rdbms/admin/dcore.bsq
create tablespace SYSTEM datafile '/u01/oradata/nina/system01.dbf' SIZE 500M REUSE EXTENT MANAGEMENT LOCAL online
Thu Dec ::
Completed: create tablespace SYSTEM datafile '/u01/oradata/nina/system01.dbf' SIZE 500M REUSE EXTENT MANAGEMENT LOCAL online
create rollback segment SYSTEM tablespace SYSTEM
storage (initial 50K next 50K)
Completed: create rollback segment SYSTEM tablespace SYSTEM
storage (initial 50K next 50K)
processing ?/rdbms/admin/dsqlddl.bsq
processing ?/rdbms/admin/dmanage.bsq
CREATE TABLESPACE sysaux DATAFILE '/u01/oradata/nina/sysaux01.dbf' SIZE 325M REUSE #system和sysaux表空间创建成功 EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ONLINE
Thu Dec ::
Completed: CREATE TABLESPACE sysaux DATAFILE '/u01/oradata/nina/sysaux01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ONLINE
processing ?/rdbms/admin/dplsql.bsq
processing ?/rdbms/admin/dtxnspc.bsq
CREATE UNDO TABLESPACE UNDOTBS_01 DATAFILE '/u01/oradata/nina/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
Thu Dec ::
Successfully onlined Undo Tablespace .
Completed: CREATE UNDO TABLESPACE UNDOTBS_01 DATAFILE '/u01/oradata/nina/undotbs01.dbf' #撤销表空间undotbs01创建成功
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
CREATE TEMPORARY TABLESPACE TEMPTS1 TEMPFILE '/u01/oradata/nina/temp01.dbf'
SIZE 200M REUSE Completed: CREATE TEMPORARY TABLESPACE TEMPTS1 TEMPFILE '/u01/oradata/nina/temp01.dbf' #创建临时表空间TEMPPS1
SIZE 200M REUSE ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1 #指定TEMPTS1作为数据库的默认永久表空间
Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1
CREATE TABLESPACE USERS DATAFILE '/u01/oradata/nina/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
SEGMENT SPACE MANAGEMENT MANUAL
Thu Dec ::
Completed: CREATE TABLESPACE USERS DATAFILE '/u01/oradata/nina/users01.dbf' #创建User表空间
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
SEGMENT SPACE MANAGEMENT MANUAL
ALTER DATABASE DEFAULT TABLESPACE USERS #指定USERS表空间为默认永久表空间
Completed: ALTER DATABASE DEFAULT TABLESPACE USERS
processing ?/rdbms/admin/dfmap.bsq
processing ?/rdbms/admin/denv.bsq
processing ?/rdbms/admin/drac.bsq
processing ?/rdbms/admin/dsec.bsq
processing ?/rdbms/admin/doptim.bsq
processing ?/rdbms/admin/dobj.bsq
processing ?/rdbms/admin/djava.bsq
processing ?/rdbms/admin/dpart.bsq
processing ?/rdbms/admin/drep.bsq
processing ?/rdbms/admin/daw.bsq
processing ?/rdbms/admin/dsummgt.bsq
processing ?/rdbms/admin/dtools.bsq
processing ?/rdbms/admin/dexttab.bsq
processing ?/rdbms/admin/ddm.bsq
processing ?/rdbms/admin/dlmnr.bsq
processing ?/rdbms/admin/ddst.bsq
Thu Dec ::
SMON: enabling tx recovery
Starting background process SMCO
Thu Dec ::
SMCO started with pid=, OS id=
Thu Dec ::
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC #启动新后台进程QMNC
Thu Dec ::
QMNC started with pid=, OS id=
Completed: CREATE DATABASE nina
USER SYS IDENTIFIED BY *USER SYSTEM IDENTIFIED BY *MAXLOGFILES
MAXLOGMEMBERS
MAXLOGHISTORY
MAXDATAFILES
LOGFILE
GROUP ('/u01/oradata/nina/redo01.log') SIZE 100M,
GROUP ('/u01/oradata/nina/redo02.log') SIZE 100M,
GROUP ('/u01/oradata/nina/redo03.log') SIZE 100M
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/oradata/nina/system01.dbf' SIZE 500M REUSE
SYSAUX DATAFILE '/u01/oradata/nina/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/oradata/nina/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oradata/nina/temp01.dbf'
SIZE 200M REUSE
UNDO TABLESPACE undotbs_01
DATAFILE '/u01/oradata/nina/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
Thu Dec ::
db_recovery_file_dest_size of MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.

执行Oracle脚本创建数据字典

catalog.sql:数据字典视图。公用同义词及其他对象填充数据库

catproc.sql:创建Oracle提供的程序包及其他支持在数据库中使用PL/SQL代码的对象

SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql
....
Grant succeeded. PL/SQL procedure successfully completed. TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP CATALOG -- ::09

SQL> @$ORACLE_HOME/rdbms/admin/catproc.sql

 ....

 

在执行过程中,观察预警日志

Fri Dec  ::
Thread advanced to log sequence (LGWR switch)
Current log# seq# mem# : /u01/oradata/nina/redo02.log
Fri Dec ::
Thread advanced to log sequence (LGWR switch)
Current log# seq# mem# : /u01/oradata/nina/redo03.log
Fri Dec ::
Create Relation IPS_PACKAGE_UNPACK_HISTORY
Fri Dec ::
Thread advanced to log sequence (LGWR switch)
Current log# seq# mem# : /u01/oradata/nina/redo01.log
Fri Dec ::
Thread advanced to log sequence (LGWR switch)
Current log# seq# mem# : /u01/oradata/nina/redo02.log
Fri Dec ::
Thread advanced to log sequence (LGWR switch)
Current log# seq# mem# : /u01/oradata/nina/redo03.log
Fri Dec ::
Starting background process CJQ0
Fri Dec ::
CJQ0 started with pid=, OS id=
Fri Dec ::
Thread advanced to log sequence (LGWR switch)
Current log# seq# mem# : /u01/oradata/nina/redo01.log
Fri Dec ::
SERVER COMPONENT id=CATPROC: timestamp=-- ::

至此,手动建库完成!