ITPub博客

首页 > 数据库 > Oracle > Oracle 11g RAC + DG安装详解--05

Oracle 11g RAC + DG安装详解--05

原创 Oracle 作者:pennymeng 时间:2020-07-23 18:13:47 0 删除 编辑


、安装DG

1. 安装DG 数据库软件

1.1 修改/etc/hosts

[root@localhost ~]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 

#public

192.168.1.15 TSTB

 

#public vip

192.168.1.16 TSTB-vip

 

#primary

192.168.1.1 TRAC1

192.168.1.3 TRAC1-vip

192.168.1.2 TRAC2

192.168.1.4 TRAC2-vip

192.168.1.5 TRAC TRAC.shdb.domain

 

1.2 修改hostname

[root@localhost ~]# vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=TSTB

 

[root@localhost ~]# hostname TSTB

 

1.3 修改ip

双网卡绑定

 

1 vi /etc/modprobe.d/dist.conf

alias bond0 bonding

options bond0 mode=1 miimon=50

 

2 vim /etc/sysconfig/network-scripts/ifcfg-em1

 

DEVICE=em1

>

BOOTPROTO=none

TYPE=Ethernet

MASTER=bond0

SLAVE=yes

USERCTL=no

 

3 vim /etc/sysconfig/network-scripts/ifcfg-em2

DEVICE=em2

>

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

USERCTL=no

~

 

4 vim /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0

>

BOOTPROTO=none

USERCTL=no

IPADDR=192.168.1.15

NETMASK=255.255.255.0

GATEWAY=192.168.1.255

BONDING_OPTS="mode=1 miimon=50"

IPV6INIT=no

 

service NetworkManager stop

chkconfig NetworkManager off

chkconfig network on

service network restart

 

[root@localhost network-scripts]# service network restart

 

 

[root@TSTB network-scripts]# vi ifcfg-bond0:1

#DNS1=114.114.114.114

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

DEVICE= bond0:1

TYPE=Ethernet

>

NM_CONTROLLED=yes

BOOTPROTO=none

HWADDR= 14:18:77:59:21:F0

IPADDR=192.168.1.16

PREFIX=24

GATEWAY=192.168.1.255

NETMASK=255.255.255.0

IPV6INIT=no

USERCTL=no

 

[root@TSTB network-scripts]# ifup ifcfg-bond0:1

 

[root@shdbstd network-scripts]# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet6 ::1/128 scope host

       valid_lft forever preferred_lft forever

2: em1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000

    link/ether 14:18:77:59:21:f0 brd ff:ff:ff:ff:ff:ff

3: em2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000

    link/ether 14:18:77:59:21:f0 brd ff:ff:ff:ff:ff:ff

4: em3: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000

    link/ether 14:18:77:59:21:f2 brd ff:ff:ff:ff:ff:ff

5: em4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000

    link/ether 14:18:77:59:21:f3 brd ff:ff:ff:ff:ff:ff

6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP

    link/ether 14:18:77:59:21:f0 brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.15/24 brd 192.168.1.255 scope global bond0

    inet 192.168.1.16/24 brd 192.168.1.255 scope global secondary bond0:1

    inet6 fe80::1618:77ff:fe59:21f0/64 scope link

       valid_lft forever preferred_lft forever

 

1.4 磁盘配置

1)      多路径安装和配置

 

[root@shdbstd /]# cat /etc/multipath.conf

# This is a basic configuration file with some examples, for device mapper

# multipath.

# For a complete list of the default configuration values, see

# /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf.defaults

# For a list of configuration options with descriptions, see

# /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf.annotated

#

# REMEMBER: After updating multipath.conf, you must run

#

# service multipathd reload

#

# for the changes to take effect in multipathd

 

## By default, devices with vendor = "IBM" and product = "S/390.*" are

## blacklisted. To enable mulitpathing on these devies, uncomment the

## following lines.

#blacklist_exceptions {

#       device {

#               vendor  "IBM"

#               product "S/390.*"

#       }

#}

 

