(一)基础环境
虚拟机环境 :vmware workstation 12
操作系统 : redhat6.7 - 64bit
数据库版本 :11.2.0.4
(二)安装前的环境准备
[oracle@standbydb1 bin]$vim /etc/hosts # 添加2个节点的IP信息 192.168.10.41 standbydb1 10.42 standbydb2 10.43 standbydb1-vip 10.44 standbydb2-10.40 standbydb-scan 10.10.10.41 standbydb1-priv 10.42 standbydb2-priv
(2.2.1)修改/etc/sysctl.conf
[root@standbydb1 ~]# vi /etc/sysctl.conf # 在末尾添加 kernel.msgmnb = 65536 kernel.msgmax = kernel.shmmax = 68719476736 kernel.shmall = 4294967296 fs.aio-max-nr = 1048576 fs.file-max = 681574420971521306910720 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 = net.core.wmem_max = 1048586 net.ipv4.tcp_wmem = 262144 net.ipv4.tcp_rmem = 4194304 4194304
内核参数执行命令sysctl -p生效。
(2.2.2)修改/etc/security/limits.conf
[root@vi /etc/security/limits.conf # 在末尾添加 grid soft nproc 2047 grid hard nproc 16384 grid soft nofile 1024 grid hard nofile oracle soft nproc oracle hard nproc oracle soft nofile oracle hard nofile 65536
(2.2.3)修改/etc/pam.d/login
(2.3)配置共享存储
(2.3.1)分区、格式化磁盘,在一个节点上执行即可
# 在节点1上格式化,以/dev/sdb为例: [root@standbydb1 ~]# fdisk /dev/sdb The number of cylinders for this disk is set to 3824. There is nothing wrong with that,but this is larger than ,and could in certain setups cause problems with: 1) software that runs at boot time (e.g.,old versions of LILO) 2) booting and partitioning software from other OSs (e.g.,DOS FDISK,OS/ FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (4): 1 First cylinder (3824,default ): Using default value Last cylinder or +size or +sizeM or +sizeK (): Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
(2.3.2)在2个节点上添加裸设备,2个节点都要执行
[root@standbydb1 ~]# vi /etc/udev/rules.d/60-raw.rules # 在后面添加 ACTION=="add",KERNEL==sdb1/bin/raw /dev/raw/raw1 %N" ACTION==sdc1/bin/raw /dev/raw/raw2 %Nsdd1/bin/raw /dev/raw/raw3 %Nsde1/bin/raw /dev/raw/raw4 %Nsdf1/bin/raw /dev/raw/raw5 %Nsdg1/bin/raw /dev/raw/raw6 %Nsdh1/bin/raw /dev/raw/raw7 %N KERNEL==raw[1]0660gridasmadmin KERNEL==raw[2]raw[3]raw[4]raw[5]raw[6]raw[7]"
启动裸设备,2个节点都执行
[root@standbydb1 ~]# start_udev
检查裸设备,2个节点都要查看,如果看不到设备信息,重启节点即可
[root@standbydb1 ~]# raw -qa /dev/raw/raw1: bound to major 8,minor 17 /dev/raw/raw2: bound to major 33 /dev/raw/raw3: bound to major 49 /dev/raw/raw4: bound to major 65 /dev/raw/raw5: bound to major 81 /dev/raw/raw6: bound to major 97 /dev/raw/raw7: bound to major 113
(2.4)安装依赖包,2个节点都执行
yum install -y binutils-* install -y compat-libstdc++-* install -y elfutils-libelf-* install -y elfutils-libelf-devel-static-* install -y gcc-* gcc-c++-* install -y glibc-* install -y glibc-common-* install -y glibc-devel-* install -y glibc-headers-* install -y kernel-headers-* install -y ksh-* install -y libaio-* install -y libaio-devel-* install -y libgcc-* install -y libgomp-* install -y libstdc++-* install -y libstdc++-devel-* make-* install -y sysstat-* install -y compat-libcap*
(2.5)创建oracle、grid用户相关
/usr/sbin/groupadd -g 1010 oinstall /usr/sbin/groupadd -g 1020 asmadmin /usr/sbin/groupadd -g 1021 asmdba /usr/sbin/groupadd -g 1022 asmoper /usr/sbin/groupadd -g 1031 dba /usr/sbin/groupadd -g 1032 oper useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid useradd -u 1101 -g oinstall -G dba,oper oracle mkdir -p /u01/app/11.2.0/grid mkdir -p /u01/app/mkdir /u01/app/oracle chown -R grid:oinstall /u01 chown oracle:oinstall /u01/app/chmod -R 775 /u01/
(2.5.2)配置grid的环境变量,2个节点都要执行
[grid@standbydb1 ~]$ vim .bash_profile #添加 export TMP=/tmp export TMPDIR=$TMP export ORACLE_SID=+ASM1 #如果是节点2,改为:+ASM2 export ORACLE_BASE=/u01/app/grid export ORACLE_HOME=/u01/app/grid 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 umask 022
(2.5.3)配置oracle的环境变量,2个节点都要执行
[oracle@standbydb1 ~$TMP export ORACLE_SID=standby1 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/db_1 export TNS_ADMIN=$ORACLE_HOME/network/admin export PATH=/usr/022
(2.5.4)配置grid的节点互信,在一个节点用grid用户执行
./sshUserSetup.sh -hosts primarydb1 primarydb2" -user grid -advanced
(2.5.5)配置oracle的节点互信,在一个节点用oracle用户执行
./sshUserSetup." -user oracle -advanced
(2.6)安装前的检查
2个节点安装cvuqdisk包,进入grid安装包
[root@standbydb1 soft]# cd grid/ [root@standbydb1 grid]# ls doc install response rpm runcluvfy.sh runInstaller sshsetup stage welcome.html [root@standbydb1 grid]# cd rpm/ [root@standbydb1 rpm]# cvuqdisk-1.0.7-.rpm [root@standbydb1 rpm]# rpm -ivh cvuqdisk-.rpm Preparing... ########################################### [100%] Using default group oinstall to install package 1:cvuqdisk ########################################### [100%]
执行grid安装检查
./runcluvfy.sh stage -pre crsinst -n standbydb1,standbydb2 -fixup -verbose
如果没有报错,即可执行安装操作。
(三)安装
(3.1)安装grid
安装命令:
./runInstaller -ignorePrereq -silent -force -responseFile /soft/grid/grid/response/grid_install.rsp -showProgress
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0 ORACLE_HOSTNAME=standbydb1 INVENTORY_LOCATION=/u01/app/oraInventory SELECTED_LANGUAGES=en oracle.install.option=CRS_CONFIG ORACLE_BASE=/u01/app/grid ORACLE_HOME=/u01/app/grid oracle.install.asm.OSDBA=asmdba oracle.install.asm.OSOPER=asmoper oracle.install.asm.OSASM=asmadmin oracle.install.crs.config.gpnp.scanName=standbydb-scan oracle.install.crs.config.gpnp.scanPort=1521 oracle.install.crs.config.clusterName=standbydb-install.crs.config.gpnp.configureGNS=falseinstall.crs.config.gpnp.gnsSubDomain=install.crs.config.gpnp.gnsVIPAddress=install.crs.config.autoConfigureClusterNodeVIP=install.crs.config.clusterNodes=standbydb1:standbydb1-vip,standbydb2:standbydb2-vip oracle.install.crs.config.networkInterfaceList=eth0:10.0:1,eth1:2,eth2:0.0:3install.crs.config.storageOption=ASM_STORAGE oracle.install.crs.config.sharedFileSystemStorage.diskDriveMapping=install.crs.config.sharedFileSystemStorage.votingDiskLocations=install.crs.config.sharedFileSystemStorage.votingDiskRedundancy=NORMAL oracle.install.crs.config.sharedFileSystemStorage.ocrLocations=install.crs.config.sharedFileSystemStorage.ocrRedundancy=NORMAL oracle.install.crs.config.useIPMI=install.crs.config.ipmi.bmcUsername=install.crs.config.ipmi.bmcPassword=install.asm.SYSASMPassword=Oracle123 oracle.install.asm.diskGroup.name=OCR oracle.install.asm.diskGroup.redundancy=install.asm.diskGroup.AUSize=install.asm.diskGroup.disks=/dev/raw/raw1,/dev/raw/raw2,/dev/raw/raw3 oracle.install.asm.diskGroup.diskDiscoveryString=/dev/raw/* oracle.install.asm.monitorPassword=Oracle123 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= PROXY_HOST= PROXY_PORT= PROXY_USER= PROXY_PWD= PROXY_REALM=
额外工作:
(1)创建磁盘组
su - grid
sqlplus / as sysasm create diskgroup data external redundancy disk '/dev/raw/raw4',/dev/raw/raw5/dev/raw/raw6' attribute compatible.rdbms'=11.2.0.0compatible.asmau_size1M'; create diskgroup arch external redundancy /dev/raw/raw7';
启动所有节点上的磁盘组
(2)创建默认监听
su - grid srvctl add listener srvctl start listener
(3.2)安装数据库软件
安装命令:
./runInstaller -ignorePrereq -silent -force -responseFile /u01/mysoft/oracle/db_install_20190714.rsp
响应文件db_install_20190714.rsp的内容为:
oracle.rspfmt_dbinstall_response_schema_v11_2_0 oracle.INSTALL_DB_SWONLY ORACLE_HOSTNAME=standbydb1 UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/en ORACLE_HOME=/u01/app/oracle/product/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.EEOptionsSelection=install.db.optionalComponents=install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=oper oracle.install.db.CLUSTER_NODES=standbydb1,standbydb2 oracle.install.db.isRACOneInstall=install.db.racOneServiceName=install.db.config.starterdb.type=GENERAL_PURPOSE oracle.install.db.config.starterdb.globalDBName=install.db.config.starterdb.SID=install.db.config.starterdb.characterSet=install.db.config.starterdb.memoryOption=install.db.config.starterdb.memoryLimit=install.db.config.starterdb.installExampleSchemas=install.db.config.starterdb.enableSecuritySettings=trueinstall.db.config.starterdb.password.ALL=install.db.config.starterdb.password.SYS=install.db.config.starterdb.password.SYSTEM=install.db.config.starterdb.password.SYSMAN=install.db.config.starterdb.password.DBSNMP=install.db.config.starterdb.control=DB_CONTROL oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=install.db.config.starterdb.automatedBackup.enable=install.db.config.starterdb.automatedBackup.osuid=install.db.config.starterdb.automatedBackup.ospwd=install.db.config.starterdb.storageType=install.db.config.starterdb.fileSystemStorage.dataLocation=install.db.config.starterdb.fileSystemStorage.recoveryLocation=install.db.config.asm.diskGroup=install.db.config.asm.ASMSNMPPassword= MYORACLESUPPORT_USERNAME= MYORACLESUPPORT_PASSWORD= SECURITY_UPDATES_VIA_MYORACLESUPPORT= DECLINE_SECURITY_UPDATES= PROXY_HOST= PROXY_PORT= PROXY_USER=
(3.3)创建数据库
[oracle@standbydb1 bin]$ pwd /u01/app/oracle/product/0/db_1/bin [oracle@standbydb1 bin]$ ./dbca -silent -responseFile /u01/mysoft/oracle/database/response/dbca_20190714.rsp
响应文件db_install_20190714.rsp的内容为:
[GENERAL] RESPONSEFILE_VERSION = 11.2.0 OPERATION_TYPE = createDatabase [CREATEDATABASE] GDBNAME = standby DB_UNIQUE_NAME = SID = NODELIST=General_Purpose.dbc SYSPASSWORD = Oracle123 SYSTEMPASSWORD = DATAFILEDESTINATION = +DATA STORAGETYPE=ASM DISKGROUPNAME=DATA CHARACTERSET = ZHS16GBK NATIONALCHARACTERSET= UTF8 DB_BLOCK_SIZE=8192 TOTALMEMORY = 1024"
(四)结果确认
查看集群资源
[grid@standbydb1 ~]$ crsctl status res -t -------------------------------------------------------------------------------- NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- ora.ARCH.dg ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 ora.DATA.dg ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 ora.LISTENER.lsnr ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 ora.OCR.dg ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 ora.asm ONLINE ONLINE standbydb1 Started ONLINE ONLINE standbydb2 Started ora.gsd OFFLINE OFFLINE standbydb1 OFFLINE OFFLINE standbydb2 ora.net1.network ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 ora.ons ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 ora.registry.acfs ONLINE ONLINE standbydb1 ONLINE ONLINE standbydb2 -------------------------------------------------------------------------------- Cluster Resources -------------------------------------------------------------------------------- ora.LISTENER_SCAN1.lsnr ONLINE ONLINE standbydb1 ora.cvu ONLINE ONLINE standbydb1 ora.oc4j ONLINE ONLINE standbydb1 ora.scan1.vip ONLINE ONLINE standbydb1 ora.standby.db ONLINE ONLINE standbydb1 Open ONLINE ONLINE standbydb2 Open ora.standbydb1.vip ONLINE ONLINE standbydb1 ora.standbydb2.vip 1 ONLINE ONLINE standbydb2
查看数据库状态
sql> select name,open_mode from v$database; NAME OPEN_MODE --------- -------------------- STANDBY READ WRITE sql> host_name,instance_name from gv$instance; HOST_NAME INSTANCE_NAME ------------- ----------------- standbydb1 standby1 standbydb2 standby2
结束。