赞
踩
#Public IP
192.168.247.5 RAC1
192.168.247.6 RAC2
#Private IP
192.168.68.5 RAC1-priv
192.168.68.6 RAC2-priv
#Virtual IP
192.168.247.15 RAC1-vip
192.168.247.16 RAC2-vip
#Scan IP
192.168.247.7 RAC-scan
# DG
192.168.247.8 DataGuard
安装工具里面勾选:Performance Tools
Development Tools
Security Tools
System Administration Tools
上图网关单词写错,应该: GATEWAY
上图网关单词写错,应该: GATEWAY
chmod +x /etc/rc.d/rc.local
vim /etc/rc.d/rc.local
/usr/sbin/ntpdate ntp.aliyun.com
systemctl stop firewalld
systemctl disable firewalld
vi /etc/selinux/config
SELINUX=disabled
#Public IP
192.168.247.5 rac1
192.168.247.6 rac2
# Private IP
192.168.68.5 rac1-priv
192.168.68.6 rac2-priv
# Virtual IP
192.168.247.15 rac1-vip
192.168.247.16 rac1-vip
# Scan IP
192.168.247.7 rac-scan
# DG IP
192.168.247.8 DataGuard
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 3145728
oracle hard stack 3145728
oracle soft memlock 3145728
oracle hard memlock 3145728
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 3145728
grid hard stack 3145728
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=6G 0 0
mount -o remount /dev/shm
touch /etc/sysctl.d/97-oracledatabase-sysctl.conf
vi /etc/sysctl.d/97-oracledatabase-sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1572864
kernel.shmmax = 6442450944
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
net.core.wmem_max = 1048576
sysctl --system(立即生效)
sysctl -a|grep shmmax
sysctl -a|grep shmall
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
groupadd asmoper
groupadd asmdba
useradd -g oinstall -G dba,asmoper,asmadmin,asmdba grid
useradd -g oinstall -G dba,oper,asmdba,asmadmin oracle
passwd grid
passwd oracle
id oracle
id grid
2个节点的用户号必须一样
mkdir -p /u01/app/grid #grid的ORACLE_BASE
mkdir -p /u01/app/12.2.0.1/grid #grid的ORACLE_HOME,不能是包含关系
mkdir -p /u01/app/oracle/product/12.2.0.1/db_1
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/12.2.0.1
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
Grid Infrastructure
.bash_profile
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/12.2.0.1/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/12.2.0.1/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
Oracle Database
.bash_profile
export ORACLE_SID=orcl1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
修改行
hosts: files dns myhostname
为
hosts: files dns nis
cat /sys/kernel/mm/transparent_hugepage/enabled
[always]代表启用
[never]代表禁用
vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet transparent_hugepage=never"
grub2-mkconfig -o /boot/grub2/grub.cfg
重启系统
cat /proc/cmdline
systemctl stop chronyd
systemctl disable chronyd
mv /etc/chrony.conf /etc/chrony.conf.bak
avahi-daemon 服务会影响 oracle的多波通信,进而导致节点重启
因此,oracle环境下不能启用 avahi-daemon 服务
systemctl stop avahi-daemon.service
systemctl disable avahi-daemon.service
vi /etc/sysconfig/network
NOZEROCONF=yes
Share1 20G
Share2 25G
配置vmx文件,添加如下内容:
scsi1:0.deviceType = "disk"
scsi1:1.deviceType = "disk"
disk.locking="false"
diskLib.dataCacheMaxSize="0"
diskLib.dataCacheMaxReadAheadSize="0"
diskLib.DataCacheMinReadAheadSize="0"
diskLib.dataCachePageSize="4096"
diskLib.maxUnsyncedWrites="0"
scsi1.sharedBus="virtual"
scsi1:0.mode="independent-persistent"(设置为独立模式) -- 如果已设独立模式,可能会冲突
scsi1:1.mode="independent-persistent"
查看硬盘是否双节点都有加载
fdisk -l
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29bd302d56cea04ce113585e607", RUN+="/bin/sh -c 'mknod /dev/asmdisk1 b $major $minor; chown grid:asmadmin /dev/asmdisk1; chmod 0660 /dev/asmdisk1'"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29e9bbd1d9724ab6823ca21bfc1", RUN+="/bin/sh -c 'mknod /dev/asmdisk2 b $major $minor; chown grid:asmadmin /dev/asmdisk2; chmod 0660 /dev/asmdisk2'"
重启UDEV:
systemctl restart systemd-udevd.service
udevadm control --reload-rules
/sbin/udevadm trigger --type=devices --action=add
/sbin/udevadm trigger --type=devices --action=change
在安装群集时,只需要在一个节点安装软件即可,节点互信会自动把安装的软件复制到其他节点
首先配置RAC1,RAC2 Oracle用户的节点互信
su - oracle
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa (全回车,默认即可)
ssh-keygen -t dsa (全回车,默认即可)
(以上节点互信命令,RAC1,RAC2均要执行)
返回RAC1,执行(下面互信命令 RAC2不执行)
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys oracle@RAC2:~/.ssh/authorized_keys
再配置RAC1,RAC2 grid用户的节点互信
su - grid
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa (全回车,默认即可)
ssh-keygen -t dsa (全回车,默认即可)
(以上节点互信命令,RAC1,RAC2均要执行)
返回RAC1,执行(下面互信命令 RAC2不执行)
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys grid@RAC2:~/.ssh/authorized_keys
验证节点互信
su - grid (两个节点都要验证)
date ; ssh rac1 date;
date ; ssh rac2 date;
date; ssh rac1-priv date;
date; ssh rac2-priv date;
su - oracle(两个节点都要验证)
date ; ssh rac1 date;
date ; ssh rac2 date;
date; ssh rac1-priv date;
date; ssh rac2-priv date;
1. 上传 linuxx64_12201_grid_home.zip 至$ORACLE_HOME
11g可以在任意目录安装,12C需在把grid软件放置$ORACLE_HOME,在$ORACLE_HOME下安装
2.解压
su - grid
cd $ORACLE_HOME
unzip linuxx64_12201_grid_home.zip
3.安装 cvuqdisk-1.0.10-1.rpm
su root
cd /u01/app/12.2.0.1/grid/cv/rpm
rpm -ivh cvuqdisk-1.0.10-1.rpm
scp cvuqdisk-1.0.10-1.rpm rac2:/opt --在rac2安装此包
4.在系统包里找到并安装
compat-libcap1-1.10-7.el7.x86_64.rpm
ksh-20120801-139.el7.x86_64.rpm
libaio-devel-0.3.109-13.el7.x86_64.rpm
如果联网环境的话,可以直接yum安装依赖
yum install -y binutils* compat-libstdc* elfutils-libelf* gcc* glibc* ksh* libaio* libgcc* libstdc* make* sysstat* unixODBC* libaio-devel* glibc-devel.i686 libaio.i686 libaio-devel.i686 libstdc++-devel.i686 unixODBC-devel.i686 compat-libcap1* compat-libcap1.i686 expat*
5.安装前检查环境: ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose
6.设置VNC
su - grid
vncpasswd ----设置VNC密码
vncserver :2 (5902端口)
7.解决 ORACLE 12.2 在CentOS7.6上的Bug
bug:
2019/04/09 22:31:16 CLSRSC-400: A system reboot is required to continue installing.
The command '/u01/app/12.2.0.1/grid/perl/bin/perl -I/u01/app/12.2.0.1/grid/perl/lib -I/u01/app/12.2.0.1/grid/crs/install /u01/app/12
.2.0.1/grid/crs/install/rootcrs.pl ' execution failed
在ORACLE官网查找文档1369107.1可解决此BUG
下载补丁程序
百度网盘:百度网盘 请输入提取码 提取码:n9gg
文件名:p26247490_12201180417ACFSApr2018RU_Linux-x86-64.zip
8.安装Grid
./gridSetup.sh -applyOneOffs /opt/soft/26247490/26247490 --/opt/soft/26247490/26247490为补丁解压路径
./opatch lspatches
Grid安装后rac1-vip , rac-scan会出现在网卡中
ifconfig --检查一下
1.上传Oracle安装包,解压至$ORACLE_HOME
unzip linuxx64_12201_database.zip
2.cd $ORACALE_HOME/database
./runInstaller
3. 安装选项如下图
不能基于PDB级别进行DG安装,且主备库的CDB开启需保持一致
主库:非CDB 备库:非CDB
主库:CDB 备库:CDB
创建归档文件存放路径(任一节点)
su – grid
amscmd
cd data
mkdir arch
设置归档文件存放路径
su – oracle
sqlplus / as sysbda
--设置默认归档文件名称, sid='*' 所有节点都生效
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
--将所有节点的归档都存放到+data/arch
alter system set log_archive_dest_1='LOCATION=+data/arch' scope=spfile sid='*';
开启归档
shutdown immediate;(两个节点都关闭)
startup mount(启动一个节点,另一个节点自动mount)
alter database archivelog;(一个节点执行)
alter database open;(双节点执行)
或者使用群集命令关闭/开启数据库
srvctl stop database -d orcl -o immediate
srvctl start database -d orcl
select force_logging from v$database;
alter database force logging;
查询数据库唯一名,如果没有唯一名,需要设置一个唯一名
show parameter db_unique_name
设置唯一名
alter system set db_unique_name='orcl' scope=spfile; --修改之后需要重启数据库
alter system set db_unique_name=ORCL scope=spfile; --如果不打' ' FXDB是大写
alter system set log_archive_config='DG_CONFIG=(orcl,dg)' scope=both sid='*';
--任一节点执行
alter system set log_archive_dest_1='LOCATION=+data/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' scope=both sid='*';
----设置传输日志文件参数 任一节点执行
alter system set log_archive_dest_2='SERVICE=tnsdg LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg' scope=both sid='*';
--查看standby文件管理方式 show parameter standby_file_management
--将standby文件管理方式设置为主动
alter system set standby_file_management=auto scope=both sid='*';
--设置备库往主库传数据时的 路径映射
alter system set db_file_name_convert='/orcl/app/oracle/oradata/dg','+DATA/ORCL/DATAFILE','/orcl/app/oracle/oradata/dg','+DATA/ORCL/TEMPFILE' scope=spfile sid='*';
alter system set log_file_name_convert='/orcl/app/oracle/oradata/dg','+DATA/ORCL/ONLINELOG' scope=spfile sid='*';
--做切换时,客户端、服务端指定,注意这是备库切换到主库, 所以备库是服务端,主库是客户端
alter system set fal_client='tnsorcl' scope=both sid='*';
alter system set fal_server='tnsdg' scope=both sid='*';
--日志组大小根据 查询 SELECT * FROM v$log 主库日志大小设置
alter database add standby logfile thread 1 group 11 ('+DATA') size 200M;
alter database add standby logfile thread 1 group 12 ('+DATA') size 200M;
alter database add standby logfile thread 1 group 13 ('+DATA') size 200M;
alter database add standby logfile thread 2 group 14 ('+DATA') size 200M;
alter database add standby logfile thread 2 group 15 ('+DATA') size 200M;
alter database add standby logfile thread 2 group 16 ('+DATA') size 200M;
--查看参数设置
show parameter log
show parameter fal
节点rac1:
tnsorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
tnsdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
节点rac2:
tnsorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
tnsdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
11g及之前版本数据库中密码文件存储在$ORACLE_HOME/dbs下
orapwSID
12C开始,密码文件存放在ASM共享存储中。
12cRAC中:+DATA/FXDB/PASSWORD/pwdfxdb.282.1006058263
查询密码文件位置:
srvctl config database -d orcl
主库和备库的SYS密码必须一致。
su - grid
amscmd
pwcopy +DATA/FXDB/PASSWORD/pwdfxdb.282.1006058263 /tmp/mypwfile
scp /tmp/mypwfile dg:/u01/app/oracle/product/12.2.0.1/db_1/dbs
登录DG服务器,将密码文件改名
mv mypwfile orapwdg
touch initdg.ora
db_name='orcl' ---与主库一致 show parameter db_name
db_unique_name='dg'
sga_target=2G
pga_aggregate_target=800M
audit_file_dest='/u01/app/oracle/admin/dg/adump' ---需备库手工创建
compatible='12.2.0' --与主库一致 show parameter compatible
remote_login_passwordfile='EXCLUSIVE'
control_files='/u01/app/oracle/oradata/dg/control01.ctl','/u01/app/oracle/oradata/dg/control02.ctl' ---路径需备库手工创建
log_archive_config='DG_CONFIG=(orcl,dg)' --与主库设置保持一致
---设置备库归档路径
log_archive_dest_1='LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=dg'
log_archive_dest_2='SERVICE=tnsorcl LGWR SYNC AFFIRM
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'
log_archive_format='%t_%s_%r.arc'
-----查询主库数据文件路径 SELECT * FROM V$dbfile
-----查询主数据库临时文件路径 SELECT * FROM V$tempfile
db_file_name_convert='+DATA/ORCL/DATAFILE','/u01/app/oracle/oradata/dg',
'+DATA/ORCL/TEMPFILE','/u01/app/oracle/oradata/dg'
---SELECT * FROM V$LOGFILE
log_file_name_convert='+DATA/ORCL/ONLINELOG','/u01/app/oracle/oradata/dg'
fal_client='tnsdg'
fal_server='tnsorcl'
standby_file_management='AUTO'
su - oracle
mkdir -p /u01/app/oracle/admin/dg/adump
mkdir -p /u01/app/oracle/oradata/dg
mkdir -p /u01/arch
sqlplus / as sysdba
create spfile from pfile;
startup nomount
3.配置静态监听
listener.ora
LISTENER1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1522))
)
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = dg)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/db_1)
)
)
lsnrctl start listener1
备库为什么一定要配置静态监听?
nomount状态下必须使用静态监听才能连接到实例
tnsnames.ora
tnsorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
tnsdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
主库2节点和备库:
tnsping tnsfxdb
tnsping tnssbdb
主库和备库:
sqlplus sys/woailyoo@tnsorcl as sysdba
sqlplus sys/woailyoo@tnsdg as sysdba
SELECT INSTANCE_NAME,STATUS FROM V$INSTANCE;
1.duplicate
1.1离线--rman备份集
1.2在线--duplicate,适合局域网
rman target sys/woailyoo@tnsorcl 必须指定密码
rman target / 最好不要使用---可能会有密码错误
connect auxiliary sys/woailyoo@tnsdg
standby日志组:redo日志组+1 2+1
standby日志组与redo日志组大小必须一致
--查看主库日志组
SELECT THREAD#,SEQUENCE#,BYTES, MEMBERS FROM V$LOG ;
SELECT * FROM v$logfile
查看standby日志组:---备库查看
select group#,thread#,sequence#,archived,status, BYTES from v$standby_log;
备库: --大小需根据主库 SELECT * FROM V$LOG 设置(跟主库一致)
alter database add standby logfile thread 1 group 11 ('/u01/app/oracle/oradata/dg/stredo11.log') size 200M;
alter database add standby logfile thread 1 group 12 ('/u01/app/oracle/oradata/dg/stredo12.log') size 200M;
alter database add standby logfile thread 1 group 13 ('/u01/app/oracle/oradata/dg/stredo13.log') size 200M;
alter database add standby logfile thread 2 group 14 ('/u01/app/oracle/oradata/dg/stredo14.log') size 200M;
alter database add standby logfile thread 2 group 15 ('/u01/app/oracle/oradata/dg/stredo15.log') size 200M;
alter database add standby logfile thread 2 group 16 ('/u01/app/oracle/oradata/dg/stredo16.log') size 200M;
开启同步:
alter database open;---备库
开启redo应用(实时同步)commit
alter database recover managed standby database disconnect; (12C)---备库
停止redo应用----停止实实同步
alter database recover managed standby database cancel;
查看状态:
select name,open_mode,database_role,protection_mode,protection_level from v$database;
更改保护模式:
alter database set standby database to maximize performance;最大性能
alter database set standby database to maximize availability;最大可用 ---主备都执行
alter database set standby database to maximize protection;最大保护
测试同步:
create table t(id int);
insert into t values(100);
commit;
备库查询:
select * from v$managed_standby;备库查询
select * from v$standby_log;
select status, gap_status from v$archive_dest_status where dest_id = 2; --最保险的还要执行,insert
select database_role from v$database;
主库: primary
备库: physical standby
select name,database_role,switchover_status from v$database;
主库: to standby 或者 session active(有会话连接)
备库:NOT ALLOWED
tnsping tnsorcl
tnsping tnsdg
sqlplus / as sysdba
show parameter db_file
show parameter fal_
show parameter log_file
如果没设置则设置:
alter system set db_file_name_convert='/orcl/app/oracle/oradata/dg','+DATA/ORCL/DATAFILE','/orcl/app/oracle/oradata/dg','+DATA/ORCL/TEMPFILE' scope=spfile sid='*';
alter system set fal_client='tnsorcl' scope=both sid='*';
alter system set fal_server='tnsdg' scope=both sid='*';
alter system set log_file_name_convert='/orcl/app/oracle/oradata/dg','+DATA/ORCL/ONLINELOG' scope=spfile sid='*';
--日志组大小根据 查询 SELECT * FROM v$log 主库日志大小设置
alter database add standby logfile thread 1 group 11 ('+DATA') size 200M;
alter database add standby logfile thread 1 group 12 ('+DATA') size 200M;
alter database add standby logfile thread 1 group 13 ('+DATA') size 200M;
alter database add standby logfile thread 2 group 14 ('+DATA') size 200M;
alter database add standby logfile thread 2 group 15 ('+DATA') size 200M;
alter database add standby logfile thread 2 group 16 ('+DATA') size 200M;
(12C新特性)主库执行:
alter database switchover to dg verify;
alter database switchover to dg;(执行完主库所有节点自动关闭 , 备库变为mount状态)
alter database switchover to dg force;
主库:shutdown
备库:mount
--启动新备库(原主库)
startup
--新备库(原主库)开启standby同步
alter database recover managed standby database disconnect;
--启动新主库(原备库)
startup
--查看新主备状态
select name,open_mode,database_role,protection_mode,protection_level,switchover_status from v$database;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。