## Use user friendly names, instead of using WWIDs as names.

defaults {

        user_friendly_names yes

}

##

## Here is an example of how to configure some standard options.

##

#

#defaults {

#       udev_dir                /dev

#       polling_interval        10

#       path_selector           "round-robin 0"

#       path_grouping_policy    multibus

#       getuid_callout          "/lib/udev/scsi_id --whitelisted --device=/dev/%n"

#       prio                    alua

#       path_checker            readsector0

#       rr_min_io               100

#       max_fds                 8192

#       rr_weight               priorities

#       failback                immediate

#       no_path_retry           fail

#       user_friendly_names     yes

#}

##

## The wwid line in the following blacklist section is shown as an example

## of how to blacklist devices by wwid.  The 2 devnode lines are the

## compiled in default blacklist. If you want to blacklist entire types

## of devices, such as all scsi devices, you should use a devnode line.

## However, if you want to blacklist specific devices, you should use

## a wwid line.  Since there is no guarantee that a specific device will

## not change names on reboot (from /dev/sda to /dev/sdb for example)

## devnode lines are not recommended for blacklisting specific devices.

##

#blacklist {

#       wwid 26353900f02796769

#       devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"

#       devnode "^hd[a-z]"

#}

#multipaths {

#       multipath {

#               wwid                    3600508b4000156d700012000000b0000

#               alias                   yellow

#               path_grouping_policy    multibus

#               path_checker            readsector0

#               path_selector           "round-robin 0"

#               failback                manual

#               rr_weight               priorities

#               no_path_retry           5

#       }

#       multipath {

#               wwid                    1DEC_____321816758474

#               alias                   red

#       }

#}

#devices {

#       device {

#               vendor                  "COMPAQ  "

#               product                 "HSV110 (C)COMPAQ"

#               path_grouping_policy    multibus

#               getuid_callout          "/lib/udev/scsi_id --whitelisted --device=/dev/%n"

#               path_checker            readsector0

#               path_selector           "round-robin 0"

#               hardware_handler        "0"

#               failback                15

#               rr_weight               priorities

#               no_path_retry           queue

#       }

#       device {

#               vendor                  "COMPAQ  "

#               product                 "MSA1000         "

#               path_grouping_policy    multibus

#       }

#}

multipaths {

       multipath {

               wwid                    36000d31003817200000000000000000b

               alias                   dgdata1

       }

multipath {

               wwid                    36000d31003817200000000000000000c

               alias                   dgdata2

       }

        multipath {

               wwid                    36000d31003817200000000000000000d

               alias                   dgdata3

       }

        multipath {

               wwid                    36000d31003817200000000000000000e

               alias                   dgdata4

       }

        multipath {

               wwid                    36000d31003817200000000000000000f

               alias                   dgdata5

       }

        multipath {

               wwid                    36000d310038172000000000000000010

               alias                   dgdata6

       }

 

}

 

[root@shdbstd /]# service multipathd restart

ok

Stopping multipathd daemon: [  OK  ]

Starting multipathd daemon: [  OK  ]

[root@shdbstd /]# multipath -ll

dgdata1 (36000d31003817200000000000000000b) dm-0 COMPELNT,Compellent Vol

size=2.0T features='1 queue_if_no_path' hwhandler='0' wp=rw

`-+- policy='round-robin 0' prio=1 status=active

  |- 0:0:14:1 sdb 8:16 active ready running

  `- 2:0:1:1  sdc 8:32 active ready running

[root@shdbstd /]#

 

2)      LVM 配置

[root@TSTB ~]# parted /dev/mapper/dgdata1 mklabel gpt

(parted) mkpart primary 0% 100%

(parted) print                                                           

Model: Linux device-mapper (multipath) (dm)

Disk /dev/mapper/dgdata1: 2199GB

Sector size (logical/physical): 512B/4096B

Partition Table: gpt

 

Number  Start   End     Size    File system  Name     Flags

 1      17.4kB  2199GB  2199GB               primary

 

 

