Shell-InstallOracle
整個項目的完整目錄:
├── Documents
│ ├── packer box
│ │ ├── Vagrant Box 鏡像準備:Packer 打包 Oracle Linux 6.10 系統(tǒng).md
│ │ ├── Vagrant Box 鏡像準備:Packer 打包 Oracle Linux 8.3 系統(tǒng).md
│ │ ├── Vagrant Box 鏡像準備:Packer 打包 Centos 6.10 系統(tǒng).md
│ │ ├── Vagrant Box 鏡像準備:Packer 打包 Centos 7.9 系統(tǒng).md
│ │ ├── Vagrant Box 鏡像準備:Packer 打包 Centos 8.3 系統(tǒng).md
│ │ └── Vagrant Box 鏡像準備:Packer 打包 Oracle Linux 7.9 系統(tǒng).md
│ ├── rac_db
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》RAC集群系列 ? 簡單兩步快速安裝 Oracle 11GR2 RAC 數(shù)據(jù)庫.md
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》RAC集群系列 ? 簡單兩步快速安裝 Oracle 12CR2 RAC 數(shù)據(jù)庫.md
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》RAC集群系列 ? 簡單兩步快速安裝 Oracle 18C RAC 數(shù)據(jù)庫.md
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》RAC集群系列 ? 簡單兩步快速安裝 Oracle 19C RAC 數(shù)據(jù)庫.md
│ │ └── 《零基礎安裝 Oracle 數(shù)據(jù)庫》RAC集群系列 ? 簡單兩步快速安裝 Oracle 21C RAC 數(shù)據(jù)庫.md
│ ├── single_db
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機系列 ① 一鍵快速安裝 Oracle 11GR2 數(shù)據(jù)庫.md
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機系列 ② 一鍵快速安裝 Oracle 12CR2 數(shù)據(jù)庫.md
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機系列 ③ 一鍵快速安裝 Oracle 18C 數(shù)據(jù)庫.md
│ │ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機系列 ④ 一鍵快速安裝 Oracle 19C 數(shù)據(jù)庫.md
│ │ └── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機系列 ⑤ 一鍵快速安裝 Oracle 21C 數(shù)據(jù)庫.md
│ └── singleasm_db
│ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機ASM系列 1?? 一鍵快速安裝 Oracle 11GR2 數(shù)據(jù)庫.md
│ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機ASM系列 2?? 一鍵快速安裝 Oracle 12CR2 數(shù)據(jù)庫.md
│ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機ASM系列 3?? 一鍵快速安裝 Oracle 18C 數(shù)據(jù)庫.md
│ ├── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機ASM系列 4?? 一鍵快速安裝 Oracle 19C 數(shù)據(jù)庫.md
│ └── 《零基礎安裝 Oracle 數(shù)據(jù)庫》單機ASM系列 5?? 一鍵快速安裝 Oracle 21C 數(shù)據(jù)庫.md
├── LICENSE
├── OracleShellInstall.sh
├── ParameterREADME.md
├── README.md
├── rac_db
│ ├── README.md
│ ├── Vagrantfile
│ ├── config
│ │ └── vagrant.yml
│ ├── scripts
│ │ └── setup.sh
│ └── software
│ ├── 11204
│ │ └── software.txt
│ ├── 12201
│ │ └── software.txt
│ ├── 18000
│ │ └── software.txt
│ ├── 19300
│ │ └── software.txt
│ ├── 21300
│ │ └── software.txt
│ ├── OracleShellInstall.sh
│ ├── compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
│ └── rlwrap-0.42.tar.gz
├── single_db
│ ├── README.md
│ ├── Vagrantfile
│ ├── config
│ │ └── vagrant.yml
│ ├── scripts
│ │ └── setup.sh
│ └── software
│ ├── 11204
│ │ └── software.txt
│ ├── 12201
│ │ └── software.txt
│ ├── 18000
│ │ └── software.txt
│ ├── 19300
│ │ └── software.txt
│ ├── 21300
│ │ └── software.txt
│ ├── OracleShellInstall.sh
│ ├── compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
│ └── rlwrap-0.42.tar.gz
└── singleasm_db
├── README.md
├── Vagrantfile
├── config
│ └── vagrant.yml
├── scripts
│ └── setup.sh
└── software
├── 11204
│ └── software.txt
├── 12201
│ └── software.txt
├── 18000
│ └── software.txt
├── 19300
│ └── software.txt
├── 21300
│ └── software.txt
├── OracleShellInstall.sh
├── compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
└── rlwrap-0.42.tar.gz
32 directories, 61 files
背景
為什么要寫這個腳本呢?
- 首先,安裝 Oracle 數(shù)據(jù)庫是一件極為復雜且枯燥的任務;
- 常規(guī)的操作方式往往是基于文檔,博客,視頻等教程方式,按部就班的執(zhí)行安裝步驟,耗時費力,且極為容易因為粗心導致各種各樣的問題產(chǎn)生;
- 于是,我想到可以編寫一個基于標準流程的
Shell
腳本來進行安裝,因為只要代碼沒有錯誤,機器執(zhí)行是不會出錯的; - 經(jīng)過大量時間的代碼編寫和運行測試,目前已可以用于生產(chǎn)環(huán)境安裝部署。
項目支持哪些平臺安裝?
- 本項目僅支持 「 Linux64-6/7/8 」 平臺:Centos、Redhat、OracleLinux。
- 支持大部分主流 「 ORACLE 」 版本: 11GR2、12CR2、18C、19C、21C。
- 支持數(shù)據(jù)庫安裝模式:單機、單機 ASM、
RAC
集群。
使用說明
本腳本使用方式分為 新手純享版本
和 高手進階版本
,平時學習測試建議使用新手純享版本即可!
新手純享版本
新手純享版本基本不需要基礎,免安裝操作系統(tǒng),一鍵擁有 Oracle 數(shù)據(jù)庫!但是必須使用 [vagrant]
和 [virtualbox]
,請確保你本地已經(jīng)安裝。
進入項目目錄 InstallOracleshell/single_db/software
下,可以看到有不同 Oracle 版本目錄,其中有一個 software.txt
文件,內(nèi)容為你需要上傳的 Oracle 安裝包。
├── 11204
│ ├── p13390677_112040_Linux-x86-64_1of7.zip
│ └── p13390677_112040_Linux-x86-64_2of7.zip
├── 12201
│ └── LINUX.X64_122010_db_home.zip
├── 18000
│ └── LINUX.X64_180000_db_home.zip
├── 19300
│ └── LINUX.X64_193000_db_home.zip
├── 21300
│ └── LINUX.X64_213000_db_home.zip
確認你需要安裝的 Oracle 版本,拷貝 Oracle 安裝包到對應目錄下,確保安裝包名稱與以下名稱相同,否則安裝失敗!
進入項目目錄 InstallOracleshell/single_db/config
下,打開 vagrant.yml
文件:
box: luciferliu/centos7.9
vm_name: orcl
hostname: orcl
mem_size: 2048
cpus: 2
public_ip: 192.168.56.100
non_rotational: 'on'
db_version: 11
db_patch:
oracle_password: oracle
oracle_sid: orcl
install_base: /u01/app
characterset: AL32UTF8
cdb: true
pdb: pdb01
參數(shù)介紹:
box : Linux 主機版本,19c 和 21c 版本不支持 linux 6 版本!
可選值:
- luciferliu/centos6.10
- luciferliu/centos7.9
- luciferliu/centos8.3
- luciferliu/oraclelinux6.10
- luciferliu/oraclelinux7.9
- luciferliu/oraclelinux8.3
vm_name : 虛擬機名稱,隨意修改,默認即可。
hostname : 主機名稱,隨意修改,默認即可。
mem_size : 內(nèi)存大小,單位是 `MiB`,根據(jù)需要修改,正常默認即可。
cpus : cpu 個數(shù),根據(jù)需要修改,正常默認即可。
public_ip : IP 地址,根據(jù)網(wǎng)卡定義修改,正常默認即可。
non_rotational : 不用修改值,默認即可。
db_version : oracle 數(shù)據(jù)庫版本,根據(jù)實際情況填寫!
db_patch : PSU/RU 補丁號,根據(jù)需要填寫,不打補丁可以不填。
oracle_password : oracle 用戶密碼,默認即可。
oracle_sid : oracle 數(shù)據(jù)庫實例名,默認即可。
install_base : oracle 安裝根目錄,默認即可。
characterset : 數(shù)據(jù)庫字符集,根據(jù)實際需要填寫,正常默認即可。
cdb : CDB 模式需要填寫 true。
pdb : PDB 名稱,開啟 CDB 模式后才可生效。
根據(jù)實際情況修改腳本,默認不修改將安裝 Oracle 11GR2 數(shù)據(jù)庫。
- 第三步,執(zhí)行
vagrant up
安裝:
回到 InstallOracleshell/single_db
目錄下,執(zhí)行 vagrant up
開始安裝。
📢 注意: InstallOracleshell/single_db/software 目錄中的 OracleShellInstall.sh 腳本需要保持最新,最新版本腳本在上層目錄 InstallOracleshell 下。
這里有三種方式來連接主機:
1、使用 ssh root@192.168.56.100
來連接,root 用戶密碼是 oracle ,使用 Xshell 等連接工具也可連接;
2、使用 vagrant ssh
來連接,注意要在 InstallOracleshell/single_db
目錄下執(zhí)行,連接進去是 vagrant 用戶,使用 su - oracle
來切換即可。
3、使用 Virtualbox 虛擬機直接打開訪問。
1、在主機中,執(zhí)行 init 0
等關機命令關閉主機。
2、使用 Virtualbox 虛擬機右鍵關閉。
3、進入 InstallOracleshell/single_db
目錄下執(zhí)行 vagrant halt
關閉。
用完了,不需要使用了怎么辦?
1、直接打開 Virtualbox 虛擬機,右鍵刪除。
2、進入 InstallOracleshell/single_db
目錄下執(zhí)行 vagrant destory
銷毀它。
高手進階版本
正常來說,平時學習測試使用 新手純享版本
完全夠了,但是如果你想使用在 生產(chǎn)環(huán)境
,那你必須得學會 高手進階版本
!真正提高生產(chǎn)力~
既然看到這的說明都是高手,那就長話短說,進階版本只需要這一個腳本 OracleShellInstall.sh
就夠了!
腳本有了,具體如何使用?
📢 前提: 提前安裝 Linux 系統(tǒng),上傳安裝介質(zhì),掛載 ISO 鏡像。
單機
最簡安裝
腳本示例:
./OracleShellInstall.sh -i 192.168.56.155
單機自定義
腳本命令示例:
./OracleShellInstall.sh -i 192.168.56.155 `#Public ip`\
-n topdbdev `# hostname`\
-o topstd `# oraclesid`\
-c TRUE `# ISCDB`\
-pb pdb01 `# PDBNAME`\
-rs oracle `# root password`\
-op oracle `# oracle password`\
-gp oracle `# grid password`\
-b /u01/app `# install basedir`\
-s AL32UTF8 `# characterset`\
-ns UTF8 `# national characterset`
腳本中所有操作均為靜默連續(xù)執(zhí)行,敲下命令之后無需任何操作,等待安裝成功即可。
單機ASM
單機ASM
腳本命令示例:
./OracleShellInstall.sh -i 192.168.56.155 `#Public ip`\
-n topdbdev `# hostname`\
-o topstd `# oraclesid`\
-rs oracle `# root password`\
-op oracle `# oracle password`\
-gp oracle `# grid password`\
-b /u01/app `# install basedir`\
-s AL32UTF8 `# characterset`\
-ns UTF8 `# national characterset`\
-dd /dev/sde `# asm data disk`\
-dn DATA `# asm data diskgroupname`\
-dr EXTERNAL `# asm data redundancy`\
-gpa 31718723 `# Grid PSU NUMBER`
RAC
這里我簡單說下在生產(chǎn)環(huán)境使用腳本部署 RAC
的大概步驟:
-
第一步, 手動安裝兩臺 Linux 主機;
-
第二步, 分別配置網(wǎng)絡,掛載 iso 鏡像源,掛載共享存儲;
-
第三步, 節(jié)點一創(chuàng)建 /soft 目錄并上傳安裝介質(zhì);
-
第四步, 編輯腳本安裝命令,填寫兩臺主機的關鍵信息;
RAC
腳本命令示例:
./OracleShellInstall.sh -i 192.168.56.151 `# node1 Public ip`\
-n topdb `# rac hostname`\
-o TOPDB `# oraclesid`\
-rs oracle `# root password`\
-op oracle `# oracle password`\
-gp oracle `# grid password`\
-b /u01/app `# install basedir`\
-s AL32UTF8 `# characterset`\
-ns UTF8 `# national characterset`\
-pb1 192.168.56.151 -pb2 192.168.56.153 `# node public ip`\
-vi1 192.168.56.152 -vi2 192.168.56.154 `# node virtual ip`\
-pi1 10.10.10.11 -pi2 10.10.10.12 `# node private ip`\
-pi3 10.10.11.11 -pi4 10.10.11.12 `# node private1 ip`\
-si 192.168.56.150 `# scan ip`\
-od /dev/sdb,/dev/sdc,/dev/sdd `# asm ocr disk`\
-dd /dev/sde `# asm data disk`\
-on OCR `# asm ocr diskgroupname`\
-dn DATA `# asm data diskgroupname`\
-or NORMAL `# asm ocr redundancy`\
-dr EXTERNAL `# asm data redundancy`\
-puf team0 -prf em3 -prf1 em4 `# network fcname`\
-tsi 192.168.56.252 `# timeserver`\
-gpa 31718723 `# Grid PSU NUMBER`
-
第五步, 節(jié)點一 root
用戶下進入 /soft
目錄下執(zhí)行腳本安裝命令;
-
第六步, 等待安裝過程中,可以進入 /soft
目錄中查看安裝部署日志,安裝結(jié)束后重啟兩臺主機;
-
第七步, 檢查兩臺主機數(shù)據(jù)庫運行情況。
腳本中所有操作均為靜默連續(xù)執(zhí)行,敲下命令之后無需任何操作,等待安裝成功即可!
使用許可
MIT ? Lucifer三思而后行