下載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
寧陽網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),寧陽網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為寧陽近1000家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的寧陽做網(wǎng)站的公司定做!
一 安裝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
三 創(chuàng)建用戶組和用戶
userdel -r oracle
groupadd -g 700 oinstall
groupadd -g 701 dba
useradd -g oinstall -G dba -u 700 oracle
passwd oracle
id oracle
四 設(shè)置ORACLE環(huán)境變量
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
查看環(huán)境變量是否完成
env | grep ORA
五 創(chuàng)建安裝目錄
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/oralnventory
inst_group=oinstall
source /etc/oralnst.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
六 復(fù)制響應(yīng)文件模板
用oracle用戶復(fù)制
su - oracle
mkdir /home/oracle/etc
mkdir /home/oracle/oralnventory
cp /u02/oracle/database/response/* /home/oracle/etc/
七 設(shè)置響應(yīng)文件
su - root
chmod 700 /home/oracle/etc/*.rsp(注意所有者,oinstall)
八 靜默安裝Oracle軟件
su - oracle
修改安裝Oracle軟件的響應(yīng)文件/home/oracle/etc/db_install.rsp
#刪除應(yīng)答文件中的注釋行(以#開頭)
$ sed -i 's/^#.*$//g' *.rsp
刪除沒有內(nèi)容的空行(^$)
$ 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 數(shù)據(jù)庫類型
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 自動管理內(nèi)存的內(nèi)存(M)
oracle.install.db.config.starterdb.password.ALL=oracle // 233 設(shè)定所有數(shù)據(jù)庫用戶使用同一個密碼
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false // 376(手動寫了false)
DECLINE_SECURITY_UPDATES=true // 385 設(shè)置安全更新(貌似是有bug,這個一定要選true,否則會無限提醒郵件地址有問題,終止安裝。PS:不管地址對不對)
執(zhí)行命令 開始默認安裝
cd /u02/oracle/database
./runInstaller -ignorePrereq -silent -force -responseFile /home/oracle/etc/db_install.rsp
安向?qū)?zhí)行倆文件
/home/oracle/oraInventory/orainstRoot.sh
/u02/oracle/product/11.2.0/dbhome_1/root.sh
九 靜默配置網(wǎng)絡(luò)
編輯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 /u02/oracle/database/response/netca.rsp
十 靜默安裝數(shù)據(jù)庫
在oracle 用戶安裝。需要配置靜默安裝數(shù)據(jù)庫響應(yīng)的模板文件,也是在安裝軟件包中解壓在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" #全局數(shù)據(jù)庫的名字
SID = "orcl" # 數(shù)據(jù)庫實例,根據(jù)上面的你寫的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 /u02/oracle/database/response/dbca.rsp
跟蹤錯誤sqlplus 方法
strace sqlplus / as sysdba
查看為什么出現(xiàn) ORA-12547: TNS:lost contact
參考 使用Shell腳本實現(xiàn)自動化靜默安裝Oracle軟件https://github.com/yoshinorim/mha4MySQL-manager.git
一個表或索引或其它對象使用BUFFER CACHE,最終使用哪個CBC LATCH,由其文件號以及數(shù)據(jù)塊號,進行HASH后使用指定的CBC LATCH
使用Shell腳本實現(xiàn)自動化靜默安裝Oracle軟件
第一篇 靜默方式安裝oracle 11g 完整攻略
下載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
各個版本的檢查包和版本可以看官方文檔
https://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#BHCFACHG
具體所有安裝包是否已安裝檢查方法
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
如缺少相應(yīng)包可用yum -y install 安裝,也可以按如下方式直接把需要的所有依賴包安裝上
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
網(wǎng)上搜索的方法也可以參考如下
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
三 創(chuàng)建用戶組和用戶
userdel -r oracle
groupadd -g 700 oinstall
groupadd -g 701 dba
useradd -g oinstall -G dba -u 700 oracle
passwd oracle
id oracle
四 設(shè)置ORACLE環(huán)境變量
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
//腳本方式初始化環(huán)境變量參考方法
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
查看環(huán)境變量是否完成
env | grep ORA
五 創(chuàng)建安裝目錄
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
六 復(fù)制響應(yīng)文件模板
用oracle用戶復(fù)制
su - oracle
mkdir /home/oracle/etc --放配置文件 如響應(yīng)文件
mkdir /home/oracle/oraInventory --放產(chǎn)品目錄相關(guān)文件
cp /u02/oracle/database/response/* /home/oracle/etc/
七 設(shè)置響應(yīng)文件權(quán)限
su - root
chmod 700 /home/oracle/etc/*.rsp(注意所有者,oinstall)
八 靜默安裝Oracle軟件
su - oracle
修改安裝Oracle軟件的響應(yīng)文件/home/oracle/etc/db_install.rsp
#刪除應(yīng)答文件中的注釋行(以#開頭)
$ sed -i 's/^#.*$//g' *.rsp
刪除沒有內(nèi)容的空行(^$)
$ sed -i '/^$/d' *.rsp
文件內(nèi)容詳細介紹
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 數(shù)據(jù)庫類型
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 自動管理內(nèi)存的內(nèi)存(M)
oracle.install.db.config.starterdb.password.ALL=oracle // 233 設(shè)定所有數(shù)據(jù)庫用戶使用同一個密碼
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false // 376(手動寫了false)
DECLINE_SECURITY_UPDATES=true // 385 設(shè)置安全更新(貌似是有bug,這個一定要選true,否則會無限提醒郵件地址有問題,終止安裝。PS:不管地址對不對)
實際產(chǎn)品庫詳單參考db_install.rsp內(nèi)容
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=
ORACLE_HOSTNAME=iZ2zehy7gff0kpg1swp1czZ
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u02/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u02/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=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.CLUSTER_NODES=
"/home/oracle/etc/db_install.rsp" 53L, 2500C
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=
ORACLE_HOSTNAME=iZ2zehy7gff0kpg1swp1czZ
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u02/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u02/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=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl11g
oracle.install.db.config.starterdb.SID=orcl11g
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=400
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
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=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u02/oracle/oradata/
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u02/oracle/flash_recovery_area/
oracle.install.db.config.asm.diskGroup=
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=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
執(zhí)行命令 開始默認安裝
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'.
這個錯誤相當(dāng)于圖形界面安裝時遇到的錯誤,但圖形界面安裝遇到錯誤,會停止,且提供重試的按鈕,靜默安裝就不成,具體解決方法可以參考
http://www.jb51.net/article/129719.htm《CentOS 7.4下安裝Oracle 11.2.0.4數(shù)據(jù)庫的方法》 這里需要編輯安裝文件
按向?qū)?zhí)行倆文件
/home/oracle/oraInventory/orainstRoot.sh
/u02/oracle/product/11.2.0/dbhome_1/root.sh
九 靜默配置網(wǎng)絡(luò)
編輯netca.rsp文件
$ more /home/oracle/etc/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
十 靜默安裝數(shù)據(jù)庫
在oracle 用戶安裝。需要配置靜默安裝數(shù)據(jù)庫響應(yīng)的模板文件,也是在安裝軟件包中解壓在database下的response 目錄下的 dbca_rsp 文件,具體配置如下
//$ more /u02/soft/database/response/dbca.rsp
vi /home/oracle/etc/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl11g.localdomain"
SID = "orcl11g"
TEMPLATENAME = "General_Purpose.dbc"
DATAFILEDESTINATION=/u02/oracle/oradata
RECOVERYAREADESTINATION=/u02/oracle/flash_recovery_area
CHARACTERSET = "AL32UTF8"
NATIONALCHARACTERSET= "AL16UTF16"
DB_UNIQUE_NAME = "orcl11g"
LISTENERS=LISTENER
TOTALMEMORY = "700"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
執(zhí)行安裝
$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
--/u02/oracle/database/response/dbca.rsp
十一 刪除方法
數(shù)據(jù)庫安裝成功后,要刪除執(zhí)行的命令
先刪除數(shù)據(jù)庫
/home/oracle/database/dbca -silent -deleteDatabase -sourcedb orcl11g -sid orcl11g -sysDBAUserName system -sysDBAPassword oracle
沒安裝成功時刪除數(shù)據(jù)庫和軟件方法
刪除/u02/oracle/oradata目錄下對應(yīng)數(shù)據(jù)庫文件夾
刪除/u02/oracle/flash_recovery_area 目錄下對應(yīng)數(shù)據(jù)庫文件夾
最重要/etc/oratab 刪除里面最后的對應(yīng)數(shù)據(jù)庫的記錄
--刪除 vi /home/oracle/oraInventory/ContentsXML/inventory.xml
root用戶
清空swap空間,刪除數(shù)據(jù)文件和oracle相應(yīng)目錄
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
刪除配置文件內(nèi)容
vi /etc/oratab
--vi /home/oracle/oraInventory/ContentsXML/inventory.xml
--sed -i '/^
mkdir -p /u02/oracle/product/11.2.0/dbhome_1
chown -R oracle:oinstall /u02/oracle
chmod -R 775 /u02/oracle
mkdir -p /u02/oracle/oradata
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
跟蹤錯誤sqlplus 方法
strace sqlplus / as sysdba
strace -f -o /tmp/sqlplus.log sqlplus / as sysdba
查看為什么出現(xiàn) ORA-12547: TNS:lost contact
select open_mode from v$database;
遇到的問題
問題1
在靜默安裝oracle的時候,在安裝軟件以后,進入sqlplus后,總是報TNS connect lost,這時就在網(wǎng)上查看了這個錯誤對應(yīng)問題,其中說是
bin目錄里oracle執(zhí)行文件大小為0,后來就反復(fù)裝,發(fā)現(xiàn)裝的時候果然系統(tǒng)裝到link oracle的時候就不動了,最后看日志的時候看這里最終
報錯。然后就在日志里查看了對應(yīng)的錯誤。和日志里遇到的第一個錯誤。
其實判斷這個題很容易,重要的是看日志
日志在安裝時,已經(jīng)輸出了具體位置和文件名,打開后就能看到。里面發(fā)現(xiàn)的第一個報錯信息
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: End output from spawned process.
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
然后根據(jù)網(wǎng)上的提示就是在ins_emagent里加 -lnnet11
然后為讓這些字節(jié)是0的文件生效,就執(zhí)行了bin目錄里的relink all
最后oracle文件就生成了,且在進入sqlplus就不報tns的錯誤了,最后說的是連接一個正常實例的問題。
打印日志的時候,在這個位置會等很長時間
INFO: - Linking Oracle
rm -f /u02/oracle/product/11.2.0/dbhome_1/rdbms/lib/oracle
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
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
問題2 創(chuàng)建數(shù)據(jù)庫時報錯
排錯方法 看建立數(shù)據(jù)庫時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;
/u02/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_ora_16270.trc
要根據(jù)pfile生成spfile,數(shù)據(jù)庫就能啟動到open了
create spfile from pfile='/u02/oracle/cfgtoollogs/dbca/orcl11g/initorcl11gTemp.ora'
create spfile from pfile='$ORACLE_HOME/dbs/initorcl11g.ora'
問題3 手工建庫時的問題
根據(jù)文檔手工創(chuàng)建數(shù)據(jù)庫,但輸入創(chuàng)建語句后,系統(tǒng)提示如下錯誤
ERROR at line 1:
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
這個提示實際很明顯,但特別注意的是要保證參數(shù)文件里的回退表空間名字和create database語句
里的表空間名字要一樣,而不是和create database里的回退數(shù)據(jù)文件名一樣,這很重要,這可以保證
后面執(zhí)行腳本時沒有莫名其妙的錯誤。
手工建庫的過程如下
1 刪除已有數(shù)據(jù)庫
rm -fr oradata/orcl11g/*.*
rm -fr fast_recovery_area/orcl11g/control02.ctl
2
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 必須和參數(shù)文件中指定名字一樣
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 --這樣可以執(zhí)行sql腳本后的日志
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
spool off
克隆安裝數(shù)據(jù)庫軟件
在一臺機器上克隆安裝第二個oracle 軟件
1增加swap分區(qū)
dd if=/dev/zero of=/home/swap1 bs=612 count=612000
mkswap /home/swap1
swapon /home/swap1
2復(fù)制dbhome_1到新位置 cp -r /u02/oracle/product/11.2.0/dbhome_1 /u03_clone/oracle/product/11.2.0/dbhome_1
3chown -R oracle:oinstall /u03_clone/oracle
su - oracle
4 登記復(fù)制后的信息命令
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 驗證是否加入產(chǎn)品列表目錄,軟件是否安裝成功
vi /home/oracle/oraInventory/ContentsXML/inventory.xml
dgbroker
1:主庫配置listener.ora文件和tnsnames.ora文件,添加GLOBAL_DBNAME參數(shù),重啟監(jiān)聽器,所有的節(jié)點都需要配置
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))
)
)
ADR_BASE_LISTENER = /u02/oracle
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)
)
)
復(fù)制主庫listener和tnsname到備庫
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))
)
)
ADR_BASE_LISTENER = /u02/oracle
備庫的tnsname
PHYSICAL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.localdomain)
)
)
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = iZ2zehy7gff0kpg1swp1czZ)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl11g.localdomain)
)
)
注意 這里端口號和主庫的端口不應(yīng)一致,因為此時環(huán)境是一個節(jié)點上有兩個ORACLE產(chǎn)品兩個ORACLE數(shù)據(jù)庫
2:設(shè)置DG_BROKER_START參數(shù),所有的節(jié)點都需要配置
2.1基本配置
alter system set db_unique_name='PRIMARY' scope=spfile;
alter system set standby_file_management ='AUTO';
alter database add standby logfile group 11 '/u02/oracle/oradata/orcl11g/standbylog/standby11.log' size 50m;
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;
2.2主庫歸檔
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
alter database open;
在主庫重新生成pfile create pfile from spfile;
2.3 備份主庫:
a.rman target /
b.backup database;
2.4 在備庫上克隆主庫:
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軟件,所以還要設(shè)置數(shù)據(jù)存放位置的參數(shù)
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
如果主端與備端目錄不同繼續(xù)修改參數(shù),在兩端的pfile文件中要添加,當(dāng)然如果相同也可以添加:
*.log_file_name_convert='/u02/oracle/oradata/orcl11g/','/u03_clone/oracle/oradata/orcl11g'
*.db_file_name_convert='/u02/oracle/oradata/orcl11g/','/u03_clone/oracle/oradata/orcl11g'
要在同一臺機器上啟動另一產(chǎn)品的數(shù)據(jù)庫,必須先啟動不同的listener,然后啟動倆數(shù)據(jù)庫
同一機器上啟動不同產(chǎn)品的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
b.啟動數(shù)據(jù)庫到nomount:
在窗口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
在備庫還得再創(chuàng)建一個空的新的數(shù)據(jù)庫
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 sys/oracle@PRIMARY auxiliary sys/oracle@PHYSICAL
rman target system/oracle@PHYSICAL auxiliary system/oracle@PRIMARY
d.開始克?。?/p>
問題 重點看
rman target sys/oracle@PRIMARY auxiliary sys/oracle@PHYSICAL
這里連接auxiliary庫的時候,死活又在那報無效用戶名密碼的問題,具體提示如下
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-01017: invalid username/password; logon denied
解決問題是想在一臺機器上復(fù)制一個已經(jīng)可以的oracle軟件產(chǎn)品,到另一個目錄,重新安裝一個oracle軟件,特別是
復(fù)制了已安好的ORACLE_HOME下的dbs下的所有文件后,發(fā)現(xiàn)initorcl.ora需要修改成initsorcl.ora,這邊新安得軟件對應(yīng)的庫
才能識別,所以同意密碼文件也應(yīng)該是orapwsorcl 而不是直接從原來的庫拿過來的密碼文件對應(yīng)的數(shù)據(jù)庫名,原庫密碼文件是
orapworcl 要改成oraopworcl 數(shù)據(jù)庫名和原數(shù)據(jù)庫名一樣對應(yīng)密碼文件名也要修改。
另外注意 遠程連接rman時,system沒有權(quán)限訪問rman所以也會報無效用戶名密碼問題,所以只能用sys用戶遠程連接rman
duplicate target database for standby nofilenamecheck from active database;
如果數(shù)據(jù)文件與重做日志文件目錄相同,要添加 nofilenamecheck ,否則不需要添加
查看日志
vi /u03_clone/oracle/diag/rdbms/physical/orcl11g/trace/alert_orcl11g.log
vi /u03_clone/oracle/diag/rdbms/physical/sorcl11g/trace/alert_sorcl11g.log
vi /u02/oracle/diag/rdbms/primary/orcl11g/trace/alert_orcl11g.log
/u02/oracle/diag/rdbms/primary/orcl11g/trace/drcorcl11g.log
startup nomount pfile=/u03_clone/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora
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
@/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
測試遠程連接備庫
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
tnsping DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=iZ2zehy7gff0kpg1swp1czZ)(PORT=1522)))(CONNECT_DATA=(SERVICE_NAME=PHYSICAL.localdomain)(CID=(PROGRAM=oracle)(HOST=iz2zehy7gff0kpg1swp1czz)(USER=oracle))))
(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=test01.cyou.com) (PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=stest_DGMGRL) (INSTANCE_NAME=test)(SERVER=DEDICATED)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=iZ2zehy7gff0kpg1swp1czZ)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=PHYSICAL.localdomain)(INSTANCE_NAME=sorcl)(SERVER=DEDICATED)))
cd $ORACLE_HOME/bin
./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/
cd $ORACLE_HOME/bin
./sqlplus / as sysdba
./lsnrctl status
startup open pfile=/u02/oracle/product/11.2.0/dbhome_1/dbs/initorcl11g.ora
./sqlplus system/oracle@PRIMARY
2.5:創(chuàng)建并啟用配置文件
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;
add database 'standby',這兒的standby是指database的db_unique_name,而AS CONNECT IDENTIFIER IS 'standby' 這里的standby是指
tnsname.ora 連接到standby database的net service name。
還可以這樣
alter system set log_archive_dest_2='SERVICE=ocrls ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ocrls' scope=spfile;
=》alter system set log_archive_dest_2='SERVICE=PHYSICAL LGWR ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHYSICAL' scope=spfile;
service=physical, LGWR ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300db_unique_name=physical net_timeout=30, valid_for=(all_logfiles,primary_role)
--alter system set log_archive_dest_2='SERVICE=PHYSICAL lgwr async noaffirm delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 net_timeout=30, VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHYSICAL'
enable configuration
show configuration [verbose];
alter system set fal_client=
主庫該參數(shù)
alter system set fal_client='PRIMARY';
ALTER system set fal_server='PHYSICAL';
備庫該參數(shù)
alter system set fal_client='PHYSICAL';
alter system set fal_server='PRIMARY';
這次遇到的問題是在安裝了oracle軟件后,再創(chuàng)建數(shù)據(jù)庫時,特別最后執(zhí)行catproc.sql時怎么都執(zhí)行不完,還老報錯
關(guān)閉數(shù)據(jù)庫重啟open后,還說要按upgrade方式打開數(shù)據(jù)庫,顯然catproc.sql未完全執(zhí)行完,最后發(fā)現(xiàn)原因?qū)嶋H是數(shù)據(jù)庫內(nèi)存不足
在運行腳本時,速度很慢,而且free -mh查看內(nèi)存只有幾十M可用,于是,關(guān)閉占用內(nèi)存的應(yīng)用,重新執(zhí)行腳本很快就執(zhí)行好了,而且
可以順利啟動到open狀態(tài)
http://blog.51cto.com/ylw6006/686900
SQL> alter system set LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(HOST = iz2zehy7gff0kpg1swp1czz)(PORT = 1521))' scope=spfile;
SQL> alter system set LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(HOST = iz2zehy7gff0kpg1swp1czz)(PORT = 1522))' scope=spfile;
在備庫上克隆主庫
https://www.cnblogs.com/vijayfly/archive/2015/12/16/5051614.html oracle11G使用DGbroker創(chuàng)建dg
standby上SRL完全等同與primary上的ORL,在primary發(fā)生日志切換時,Remote File System(RFS)進程把primary上的ORL寫到standby的SRL,同時standby歸檔上一個SRL
log_archive_dest_20
解決問題
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
這個錯誤最大的問題是 一個節(jié)點上安了兩個oracle軟件,在啟動第二個oracle軟件時,環(huán)境變量ORACLE_HOME還是第一個oracle軟件的
,所以啟動數(shù)據(jù)庫時,是在環(huán)境變量1的基礎(chǔ)上啟動的數(shù)據(jù)庫,造成啟動時數(shù)據(jù)庫會用到錯誤的環(huán)境變量ORACLE_HOME,最終啟動雖然
正常,但遠程連接時就報上面的錯誤。sqlplus system/oracle@PHYSICAL
另外出現(xiàn) shared memory realm does not exist的原因還有可能是虛擬機物理內(nèi)存不足造成
重啟時的日志報錯
db_recovery_file_dest_size of 4182 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Mon Jan 29 08:19:50 2018
Starting background process CJQ0
Mon Jan 29 08:19:50 2018
CJQ0 started with pid=30, OS id=10515
Mon Jan 29 08:20:00 2018
ORA-1652: unable to extend temp segment by 128 in tablespace TEMPTS1
Errors in file /u02/oracle/diag/rdbms/primary/orcl11g/trace/orcl11g_j003_10529.trc:
ORA-12012: error on auto execute of job "SYS"."BSLN_MAINTAIN_STATS_JOB"
ORA-01652: unable to extend temp segment by 128 in tablespace TEMPTS1
ORA-06512: at "DBSNMP.BSLN_INTERNAL", line 2073
log_archive_dest_1 /u02/oracle/oradata/orcl11g/archivelog
db_recovery_file_dest /u02/oracle/fast_recovery_area
FAST_START_MTTR_TARGET
standy_archive_dest ?/dbs_arch 能說明有dataguard么
主庫總是停機
ORA-00445: background process "SMCO" did not start after 120 seconds
Tue Feb 13 02:52:18 2018
Suspending MMON action 'Process staged incidents' for 82800 seconds
Tue Feb 13 03:00:25 2018
Errors in file /u02/oracle/diag/rdbms/primary/orcl11g/trace/orcl11g_pmon_27930.trc:
ORA-00445: background process "SMCO" did not start after 120 seconds
Tue Feb 13 03:01:37 2018
Restarting dead background process SMCO
Tue Feb 13 03:05:34 2018
Errors in file /u02/oracle/diag/rdbms/primary/orcl11g/trace/orcl11g_qmnc_28070.trc (incident=34271):
ORA-00445: background process "q003" did not start after 120 seconds
Tue Feb 13 03:14:56 2018
Errors in file /u02/oracle/diag/rdbms/primary/orcl11g/trace/orcl11g_pmon_27930.trc (incident=34280):
ORA-00445: background process "SMCO" did not start after 120 seconds
Tue Feb 13 03:28:02 2018
Errors in file /u02/oracle/diag/rdbms/primary/orcl11g/trace/orcl11g_pmon_27930.trc:
ORA-00445: background process "SMCO" did not start after 120 seconds
Tue Feb 13 03:30:21 2018
Warning: VKTM detected a time drift.
Tue Feb 13 03:30:57 2018
Time drifts can result in an unexpected behavior such as time-outs. Please check trace file for more details.
這實際是數(shù)據(jù)庫主機的內(nèi)存不夠?qū)е孪鄳?yīng)進程在規(guī)定時間起不來,造成數(shù)據(jù)庫停機。每次都要startup
ORA-01665: control file is not a standby control file
select controlfile_type from v$database;
問題2 跳歸檔解決GAP問題 重點看
日志無法應(yīng)用
在搭建了dataguard以后,我們需要判斷備庫是否能正常接收主庫的日志,以及是否能正常應(yīng)用傳送來的日志。并且在日常維護中也需要經(jīng)常監(jiān)控
主備是否一致。這次對某套dataguard環(huán)境巡檢的時候,發(fā)現(xiàn)了主備庫不一致,存在間隙的情況。
在主庫和備庫分別使用如下查詢查看應(yīng)用日志的具體時間和日志號
SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME
FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
發(fā)現(xiàn)主庫和備庫顯示出的日志數(shù)量不一致
查看備庫是否有GAP
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 24 30
從上面結(jié)果發(fā)現(xiàn),備庫從24號到30號日志都缺失。
備庫查看RFS接收日志和MRP應(yīng)用日志同步主庫情況
select process, sequence#, status, delay_mins from v$managed_standby;
MRP0 24 WAIT_FOR_GAP
說明這里 MRP0只應(yīng)用日志到24,正好說明備庫和主庫是有g(shù)ap的。而且備庫有g(shù)ap時,gap后面的日志只能接收,但不能應(yīng)用
備庫執(zhí)行,于是查看備庫是否應(yīng)用接收的日志
SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG
ORDER BY SEQUENCE#;
從結(jié)果(條件限時未對結(jié)果截圖)看目前這個備庫是從31號日志接收日志的。且無法應(yīng)用
要想讓主庫和備庫歸檔一致,應(yīng)用的日志也一致,可以把缺少的日志從主庫拷貝到從庫,具體方法看
http://blog.itpub.net/29500582/viewspace-1308247/
但發(fā)現(xiàn)主庫沒有了GAP的日志,所以只能用基于SCN不完全恢復(fù)的方法
參考查看歸檔進程狀態(tài) http://blog.csdn.net/wll_1017/article/details/9699631《dg 備庫歸檔位置不一致》
跳歸檔具體方法
1主備庫都執(zhí)行
SELECT CURRENT_SCN FROM V$DATABASE;
備庫SCN 1112907 主庫SCN 1817052
注意 select scn_to_timestamp(1112907) scn from dual; 可以用如上方法查看SCN對應(yīng)的時間
2主庫上
rman target /
BACKUP INCREMENTAL FROM SCN 1112907 DATABASE FORMAT '/home/oracle/backup_stage/increment_backup_%U_%T' tag 'FORSTANDBY';
就是備份從備庫沒追平的時間到現(xiàn)在的增量備份
3在備庫恢復(fù)
rman target /
catalog start with '/home/oracle/backup_stage/increment_backup'; 登記所有increment_backup開頭的備份到備份目錄
recover database; 恢復(fù)增量備份的數(shù)據(jù) 可以用 noredo 加速恢復(fù)
recover managed standby database disconnect from session; 最后再備庫開啟應(yīng)用恢復(fù)的進程,讓備庫和主庫完全一致
參考 http://www.linuxidc.com/Linux/2016-08/134300.htm
查看dataguard狀態(tài)
select MESSAGE,TIMESTAMP from v$dataguard_status
order by TIMESTAMP;
另外還可以查詢備庫,查看從主庫接收的日志
SQL> SELECT THREAD#, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE# FROM V$ARCHIVED_LOG;
查看備庫上的 standby log
SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
gap都解決了還總是停機
ARC1: Archive log rejected (thread 1 sequence 75) at host 'PHYSICAL'
FAL[server, ARC1]: FAL archive failed, see trace file.
ARCH: FAL archive failed. Archiver continuing
ORACLE Instance orcl11g - Archival Error. Archiver continuing.
Fri Feb 23 15:30:08 2018
看歸檔日志 找到出錯時間時對應(yīng)的arc的trace
ll -tr /u02/oracle/diag/rdbms/primary/orcl11g/trace/
vi /u02/oracle/diag/rdbms/primary/orcl11g/trace/orcl11g_arc3_5025.trc
Detailed OCI error val is 1017 and errmsg is 'ORA-01017: invalid username/password; logon denie
SQL> select process, sequence#, status, delay_mins from v$managed_standby;
PROCESS SEQUENCE# STATUS
--------------------------- ---------- ------------------------------------
DELAY_MINS
----------
ARCH 56 CLOSING
0
ARCH 0 CONNECTED
0
ARCH 0 CONNECTED
0
PROCESS SEQUENCE# STATUS
--------------------------- ---------- ------------------------------------
DELAY_MINS
----------
ARCH 55 CLOSING
0
RFS 0 IDLE
0
RFS 0 IDLE
0
PROCESS SEQUENCE# STATUS
--------------------------- ---------- ------------------------------------
DELAY_MINS
----------
RFS 0 IDLE
0
RFS 60 IDLE
0