dgbroker搭建的完整过程
本篇内容介绍了"dgbroker搭建的完整过程"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
一个表或索引或其它对象使用BUFFER CACHE,最终使用哪个CBC LATCH,由其文件号以及数据块号,进行HASH后使用指定的CBC LATCH
使用Shell脚本实现自动化静默安装Oracle软件
下载oracle 11g
下载地址:wget http://v.yingsun.net/cobra/download/linux.x64_11gR2_database_1of2.zip
下载地址:wget http://v.yingsun.net/cobra/download/linux.x64_11gR2_database_2of2.zip
一 安装java
查看CentOS自带JDK是否已安装。yum list installed |grep java
查看yum库中的Java安装包 命令:yum -y list java 看看可安装的软件包有没有java-1.8.0-openjdk
二 检查和安装需要的rpm
yum -y install binutils compat-libstdc++ compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers ksh libaio-devel libstdc++-devel make sysstat unixODBC-devel binutils-* compat-libstdc++* elfutils-libelf* glibc* gcc-* libaio* libgcc* libstdc++* make* sysstat* unixODBC* wget unzip
unixODBC-devel
还有必须下载的包
wget ftp://ftp.pbone.net/mirror/www.whiteboxlinux.org/whitebox/4/en/updates/i686/glibc-2.3.4-2.43.i686.rpm
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
安装依赖包
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
检查有没有31个
还能用如下方式检查,包括centos6,centos7的包
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \
compat-libcap1 \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
libXi \
libXtst \
make \
sysstat \
unixODBC \
unixODBC-devel
各个版本的检查包和版本课看官方文档
https://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#BHCFACHG
三 创建用户组和用户
userdel -r oracle
groupadd -g 700 oinstall
groupadd -g 701 dba
useradd -g oinstall -G dba -u 700 oracle
passwd oracle
id oracle
四 设置ORACLE环境变量
su - oracle
vi ~/.bash_profile
export ORACLE_BASE=/u02/oracle
export ORACLE_HOME=/u02/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export NLS_LANG="american_america.AL32UTF8"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:Mi:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
//脚本方式
new_export = "export ORACLE_BASE=/u02/oracle"
echo "export ORACLE_BASE=/u02/oracle" >> ~/.bash_profile
echo "export ORACLE_HOME=/u02/oracle/product/11.2.0/dbhome_1" >> ~/.bash_profile
echo "export ORACLE_SID=orcl" >> ~/.bash_profile
bash shell:脚本中修改profile文件更新LD_LIBRARY_PATH的示例 http://blog.csdn.net/10km/article/details/51953721
source ~/.bash_profile
查看环境变量是否完成
env | grep ORA
五 创建安装目录
su - root
mkdir -p /u02/oracle
mkdir -p /u02/oracle/product/11.2.0/dbhome_1
chown -R oracle:oinstall /u02/oracle
chmod -R 775 /u02/oracle
vi /etc/oraInst.loc
inventory_loc==/home/oracle/oraInventory
inst_group=oinstall
source /etc/oraInst.loc
chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc
五 解压
unzip p10404530_112030_Linux-x86-64_1of7.zip; unzip p10404530_112030_Linux-x86-64_2of7.zip
六 复制响应文件模板
用oracle用户复制
su - oracle
mkdir /home/oracle/etc
mkdir /home/oracle/oraInventory
cp /u02/oracle/database/response/* /home/oracle/etc/
七 设置响应文件
su - root
chmod 700 /home/oracle/etc/*.rsp(注意所有者,oinstall)
八 静默安装Oracle软件
su - oracle
修改安装Oracle软件的响应文件/home/oracle/etc/db_install.rsp
#删除应答文件中的注释行(以#开头)
$ sed -i 's/^#.*$//g' *.rsp
刪除沒有內容的空行(^$)
$ sed -i '/^$/d' *.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY // 29 安装类型
ORACLE_HOSTNAME=oracle // 37 主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall // 42 安装组
INVENTORY_LOCATION=/home/oracle/oraInventory //47 INVENTORY目录(不填就是默认值) 注意:这里inventory目录最好不要填写与oracle安装路径一致的目录,会报错
SELECTED_LANGUAGES=en,zh_CN,zh_TW // 78 选择语言
ORACLE_HOME=/u02/oracle/product/11.2.0/dbhome_1 // 83 oracle_home
ORACLE_BASE=/u02/oracle // 88 oracle_base
oracle.install.db.InstallEdition=EE // 99 oracle版本
oracle.install.db.isCustomInstall=false //自定义安装,否,使用默认组件
oracle.install.db.DBA_GROUP=dba // 143 dba用户组
oracle.install.db.OPER_GROUP=oinstall // 147 oper用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE // 160 数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl // 165 globalDBName
oracle.install.db.config.starterdb.SID=orcl // 170 SID
oracle.install.db.config.starterdb.memoryLimit=81920 // 200 自动管理内存的内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle // 233 设定所有数据库用户使用同一个密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false // 376(手动写了false)
DECLINE_SECURITY_UPDATES=true // 385 设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)
执行命令 开始默认安装
cd /u02/oracle/database
./runInstaller -ignorePrereq -showProgress -silent -responseFile /home/oracle/etc/db_install.rsp
./runInstaller -ignorePrereq -showProgress -silent -force -responseFile /home/oracle/etc/db_install.rsp
./runInstaller -silent -force -responseFile /home/oracle/etc/db_install.rsp
这时可以看安装日志
INFO: Number of threads for fast copy :1
这里在centos7上安装oracle11g时,不论11.1.0.1还是 11.2.0.4 都会报错
String: Error in invoking target 'agent nmhs' of makefile '/u02/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'.
这个错误相当于图形界面安装时遇到的错误,但图形界面安装遇到错误,会停止,且提供重试的按钮,静默安装就不成,具体解决方法可以参考
http://www.jb51.net/article/129719.htm
安向导执行俩文件
/home/oracle/oraInventory/orainstRoot.sh
/u02/oracle/product/11.2.0/dbhome_1/root.sh
九 静默配置网络
编辑netca.rsp文件
$ more /u02/oracle/database/response/netca.rsp
[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
在oracle用户下
$ORACLE_HOME/bin/netca /silent /responsefile /home/oracle/database/response/netca.rsp
十 静默安装数据库
在oracle 用户安装。需要配置静默安装数据库响应的模板文件,也是在安装软件包中解压在database下的response 目录下的 dbca_rsp 文件,具体配置如下
vim dbca.rsp
//$ more /u02/soft/database/response/dbca.rsp
cp /u02/oracle/database/response/dbca.rsp /u02/oracle/database/response/dbca.rsp.bak
vi /u02/oracle/database/response/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "lanmao" #全局数据库的名字 DB_NAME_DB_DOMAIN
SID = "orcl" # 数据库实例,根据上面的你写的SID 一样的,随便写。
TEMPLATENAME = "General_Purpose.dbc" # 这个可以是默认的模板,不会写默认的,最好是默认,
这里是我们dba 写的,所以就用上了。
SYSPASSWORD = "2011@oracle"
SYSTEMPASSWORD = "2011@oracle"
SYSMANPASSWORD = "2011@oracle"
DBSNMPPASSWORD = "2011@oracle" # 前面这四个都可以不管,默认就行
CHARACTERSET = "ZHS16GBK" #编码
NATIONALCHARACTERSET="UTF8" #编码
[createTemplateFromDB]
SOURCEDB = "iZ2zehy7gff0kpg1swp1czZ:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
NODELIST=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
INSTANCENAME = "orcl11g"
SYSDBAUSERNAME = "sys"
$ORACLE_HOME/bin/dbca -silent -responseFile /db/soft/database/response/dbca.rsp
$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
/u02/oracle/database/response/dbca.rsp
十一 删除方法
数据库安装成功后,要删除执行的命令
先听数据库
/home/oracle/database/dbca -silent -deleteDatabase -sourcedb orcl11g -sid orcl11g -sysDBAUserName system -sysDBAPassword oracle
没安装成功时删除数据库和软件方法
删除/u02/oracle/oradata目录下对应数据库文件夹
删除/u02/oracle/flash_recovery_area 目录下对应数据库文件夹
最重要/etc/oratab 删除里面最后的对应数据库的记录
--删除 vi /home/oracle/oraInventory/ContentsXML/inventory.xml
root用户
swapoff -a && swapon -a
rm -fr /u02/oracle/oradata
rm -fr /u02/oracle/flash_recovery_area
rm -fr /home/oracle/oraInventory
rm -fr /u02/oracle/product/11.2.0/dbhome_1
mkdir -p /u02/oracle/product/11.2.0/dbhome_1 mkdir -p /u02/oracle/oradata 跟踪错误sqlplus 方法 select open_mode from v$database; INFO: End output from spawned process. INFO: gcc -o /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/oracle -m64 -z noexecstack -L/u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/ -L/u02/oracle/product/11.2.0/dbhome_1/lib/ -L/u02/oracle/product/11.2.0/dbhome_1/lib/stubs/ -Wl,-E /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/opimai.o /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/ssoraed.o /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/ttcsoi.o -Wl,--whole-archive -lperfsrv11 -Wl,--no-whole-archive /u02/oracle/product/11.2.0/dbhome_1/lib/nautab.o /u02/oracl ...... 问题2 创建数据库时报错 /u02/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_ora_16270.trc ORA-01092: ORACLE instance terminated. Disconnection forced ORA-01501: CREATE DATABASE failed ORA-01519: error while processing file '?/rdbms/admin/dtxnspc.bsq' near line 5 ORA-00604: error occurred at recursive SQL level 1 ORA-30012: undo tablespace 'UNDOTBS1' does not exist or of wrong type 这个提示实际很明显,但特别注意的是要保证参数文件里的回退表空间名字和create database语句 手工建库的过程如下 2 克隆安装数据库软件 2复制dbhome_1到新位置 cp -r /u02/oracle/product/11.2.0/dbhome_1 /u03_clone/oracle/product/11.2.0/dbhome_1 dgbroker ADR_BASE_LISTENER = /u02/oracle 复制主库listener和tnsname到备库 ADR_BASE_LISTENER = /u02/oracle 备库的tnsname PHYSICAL = PRIMARY = 2:设置DG_BROKER_START参数,所有的节点都需要配置 alter system set standby_file_management ='AUTO'; alter database add standby logfile group 11 '/u02/oracle/oradata/orcl11g/standbylog/standby11.log' size 50m; 2.2主库归档 alter database open; 2.3 备份主库: a.rman target / b.backup database; 2.4 在备库上克隆主库: b.启动数据库到nomount: 在备库还得再创建一个空的新的数据库 rman target sys/oracle@PRIMARY auxiliary system/oracle@PHYSICAL duplicate target database for standby nofilenamecheck from active database; 查看日志 startup nomount pfile=/u03_clone/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora @/u03_clone/oracle/product/11.2.0/dbhome_1/rdbms/admin/catupgrd.sql startup open pfile=/u02/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora cd $ORACLE_HOME/bin 测试远程连接主库 cd $ORACLE_HOME/bin 2.5:创建并启用配置文件 这次遇到的问题是在安装了oracle软件后,再创建数据库时,特别最后执行catproc.sql时怎么都执行不完,还老报错 在备库上克隆主库 https://www.cnblogs.com/vijayfly/archive/2015/12/16/5051614.html oracle11G使用DGbroker创建dg 解决问题 Service "PHYSICAL.localdomain" has 1 instance(s). Service "PHYSICAL" has 1 instance(s). "dgbroker搭建的完整过程"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!
vi /etc/oratab
--vi /home/oracle/oraInventory/ContentsXML/inventory.xml
--sed -i '/^
chown -R oracle:oinstall /u02/oracle
chmod -R 775 /u02/oracle
mkdir -p /u02/oracle/flash_recovery_area
chown -R oracle:oinstall /u02/oracle/oradata
chmod -R 775 /u02/oracle/oradata
su - oracle
mkdir /home/oracle/oraInventory
/u02/oracle/oradiag_oracle/diag/clients/user_oracle/host_2133379358_76/alert
strace sqlplus / as sysdba
strace -f -o /tmp/sqlplus.log sqlplus / as sysdba
查看为什么出现 ORA-12547: TNS:lost contact
遇到的问题
问题1
在静默安装oracle的时候,在安装软件以后,进入sqlplus后,总是报TNS connect lost,这时就在网上查看了这个错误对应问题,其中说是
bin目录里oracle执行文件大小为0,后来就反复装,发现装的时候果然系统装到link oracle的时候就不动了,最后看日志的时候看这里最终
报错。然后就在日志里查看了对应的错误。和日志里遇到的第一个错误。
其实判断这个题很容易,重要的是看日志
日志在安装时,已经输出了具体位置和文件名,打开后就能看到。里面发现的第一个报错信息
INFO: collect2: error: ld returned 1 exit status
make[1]: *** [/u02/oracle/product/11.2.0/dbhome_1/sysman/lib/emdctl] Error 1
make: *** [emdctl] Error 2
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'agent nmhs' of makefile '/u02/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'. See '/home/oracle/oraInventory/logs/installActions2017-12-12_04-48-00PM.log' for details.
Exception Severity: 1
然后根据网上的提示就是在ins_emagent里加 -lnnet11
然后为让这些字节是0的文件生效,就执行了bin目录里的relink all
最后oracle文件就生成了,且在进入sqlplus就不报tns的错误了,最后说的是连接一个正常实例的问题。
打印日志的时候,在这个位置会等很长时间
INFO: - Linking Oracle
rm -f /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/oracle
INFO: e/product/11.2.0/dbhome_1/lib/naeet.o /u02/oracle/product/11.2.0/dbhome_1/lib/naect.o /u02/oracle/product/11.2.0/dbhome_1/lib/naedhs.o /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/config.o -lserver11 -lodm11 -lcell11 -lnnet11 -lskgxp11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lvsn11 -lcommon11 -lgeneric11 -lknlopt `if /usr/bin/ar tv /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/libknlopt.a | grep xsyeolap
`cat /u02/oracle/product/11.2.0/db
INFO: home_1/lib/sysliblist` -Wl,-rpath,/u02/oracle/product/11.2.0/dbhome_1/lib -lm `cat /u02/oracle/product/11.2.0/dbhome_1/lib/sysliblist` -ldl -lm -L/u02/oracle/product/11.2.0/dbhome_1/lib
orapwd FILE=orapwdORCL11g.pwd PASSWORD=welcome1 ENTRIES=30
排错方法 看建立数据库时alert方法
[oracle@iZ2zehy7gff0kpg1swp1czZ ~]$ cd $ORACLE_BASE/diag/rdbms/orcl11g/orcl11g/trace
[oracle@iZ2zehy7gff0kpg1swp1czZ trace]$ ls -alcr | grep alert
-rw-r----- 1 oracle oinstall 64209 Dec 14 14:45 alert_orcl11g.log
[oracle@iZ2zehy7gff0kpg1swp1czZ trace]$ ls -alcr | grep alert
在其中找到了pfile文件
/u02/oracle/cfgtoollogs/dbca/orcl11g/initorcl11gTemp.ora
startup nomount pfile=/u02/oracle/cfgtoollogs/dbca/orcl11g/initorcl11gTemp.ora;
要根据pfile生成spfile,数据库就能启动到open了
create spfile from pfile='/u02/oracle/cfgtoollogs/dbca/orcl11g/initorcl11gTemp.ora'
create spfile from pfile='$ORACLE_HOME/dbs/initorcl11g.ora'
问题3 手工建库时的问题
根据文档手工创建数据库,但输入创建语句后,系统提示如下错误
ERROR at line 1:
里的表空间名字要一样,而不是和create database里的回退数据文件名一样,这很重要,这可以保证
后面的执行脚本时没有莫名其妙的错误。
1 删除已有数据库
rm -fr oradata/orcl11g/*.*
rm -fr fast_recovery_area/orcl11g/control02.ctl
orapwd FILE=orapwdSORCL.pwd PASSWORD=oracle ENTRIES=30
CREATE SPFILE='spfile.ora' FROM
PFILE='init.ora';
CREATE DATABASE orcl11g
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u02/oracle/oradata/orcl11g/redo01.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u02/oracle/oradata/orcl11g/redo02.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u02/oracle/oradata/orcl11g/redo03.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u02/oracle/oradata/orcl11g/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u02/oracle/oradata/orcl11g/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u02/oracle/oradata/orcl11g/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u02/oracle/oradata/orcl11g/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs --undotbs 必须和参数文件中指定名字一样
DATAFILE '/u02/oracle/oradata/orcl11g/UNDOTBS_01.dbf' --UNDOTBS_01没事随便取名
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
rm -fr /tmp/logsql.txt
spool /tmp/logsql.txt --这样可以执行sql脚本后的日志
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
spool off
在一台机器上克隆安装第二个oracle 软件
1增加swap分区
dd if=/dev/zero of=/home/swap1 bs=612 count=612000
mkswap /home/swap1
swapon /home/swap1
3chown -R oracle:oinstall /u03_clone/oracle
su - oracle
4 登记复制后的信息命令
cd /u03_clone/oracle/product/11.2.0/dbhome_1/clone/bin
perl clone.pl ORACLE_BASE=/u03_clone/oracle ORACLE_HOME=/u03_clone/oracle/product/11.2.0/dbhome_1 ORACLE_HOME_NAME=OraDb11g_home_clone
5 验证是否加入产品列表目录,软件是否安装成功
vi /home/oracle/oraInventory/ContentsXML/inventory.xml
1:主库配置listener.ora文件和tnsnames.ora文件,添加GLOBAL_DBNAME参数,重启监听器,所有的节点都需要配置
cat $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = PRIMARY)
(ORACLE_HOME = /u02/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl11g)
)
(SID_DESC =
(GLOBAL_DBNAME = PRIMARY_DGMGRL)
(ORACLE_HOME = /u02/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl11g)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
cat $ORACLE_HOME/network/admin/tnsnames.ora
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.localdomain)
)
)
PHYSICAL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.localdomain)
)
)
cd /u02/oracle/product/11.2.0/dbhome_1/network/admin
cp listener.ora tnsnames.ora /u03_clone/oracle/product/11.2.0/dbhome_1/network/admin/
备库上的listener和tnsname
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = PHYSICAL)
(ORACLE_HOME = /u03_clone/oracle/product/11.2.0/dbhome_1)
(SID_NAME = sorcl11g)
)
(SID_DESC =
(GLOBAL_DBNAME = PHYSICAL_DGMGRL)
(ORACLE_HOME = /u03_clone/oracle/product/11.2.0/dbhome_1)
(SID_NAME = sorcl11g)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.localdomain)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.localdomain)
)
)
注意 这里端口号和主库的端口不应一致,因为此时环境是一个节点上有两个ORACLE产品两个ORACLE数据库
2.1基本配置
alter system set db_unique_name='PRIMARY' scope=spfile;
alter database add standby logfile group 12 '/u02/oracle/oradata/orcl11g/standbylog/standby12.log' size 50m;
alter database add standby logfile group 13 '/u02/oracle/oradata/orcl11g/standbylog/standby13.log' size 50m;
alter database add standby logfile group 14 '/u02/oracle/oradata/orcl11g/standbylog/standby14.log' size 50m;
shutdown immediate;
startup mount;
alter system set log_archive_dest_1='location=/u02/oracle/oradata/orcl11g/archivelog';
alter database archivelog;
主库启动broker
show parameter dg_broker_start;
!ps -ef |grep dmon
alter system set dg_broker_start=TRUE;
!ps -ef |grep dmon
在主库重新生成pfile create pfile from spfile;
a.cd /u02/oracle/product/11.2.0/dbhome_1/dbs
cp initorcl11g.ora orapworcl11g /u03_clone/oracle/product/11.2.0/dbhome_1/dbs/
修改备库pfile上的db_unique_name=PHYSICAL
因为在同一台机器的不同位置安装了另一个oracle软件,所以还要设置数据存放位置的参数
su - oracle
mkdir -p /u03_clone/oracle/oradata/orcl11g/archivelog
mkdir -p /u03_clone/oracle/flash_recovery_area
mkdir -p /u03_clone/oracle/admin/orcl11g/adump
要在同一台机器上启动另一产品的数据库,必须先启动不同的listener,然后启动俩数据库
同一机器上启动不同产品的listener 必须要有TNS_ADMIN
打开窗口1 export TNS_ADMIN=/u02/oracle/product/11.2.0/dbhome_1/network/admin 主库listener
打开窗口2 export TNS_ADMIN=/u03_clone/oracle/product/11.2.0/dbhome_1/network/admin 备库listener
在窗口1
export ORACLE_SID=orcl11g
echo $ORACLE_SID
sqlplus / as sysdba
startup open pfile=/u02/oracle/product/11.2.0/dbhome_1/dbs
在窗口2
export ORACLE_SID=sorcl11g
echo $ORACLE_SID
sqlplus / as sysdba
startup nomount pfile=/u03_clone/oracle/product/11.2.0/dbhome_1/dbs
CREATE DATABASE orcl11g
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u03_clone/oracle/oradata/orcl11g/redo01.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u03_clone/oracle/oradata/orcl11g/redo02.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u03_clone/oracle/oradata/orcl11g/redo03.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u03_clone/oracle/oradata/orcl11g/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u03_clone/oracle/oradata/orcl11g/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u03_clone/oracle/oradata/orcl11g/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u03_clone/oracle/oradata/orcl11g/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u03_clone/oracle/oradata/orcl11g/UNDOTBS_01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
c.登陆rman:
rman target system/oracle@PHYSICAL auxiliary system/oracle@PRIMARY
d.开始克隆:
vi /u03_clone/oracle/diag/rdbms/physical/orcl11g/trace/alert_orcl11g.log
vi /u02/oracle/diag/rdbms/primary/orcl11g/trace/alert_orcl11g.log
startup upgrade pfile=/u03_clone/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora
startup open pfile=/u03_clone/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora
@/u03_clone/oracle/product/11.2.0/dbhome_1/rdbms/admin/catalog.sql
@/u03_clone/oracle/product/11.2.0/dbhome_1/rdbms/admin/catproc.sql
测试远程连接备库
export ORACLE_SID=sorcl11g
export ORACLE_HOME=/u03_clone/oracle/product/11.2.0/dbhome_1
export TNS_ADMIN=/u03_clone/oracle/product/11.2.0/dbhome_1/network/admin/
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
./sqlplus / as sysdba
./lsnrctl status
startup open pfile=/u03_clone/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora
./sqlplus system/welcome1@PHYSICAL
rman target /
export ORACLE_SID=orcl11g
export ORACLE_HOME=/u02/oracle/product/11.2.0/dbhome_1
export TNS_ADMIN=/u02/oracle/product/11.2.0/dbhome_1/network/admin/
./sqlplus / as sysdba
./lsnrctl status
startup open pfile=/u02/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora
./sqlplus system/oracle@PRIMARY
dgmgrl sys/oracle@PRIMARY
create configuration dgc as primary database is PRIMARY connect identifier is PRIMARY;
add database PHYSICAL as connect identifier is PHYSICAL maintained as physical;
enable configuration
show configuration [verbose];
关闭数据库重启open后,还说要按upgrade方式打开数据库,显然catproc.sql未完全执行完,最后发现原因实际是数据库内存不足
在运行脚本时,速度很慢,而且free -mh查看内存只有几十M可用,于是,关闭占用内存的应用,重新执行脚本很快就执行好了,而且
可以顺利启动到open状态
http://blog.51cto.com/ylw6006/686900
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
这个错误最大的问题是 一个节点上安了两个oracle软件,在启动第二个oracle软件时,环境变量ORACLE_HOME还是第一个oracle软件的
,所以启动数据库时,是在环境变量1的基础上启动的数据库,造成启动时数据库会用到错误的环境变量ORACLE_HOME,最终启动虽然
正常,但远程连接时就报上面的错误。sqlplus system/oracle@PHYSICAL
另外出现 shared memory realm does not exist的原因还有可能是虚拟机物理内存不足造成
Instance "sorcl11g", status READY, has 1 handler(s) for this service...
Service "PRIMARY" has 1 instance(s).
Instance "orcl11g", status UNKNOWN, has 1 handler(s) for this service...
Service "PRIMARY_DGMGRL" has 1 instance(s).
Instance "orcl11g", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl11g.localdomain" has 1 instance(s).
Instance "orcl11g", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl11gXDB.localdomain" has 1 instance(s).
Instance "sorcl11g", status READY, has 1 handler(s) for this service...
Instance "sorcl11g", status UNKNOWN, has 1 handler(s) for this service...
Service "PHYSICAL_DGMGRL" has 1 instance(s).
Instance "sorcl11g", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl11g.localdomain" has 1 instance(s).
Instance "sorcl11g", status UNKNOWN, has 1 handler(s) for this service...