[root@shdbstd /]# pvcreate /dev/mapper/dgdata1p1

[root@shdbstd /]# vgcreate voldg /dev/mapper/dgdata1p1

[root@shdbstd /]# lvcreate -l +524286 -n data voldg

[root@shdbstd /]# mkfs.ext4 /dev/mapper/voldg-data

[root@shdbstd /]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/voldg/data

  LV Name                data

  VG Name                voldg

  LV UUID                JE1Eif-8qfu-LzR4-nn7w-bqfT-LCsG-4RKk4s

  LV Write Access        read/write

  LV Creation host, time shdbstd, 2017-07-05 15:46:08 +0800

  LV Status              available

  # open                 1

  LV Size                2.00 TiB

  Current LE             524286

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:2

 

parted /dev/mapper/dgdata2 mklabel gpr mkpart primary 0 100%

parted /dev/mapper/dgdata2 mklabel gpt mkpart primary 0 100%

parted /dev/mapper/dgdata3 mklabel gpt mkpart primary 0 100%

parted /dev/mapper/dgdata4 mklabel gpt mkpart primary 0 100%

parted /dev/mapper/dgdata5 mklabel gpt mkpart primary 0 100%

parted /dev/mapper/dgdata6 mklabel gpt mkpart primary 0 100%

 

pvcreate /dev/mapper/dgdata2p1

pvcreate /dev/mapper/dgdata3p1

pvcreate /dev/mapper/dgdata4p1

pvcreate /dev/mapper/dgdata5p1

pvcreate /dev/mapper/dgdata6p1

 

vgextend voldg /dev/mapper/dgdata2p1

vgextend voldg /dev/mapper/dgdata3p1

vgextend voldg /dev/mapper/dgdata4p1

vgextend voldg /dev/mapper/dgdata5p1

vgextend voldg /dev/mapper/dgdata6p1

 

lvextend -l +2621430 /dev/voldg/data

3)      修改/etc/fstab

添加lvm 挂载

/dev/mapper/voldg-data  /oradata                ext4    defaults        0 0

执行下面的命令让挂载生效

[root@shdbstd /]# mount -a

4)      添加磁盘

扫描磁盘

for i in `ls /sys/class/scsi_host/`; do echo "- - -" >> /sys/class/scsi_host/$i/scan ; done

 

扫描磁盘wwid

scsi_id --whitelisted --replace-whitespace /dev/sd*

 

添加多路径配置

/etc/multipath.conf

multipaths {

       multipath {

               wwid                    36000d31003817200000000000000000b

               alias                   dgdata1

       }

       multipath {

               wwid                    36000d31003817200000000000xxxxxxxx

               alias                   dgdatax

       }

}

 

重启多路径

[root@shdbstd /]# service multipathd restart

ok

Stopping multipathd daemon: [  OK  ]

Starting multipathd daemon: [  OK  ]

 

5)      扩展lvm

parted 对新磁盘做分区,例如parted /dev/mapper/dgdatax mklabel gpt mkpart primary 0 100%

pvcreate /dev/mapper/dgdataxp1

vgextend voldg /dev/mapper/dgdataxp1

vgdisplay 查看free PE 大小

lvextend -l +xxxxx /dev/voldg/data  xxxxxx 为上面查到的free PE 大小)

resize2fs /dev/mapper/voldg-dgdata

df -h 验证目录大小

 

 

1.5 安装DG 数据库软件

        1. ---- 关闭系统的防火墙

chkconfig iptables off (永久生效)

service iptables stop )(临时生效)

 

 

--- 关闭selunix 服务

vi /etc/selinux/config

SELINUX=disabled

 

2. 修改内核参数

cp /etc/sysctl.conf /etc/sysctl.conf.bak

vi /etc/sysctl.conf 末尾

# 注释掉kernel.shmmax kernel.shmall 两行

kernel.shmall = 11111                              ( 单位:字节  物理内存/4096)

