CENTOS8 安裝 Oracle


首先,環境配置

oracle數據庫對環境要求很高,docker我沒找到一個用起來順手的,所以有了自己安裝的想法。

在網上找到的一個一鍵配置oracle環境的shell:
https://wwr.lanzoui.com/iXKBBu3uoda
這個shell只是方便環境配置,會自動幫你創建賬號、文件夾、權限、環境變量。

chmod 777 oraclePreInstallCheck.sh
./oraclePreInstallCheck.sh

因為CENTOS8自帶rpm,所以就不需要下載rpm了。

然后檢查依賴包是否安裝:

rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel bc

如果發現沒有安裝的依賴,需要手動安裝,到下面這個網址搜索:

https://centos.pkgs.org/
搜索到軟件后,找到binary package,這是已編譯好的包,也可以選擇源碼包Source Package。
image

復制這個地址,然后輸入命令,就開始安裝了。如果有報錯的請自行百度。

rpm -ivh http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/elfutils-libelf-devel-static-0.182-3.el8.x86_64.rpm

注意:compat-libstdc++ 這個包的名字改了,所以檢查程序沒有匹配得到,現在是2021年,我搜索出來的名字是Compat-libstdc++-33

依賴安裝完畢后,終於

開始安裝Oracle

然后解壓在官網下載的安裝包,我這里下載的是11.2G XE的版本

下載鏈接:https://download.oracle.com/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip

unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip

解壓后的文件目錄

[root@centos8-1 ~]# tree

├── Disk1
│   ├── oracle-xe-11.2.0-1.0.x86_64.rpm
│   ├── response
│   │   └── xe.rsp
│   └── upgrade
│       └── gen_inst.sql

開始安裝

[root@centos8-1 Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Verifying...                          ################################# [100%]
准備中...                          ################################# [100%]
正在升級/安裝...
   1:oracle-xe-11.2.0-1.0             ################################# [100%]
Executing post-install steps...

You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.

安裝后進行配置:

[root@centos8-1 ~]# /etc/init.d/oracle-xe configure

Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:   #默認端口8080沒什么用,隨意

Specify a port that will be used for the database listener [1521]:               #默認數據庫監聽端口

Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Confirm the password:

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y   #是否開機啟動

Starting Oracle Net Listener...Done
Configuring database...grep: /u01/app/oracle/product/11.2.0/xe/config/log/*.log: No such file or directory
grep: /u01/app/oracle/product/11.2.0/xe/config/log/*.log: No such file or directory
Done
/bin/chmod: cannot access '/u01/app/oracle/diag': No such file or directory
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.

最后進行配置變量:

vim /etc/profile

文件尾加入以下配置

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe
ORACLE_SID=XE                                     #這里特別注意,XE一定要大寫,與tnsnames.ora文件內容一致,否則在使用oracle時會報ORA-01034的錯誤
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

保存后執行:

source /etc/profile

ok,安裝基本完成,如果需要開防火牆的:

firewall-cmd --zone=public --add-port=1521/tcp --permanent    #(--permanent永久生效,沒有此參數重啟后失效)

firewall-cmd --reload   #重新載入

然后需要修改文件

[root@bogon ~]# cd  /u01/app/oracle/product/11.2.0/xe/dbs/
[root@bogon dbs]# cp init.ora initXE.ora
[root@bogon dbs]# vim initXE.ora
db_name='ORCL'  #這個需要改成XE或者自己的實例名
memory_target=1G
processes = 150
audit_file_dest='<ORACLE_BASE>/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='<ORACLE_BASE>/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='<ORACLE_BASE>'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'

然后使用sqlplus登錄

[root@bogon ~]# sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 16 17:08:47 2021

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> startup;

如果這里連上就成功了
如果顯示報錯:

ORA-01031: insufficient privileges

那么需要重啟一下。

[root@bogon ~]# su - oracle
上一次登錄:四 9月 16 17:06:12 CST 2021pts/0 上
[oracle@bogon ~]$ sqlplus /nolog
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

這里我理解是因為沒有重啟系統,導致oracle賬號沒有更新環境變量,那么更新它就完了。

[oracle@bogon ~]$ vim /etc/profile
[oracle@bogon ~]$ source /etc/profile
[oracle@bogon ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Thu Sep 16 17:12:01 2021

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

現在連上了,開始重啟

SQL> conn / as sysdba
Connected.
SQL> startup mount;
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown Immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  768294912 bytes
Fixed Size                  2230448 bytes
Variable Size             457181008 bytes
Database Buffers          306184192 bytes
Redo Buffers                2699264 bytes
Database mounted.
SQL> alter database open;

Database altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  768294912 bytes
Fixed Size                  2230448 bytes
Variable Size             457181008 bytes
Database Buffers          306184192 bytes
Redo Buffers                2699264 bytes
Database mounted.
Database opened.
SQL> exit

大功告成!

最后創建用戶、獲取權限都不再這里闡述了。

oracle的使用方式實在是對開發人員太不友好了,可能配置一次就不想再配置了。對比mysql、mssql哪個不是一裝就完事呢。所以說oracle能夠走到今天這一步還是有很多優點的,能夠讓大家忍受那些安裝配置出現的令人抓狂的錯誤。如果oracle今后能夠優化一下這方面的內容還是值得期待的。但是現在看來19版也不過如此。在我看來如果不是客戶要求,可能永遠都不會用這玩意兒。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM