Oracle Database,又名Oracle RDBMS,或簡(jiǎn)稱(chēng)Oracle。是甲骨文公司的一款關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng)。它是在數(shù)據(jù)庫(kù)領(lǐng)域一直處于領(lǐng)先地位的產(chǎn)品??梢哉f(shuō)Oracle數(shù)據(jù)庫(kù)系統(tǒng)是目前世界上流行的關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng),系統(tǒng)可移植性好、使用方便、功能強(qiáng),適用于各類(lèi)大、中、小、微機(jī)環(huán)境。它是一種高效率、可靠性好的適應(yīng)高吞吐量的數(shù)據(jù)庫(kù)解決方案。
安裝前準(zhǔn)備
- 相關(guān)文件準(zhǔn)備(超鏈接為下載地址)
- 已安裝好 CentOS 7 最小化系統(tǒng),并配置好了網(wǎng)絡(luò)
- 下載 Oracle 12c 數(shù)據(jù)庫(kù)企業(yè)版,2個(gè)壓縮包哦
- 將
SELinux設(shè)置為enforcing模式
# 查看 SELinux 狀態(tài)
[root@centos7 ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
# 如果不是 enforcing 模式,則運(yùn)行以下命令并重啟即可生效。
sed -i 's/SELINUX.*/SELINUX=enforcing/' /etc/selinux/config
- 為安全性考慮,啟動(dòng)防火墻服務(wù)(如果不啟動(dòng)可以跳過(guò)后面的防火墻配置)
systemctl start firewalld # 啟動(dòng)防火墻
firewall-cmd --state # 查看當(dāng)前防火墻狀態(tài)
- 更新
CentOS 7的yum源為國(guó)內(nèi)源,以下源中任選一種即可,當(dāng)然您一股腦的將下面命令全部運(yùn)行也并沒(méi)有什么問(wèn)題。
# 備份并刪除現(xiàn)有源
cat /etc/yum.repos.d/* > /etc/yum.repos.d/repo.bak
rm -rf /etc/yum.repos.d/*.repo
# 配置阿里源(2選1)
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-aliyun.repo
# 配置網(wǎng)易163源(2選1)
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repos.d/CentOS-163.repo
# 最后使源生效
yum clean all && yum makecache
- 把
CentOS系統(tǒng)更新至最新組件
yum update -y
安裝步驟
- 為
Oracle數(shù)據(jù)庫(kù)創(chuàng)建所須的操作系統(tǒng)用戶(hù)及群組
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
groups oracle # 查看用戶(hù)所屬的組
-
在
/etc/sysctl.conf加入下列內(nèi)核參數(shù)fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 1987162112 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 = 1048586 檢查并使修改的配置文件生效
sysctl -p
sysctl -a
- 修改系統(tǒng)默認(rèn)的對(duì)
oracle用戶(hù)一些限制,以下命令沒(méi)有反饋,請(qǐng)勿重復(fù)運(yùn)行
cat >> /etc/security/limits.conf <<-EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF
- 使用
xftp工具或者scp命令將Oracle數(shù)據(jù)庫(kù)文件上傳到虛擬機(jī)的/tmp目錄下 - 將
Oracle數(shù)據(jù)庫(kù)安裝文件解壓至/stage目錄,并修改/stage目錄權(quán)限,解壓文件名根據(jù)實(shí)際情況。
mkdir /stage
yum install -y zip unzip
unzip /tmp/linuxamd64_12102_database_1of2.zip -d /stage/
unzip /tmp/linuxamd64_12102_database_2of2.zip -d /stage/
chown -R oracle:oinstall /stage/
- 為
Oracle創(chuàng)建/u01作為安裝目錄,以及創(chuàng)建/u02作為數(shù)據(jù)庫(kù)文件目錄
mkdir /u01
mkdir /u02
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /u02
chmod -R 775 /u01
chmod -R 775 /u02
chmod g+s /u01 # g+s權(quán)限意為任何用戶(hù)在此目錄下創(chuàng)建的文件都具有和該目錄所屬的組相同的組
chmod g+s /u02
- 安裝所需的組件
yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64
- 安裝
X Window System組件
yum groupinstall -y "X Window System"
-
由于
Oracle安裝程序需要用到圖形化界面,你可通過(guò)以下兩個(gè)辦法來(lái)進(jìn)行- 找任意一臺(tái)帶有圖形界面的
Linux或Mac系統(tǒng)的電腦遠(yuǎn)程登陸,Mac系統(tǒng)我猜想能用這個(gè)辦法,而未測(cè)試
ssh -X oracle@ipaddr # 替換 ipaddr 為你的ip地址 - 找任意一臺(tái)帶有圖形界面的
請(qǐng)采用上述的方案登錄為
oracle用戶(hù),然后執(zhí)行Oracle安裝程序
[oracle@centos7 ~]$ /stage/database/runInstaller
Starting Oracle Universal Installer...
Oracle 安裝程序畫(huà)面
- 安全性更新
假若你不想接收來(lái)自Oracle支持部的電郵,請(qǐng)取消勾選該項(xiàng)目并按Next,在新打開(kāi)的窗口按YES。
oracle-email - 安裝選項(xiàng)
選擇Create and configure a database并按Next。 - 系統(tǒng)級(jí)別
選擇Desktop Class進(jìn)行缺省的簡(jiǎn)便Oracle數(shù)據(jù)庫(kù)安裝。 - 典型安裝
在Typical Install Configuration畫(huà)面,設(shè)置以下功能。另外請(qǐng)?jiān)O(shè)置合適的Database edition(數(shù)據(jù)庫(kù)版本)及Character set(字符集,最好為UTF-8)。為數(shù)據(jù)庫(kù)的管理員設(shè)定密碼,最后請(qǐng)取消勾選Create as Container database選項(xiàng)。
| Variable | Value |
|---|---|
| Oracle base | /u01/app/oracle |
| Software location | /u01/app/oracle/product/12.1.0/dbhome_1 |
| Database file location | /u02 |
| Global database name | orcl.example.com |
選擇日志目錄
選擇/u01/app/oraInventory這個(gè)目錄并點(diǎn)擊下一步。檢查后點(diǎn)擊安裝
執(zhí)行設(shè)置腳本
因?yàn)橛行┌惭b命令需要root用戶(hù)權(quán)限,當(dāng)詢(xún)問(wèn)窗口出現(xiàn)時(shí),請(qǐng)登錄用戶(hù)root并執(zhí)行以下兩個(gè)腳本:
[root@centos7 ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@centos7 ~]# /u01/app/oracle/product/12.1.0/dbhome_1/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/12.1.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]: <PRESS ENTER>
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
You can follow the installation in a separated window.
- 順利完成安裝
安裝過(guò)程非常慢,請(qǐng)耐性等待直至安裝完成,如若遇到問(wèn)題,請(qǐng)問(wèn)度娘或者谷歌。
安裝后的任務(wù)
防火墻
- 登陸
root用戶(hù)并執(zhí)行以下命令來(lái)打開(kāi)Oracle服務(wù)的防火墻
firewall-cmd --zone=public --add-port=1521/tcp --add-port=5500/tcp --add-port=5520/tcp --add-port=3938/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports # 查看已開(kāi)通的防火墻端口
Oracle 工作環(huán)境
-
登錄為
oracle用戶(hù)并在/home/oracle/.bash_profile文件中添加以下信息:TMPDIR=$TMP; export TMPDIR ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1; export ORACLE_HOME ORACLE_SID=orcl; export ORACLE_SID PATH=$ORACLE_HOME/bin:$PATH; export PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH 運(yùn)行以下命令使環(huán)境變量生效
source ~/.bash_profile
登陸數(shù)據(jù)庫(kù)
- 最后請(qǐng)登陸數(shù)據(jù)庫(kù):
[oracle@centos7 ~]$ sqlplus system@orcl
... output omitted ...
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
Ending...
文中如果有錯(cuò)誤的地方,歡迎評(píng)論與指正。如果你喜歡我寫(xiě)的文章,也可以點(diǎn)擊下方的打賞支持一下,你的支持就是我更新的動(dòng)力!謝謝大家??!