kernel.shmmax = 11111                  (单位:字节  物理内存-1

添加:

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmmax = 135221043199

kernel.shmmni = 4096

kernel.shmall = 33012950

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

以上参数为使用oracle yum 自动配置的参数

重新加载生效:

[root@TRAC1 ~]# sysctl -p

 

3. 安装必要的包

两节点分别执行如下三步:

    配置yum

[root@TRAC1 grid]# cd /etc/yum.repos.d/

[root@TRAC1 yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak

[root@TRAC1 yum.repos.d]# vi /etc/yum.repos.d/CentOS-Base.repo

[base]

name=CentOS-$releasever - Base

baseurl=http://192.168.1.10 YUM 源)/centos6.9

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

[root@TRAC1 yum.repos.d]# yum clean all

Loaded plugins: fastestmirror, refresh-packagekit, security

Cleaning repos: base

Cleaning up Everything

Cleaning up list of fastest mirrors

[root@TRAC1 yum.repos.d]# yum makecache

Loaded plugins: fastestmirror, refresh-packagekit, security

Determining fastest mirrors

Metadata Cache Created

…….

[root@TRAC1 yum.repos.d]#

 

    检查哪些包没安装

for i in binutils compat-gcc-34 compat-libstdc++-296 control-center \

  gcc gcc-c++ glibc glibc-common glibc-devel libaio libgcc elfutils-libelf-devel \

  libstdc++ libstdc++-devel libXp make openmotif22 setarch \

  compat-libstdc++-33 libaio-devel sysstat unixODBC unixODBC-devel \

compat-libcap1 ksh tigervnc-server

do

  rpm -q $i &>/dev/null || F="$F $i"

done ;echo $F;unset F

 

    使用yum 安装这些包

[root@TRAC1 yum.repos.d]# yum install -y compat-gcc-34 compat-libstdc++-296 gcc gcc-c++ elfutils-libelf-devel libstdc++-devel libXp openmotif22 setarch compat-libstdc++-33 libaio-devel unixODBC unixODBC-devel compat-libcap1 ksh tigervnc-server

 

4. 修改oracle 用户限制

cp /etc/security/limits.conf /etc/security/limits.conf.bak

vi /etc/security/limits.conf 末尾添加:

oracle   soft   nofile   2047

oracle   hard   nofile   65536

oracle   soft   nproc    2047

oracle   hard   nproc    16384

oracle   soft   stack    10240

oracle   hard   stack    32768

 

5. 修改/etc/pam.d/login

cp /etc/pam.d/login /etc/pam.d/login.bak

vi /etc/pam.d/login 末尾添加:

session    required     /lib64/security/pam_limits.so

 

6. 更改安装所有者的 ulimit 设置

vi /etc/profile 末尾添加:

if [ /$USER = "oracle" ] ; then

    if [ /$SHELL = "/bin/ksh" ]; then

        ulimit -p 16384

        ulimit -n 65536

    else

        ulimit -u 16384 -n 65536

    fi

    umask 022

fi

 

7. 建立必要的组和用户

[root@ ~]#

groupadd -g 501 oinstall

groupadd -g 502 dba

groupadd -g 503 oper

groupadd -g 504 asmadmin

groupadd -g 505 asmdba

groupadd -g 506 asmoper

 

useradd -u 501 -g oinstall -G dba,oper,asmdba oracle

echo "123456"|passwd --stdin oracle

 

8. 建立安装目录

[root@ ~]#

chown -R oracle:oinstall /home/oracle

mkdir -p /home/app/oracle

chown -R oracle:oinstall /home/app/oracle

chmod 755 /home/oracle

chmod -R 775 /home/app

 

 

9. 设置oracle 的环境变量

su - oracle

vi .bash_profile 末尾添加:

export ORACLE_BASE=/home/app/oracle

export ORACLE_HOME=/home/app/oracle/product/11.2.0

export ORACLE_SID=TSTB

export PATH=$PATH:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export NLS_LANG=AMERICAN_AMERICA.UTF8

 

[oracle@TSTB database]$ ./runInstaller

2. 数据复制

2.1 准备备库pfile

主库节点 1

[oracle@TRAC1 nfs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 28 14:46:42 2017

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> create pfile='/home/app/oracle/product/11.2.0/dbs/initTSTB.ora' from spfile;

 

File created.

 

SQL> exit

[oracle@TRAC1 dbs]$ scp /home/app/oracle/product/11.2.0/dbs/initTSTB.ora oracle@TSTB:/home/app/oracle/product/11.2.0/dbs/initTSTB.ora

oracle@TSTB's password:

initTSTB.ora                                                                                                                     100% 1345     1.3KB/s   00:00   

[oracle@TRAC1 dbs]$

 

备库

mkdir -p /home/app/oracle/admin/TSTB/adump

[oracle@TSTB ~]$ cd /oradata/

[oracle@TSTB oradata]$ mkdir TSTB

[oracle@TSTB oradata]$ cd TSTB/

[oracle@TSTB TSTB]$ mkdir controlfile

[oracle@TSTB TSTB]$ mkdir datafile

[oracle@TSTB TSTB]$ mkdir archivelog

[oracle@TSTB TSTB]$ mkdir onlinelog

[oracle@TSTB TSTB]$ mkdir parameterfile

[oracle@TSTB TSTB]$ mkdir tempfile

 

[oracle@TSTB dbs]$ vi initTSTB.ora

*.cluster_database=true

TSTB.__db_cache_size=40802189312

TSTB.__java_pool_size=939524096

TSTB.__large_pool_size=1073741824

TSTB.__oracle_base='/home/app/oracle'#ORACLE_BASE set from environment

TSTB.__pga_aggregate_target=10737418240

TSTB.__sga_target=53687091200

TSTB.__shared_io_pool_size=0

TSTB.__shared_pool_size=10603200512

TSTB.__streams_pool_size=0

*.audit_file_dest='/home/app/oracle/admin/TSTB/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_file_record_keep_time=14

*.control_files='/oradata/TSTB/controlfile/controlfile01','/oradata/TSTB/datafile/controlfile02'

*.db_block_size=8192

*.db_create_file_dest='/oradata'

*.db_domain=''

*.db_files=20000

*.db_name='TRAC'

*.db_unique_name='TSTB'

*.db_recovery_file_dest='/oradata/TSTB/archivelog'

*.db_recovery_file_dest_size=536870912000

*.diagnostic_dest='/home/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=TRACXDB)'

*.fal_client='TSTB'

*.fal_server='TRAC'

*.log_archive_config='dg_config=(TRAC,TSTB)'

*.log_archive_dest_1='location=/oradata/TSTB/archivelog valid_for=(all_logfiles,all_roles)  db_unique_name=TSTB'

*.log_archive_dest_2='service=TRAC lgwr async affirm  valid_for=(online_logfiles,primary_role) db_unique_name=TRAC'

*.db_file_name_convert="+SSDDATA/TRAC","/oradata/TSTB","+SASDATA/TRAC","/oradata/TSTB"

*.log_file_name_convert="+SSDDATA/TRAC","/oradata/TSTB","+SASDATA/TRAC","/oradata/TSTB"

*.log_archive_dest_state_1='enable'

*.log_archive_dest_state_2='enable'

*.standby_file_management='auto'

*.log_archive_format='%t_%s_%r.dbf'

*.open_cursors=300

*.pga_aggregate_target=10737418240

*.processes=15000

*.remote_listener='TRAC.shdb.domain:1521'

*.remote_login_passwordfile='exclusive'

*.sessions=16505

*.sga_target=53687091200

TSTB.thread=1

TSTB.undo_tablespace='UNDOTBS1'

 

备库 startup nomount

[oracle@TSTB dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jun 29 15:43:50 2017

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> shutdown immediate;

ORA-01109: database not open

 

 

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area 4325888000 bytes

Fixed Size                  2260208 bytes

Variable Size             905970448 bytes

Database Buffers         3405774848 bytes

Redo Buffers               11882496 bytes

 

2.2 修改主库pfile ,此步可略过

[oracle@TRAC1 ~]$ cd /home/app/oracle/product/11.2.0/dbs

[oracle@TRAC1 dbs]$ vi initTRAC1.ora.new

增加下面的内容

*.log_archive_dest_1='location=+ARCH valid_for=(all_logfiles,all_roles)  db_unique_name=TRAC'

*.log_archive_dest_2="SERVICE=TSTB LGWR async AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TSTB"

*.fal_server=' TSTB'

*.fal_client=' TRAC'

*.log_archive_dest_state_1=enable’

*.log_archive_dest_state_2=enable

#*.db_file_name_convert="/oradata/TSTB/","+DATA/TRAC","/oradata/TSTB/","+SASDATA/TRAC","/oradata/TSTB/","+FRA/TRAC","/oradata/TSTB/","+ARCH/TRAC"

#*.log_file_name_convert="/oradata/TSTB/","+DATA/TRAC","/oradata/TSTB/","+SASDATA/TRAC","/oradata/TSTB/","+FRA/TRAC","/oradata/TSTB/","+ARCH/TRAC"

#*.db_unique_name=TRAC

*.standby_file_management=auto

*.log_archive_config="DG_CONFIG=(TRAC,TSTB)"

 

2.3 更新主库spfile

节点1,2

alter system set log_archive_dest_1='location=+SASDATA valid_for=(all_logfiles,all_roles)  db_unique_name=TRAC' scope=both sid='*';

alter system set log_archive_dest_2="SERVICE=TSTB LGWR async AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=TSTB" scope=both sid='*';

alter system set fal_server='TSTB' scope=both sid='*';

alter system set fal_client='TRAC' scope=both sid='*';

alter system set log_archive_dest_state_1='enable' scope=both sid='*';

alter system set log_archive_dest_state_2='enable' scope=both sid='*';

alter system set standby_file_management='auto' scope=both sid='*';

alter system set log_archive_config="DG_CONFIG=(TRAC,TSTB)" scope=both sid='*' ;

 

 

2.2 主库修改tnsnames.ora

节点 1

vi /home/app/oracle/product/11.2.0/network/admin/tnsnames.ora

[oracle@TRAC1 admin]$ vi /home/app/oracle/product/11.2.0/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /home/app/oracle/product/11.2.0/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

TRAC =

  (DESCRIPTION =(ENABLE=BROKEN)

  (ADDRESS_LIST=

    (ADDRESS = (PROTOCOL = TCP)(HOST = TRAC1-vip)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = TRAC2-vip)(PORT = 1521))

    (LOAD_BALANCE=NO)(FAILOVER=YES))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TRAC)

    )

  )

 

TSTB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = TSTB)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TSTB)

    )

  )

 

