老库10.2.0.4 rac
新库11.2.0.4单机,准备搭建standalone
只要10g版本大于10.2.0.2就可以升级到11g
搭建Oracle 11g standalone,同时放10g的数据库软件和11g的数据库软件
迁移过程:
10g(主)--10g(备)的dg--》swith(10g备库成主库)--》10g新主库update--》11g新主库
以root用户编辑目标端的/etc/hosts文件:
[root@lzldb ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.100 lzldb
[root@lzldb ~]# vi /etc/sysconfig/network
[root@lzldb ~]# cat /etc/sysconfig/network
# Created by anaconda
HOSTNAME=lzldb
NOZEROCONF=yes
创建组oinstall和dba,创建用户oracle
/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/useradd -u 502 -g oinstall -G dba oracle -m -s /bin/bash
/usr/sbin/useradd -u 501 -g oinstall -G dba grid -m -s /bin/bash
echo "123456"|passwd oracle --stdin
echo "123456"|passwd grid --stdin
以root用户,执行以下命令创建目录:
mkdir -p /oracle
mkdir -p /oracle/app/grid
mkdir -p /oracle/app/11.2.0/grid
mkdir -p /oracle/app/oracle/product/11.2.0/dbhome_1
以root用户,执行以下命令更改权限
chown -R grid:oinstall /oracle
chown -R grid:oinstall /oracle/app/11.2.0/grid
chown -R oracle:oinstall /oracle/app/oracle
需要准备10g的profile和11g的profile
grid用户profile
echo "export PATH
export ORACLE_BASE=/oracle/app/grid
export ORACLE_HOME=/oracle/app/11.2.0/grid
export ORACLE_SID=+ASM
export PATH=\$ORACLE_HOME/bin:\$PATH:\$ORACLE_HOME/OPatch
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$ORACLE_HOME/lib32:/lib/usr/lib:/usr/local/lib
export TEMP=/tmp
export TMP=/tmp
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export NLS_OS_CHARSET=ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
set -o vi
stty erase ^h
stty erase ^?
umask 022">>/home/grid/.bash_profile
cat /home/grid/.bash_profile
oracle用户10g profile
echo "export PATH
export ORACLE_BASE=/oracle10g/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=lzldb
export PATH=\$ORACLE_HOME/bin:\$PATH:\$ORACLE_HOME/OPatch
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$ORACLE_HOME/lib32:/lib/usr/lib:/usr/local/lib
export TEMP=/tmp
export TMP=/tmp
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export NLS_OS_CHARSET=ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
set -o vi
stty erase ^h
stty erase ^?
umask 022">>/home/oracle/.bash_profile
cat /home/oracle/.bash_profile
oracle用户11g profile
echo "export PATH
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=lzldb
export PATH=\$ORACLE_HOME/bin:\$PATH:\$ORACLE_HOME/OPatch
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$ORACLE_HOME/lib32:/lib/usr/lib:/usr/local/lib
export TEMP=/tmp
export TMP=/tmp
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export NLS_OS_CHARSET=ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
set -o vi
stty erase ^h
stty erase ^?
umask 022">>/home/oracle/.bash_profile
cat /home/oracle/.bash_profile
ntp略
fs.file-max = 6815744
kernel.sem = 10000 10240000 10000 1024
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 34359738368
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.wmem_default = 16777216
fs.aio-max-nr = 6194304
vm.dirty_ratio=20
vm.dirty_background_ratio=3
vm.dirty_writeback_centisecs=100
vm.dirty_expire_centisecs=500
vm.swappiness=10
vm.min_free_kbytes=524288
net.core.netdev_max_backlog = 30000
net.core.netdev_budget = 600
vm.nr_hugepages =8200
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
生效
sysctl -p
vi /etc/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
cp /etc/selinux/config /etc/selinux/config_`date +"%Y%m%d_%H%M%S"`&& sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/g' /etc/selinux/config
挂载iso镜像文件
mkdir /cdrom
mount -o loop /tools/rhel-server-7.6-x86_64-dvd.iso /cdrom
配置yum源
[root@YYServer Packages]# cat /etc/yum.repos.d/iso.repo
[redhat]
name=redhat7
baseurl=file:///cdrom
enabled=1
gpgcheck=0
yum install -y \
binutils \
compat-libcap1 \
compat-libstdc++-33 \
compat-libstdc++-33 \
gcc \
gcc-c++ \
glibc \
glibc \
glibc-devel \
glibc-devel \
ksh \
libstdc++ \
libstdc++ \
libstdc++-devel \
libstdc++-devel \
libaio \
libaio \
libaio-devel \
libaio-devel \
make \
sysstat \
unzip \
systemctl stop tuned.service ktune.service firewalld.service postfix.service avahi-daemon.socket avahi-daemon.service atd.service bluetooth.service wpa_supplicant.service accounts-daemon.service atd.service cups.service postfix.service ModemManager.service debug-shell.service rtkit-daemon.service rpcbind.service rngd.service upower.service rhsmcertd.service rtkit-daemon.service ModemManager.service mcelog.service colord.service gdm.service libstoragemgmt.service ksmtuned.service brltty.service
systemctl disable tuned.service ktune.service firewalld.service postfix.service avahi-daemon.socket avahi-daemon.service atd.service bluetooth.service wpa_supplicant.service accounts-daemon.service atd.service cups.service postfix.service ModemManager.service debug-shell.service rtkit-daemon.service rpcbind.service rngd.service upower.service rhsmcertd.service rtkit-daemon.service ModemManager.service mcelog.service colord.service gdm.service libstoragemgmt.service ksmtuned.service brltty.service
echo "
oracle soft nproc 655350
oracle hard nproc 655350
oracle soft nofile 655360
oracle hard nofile 655360
grid soft nproc 655350
grid hard nproc 655350
grid soft nofile 655360
grid hard nofile 655360
oracle soft stack 102400
oracle hard stack 327680
grid soft stack 102400
grid hard stack 327680
oracle soft memlock -1
oracle hard memlock -1
grid soft memlock -1
grid hard memlock -1
root soft memlock -1
root hard memlock -1" >>/etc/security/limits.conf
配置profile
cp /etc/profile /etc/profile_`date +"%Y%m%d_%H%M%S"`
echo "
if [ \$USER = \"oracle\" ] || [ \$USER = \"grid\" ] || [ \$USER = \"root\" ]; then
if [ \$SHELL = \"/bin/ksh\" ]; then
ulimit -p 655350
ulimit -n 655350
else
ulimit -u 655350 -n 655350
fi
fi">>/etc/profile
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c2955e3129fd63c49734d32046ff", RUN+="/bin/sh -c 'mknod /dev/asmdata01 b $major $minor; chown grid:oinstall /dev/asmdata01; chmod 0660 /dev/asmdata01'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29652e3c5634168336bb94bd44e", RUN+="/bin/sh -c 'mknod /dev/asmdata02 b $major $minor; chown grid:oinstall /dev/asmdata02; chmod 0660 /dev/asmdata02'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c2955f89f5d7a533199275dce385", RUN+="/bin/sh -c 'mknod /dev/asmdata03 b $major $minor; chown grid:oinstall /dev/asmdata03; chmod 0660 /dev/asmdata03'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29c21a0876bf738512713b23ce2", RUN+="/bin/sh -c 'mknod /dev/asmdata04 b $major $minor; chown grid:oinstall /dev/asmdata04; chmod 0660 /dev/asmdata04'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c2903beeca1fe91ed9f174eae459", RUN+="/bin/sh -c 'mknod /dev/asmdata05 b $major $minor; chown grid:oinstall /dev/asmdata05; chmod 0660 /dev/asmdata05'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c296f5677945354c271315df2c8f", RUN+="/bin/sh -c 'mknod /dev/asmdata06 b $major $minor; chown grid:oinstall /dev/asmdata06; chmod 0660 /dev/asmdata06'"
使udev生效
/sbin/udevadm trigger --type=devices --action=change
/sbin/udevadm control --reload
ls -lrt /dev/asm*
11g GI在Redhat7上安装时存在ohasd启动问题,需要提前配置ohas服务
echo "[Unit]
Description=OracleHigh Availability Services
After=syslog.target
[Service]
ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simple
Restart=always
[Install]
WantedBy=multi-user.target">/etc/systemd/system/ohasd.service
启动ohasd服务
systemctl daemon-reload
systemctl enable ohasd.service
systemctl start ohasd.service
standalone安装
以静默方式安装GI软件
./runInstaller -responseFile /software/grid/response/grid_install.rsp -silent -ignorePrereq -showProgress
其中response文件配置如下:
[root@YYServer app]# grep -v ^# /software/grid/response/grid_install.rsp|grep -v grep
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0
ORACLE_HOSTNAME=YYServer
INVENTORY_LOCATION=/oracle/app/oraInventory
SELECTED_LANGUAGES=en
oracle.install.option=HA_CONFIG
ORACLE_BASE=/oracle/app/grid
ORACLE_HOME=/oracle/app/11.2.0/grid
oracle.install.asm.OSDBA=oinstall
oracle.install.asm.OSOPER=oinstall
oracle.install.asm.OSASM=oinstall
oracle.install.crs.config.gpnp.scanName=
oracle.install.crs.config.gpnp.scanPort=
oracle.install.crs.config.clusterName=Clusteralone1
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.gpnp.gnsSubDomain=
oracle.install.crs.config.gpnp.gnsVIPAddress=
oracle.install.crs.config.autoConfigureClusterNodeVIP=
oracle.install.crs.config.clusterNodes=
oracle.install.crs.config.networkInterfaceList=
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=NORMAL
oracle.install.crs.config.sharedFileSystemStorage.ocrLocations=
oracle.install.crs.config.sharedFileSystemStorage.ocrRedundancy=NORMAL
oracle.install.crs.config.useIPMI=false
oracle.install.crs.config.ipmi.bmcUsername=
oracle.install.crs.config.ipmi.bmcPassword=
oracle.install.asm.SYSASMPassword=123456
oracle.install.asm.diskGroup.name=data
oracle.install.asm.diskGroup.redundancy=EXTERNAL
oracle.install.asm.diskGroup.AUSize=4
oracle.install.asm.diskGroup.disks=/dev/asmdata01,/dev/asmdata02,/dev/asmdata03
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/asm*
oracle.install.asm.monitorPassword=123456
oracle.install.crs.upgrade.clusterNodes=
oracle.install.asm.upgradeASM=false
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
创建ASM
asmca -silent -configureASM -sysAsmPassword sysPassw0rd -asmsnmpPassword asmsnmpPassw0rd -diskString '/dev/asm*' -diskGroupName DATA -disk '/dev/asm*' -redundancy EXTERNAL
vi /etc/udev/rules.d/99-oracleasm-permissions.rules
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29e5a60f5a95f9d86e76eee4636", RUN+="/bin/sh -c 'mknod /dev/asmarch01 b $major $minor; chown grid:oinstall /dev/asmarch01; chmod 0660 /dev/asmarch01'"
/sbin/udevadm trigger --type=devices --action=change
ls -lrt /dev/asm*
create diskgroup ARCH external redundancy disk '/dev/asmarch01';
netca -silent -responsefile /oracle/app/11.2.0/grid/assistants/netca/netca.rsp
./runInstaller -responseFile /software/database/response/db_install.rsp -silent -ignorePrereq -showProgress
Response文件配置如下
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=YYServer
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/oracle/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=true
oracle.install.db.racOneServiceName=YYServer
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=123456
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=ASM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=DATA
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
替换oracle和grid的OPatch
[grid@YYServer ~]$ opatch version
OPatch Version: 11.2.0.3.19
OPatch succeeded.
[oracle@YYServer 28813878]$ opatch version
OPatch Version: 11.2.0.3.19
OPatch succeeded.
Grid用户执行生产ocm.rsp:
$ORACLE_HOME/OPatch/ocm/bin/emocmrsp -no_banner -output /tmp/ocm.rsp
Root用户执行opatch auto:
/oracle/app/11.2.0/grid/OPatch/opatch auto /software/28813878 -ocmrf /tmp/ocm.rsp
auto打gi成功,oracle失败用root用户单独执行oracle的补丁:
/oracle/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch auto /software/28813878 -ocmrf /tmp/ocm.rsp -oh /oracle/app/oracle/product/11.2.0/dbhome_1
查看oracle和grid下补丁信息
[grid@YYServer ~]$ opatch lsinv
Oracle Interim Patch Installer version 11.2.0.3.19
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /oracle/app/11.2.0/grid
Central Inventory : /oracle/app/oraInventory
from : /oracle/app/11.2.0/grid/oraInst.loc
OPatch version : 11.2.0.3.19
OUI version : 11.2.0.4.0
Log file location : /oracle/app/11.2.0/grid/cfgtoollogs/opatch/opatch2020-05-21_16-00-40PM_1.log
Lsinventory Output file location : /oracle/app/11.2.0/grid/cfgtoollogs/opatch/lsinv/lsinventory2020-05-21_16-00-40PM.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: YYServer
ARU platform id: 226
ARU platform description:: Linux x86-64
Installed Top-level Products (1):
Oracle Grid Infrastructure 11g 11.2.0.4.0
There are 1 products installed in this Oracle Home.
Interim patches (1) :
Patch 28729234 : applied on Thu May 21 15:50:56 CST 2020
Unique Patch ID: 22546711
Patch description: "OCW Patch Set Update : 11.2.0.4.190115 (28729234)"
Created on 8 Nov 2018, 23:01:45 hrs PST8PDT
Bugs fixed:
18328800, 19270660, 18691572, 18508710, 20038451, 21251192, 22162062
20365005, 21232394, 17336871, 17387214, 17750548, 17617807, 14497275
20219458, 17733927, 18180541, 23757020, 18962892, 17292250, 17378618
16759171, 20110156, 17843489, 17065496, 13991403, 21694632, 17273020
22762046, 17336884, 17155238, 17336889, 18261183, 18053580, 20012766
21245437, 20218012, 17013634, 17886392, 20995001, 24422155, 17039197
16317771, 17947785, 10052729, 20340620, 22353346, 16237657, 20317221
18199185, 15917869, 18399991, 20186278, 18024089, 17374271, 16849642
20246071, 20746251, 14270845, 23621494, 20552947, 18414137, 18882642
17001914, 17927970, 14378120, 16346413, 15986647, 17336898, 18068871
21222147, 16206997, 18143836, 21982225, 25490238, 19168690, 18343490
20235511, 21875360, 16613232, 19276791, 17722664, 20440643, 12928658
18226143, 18520351, 16249829, 18952577, 17172091, 18229842, 16076412
18265482, 20676340, 17818075, 20091753, 18231837, 14373486, 17483479
20136892, 20551654, 18120545, 18729166, 13843841, 17405302, 21225209
18709496, 18330979, 18744838, 14525998, 18187697, 17087371, 20531190
20598625, 14385860, 18348155, 19479503, 12928592, 17516024, 18370031
17764053, 19272663, 17551223, 14671408, 18272135, 14207615, 21255373
17500165, 18875012, 14769643, 25656952, 19558324, 18464784, 18848125
19241857, 17955615, 14851828, 14693336, 20315294, 16284825, 17352230
20014326, 17238586, 17089344, 17405605, 17531342, 21327402, 26546632
19398098, 17159489, 17640316, 13823394, 16543190, 22024217, 17983675
20795241, 17481314, 18346135, 17598201, 16281493, 15986311, 17208793
19601468, 18999857, 18700935, 14076173, 18428146, 16709532, 17435488
18352845, 18352846, 20408163, 17592037, 19616601, 17387779, 17391726
14777968, 15851860, 16206882, 20141091, 15832129, 17305100, 20175174
21113068, 19885321, 16901346, 17985714, 25591658, 18536826, 17780903
18752378, 18946768, 16876500, 16875342, 17769597, 19955755, 16429265
18336452, 17273003, 17209968, 25484507, 16988311, 19319357, 20094984
17046460, 17059927, 18053631, 16867761, 18774591, 21442094, 20235486
19359787, 15869775, 17447588, 19642566, 21152052, 16798862, 15920201
--------------------------------------------------------------------------------
OPatch succeeded.
下载patchset,图形界面安装
在1节点,oracle用户登陆数据库,执行如下命令:
alter database force logging;
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(lzldb,lzldb_new)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lzldb' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=epmsc_new LGWR ASYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lzldb_new' scope=both sid='*';;
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both sid='*';
alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=both sid='*';
alter system set LOG_ARCHIVE_MAX_PROCESSES=4 scope=both sid='*';
alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both sid='*';
10g参数文件
cat /home/oracle/pfile_10g.ora
aq_tm_processes=0
audit_file_dest='/oracle/app/oracle/admin/lzldb/adump'
background_dump_dest='/oracle/app/oracle/admin/lzldb/bdump'
cluster_database=false
compatible='10.2.0.4.0'
control_files='+DATA/lzldb_new/control01.ora', '+ARCH/lzldb_new/control02.ora'
core_dump_dest='/oracle/app/oracle/admin/lzldb/cdump'
db_block_size=8192
pga_aggregate_target=5G
sga_target=20G
sga_max_size=20G
db_domain=''
db_file_multiblock_read_count=16
db_files=4000
db_name='lzldb'
disk_asynch_io=TRUE
dispatchers='(PROTOCOL=TCP) (SERVICE=lzldbXDB)'
job_queue_processes=0
log_archive_format='%t_%s_%r.dbf'
processes=2000
remote_login_passwordfile='exclusive'
resource_limit=TRUE
session_cached_cursors=20
sessions=2205
undo_management='AUTO'
undo_retention=900
undo_tablespace='UNDOTBS1'
db_create_file_dest='+DATA'
user_dump_dest='/oracle/app/oracle/admin/lzldb/udump'
db_file_name_convert='+DATA/lzldb/datafile','+DATA/lzldb_new/datafile','+FRA/lzldb/datafile','+DATA/lisle_new/datafile'
log_file_name_convert='+DATA/lzldb/onlinelog','+DATA/lzldb_new/onlinelog','+FRA/lzldb/onlinelog','+ARCH/lzldb_new/onlinelog'
db_unique_name='lzldb_new'
fal_server='lzldb_new'
fal_client='lzldb'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(lzldb,lzldb_new)'
log_archive_dest_1='LOCATION=+ARCH VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lzldb_new'
准备11g参数文件
cat /home/oracle/pfile_11g.ora
aq_tm_processes=0
audit_file_dest='/oracle/app/oracle/admin/lzldb/adump'
cluster_database=false
compatible='11.2.0.4.0'
control_files='+DATA/lzldb_new/control01.ora', '+ARCH/lzldb_new/control02.ora'
core_dump_dest='/oracle/app/oracle/admin/lzldb/cdump'
db_block_size=8192
pga_aggregate_target=5G
sga_target=20G
sga_max_size=20G
db_domain=''
db_file_multiblock_read_count=16
db_files=4000
db_name='lzldb'
disk_asynch_io=TRUE
dispatchers='(PROTOCOL=TCP) (SERVICE=lzldbXDB)'
job_queue_processes=0
log_archive_format='%t_%s_%r.dbf'
processes=2000
remote_login_passwordfile='exclusive'
resource_limit=TRUE
session_cached_cursors=20
sessions=2205
undo_management='AUTO'
undo_retention=900
undo_tablespace='UNDOTBS1'
db_create_file_dest='+DATA'
db_unique_name='lzldb_new'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(lzldb,lzldb_new)'
log_archive_dest_1='LOCATION=+ARCH VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lzldb_new'
从主库拷贝密码文件到备库
scp $ORACLE_HOME/dbs/orapwlzldb1 192.168.0.100:/oracle10g/app/oracle/product/10.2.0/dbhome_1/dbs/orapwlzldb
LISTENER_1522 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1522))
)
)
)
SID_LIST_LISTENER_1522 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = lzldb_new)
(ORACLE_HOME = /oracle/app/oracle/product/11.2.0.4/dbhome_1)
(SID_NAME = lzldb)
)
)
主库上创建tns
lzldb_new =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100 )(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = lzldb_new)
)
)
从nfs上复制数据到备库
检查主库归档日志
检查归档日志保留情况,查看归档日志删除脚本。
lzldb老库备份任务已失效,但是仍然每天在运行,可用注释备份任务。由于每天归档量不多,但是频繁在执行删除归档脚本,需要注释删除归档脚本保障归档的连续性。
[oracle@lzldbold autorman]$ crontab -l
#*/4 * * * * sh /home/oracle/enmo/delete_arch.sh > /home/oracle/enmo/delete.log 2>&1
挂载nfs
数据库datafile大小为3.7T,申请4T的盘做nfs,用于全库备份恢复
4T的盘时候用parted进行分区并挂载到/backup
parted /dev/sdi
mklabel gpt
mkpart primary 0 -1
mkfs.xfs /dev/sdi1
mount /dev/sdi1 /backup
nfs配置
[root@lzldb ~]# cat /etc/exports
/backup *(rw,sync,no_root_squash)
备库安装nfs服务
[root@lzldb cdrom]# yum install nfs-utils -y
[root@lzldb cdrom]# systemctl start nfs-server
[root@lzldb cdrom]# exportfs -rv
exporting *:/backup
主库查看nfs映射
[root@lzldb ~]# showmount -e 192.168.0.100
Export list for 192.168.0.100:
/backup *
主库挂载
mkdir /backup
mount -t nfs -o rw,bg,noac,hard,nointr,rsize=32768,wsize=32768,nolock,proto=tcp,actimeo=0,vers=3,timeo=600 192.168.0.100:/backup /backup
修改/backup权限
Chown oracle:oinstall /backup -R
Rman全库备份
$ORACLE_HOME/bin/rman @backup0.sql log=backup0.log
Backup0.sql如下
connect target /
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
sql "alter system archive log current";
run{
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backupset;
delete noprompt expired backup;
backup format '/backup/lzldb_full_%s_%p_%t' database plus archivelog delete input;
backup format '/backup/cntrl_%s_%p_%t' current controlfile;
report obsolete;
delete noprompt obsolete;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
}
exit
主库创建standby control file
在主库执行
SQL> alter database create standby controlfile as '/backup/controlfile';
备库恢复控制文件并mount
Restore standby control file from ‘/backup/controlfile’;
Alter database mount;
恢复数据文件
run{
Allocate channel c1 type disk;
Allocate channel c2 type disk;
Allocate channel c3 type disk;
Allocate channel c4 type disk;
Allocate channel c5 type disk;
Allocate channel c6 type disk;
Allocate channel c7 type disk;
Allocate channel c8 type disk;
restore database;
Release channel c1;
Release channel c2;
Release channel c3;
Release channel c4;
Release channel c5;
Release channel c6;
Release channel c7;
Release channel c8;
}
restore standby controlfile from '/backup/controlfile';
alter database mount;
recover database;
alter database add standby logfile thread 1 group 10 '+data' size 500m;
alter database add standby logfile thread 1 group 11 '+data' size 500m;
alter database add standby logfile thread 1 group 12 '+data' size 500m;
alter database add standby logfile thread 1 group 13 '+data' size 500m;
alter database add standby logfile thread 1 group 14 '+data' size 500m;
alter database add standby logfile thread 1 group 15 '+data' size 500m;
alter database add standby logfile thread 1 group 16 '+data' size 500m;
alter database add standby logfile thread 1 group 17 '+data' size 500m;
SQL> recover managed standby database using current logfile disconnect;
当备库应用日志应用跟主库一致时,此时可以在备库的Alert中可以发现如下的日志:
Archived Log entry 172 added for thread 1 sequence 120443 rlc 905861515 ID 0xb7d9620b dest 2:
Sat Feb 03 10:00:18 2018
Media Recovery Log +ARCH/crmzcdbdg/archivelog/2018_02_03/thread_1_seq_120443.425.967110319
Media Recovery Log +ARCH/crmzcdbdg/archivelog/2018_02_03/thread_2_seq_120050.427.967110321
Media Recovery Waiting for thread 2 sequence 120051 (in transit)
可以将数据库启动Adg模式,执行下面命令:
sqlplus "/ as sysdba"<
alter database open;
recover managed standby database using current logfile disconnect;
exit;
EOF
停止数据库job
SQL> alter system set job_queue_processes=0 scope=both sid='*';
关闭原库监听
srvctl stop listener
ps -ef|grep tns
检查主库数据文件状态
SQL> select name,status from v$datafile where status not in ('SYSTEM','ONLINE');
检查当前系统数据库组件信息
SQL> select comp_name,VERSION,STATUS from dba_registry;
禁止操作系统自动作业计划
清空回收站
SQL> purge dba_recyclebin
处理分布式事务
SQL> select * from dba_2pc_pending;
如果有返回行,执行以下sql
SQL> select ' exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('||chr(39)||LOCAL_TRAN_ID||chr(39)||');'||chr(10)||'commit;' from dba_2pc_pending;
删除pump失败后的表
SQL> select 'drop table '||owner_name||'.'||job_name||';' from dba_datapump_jobs where owner_name in ('SYS','SYSTEM) and state in ('NOT RUNNING')
编译无效对象
SQL> @?/rdbms/admin/utlrp.sql
SQL> select count(*) from dba_objects where status in ('INVALID');
停止原主库
SQL> srvctl stop database -d lzldb
强制切换备库为主库
检查同步情况
SQL> select inst_id,name,value,time_computed,DATUM_TIME,sysdate from gv$dataguard_stats order by inst_id;
关闭DG监听
lsnrctl stop listener1522
强制切换备库为主库
SQL> alter database recover managed standby database finish;
SQL> alter database commit to switchover to primary;
SQL> shutdown immediate;
SQL> startup mount;
检查新库状态
SQL> select database_role,switchover_status from v$database;
数据检查
启动原库到open read only
SQL> startup mount;
SQL> alter database open read only;
启动新库到open
SQL> shutdown immediate;
SQL> startup pfile='/home/oracle/pfile_10g.ora'
重建temp文件
SQL> alter tablespace temp add tempfile '+DATA' size 30720m;
SQL> alter tablespace temp add tempfile '+DATA' size 30720m;
SQL> alter tablespace temp add tempfile '+DATA' size 30720m;
SQL> alter tablespace temp add tempfile '+DATA' size 30720m;
SQL> alter tablespace temp add tempfile '+DATA' size 30720m;
SQL> alter tablespace TEMP drop tempfile '+DATA/lzldb/tempfile/temp3.ora';
SQL> alter tablespace TEMP drop tempfile '+DATA/lzldb/tempfile/temp4.ora';
SQL> alter tablespace TEMP drop tempfile '+DATA/lzldb/tempfile/temp263.819995001';
SQL> alter tablespace TEMP drop tempfile '+DATA/lzldb/tempfile/temp.3231.957638307';
删除standby redo log
SQL> alter database drop standby logfile group 10;
SQL> alter database drop standby logfile group 11;
SQL> alter database drop standby logfile group 12;
SQL> alter database drop standby logfile group 13;
SQL> alter database drop standby logfile group 14;
SQL> alter database drop standby logfile group 15;
SQL> alter database drop standby logfile group 16;
SQL> alter database drop standby logfile group 17;
执行预升级检查脚本
SQL> @/home/oracle/enmo/utlu112i.sql
检查数据的完整性
SQL> @/home/oracle/enmo/dbupgdiag.sql
检查是否存在介质恢复
SQL> SELECT * FROM v$recover_file;
SQL> SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';
处理分布式事务
SQL> select * from dba_2pc_pending;
如果有返回行,执行以下sql
SQL> select ' exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('||chr(39)||LOCAL_TRAN_ID||chr(39)||');'||chr(10)||'commit;' from dba_2pc_pending;
检查SYS和SYSTEM用户的默认表空间
SQL> SELECT username, default_tablespace FROM dba_users WHERE username in ('SYS','SYSTEM');
检查METHOD_OPT
SQL> select DBMS_STATS.GET_PARAM('METHOD_OPT') from dual;
DBMS_STATS.GET_PARAM('METHOD_OPT')
-------------------------------------------------------------
FOR COLUMNS ID SIZE 1
如果返回结果如上,执行如下
SQL> sqlexec DBMS_STATS.SET_PARAM('METHOD_OPT','FOR ALL COLUMNS SIZE AUTO');
修改系统为11g环境
SQL> shutdown immediate;
Vi .bash_profile
. ~/.bash_profile_10g -->~/.bash_profile_11g
cp /etc/oratab.bak /etc/oratab
cp /etc/oraInst.loc.bak /etc/oraInst.loc
启动数据库到11g环境
SQL> startup upgrade pfile='/home/oracle/pfile_11g.ora’
执行升级脚本
SQL> @?/rdbms/admin/catupgrd.sql
汇总升级总结
SQL> startup pfile='/home/oracle/pfile_11g.txt'
SQL> @?/rdbms/admin/utlu112s.sql
升级剩余项
SQL> @?/rdbms/admin/catuppst.sql
编译无效对象
SQL> @?/rdbms/admin/utlrp.sql
更新oracle text
检查$ORACLE_HOME/ctx/admin/ctxf102.txt是否存在;
SQL> @?/rdbms/ctx/admin/ctxf102.sql
创建spfile
SQL> create spfile from pfile='/home/oracle/pfile_11g.ora'
重启数据库进行测试
Shutdown immediate
Startup
如果备库是rac还有把数据库添加到集群中管理的操作
有些项目可能需要更换ip,升级完成后可用直接在/etc/hosts中更改