oracle11g静默安装

摘要

图形化安装oracle时间又长,过程又枯燥,安装过程还要进行配置。

静默安装无需图形化,安装时间短,可以将所有配置提前设置好,配置文件也可以进行留存,用以以后的安装。

安装

安装依赖包

1
yum install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc libstdc++-devel libaio libaio-devel make sysstat unixODBC unixODBC-devel -y

创建用户、用户组

1
2
3
4
5
6
7
8
groupadd -g 2001 oinstall
groupadd -g 2002 dba
groupadd -g 2003 oper
useradd -u 2002 -g oinstall -G dba,oper oracle
id oracle
uid=1002(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba),1003(oper)
[root@leopard ~]# passwd oracle ==>Oracle@lifec.123
sys system Oraclelifec123

添加环境变量

1
2
3
4
5
6
7
8
9
10
11
12
echo "
export PATH
export TEMP=/tmp
export TEMPDIR=$TMP
export ORACLE_BASE=/server/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2/db_1
export ORACLE_SID=oracle
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8";
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';
" >> . bash_profile

修改系统参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
>>>>>>>>>>>>>>>>>>
[root@leopard ~]# vim /etc/sysctl.conf
kernel.shmmax = 536870912
kernel.shmmni = 4096
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
[root@leopard ~]# sysctl -p
>>>>>>>>>>>>>>>>>>>>
[root@leopard ~]# vim /etc/security/limits.conf
oracle soft nproc 65535
oracle hard nproc 65536
oracle soft nofile 65535
oracle hard nofile 65536
oracle soft stack 65535
[root@leopard ~]# vim /etc/pam.d/login
session required pam_limits.so

创建目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mkdir -p /server/oracle
chown -R oracle:oinstall /server/oracle
chmod -R 775 /server/oracle
mkdir -p /server/oraInventory
chown -R oracle:oinstall /server/oraInventory
chmod -R 775 /server/oraInventory
mkdir -p /data/oradata
chown -R oracle:oinstall /data/oradata
chmod -R 775 /data/oradata
mkdir -p /data/recovery_area
chown -R oracle:oinstall /data/recovery_area
chmod -R 775 /data/recovery_area
mkdir -p /server/oracle/admin/oracle/adump
chown -R oracle:oinstall /server/oracle/admin/oracle/adump
mkdir -p /data/oradata/oracle/
chown -R oracle:oinstall /data/oradata/oracle/
>>>>>>>>>>>>>>>>>>>

挂载oracle镜像

1
2
3
4
mkdir /mnt/iso
mount -o loop oracle11g_11204_x86_64.iso /mnt/iso/;cd /mnt/iso/
unzip p13390677_112040_Linux-x86-64_1of7.zip -d /home/oracle/
unzip p13390677_112040_Linux-x86-64_2of7.zip -d /home/oracle/

修改db_install.rsp文件

待续。。。

执行静默安装

1
2
./runInstaller -silent -force -responseFile /home/oracle/database/response/db_install.rsp
ps>>>>>>db_install.rsp文件需要进行编辑修改

后续优化操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
create tablespace MIRACLE
datafile '/data/oradata/oracle/miracle01.dbf'
size 10G autoextend on next 100m maxsize 30G,
'/data/oradata/oracle/miracle02.dbf'
size 10G autoextend on next 100m maxsize 30G;
alter tablespace miracle add datafile
'/data/oradata/oracle/miracle02.dbf'
size 10G autoextend on next 100m maxsize 30G extent management local autoallocate;
create tablespace IDX_MIRACLE
datafile '/data/oradata/oracle/idx_miracle01.dbf'
size 5G
autoextend on next 100m maxsize 15G,
'/data/oradata/oracle/idx_miracle02.dbf'
size 5G
autoextend on next 100m maxsize 15G;
ALTER USER MIRACLE DEFAULT TABLESPACE MIRACLE;
ALTER USER MIRACLE QUOTA UNLIMITED ON MIRACLE;
ALTER USER MIRACLE QUOTA UNLIMITED ON IDX_MIRACLE;
startup;
@cuser.sql
impdp miracle/miracle directory=pump_dir dumpfile=miracle2015-08-04-06x0.dmp schemas=miracle remap_tablespace=users:MIRACLE
ALTER TABLE "orders" MOVE TABLESPACE MIRACLE;
remap_tablespace=users:MIRACLE
create tablespace MIRACLE
datafile '/data/oradata/oracle/miracle01.dbf'
size 5G autoextend on next 100m maxsize 10G,
'/data/oradata/oracle/miracle02.dbf'
size 5G autoextend on next 100m maxsize 10G;
开启归档日志
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
archive log list;
开启闪回
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database flashback on;
SQL> alter database open;
开启强制日志--用于dg
select force_logging from v$database;
alter database force logging;
开启附加日志--用于日志挖掘
select supplemental_log_data_min from v$database;
alter database add supplemental log data;
关闭系统审计aud$
alter system set audit_trail=none scope=spfile;
shutdown immediate;
startup;
truncate table SYS.AUD$;
一、打开闪回数据库特性:
1、确保数据库处于归档模式,如果为非归档模式,将数据库转换成归档模式
SQL> archive log list;
数据库日志模式 存档模式
自动存档 启用
存档终点 /cwarch
最早的联机日志序列 1274
下一个存档日志序列 1276
当前日志序列 1276
2、设置闪回恢复区
设置闪回区大小:
SQL> alter system set db_recovery_file_dest_size=80g scope=spfile;
设置闪回区位置:
SQL> alter system set db_recovery_file_dest='/workdb/account_flashback_area' scope=spfile;
设置闪回目标为5天,以分钟为单位,每天为1440分钟:
SQL> alter system set db_flashback_retention_target=7200 scope=spfile;
3、打开闪回功能
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database flashback on;
SQL> alter database open;
4、确认数据库闪回特性已经启用
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
二、关闭闪回数据库特性:
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database flashback off;
SQL> alter database open;