同步到节点 2

[oracle@TRAC1 admin]$ scp tnsnames.ora oracle@TRAC2://home/app/oracle/product/11.2.0/network/admin/tnsnames.ora

The authenticity of host 'TRAC2 (166.188.20.56)' can't be established.

RSA key fingerprint is 60:b3:55:fe:99:f5:20:6b:19:41:01:49:6b:d7:3b:f9.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'TRAC2' (RSA) to the list of known hosts.

tnsnames.ora                                                                                                                         100%  650     0.6KB/s   00:00   

[oracle@TRAC1 admin]$

 

2.3 备库建监听器

netca 建立监听器

 

[oracle@TSTB 11.2.0]$ cat ./network/admin/listener.ora

# listener.ora Network Configuration File: /home/app/oracle/product/11.2.0/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = TSTB)

      (ORACLE_HOME = /home/app/oracle/product/11.2.0)

      (SID_NAME = TSTB)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = TSTB))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = TSTB)(PORT = 1521))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

  )

 

ADR_BASE_LISTENER = /home/app/oracle

 

2.4 修改主库与备库tnsnames.ora

[oracle@TSTB admin]$ vi tnsnames.ora

TRAC =

  (DESCRIPTION =(ENABLE=BROKEN)

  (ADDRESS_LIST=

    (ADDRESS = (PROTOCOL = TCP)(HOST = TRAC1-vip)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = TRAC2-vip)(PORT = 1521))

    (LOAD_BALANCE=NO)(FAILOVER=YES))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TRAC)

    )

  )

 

