主机192.168.50.191
备机192.168.50.192
安装前配置
1. 解压安装文件
unzip linux_11gR2_database_1of2.zip
unzip linux_11gR2_database_2of2.zip
chmod -R 777 /opt
2.修改 /etc/hosts
本机IP地址 主机名 localhost
192.168.1.210 linuxserver localhost
3. 设置内核参数/etc/sysctl.conf
# This is Oracle 10g sysctl Kernel Setting by heweilong 20110415
# 可以使用的共享内存的总量 (最小内存)
kernel.shmall = 2097152
# 最大共享内存段大小 (内存大小)
kernel.shmmax = 1073741824
# 整个系统共享内存段的最大数目 (4096)
kernel.shmmni = 4096
# 每个信号对象集的最大信号对象数;系统范围内最大信号对象数;每个信号对象支持的最大操作数;系统范围内最大信号对象集数 (250 32000 100 128)
kernel.sem = 5010 641280 5010 128
# 系统中所允许的文件句柄最大数目 (65536)
fs.file-max = 65536
# 应用程序可使用的IPv4端口范围 (1024 65000)
net.ipv4.ip_local_port_range = 1024 65000
# 套接字接收缓冲区大小的缺省值 (262144)
net.core.rmem_default = 1048576
# 套接字接收缓冲区大小的最大值 (262144)
net.core.rmem_max = 1048576
# 套接字发送缓冲区大小的缺省值 (262144)
net.core.wmem_default = 262144
# 套接字发送缓冲区大小的最大值 (262144)
net.core.wmem_max = 262144
# 禁止ping主机 (0)
# net.ipv4.icmp_echo_ignore_all = 1
oracle11g 也可不设置,系统会自动更改
fs.file-max = 65536
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_max = 1048576
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
4.重新编译内核执行生效
# /sbin/sysctl -p
5. 编辑/etc/security/limits.conf 添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
或者
* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536
6.编辑/etc/pam.d/login 添加 (可选)
session required pam_limits.so
7. 修改/etc/selinux/config文件(可选)
SELINUX=disabled
8. 创建组和用户
# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba oracle
# passwd oracle
设置密码
9. 创建安装文件夹(可选)
# mkdir -p /opt/oracle/ora11g
# chown -R oracle.oinstall /opt
10. 修改XManager显示(可选)
xhost +IP
# xhost +192.168.1.210
11. 修改版/etc/redhat-release(可选)
# Red Hat Enterprise Linux Server release 5.3 (Tikanga)
Red Hat Enterprise Linux Server release 4 (Tikanga)
12. 编辑/opt/oracle.bash_profile
# This is Oracle 10g user .bash_profile Setting by heweilong 20110415
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/ora11g
export ORACLE_SID=primary
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
13. 注销root用户使用oracle用户登录系统安装数据库
执行/opt/database
#./runInstaller
安装数据库软件
1.仅安装数据库软件
2.单实例数据库
3.企业版
4.打依赖包(如果在安装包时,提示有关联,可以强制执行加入参数 –nodeps)
# rpm -ivh libaio-devel-0.3.106-5.i386.rpm
# rpm -ivh sysstat-7.0.2-11.el5.i386.rpm
# rpm -ivh –nodeps unixODBC-2.2.11-10.el5.i386.rpm
# rpm -ivh –nodeps unixODBC-devel-2.2.11-10.el5.i386.rpm
[root@node2 Server]# rpm -ivh libaio-devel-0.3.106-5.i386.rpm
warning: libaio-devel-0.3.106-5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing… ########################################### [100%]
1:libaio-devel ########################################### [100%]
[root@node2 Server]# rpm -ivh sysstat-7.0.2-11.el5.i386.rpm
warning: sysstat-7.0.2-11.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing… ########################################### [100%]
1:sysstat ########################################### [100%]
[root@node2 Server]# rpm -ivh –nodeps unixODBC-2.2.11-10.el5.i386.rpm
warning: unixODBC-2.2.11-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing… ########################################### [100%]
1:unixODBC ########################################### [100%]
[root@node2 Server]# rpm -ivh –nodeps unixODBC-devel-2.2.11-10.el5.i386.rpm
warning: unixODBC-devel-2.2.11-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing… ########################################### [100%]
1:unixODBC-devel ########################################### [100%]
5.安装数据库
安装数据库实例(主机中安装备机不需要安装)
1.实例名primary
2.数据库开启归档
3.字符集设置为ZHS16GBK
4.保存脚本
5.使用“监听程序配置”来创建从库的监听器
配置Data Guard配置文件
1.主机配置(192.168.50.191)开启数据库归档模式
如果出现乱码执行
$ export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
$ SQLplus /nolog
SQL> conn / as sysdba
SQL> startup;
SQL> alter database force logging;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> archive log list
[root@node1 ~]# su – oracle
[oracle@node1 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Tue Nov 6 10:20:58 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> startup;
ORACLE instance started.
Total System Global Area 1046224896 bytes
Fixed Size 1341140 bytes
Variable Size 603982124 bytes
Database Buffers 436207616 bytes
Redo Buffers 4694016 bytes
Database mounted.
Database opened.
SQL> alter database force logging;
Database altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 949972992 bytes
Fixed Size 1340496 bytes
Variable Size 553651120 bytes
Database Buffers 390070272 bytes
Redo Buffers 4911104 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/archive
Oldest online log sequence 3
Next log sequence to archive 5
Current log sequence 5
主机创建密码文件
orapwd file=’/opt/oracle/oradata/orapwstandby.ora’ password=sys entries=5
$ orapwd file=’/opt/oracle/oradata/orapwstandby.ora’ password=sys entries=5
主机创建控制文件命名为standby.ctl :
SQL> alter database create standby controlfile as ‘/opt/oracle/oradata/standby.ctl’;
SQL> alter database create standby controlfile as ‘/opt/oracle/oradata/standby.ctl’;
Database altered.
主机创建pfile参数文件命名为standby.ora
SQL> create pfile=’/opt/oracle/oradata/initSTANDBY.ora’ from spfile;
SQL> create pfile=’/opt/oracle/oradata/initstandby.ora’ from spfile;
File created.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
initSTANDBY.ora文件复制至本地
创建两份第一份命名为initPRIMARY.ora第二份为initSTANDBY.ora
备机pfile文件
将pfile文件initSTANDBY.ora复制至备机/opt/oracle/ora11g/dbs/initSTANDBY.ora目录下
备机密码文件
将密码文件orapwPRIMARY.ora更名为orapwSTANDBY.ora存放至备机/opt/oracle/ora11g/dbs/orapwSTANDBY.ora目录下
控制文件
将控制文件standby.ora 复制到备机 /opt/oracle/oradata/standby.ora 目录下
备机配置(192.168.50.192)创建文件夹
mkdir -p /opt/oracle/oradata/STANDBY;
mkdir -p /opt/oracle/admin/STANDBY/adump;
mkdir -p /opt/oracle/admin/STANDBY/bdump;
mkdir -p /opt/oracle/admin/STANDBY/cdump;
mkdir -p /opt/oracle/admin/STANDBY/dpdump;
mkdir -p /opt/oracle/admin/STANDBY/pfile;
mkdir -p /opt/oracle/admin/STANDBY/udump;
主机中数据文件和控制文件复制至备机,使用scp命令复制
[oracle@node1 ~]$ cd /opt/oracle/
[root@node1 oracle]# scp -r oradata/ 192.168.50.192:/opt/oracle/
root@192.168.50.192’s password:
standby.ctl 100% 9520KB 9.3MB/s 00:00
initSTANDBY.ora 100% 933 0.9KB/s 00:00
orapwSTANDBY.ora 100% 2048 2.0KB/s 00:00
redo03.log 100% 50MB 25.0MB/s 00:02
sysaux01.dbf 100% 450MB 21.4MB/s 00:21
undotbs01.dbf 100% 75MB 25.0MB/s 00:03
system01.dbf 100% 680MB 21.3MB/s 00:32
users01.dbf 100% 5128KB 5.0MB/s 00:00
control01.ctl 100% 9520KB 9.3MB/s 00:00
temp01.dbf 100% 29MB 29.0MB/s 00:00
control02.ctl 100% 9520KB 4.7MB/s 00:02
redo01.log 100% 50MB 25.0MB/s 00:02
redo02.log 100% 50MB 16.7MB/s 00:03 (more…)