⑤ 网卡:eth0 172.16.40.162、eth1 172.16.2.165
⑤ 网卡:eth0 172.16.40.163、eth1 172.16.2.166
service iptables status // 查看防火墙的状态
service iptables stop // 关闭防火墙
chkconfig --list iptables // 查看下次开机是否自动打开服务
chkconfig iptables off // 关闭下次开机自动打开服务
2、取消系统的ntp设置,采用 oracle 自带的时间同步服务
mv /etc/ntp.conf /etc/ntp.conf.org
3、配置yum,检查oracle所需的包:(参见联机文档《Grid Infrastructure Installation Guide for Linux》2.8.2)
rpm -qa | grep binutils (x86_64)
rpm -qa | grep glibc (x86_64 & i686)
rpm -qa | grep glibc-headers (x86_64)
rpm -qa | grep glibc-common
rpm -qa | grep glibc-devel (x86_64 & i686)
*rpm -qa | grep pdksh (i686)
rpm -qa | grep libaio (x86_64 & i686)
*rpm -qa | grep libaio-devel (x86_64 & i686)
rpm -qa | grep libgcc (x86_64 & i686)
rpm -qa | grep libstdc++ (x86_64 & i686)
*rpm -qa | grep libstdc++-devel (x86_64 & i686)
*rpm -qa | grep compat-libstdc++-33 (x86_64 & i686)
rpm -qa | grep make (x86_64)
rpm -qa | grep gcc (x86_64)
*rpm -qa | grep gcc-c++ (x86_64)
rpm -qa | grep sysstat (x86_64)
*rpm -qa | grep compat-libcap1 (x86_64)
*rpm -qa | grep numactl-devel (x86_64)
*rpm -qa | grep libXp (x86_64)
*rpm -qa | grep unixODBC-devel
rpm -qa | grep elfutils-libelf (x86_64)
*rpm -qa | grep elfutils-libelf-devel (x86_64)
rpm -qa | grep tigervnc-server
安装rlwrap是为了sqlplus、rman、asmcmd方便编辑命令。使用源码包或则RPM包装,在源码包安装的时候可能需要安装以下包:
yum install readline-devel
kernel.shmall = 8388608 //共享内存总量,以页为单位。推荐设置为物理内存大小除以分页大小,Linux 共享内存页大小为4KB
kernel.shmmax = 16725073919 //Linux进程可以分配的单独共享内存段的最大值,shmmax最大为内存大小减1,要大于一半的内存量
kernel.shmmni = 4096 //共享内存段的最大数量,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
net.core.wmem_max = 1048586
① vi /etc/security/limits.conf
打开文件描述符 nofile 最小1024 最小65536
单个用户可用进程数 nproc 最小2047 最小16384
进程堆栈段的大小 stack 最小10240 KB 最小10240KB,通常32768KB
useradd -g oinstall -G asmadmin,asmdba,asmoper,dba -u 500 grid
useradd -g oinstall -G asmdba,dba,oper -u 501 oracle
2、创建grid 和oracle的安装目录,并修改属性
mkdir -p /u01/app/oracle/product/11.2.0/db_1
mkdir -p /u01/app/grid_base
mkdir -p /u01/app/grid_home
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid_base
chown -R grid:oinstall /u01/app/grid_home
ORACLE_BASE=/u01/app/grid_base
ORACLE_HOME=/u01/app/grid_home
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
#export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
#export NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SSXFF'
#alias sqlplus='rlwrap sqlplus'
#alias asmcmd='rlwrap asmcmd'
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/lib
#export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms
#export TNS_ADMIN=$ORACLE_HOME/network/admin
#export NLS_LANG="simplified chinese"_china.al32utf8
#export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
#export NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SSXFF'
#export NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SSXFF TZR'
#alias sqlplus='rlwrap sqlplus'
#alias rman='rlwrap rman'
brw-rw---- 1 root disk 8, 0 12月 12 10:58 /dev/sda
brw-rw---- 1 root disk 8, 16 12月 12 10:58 /dev/sdb
brw-rw---- 1 root disk 8, 32 12月 12 10:58 /dev/sdc
② [root@vmrac-01 rules.d]# scsi_id --whitelisted --replace-whitespace --device=/dev/sda
368886030000010f9fa16eb9563779565
[root@vmrac-01 rules.d]# scsi_id --whitelisted --replace-whitespace --device=/dev/sdb
36888603000002210fa16eb9563779565
[root@vmrac-01 rules.d]# scsi_id --whitelisted --replace-whitespace --device=/dev/sdc
36888603000002211fa16eb9563779565
[root@vmrac-01 ~]# scsi_id --whitelisted --replace-whitespace --device=/dev/sdd
3688860300000195cfa16eb9563779565
[root@vmrac-01 ~]# scsi_id --whitelisted --replace-whitespace --device=/dev/sde
368886030000019a4fa16eb9563779565
[root@vmrac-01 ~]# scsi_id --whitelisted --replace-whitespace --device=/dev/sdf
36888603000001959fa16eb9563779565
[root@vmrac-01 ~]# scsi_id --whitelisted --replace-whitespace --device=/dev/sdg
36888603000001f01fa16eb9563779565
③ vi 90-oracle-asmdevices.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="3688860300000195cfa16e
b9563779565", NAME="asmdisk1", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="36888603000002210fa16e
b9563779565", NAME="asmdisk2", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="36888603000002211fa16e
b9563779565", NAME="asmdisk3", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="368886030000010f9fa16e
b9563779565", NAME="asmdisk4", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="368886030000010f9fa16e
b9563779565", NAME="asmdisk5", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="368886030000010f9fa16e
b9563779565", NAME="asmdisk6", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="368886030000010f9fa16e
b9563779565", NAME="asmdisk7", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
注:sda、sdb、sdc用于创建OCR磁盘,sdd、sde用于DATA磁盘,sdf、sdg用于FRA磁盘
vmrac-01和vmrac-02时间必须一致(用date看)
./sshUserSetup.sh -user grid -hosts "vmrac-01 vmrac-02" - noPromptPassphrase -confirm -advanced
cat /home/grid/.ssh/id_rsa.pub >> /home/grid/.ssh/authorized_keys
cat /home/grid/.ssh/id_dsa.pub >> /home/grid/.ssh/authorized_keys
scp 114.116.150.85:/home/grid/.ssh/id_dsa.pub /home/grid
scp 114.116.150.85:/home/grid/.ssh/id_rsa.pub /home/grid
cat /home/grid/id_rsa.pub >> /home/grid/.ssh/authorized_keys
cat /home/grid/id_dsa.pub >> /home/grid/.ssh/authorized_keys
scp /home/grid/.ssh/authorized_keys 114.116.150.85:/home/grid/.ssh/
cat /home/oracle/.ssh/id_rsa.pub >> /home/oracle/.ssh/authorized_keys
cat /home/oracle/.ssh/id_dsa.pub >> /home/oracle/.ssh/authorized_keys
scp 114.116.150.85:/home/oracle/.ssh/id_dsa.pub /home/oracle
scp 114.116.150.85:/home/oracle/.ssh/id_rsa.pub /home/oracle
cat /home/oracle/id_rsa.pub >> /home/oracle/.ssh/authorized_keys
cat /home/oracle/id_dsa.pub >> /home/oracle/.ssh/authorized_keys
scp /home/oracle/.ssh/authorized_keys 114.116.150.85:/home/oracle/.ssh/
RAC是一个多实例、单数据库的系统。数据文件、联机日志、控制文件、甚至归档日志等文件在一个集群中只有一份。所有节点都平等地使用这些文件。共享数据一般都是采用EMC等存储阵列,每个服务器通过HBA卡和光纤线连接到存储。
1)由Public网卡接入的网络,用于对外提供数据查询等服务
2)由Private网卡组成的私有网络;提供心跳和缓存融合
3)存储设备、光纤适配器提供,提供SCSI存储数据
单实例环境下,Oracle是运行在OS kernel之上。RAC环境下,存储设备是共享的。如果还依赖OS Kernal的服务,就无法保证多个主机间的协调工作,这时就需要引入额外的控制机制,这个机制就是位于Oracle和OS Kernel之间的CRS,它会在OS Kernel之前截获请求,然后和其他节点上的CRS协商,最终完成上层的请求。
集群环境之所以能够提供高可用性,是因为CRS对运行于其上的应用进行监视,并在发生异常进行重启、切换等干预手段。这些被CRS监控的对象就叫做CRS Resource。
GSD(Global Service Daemon)、ONS(Oracle Notification Service Daemon)、VIP、Listener
2)、database -related resource包括
Database、Instance和Service
② 使用runcluvfy.sh 来执行安装前的预检查,来避免由于环境配置引发的安装失败问题。
/u01/software/grid/runcluvfy.sh stage -pre crsinst -n vmrac-01,vmrac-02 -verbose
cd /u01/software/grid/respone
cat grid_install.rsp | grep -v ^# | grep -v ^$ >> grid.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0
ORACLE_HOSTNAME=vmrac-01 //主机名
INVENTORY_LOCATION=/u01/app/oraInventory //指定产品清单oracle inventory目录的路径
SELECTED_LANGUAGES=en //指定语言
oracle.install.option=CRS_CONFIG
ORACLE_BASE=/u01/app/grid_base //grid的BASE和HOME目录
ORACLE_HOME=/u01/app/grid_home
oracle.install.asm.OSDBA=asmdba //添加所需要的组
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin
oracle.install.crs.config.gpnp.scanName=vmrac-scan //scan 名,要与hosts对应
oracle.install.crs.config.gpnp.scanPort=1521 //listener对外服务端口
oracle.install.crs.config.clusterName=hwy-cluster //cluster 名称
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.gpnp.gnsSubDomain=
oracle.install.crs.config.gpnp.gnsVIPAddress=
oracle.install.crs.config.autoConfigureClusterNodeVIP=false
oracle.install.crs.config.clusterNodes=vmrac-01:vmrac-01-vip,vmrac-02:vmrac-02-vip
// 配置网络信息,格式为:node1:node1-vip,node2:node2-vip
oracle.install.crs.config.networkInterfaceList=eth0:172.15.22.0:1,eth1:172.15.1.0:2
// 格式为: eth0:141.88.24.0:1,eth1:10.2.1.0:2,eth2:141.88.52.0:3
oracle.install.crs.config.storageOption=ASM_STORAGE //配置存储形式
oracle.install.crs.config.sharedFileSystemStorage.diskDriveMapping=
oracle.install.crs.config.sharedFileSystemStorage.votingDiskLocations=
oracle.install.crs.config.sharedFileSystemStorage.votingDiskRedundancy=
oracle.install.crs.config.sharedFileSystemStorage.ocrLocations=
oracle.install.crs.config.sharedFileSystemStorage.ocrRedundancy=
oracle.install.crs.config.useIPMI=false //配置 IPMI
oracle.install.crs.config.ipmi.bmcUsername=
oracle.install.crs.config.ipmi.bmcPassword=
oracle.install.asm.SYSASMPassword= //配置ASM
oracle.install.asm.diskGroup.name=CRS // 磁盘的名字
oracle.install.asm.diskGroup.redundancy=NORMAL //选择冗余方式
oracle.install.asm.diskGroup.AUSize=4 //设置AU为4M
oracle.install.asm.diskGroup.disks=/dev/asmdisk1,/dev/asmdisk2,/dev/asmdisk3
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/asmdisk*
oracle.install.asm.monitorPassword= //密码
oracle.install.crs.upgrade.clusterNodes=
oracle.install.asm.upgradeASM=false
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
./runInstaller -responseFile /u01/software/grid/response/grid.rsp -silent -ignorePrereq -ignoreSysPrereqs -showProgress
vmrac-01:/u01/app/oraInventory/orainstRoot.sh
vmrac-02:/u01/app/oraInventory/orainstRoot.sh
vmrac-01:/u01/app/grid_home/root.sh
(可以通过tail -f /u01/app/grid_home/install/root_vmrac-01_2017-12-13_10-06-24.log
vmrac-02:/u01/app/grid_home/root.sh
(可以通过tail -f /u01/app/grid_home/install/root_vmrac-02_2017-12-13_11-31-26.log
如果在安装过程中报错运行/u01/app/grid_home/crs/install/roothas.pl -deconfig -force -verbose)修改后再次执行脚本。
crsctl query css votedisk
./sshUserSetup.sh -user oracle -hosts "vmrac-01 vmrac-02" - noPromptPassphrase -confirm -advanced
./runInstaller -silent -debug -force -ignoreSysPrereqs -ignorePrereq \
FROM_LOCATION=/u01/software/database/stage/products.xml \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 \
ORACLE_BASE=/u01/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.isCustomInstall=false \
oracle.install.db.DBA_GROUP=dba \
oracle.install.db.OPER_GROUP=oinstall \
oracle.install.db.CLUSTER_NODES=vmrac-01,vmrac-02 \
DECLINE_SECURITY_UPDATES=true
Before you can install Oracle RAC, you must install Oracle Grid Infrastructure on all servers (Oracle Clusterware and Oracle ASM) to create a cluster.
修改/u01/app/oraInventory/ContentsXML/inventory.xml
<HOME NAME="Ora11g_gridinfrahome1" LOC="/u01/app/grid_home" TYPE="O" IDX="1" CRS="true">
netca -silent -responsefile /u01/app/grid_home/assistants/netca/netca.rsp
①asmca -silent -createDiskGroup -sysAsmPassword 123123 -diskString '/dev/' -diskGroupName DATA -diskList '/dev/asmdisk4,/dev/asmdisk5,/dev/asmdisk6' -redundancy EXTERNAL -compatible.asm 11.2 -compatible.rdbms 11.2
②asmca -silent -createDiskGroup -sysAsmPassword 123123 -diskString '/dev/' -diskGroupName FRA -diskList '/dev/asmdisk7' -au_size 4 -redundancy EXTERNAL -compatible.asm 11.2 -compatible.rdbms 11.2
192.168.3.88 vmrac-01 192.168.3.88 vmrac-01
192.168.3.88 vmrac-01 192.168.3.88 vmrac-01
db_name ins_name hostname db_uniq_name service_dbname tnsnames
rac-01 orcl orcl1 rac-01 orcl orcl orcltds
rac-02 orcl orcl2 rac-02 orcl orcl orcltds
vmrac-01 vmorcl orcle1 vmrac-01 vmorcl vmorcl vmorcltds
vmrac-02 vmorcl orcl2 vmrac-02 vmorcl vmorcl vmorcltds
①alter database force logging;
②alter system set log_archive_config='DG_CONFIG=(orcl,vmorcl)';
③alter system set log_archive_dest_1='location=+FRA valid_for=(all_logfiles,all_roles) db_unique_name=orcl';
④alter system set log_archive_dest_2='service=vmorcltds LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=vmorcl';
⑤LOG_ARCHIVE_DEST_STATE_1=ENABLE,LOG_ARCHIVE_DEST_STATE_2=ENABLE (默认是enable)
⑥alter system set fal_server=vmorcltds;
⑦alter system set standby_file_management='AUTO';
①alter database force logging;
②alter system set log_archive_config='DG_CONFIG=(orcl,vmorcl)';
③alter system set log_archive_dest_1='location=+FRA valid_for=(all_logfiles,all_roles) db_unique_name=vmorcl';
④alter system set log_archive_dest_2='service=vmorcltds LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=orcl';
⑤LOG_ARCHIVE_DEST_STATE_1=ENABLE,LOG_ARCHIVE_DEST_STATE_2=ENABLE (默认是enable)
⑥alter system set fal_server=orcltds;
⑦alter system set standby_file_management='AUTO';
⑧alter system set REMOTE_LISTENER='vmrac-scan:1521'
mkdir -p /u01/app/oracle/admin/orcl/adump
②backup current controlfile for standby format '/u01/software/backup/std.con'
③ backup database format '/u01/software/backup/db_%U.bak'
scp 172.16.35.153:/u01/software/backup/db_1msm1f6t_1_1.bak ./
scp 172.16.35.153:/u01/software/backup/std.con ./
scp 172.16.35.153:/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl1 /u01/app/oracle/product/11.2.0/db_1/dbs/orapwvmorcl1
②restore spfile to '+DATA/racdb/spfile' from '/u01/software/backup/db_%U.bak';
③shutdown immediate之后以asm中的spfile启动,在启动之前要设置sga和pga的,备机内存要比主机小(主机128G,备机16G)
④vi /u01/app/oracle/product/11.2.0/db_1/dbs/initorcl1.ora
SPFILE='+DATA/orcl/spfileorcl.ora'
restore standby controlfile from '/u01/software/backup/std.con'
catalog start with '/u01/software/backup'
alter system set cluster_interconnects = '172.16.2.166' scope=spfile sid='orcl1' ;
alter system set cluster_interconnects = '172.16.2.167' scope=spfile sid='orcl2' ;
⑨添加standby日志组,clear logfile
alter database add standby logfile thread 1 ('+DATA/vmorcl/onlinelog/std_redo01_1.log','+DATA/vmorcl/onlinelog/std_redo01_2.log') size 512M;
alter database add standby logfile thread 1 ('+DATA/vmorcl/onlinelog/std_redo06_1.log','+DATA/vmorcl/onlinelog/std_redo06_2.log') size 512M;
alter database add standby logfile thread 2 ('+DATA/vmorcl/onlinelog/std_redo07_1.log','+DATA/vmorcl/onlinelog/std_redo07_2.log') size 512M;
alter database add standby logfile thread 2 ('+DATA/vmorcl/onlinelog/std_redo12_1.log','+DATA/vmorcl/onlinelog/std_redo12_2.log') size 512M;
alter database clear logfile group 1;
vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.40.155)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.40.156)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.40.163)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.40.164)(PORT = 1521))
select name from v$archived_log;
查看DG的几个进程RFS,LNS,MRP,LSP的状态
select process,sid,status from v$managed_standby;
recover managed standby database using current logfile disconnect from session;