TSTB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = TSTB)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TSTB)

    )

  )

 

2.5 拷贝orapw 文件到备库

节点1

[oracle@TRAC1 dbs]$ pwd

/home/app/oracle/product/11.2.0/dbs

[oracle@TRAC1 dbs]$ scp orapwTRAC1 oracle@TSTB:/home/app/oracle/product/11.2.0/dbs/orapwTSTB

oracle@TSTB's password:

orapwTRAC1                                                                                                                        100% 1536     1.5KB/s   00:00   

[oracle@TRAC1 dbs]$

 

2.6 复制主库到备库

 

2.6.1 节点2 备份数据库--- 忽略…..

RMAN> BACKUP INCREMENTAL LEVEL 0 SECTION SIZE 200G DATABASE PLUS ARCHIVELOG DELETE ALL INPUT;

 

 

Starting backup at 03-JUL-17

current log archived

using channel ORA_DISK_1

…….

 

RMAN>  DELETE FORCE NOPROMPT OBSOLETE REDUNDANCY 1;

 

2.6.2 节点2 备份standby control file

Last login: Thu Jul  6 10:12:43 2017 from 192.168.50.102

[root@TRAC2 ~]# su - oracle

[oracle@TRAC2 ~]$ rman target /

 

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 6 10:23:50 2017

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: TRAC (DBID=2425035173)

 

