--------------------------------每个节点和DG-------------------------------------------------------------------------
-- 配置/etc/hosts-
vim /etc/hosts
#Public
192.168.3.11 rac01
192.168.3.12 rac02
#Private
172.16.3.11 rac01-priv
172.16.3.12 rac02-priv
#Virtual
192.168.3.13 rac01-vip
192.168.3.14 rac02-vip
#SCAN
192.168.3.15 racscan
192.168.3.16 racscan
192.168.3.17 racscan
#DG
192.168.3.18 procdg
--------------------------------------DG-----------------------------------------------------------------------------------------
-- 上传安装包
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
-- 解压安装包
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
-- 关闭防火墙
service iptables stop
chkconfig iptables off
-- 配置yum
mount /dev/cdrom /mnt
vim /etc/yum.repos.d/server.repo
[base]
name=Red Hat
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
-- 修改内核参数
vim /etc/sysctl.conf
#for oracle softe
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
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
sysctl -p
--添加资源限制参数
vim /etc/security/limits.conf
#for oracle
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
-- 配置login
vim /etc/pam.d/login
session required pam_limits.so
-- 创建用户和组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
-- 安装目录配置
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
-- 环境变量
vim /home/oracle/.bash_profile
export ORACLE_SID=proc
export ORACLE_UNQNAME=proc
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_TERM=xterm; export ORACLE_TERM
export PATH=$ORACLE_HOME/bin:$PATH
umask 022
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
source /home/oracle/.bash_profile
-- 安装必要的软件包
yum -y install binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat
-- 开始安装(打开xmanager-passive)
mv database/ /home/oracle
su - oracle
cd database/
export DISPLAY=192.168.3.1:0.0
./runInstaller
-- 装到94%的时候回弹出一个框,执行两个脚本
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh
--------------------------------------------------每个节点、DG-----------------------------------------------
vim tnsnames.ora
PROCDG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = procdg)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = proc)
)
)
PROC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = racscan)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = proc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 主机名)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = proc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = proc)
)
)
---------------------------节点1-----------------------------------------------------
-- 设置数据库archivelog模式、force logging模式
SQL> select log_mode,force_logging from v$database; #查看数据库归档状态,强日志状态
LOG_MODE FOR
------------ ---
NOARCHIVELOG NO
SQL> alter database force logging; #开启强日志
Database altered.
SQL> shutdown immediate; #关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount; #修改归档状态必须在mount状态
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 541068856 bytes
Database Buffers 239075328 bytes
Redo Buffers 2596864 bytes
Database mounted.
SQL> alter database archivelog;#修改归档状态必须在mount状态,并且其他实例必须是not open状态
alter database archivelog
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any
instance
SQL> alter database archivelog;#开启归档
Database altered.
-- 再次查看archive和force logging状态
SQL> select log_mode,force_logging from v$database;
LOG_MODE FOR
------------ ---
ARCHIVELOG YES
-- 开启数据库到open状态,其他节点也打开
SQL> alter database open;
Database altered.
-------------------------------------------节点1--------------------------------------------------------------------
-- 传输密码文件,参数文件到备库
cd /u01/app/oracle/product/11.2.0/db_1/dbs/
scp orapwproc1 procdg:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwproc
scp initproc1.ora procdg:/u01/app/oracle/product/11.2.0/db_1/dbs/initproc.ora
-----------------------------------------节点1-----------------------------------------------------
-- 修改主库的参数文件
[oracle@rac01 rmanbak]$ vim initproc1.ora
#以下为配置DG而添加的内容
*.db_unique_name='proc'
*.log_archive_config='dg_config=(proc,procdg)'
*.log_archive_dest_1='location=+DATA/proc/archivelog #一般放在+FRA
valid_for=(all_logfiles,all_roles) db_unique_name=proc'
*.log_archive_dest_2='service=procdg
valid_for=(online_logfiles,primary_role)
db_unique_name=procdg'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.log_archive_format='arc_%t_%s_%r.arc'
#为switchover或failover而设置的参数
*.fal_server=procdg
*.standby_file_management='auto'
*.db_file_name_convert='/u01/app/oracle/oradata/proc/datafile','+DATA/proc/datafile'
*.log_file_name_convert='/u01/app/oracle/oradata/proc/onlinelog','+DATA/proc/onlinelog'
-- 修改完后创建到spfile
SQL> create spfile from pfile;
---------------------------------DG-------------------------------------
-- 修改备库参数文件
*.control_files='/u01/app/oracle/oradata/proc/controlfile/control01.ctl'
*.db_unique_name='procdg'
*.log_archive_config='dg_config=(proc,procdg)'
*.log_archive_dest_1='location=/u01/app/oracle/oradata/proc/archivelog
valid_for=(all_logfiles,all_roles) db_unique_name=procdg'
*.log_archive_dest_2='service=proc LGWR SYNC AFFIRM
valid_for=(online_logfiles,primary_role)
db_unique_name=proc'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.log_archive_format='arc_%t_%s_%r.arc'
*.fal_server=proc
*.standby_file_management=auto
*.db_file_name_convert='+DATA/proc/datafile','/u01/app/oracle/oradata/proc/datafile'
*.log_file_name_convert='+DATA/proc/onlinelog' ,'/u01/app/oracle/oradata/proc/onlinelog'
-- 在备库创建相应目录
mkdir -p /u01/app/oracle/admin/proc/adump
mkdir -p /u01/app/oracle/oradata/proc/controlfile
mkdir -p /u01/app/oracle/oradata/proc/archivelog
mkdir -p /u01/app/oracle/oradata/proc/datafile
mkdir -p /u01/app/oracle/oradata/proc/onlinelog
--从刚才创建的参数创建spfile
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initproc.ora'
---------------------------------节点1-----------------------
-- 在主库创建redolog
SQL> select thread#,group#,bytes/1024/1024 M from v$log;
THREAD# GROUP# M
---------- ---------- ----------
1 1 50
1 2 50
2 3 50
2 4 50
SQL> alter database add standby logfile thread 1 group 5 size 50M ,group 6 size 50M
,group 7 size 50M;
Database altered.
SQL> alter database add standby logfile thread 2 group 8 size 50M ,group 9 size 50M
,group 10 size 50M ;
Database altered.
---------------------------------------------------------任意节点----------------
rman target sys/oracle@proc auxiliary sys/oracle@procdg
duplicate target database for standby from active database nofilenamecheck;
--------------------------------------DG---------------------------