cd /tools/database
. runInstaller (如果不出來圖形介面,請exit 在root用戶下執行xhost +)
1.不需要提供Email,因為一般狀況下,服務器是禁止上Internet,也不需要提供
2.不需要自動更新(skip software updates)
3.選擇Install database software only
4.選擇Single Instance database installion
5.Language把我們認為需要的都選擇上
6.肯定選擇Enterprise Edition
7.Oracle Base 以及Software Location按照Default即可
一路Next
一些依賴軟件包需要安裝,按著提示的依次安裝即可,例如:
yum install gcc-4.4.7
yum install gcc-c++-4.4.7
pdksh在redhat6.8中沒有提供,我是從redhat5.5中找到並安裝這個rpm的
pdksh-5.2.14-36.el5.x86_64.rpm
最後再按照提示,以root用戶執行兩個腳本,應該就會提示:
The installation of Oracle Database was successful
执行netca 设置Listenrer
按照向導選擇Listener Configuration 一直Next至到出現Finish按鈕為止
此時執行lsnrctl status,即可看到
The listener supports no services 因為還沒有任何Instance運行
The command completed successfully
执行 dbca 创建数据库
Database Identification 頁面,注意設定和自己編輯的Bash_profile中的SID一致
在本例中,Global Database Name 和SID 都設定為SFIC
Database Credentials 頁面,注意設定密碼,
一般選擇Use the Same Administrative Password for all Accounts
Database File Locations 頁面,注意設定數據庫文件路徑
我是選擇Use Common Location for All Database Files,然後選擇/u02/oradata
Recovery Configuation 頁面,注意取消勾選,Specify Fast Recovery Area
因為當真有無操作,我們可以利用Flashback恢復數據,當然這有時間限制
Initialization Parameters 頁面,注意:
1.內存 2.Sizing中的Processes
3.Character Sets,我一般選擇Use Unicode(Al32UTF8)
4.Connection Mode,我一般選擇Dedicated Server Mode
沒有特別說明的,就直接Next即可,隨後就是數據庫創建進度
安裝完成後,再執行lsnrctl status ,可以看到有Instance "SFIC", status READY
配置数据库备份机制(oracle用戶)
配置Archive归档模式(Standby和Rman的使用必须是归档模式)
alter system set log_archive_dest_1='location=/u02/archive/sfic' scope=both;
alter system set archive_lag_target=600 scope=both; 強制每十分鐘歸檔一次
好處是避免服務器的突然宕機,再也起不來的情形下,少丟失數據,當然前提是我們要有Standby機制
shutdown immediate
startup mount;
alter database archivelog;
alter database open;
编辑Rman备份脚本
在/u02/backup/文件夾中創建RmanBackup.sh,內容如下
#Channel越多,備份和恢復越快,Rate 40M,數字越大,備份時耗的資源越多#如此腳本的好處是,在服務器上保留兩次的備份,並且會把不需要的Archive文件自動清除
ORACLE_HOME=/u01/oracle/db
export ORACLE_HOME
ORACLE_BASE=/u01/oracle
export ORACLE_BASE
ORACLE_SID=SFIC
export ORACLE_SID
$ORACLE_HOME/bin/rman nocatalog target sys/oracle <<EOF
spool log to '/u02/backup/RmanBackup.log' append;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
report obsolete;
delete noprompt obsolete;
run{
allocate channel d1 device type disk rate 40M;
allocate channel d2 device type disk rate 40M;
allocate channel d3 device type disk rate 40M;
allocate channel d4 device type disk rate 40M;
backup as compressed backupset format'/u02/backup/sfic/db_%d_%T_%U.dbf' database;
backup current controlfile format'/u02/backup/sfic/db_%d_%T_%U.ctl';
release channel d1;
release channel d2;
release channel d3;
release channel d4;}
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;exit;
EOF
首先要在另一台服務器上創建一個相同SID相同數據庫文件路徑並且處於歸檔模式的數據庫
實際上來講,就是一模一樣的環境,至不過硬件可能稍微差一些而已的雙胞胎吧
然後把Product服務器上的Rman備份文件scp到/u02/backup/sfic
如果路徑不同,需特別處理(catalog start with 'Path')
rman nocatalog target /
shutdown immediate
startup nomount;
restore controlfile from '/u02/backup/sfic/db_SFIC_20200418_t1un6ir0_1_1.ctl'#此時,有可能需要退出rman一次,因為原DBID和被恢復DBID是不一樣的
alter database mount;
run {
allocate channel d1 device type disk;
allocate channel d2 device type disk;
allocate channel d3 device type disk;
allocate channel d4 device type disk;
restore database;}#備份時有幾個通道,恢復時也幾個通道,會加快恢復速度
recover database
shutdown immediate
在主服務器上執行
alter database create standby controlfile as '/u02/backup/standbysfic0418.ctl'
然後把standbysfic0418.ctl複製到Standby服務器上,並替換原來的control0*.ctl
再sqlplus /nolog
startup nomount
alter database mount standby database;
recover standby database;
alter database openread only;#11g Standby可以設為只讀模式供報表查詢
alter database recover managed standby database disconnect from session;
取消standby: alter database recover managed standby database cancel;
激活standby:alter database activate standby database;
利用rman备份恢复数据库(沒有Archive文件的情形)
類似於Standby創建,不過在Restore後,直接
SQLPLUS /nolog
conn /as sysdba
recover database using backup controlfile; --Rman中沒有using的參數
auto
alter system set"_allow_resetlogs_corruption"=true scope=spfile; 隱藏參數
shutdown immediate
startup mount
alter database open resetlogs;
alter system set"_allow_resetlogs_corruption"=false scope=spfile;
即可
Install Oracle 11G On Redhat Linux 6.8安裝介質磁盤規劃Oracle 安裝環境配置配置遠端VNC訪問安裝Oracle軟件和配置數據庫(oracle用戶)配置數據庫備份策略(oracle用戶)安裝介質Linuxrhel-server-6.8-x86_64.isoOraclep13390677_112040_Linux-x86-64_1of7.z...