RMAN> backup current controlfile for standby;

 

Starting backup at 06-JUL-17

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=10720 instance=TRAC2 device type=DISK

channel ORA_DISK_1: starting compressed full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including standby control file in backup set

channel ORA_DISK_1: starting piece 1 at 06-JUL-17

channel ORA_DISK_1: finished piece 1 at 06-JUL-17

piece handle=/data_backup/60s8lllt_1_1 tag=TAG20170706T102357 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-JUL-17

 

Starting Control File and SPFILE Autobackup at 06-JUL-17

piece handle=/data_backup/ctlbackup/c-2425035173-20170706-01 comment=NONE

Finished Control File and SPFILE Autobackup at 06-JUL-17

 

RMAN> exit

2.6.3 备库还原数据

1)        启动备库到nomount 状态

 

[oracle@TSTB ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jul 3 17:49:45 2017

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup pfile='/home/app/oracle/product/11.2.0/dbs/initTSTB.ora.new' nomount

ORACLE instance started.

 

Total System Global Area 4325888000 bytes

Fixed Size                  2260208 bytes

Variable Size             905970448 bytes

Database Buffers         3405774848 bytes

Redo Buffers               11882496 bytes

SQL>

 

 

2)        恢复standby control file

[oracle@TSTB bakdata]$ rman target /

 

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jul 3 17:50:36 2017

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: TRAC (not mounted)

 

[oracle@TSTB TSTB]$ rman target /

 

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 6 10:27:19 2017

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: TRAC (not mounted)

 

RMAN>  restore standby controlfile from '/data_backup/62s8lm5a_1_1';

 

Starting restore at 06-JUL-17

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=12221 device type=DISK

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=/oradata/TSTB/controlfile/controlfile01

output file name=/oradata/TSTB/datafile/controlfile02

Finished restore at 06-JUL-17

3)        恢复数据

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

 

RMAN> restore database;

……………………………….

 

RMAN> recover database;

 

……………………………….

 

4)        备库增加standby logfile

SQL> alter database add standby logfile thread 1('/oradata/TSTB/onlinelog/stb_1.log') size 2G;

alter database add standby logfile thread 1('/oradata/TSTB/onlinelog/stb_2.log') size 2G;

alter database add standby logfile thread 1('/oradata/TSTB/onlinelog/stb_3.log') size 2G;

alter database add standby logfile thread 1('/oradata/TSTB/onlinelog/stb_4.log') size 2G;

alter database add standby logfile thread 1('/oradata/TSTB/onlinelog/stb_5.log') size 2G;

alter database add standby logfile thread 2('/oradata/TSTB/onlinelog/stb_6.log') size 2G;

alter database add standby logfile thread 2('/oradata/TSTB/onlinelog/stb_7.log') size 2G;

alter database add standby logfile thread 2('/oradata/TSTB/onlinelog/stb_8.log') size 2G;

alter database add standby logfile thread 2('/oradata/TSTB/onlinelog/stb_9.log') size 2G;

alter database add standby logfile thread 2('/oradata/TSTB/onlinelog/stb_10.log') size 2G;

 

 

5)        追加归档

节点2

 

RMAN> backup archivelog all delete all input ;

 

……………………….

 

备库

RMAN> catalog start with '/data_backup/64s8m1ae_1_1';

……………………….

 

RMAN> recover database;

 

……………………………..

 

 

RMAN>

 

 

6)        启动备库

SQL> alter database open read only;

 

Database altered.

SQL> alter database set standby database to maximize availability;

 

Database altered.

 

 

SQL> alter database recover managed standby database using current logfile disconnect from session;

 

Database altered.

 

SQL> select open_mode,database_role,switchover_status from v$database;

 

OPEN_MODE

------------------------------------------------------------

DATABASE_ROLE

------------------------------------------------

SWITCHOVER_STATUS

------------------------------------------------------------

READ ONLY WITH APPLY

PHYSICAL STANDBY

NOT ALLOWED

 

7)        备库增加tempfile

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp01.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp02.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp03.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp04.dbf' size 1G autoextend on next 100M;

SQL>  alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp05.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp06.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp07.dbf' size 1G autoextend on next 100M;

SQL>  alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp08.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp09.dbf' size 1G autoextend on next 100M;

SQL> alter tablespace temp add tempfile '/oradata/TSTB/tempfile/temp10.dbf' size 1G autoextend on next 100M;

8)        主库增加standby logfile

SQL> alter database add standby logfile thread 1('+sasdata/TRAC/onlinelog/stb_1.log') size 2G ;

alter database add standby logfile thread 1 ('+sasdata/TRAC/onlinelog/stb_2.log')  size 2G ;

alter database add standby logfile thread 1('+sasdata/TRAC/onlinelog/stb_3.log')  size 2G ;

alter database add standby logfile thread 1 ('+sasdata/TRAC/onlinelog/stb_4.log')  size 2G ;

alter database add standby logfile thread 1('+sasdata/TRAC/onlinelog/stb_5.log')  size 2G ;

alter database add standby logfile thread 2('+sasdata/TRAC/onlinelog/stb_6.log')  size 2G ;

alter database add standby logfile thread 2('+sasdata/TRAC/onlinelog/stb_7.log')  size 2G ;

alter database add standby logfile thread 2('+sasdata/TRAC/onlinelog/stb_8.log')  size 2G ;

alter database add standby logfile thread 2('+sasdata/TRAC/onlinelog/stb_9.log')  size 2G ;

alter database add standby logfile thread 2('+sasdata/TRAC/onlinelog/stb_10.log')  size 2G ;

9)        连接验证

节点1

SQL> alter system switch logfile;

System altered.

SQL> delete from test;

5 rows deleted.

SQL> commit;

Commit complete.

SQL> insert into test values ('sdfasdfsdf');

1 row created.

SQL> commit;

Commit complete.

SQL>

 

备库

SQL> select * from test;

NAME

------------------------------------------------------------

123sdadfds

adadsd

adadsd

123sdadfds

1222

 

SQL> /

no rows selected

SQL> /

NAME

------------------------------------------------------------

sdfasdfsdf

SQL>

 


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69976387/viewspace-2706591/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle 11g OCP, Oracle 11g OCM, MySQL 5.7 OCP, A member of OCMU Oracle User Group, Certificate of Aptech Certified System Master

注册时间:2020-06-03

  • 博文量
    18
  • 访问量
    10357