oracle安裝
環境資訊
- Linux 7.3
- oracle 11.2.0.4
- 無外網環境
1. 準備oracle安裝檔案
将Oracle的檔案通過SSH上傳到/usr/local/oracle中。
[[email protected] ~]# cd /usr/local/
[[email protected] local]# mkdir oracle
[[email protected] local]# cd oracle/
2. 解壓安裝檔案到目前目錄
[[email protected] root]#cd /usr/local/oracle
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_1of7.zip
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_2of7.zip
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_3of7.zip
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_4of7.zip
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_5of7.zip
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_6of7.zip
[[email protected] oracle]#unzip p13390677_112040_Linux-x86-64_7of7.zip
執行以上指令後,将會在/usr/local/oracle/下面産生名為database的目錄,這就是oracle安裝程式的目錄。
3. 準備oracle的安裝目标目錄
安裝目标目錄是使用者想将oracle安裝到哪個位置的目錄,本次我們将oracle安裝到/opt/oracle目錄中,以下為目錄建立指令。
[[email protected] oracle]#mkdir –p /opt/oracle
4. 建立oracle相關使用者和使用者組
oracle不能在root帳戶下進行安裝,是以需要為oracle的安裝專門建立一個使用者,同時需要建立dba和oinstall的使用者組。 以下指令将建立dba和oinstall使用者組:
[[email protected]ocalhost oracle]#groupadd dba
[[email protected] oracle]#groupadd oinstall
5. 以下指令将建立oracle使用者,并設定密碼
[[email protected] oracle]#useradd -g oinstall -G dba oracle
[[email protected] oracle]#passwd oracle
Changing password for user oracle.
New UNIX password: [在此鍵入密碼]
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password: [在此再次鍵入密碼]
passwd: all authentication tokens updated successfully.
6. 以下指令将oracle安裝目錄(/opt/oracle)賦予oracle使用者oins tall使用者組
[[email protected] oracle]#chown –R oracle:oinstall /opt/oracle
7. 設定linux核心參數
打開修改/etc/sysctl.conf,在最後加入以下内容
[[email protected] oracle]# vi /etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
fs.aio-max-nr = 1048576
8. 修改 /etc/security/limits.conf
在/etc/security/limits.conf,的最後,# End of file 辨別符之前加入内容
[[email protected] oracle]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
9. 修改系統環境變量/etc/profile
修改環境變量/etc/profile檔案最後加入以下内容
[[email protected] oracle]# vim /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
10. 設定ORACLE環境變量
修改oracle使用者主目錄(/home/oracle)的的環境變量配置檔案.bash_profile。使用以下指令
[[email protected] oracle]#vi /home/oracle/.bash_profile
向配置檔案中加入以下内容
#(注意這個值要和下面建立的資料庫執行個體名稱相同)
export ORACLE_SID=orcl
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
11. 開始安裝
以上步驟設定完成後,建議重新啟動系統,使所有設定生效。現在使用oracle使用者登入,并轉到ORACLE安裝程式目錄。以下的每一個步驟都oracle安裝過程的一個步驟(每一個步驟對應一個安裝界面)。
[[email protected] oracle] # su oracle
[[email protected] oracle] #cd /usr/local/oracle/database
解決oracle亂碼.
[[email protected] database] #export LANG=en_US
運作安裝指令
[[email protected] database] #./runInstaller
如果報錯.
could not retrieve local nodename
[[email protected] database] #./hostname
sun
原檔案
[[email protected] database] # cat /etc/hosts
[[email protected] database]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
修改後檔案
[[email protected] database]$ vi /etc/hosts
127.0.0.1 sun sun localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 sun sun localhost localhost.localdomain localhost6 localhost6.localdomain6
重新執行 ./runInstaller
安裝過程中如果出現錯誤資訊[無法使用指令/usr/bin/xdpyinfo 自動檢查顯示器顔色。請檢查是否設定了DISPLAY變量。],使用root帳戶執行以下指令,再切換到oracle使用者運作安裝程式(如果切換還是有錯誤,請退出root賬戶,直接用oracle賬戶登入系統)。
[[email protected] oracle]#su root
[[email protected] oracle]#xhost + [IP位址,可選]
(此問題應根據具體情況而定,不一定能解決你的問題)
11.1. 配置安全更新(configure Security Updates)
到現在已經啟動了oracle的安裝程式,第一個界面可以輸入電子郵箱位址,用來接收重大錯誤資訊。
另一選項通過My Oracle Support接收安全更新,本安裝過程沒有勾選。
11.2 下載下傳軟體更新(Download Software Updates)
這是下載下傳更新,我們是新安裝,是以直接略過即可。
選擇 Skip software updates
11.3 安裝選項(Installation Option)
此處選擇“安裝和配置資料庫”(Create and configure a database)
11.4 系統類(System Class)
有桌面類和服務類兩個選項。此處選擇伺服器類(Server Class)。
11.5 網格選項(Grid installation Options)
選擇單執行個體資料庫安裝(Single insance database installation)
11.6 安裝類型 (install Type)
選擇進階安裝類型(Advanced install)
11.7 産品語言(Product Languages)
可以選擇多種運作時語言, 窩在Linux系統中選擇預設選擇(English)
11.8 資料庫類型
此處選擇企業版(Enterprise Edition)
11.9 安裝位置
oracle基目錄為(Oracle base):/opt/oracle
oracle主目錄為(software Location):/opt/oracle/product/11.2.0/dbhome_1
目錄不要修改,在上面的修改Oracle使用者的.bash_profile檔案是,已經把檔案的位址添加進去了。
11.10 建立産品清單(Create Inventory)
本次安裝的産品清單目錄為:/opt/oracle/oraInventory
oraInventory的使用者組名為:oinstall
在安裝到Create Inventory這裡可能出現的問題
[INS-32031] Invalid inventory location
[INS-32033] Central Inventory location is not writable
這是我們安裝目錄的權限不夠引起的問題
我們根據在這一頁填寫的Inventory Dircetory的值,給他的升一級賦權即可.
如: 我們在Inventory Dircetory 中預設的是 /opt/oralnventory
那我們就賦權 /opt
[[email protected] oracle]# chown -R oracle:oinstall /opt/
11.11 配置類型(Configuration Type)
此處選擇一般用途/事務(Ceneral Purpose / Transaction Processing )
11.12 資料庫辨別符(Database Identifiers)
本次安裝的全局資料庫名和服務辨別符為:orcl(采用的預設,注意這個要和上面配置相同)
11.13 配置選項(Configuration Options )
這一步可以對oracle的記憶體使用,字元集,安全性,示例方案進行配置,本次安裝将使用oracle的預設配置。
11.14 管理選項(Management Options)
使用Oracle的預設配置
11.15 資料庫存儲(Database Storage)
此處選擇檔案系統,資料庫檔案位置使用oracle的預設位置
11.16 備份和恢複(Backup and Recovery)
此處選擇不啟用自動備份(Do not enable automated backups)
11.17 方案密碼(Schema Passwords)
此處選擇對所有帳戶使用相同的密碼(Use the same password for all accounts)
11.18 作業系統組
資料庫管理者(OSDBA)隸屬的使用者組是:dba
資料庫操作者(OSOPER)隸屬的使用者組是:dba
11.19 先決條件檢查
這一步oracle會對作業系統的使用者和使用者組、記憶體、軟體包、系統核心等參數進行檢查。不符要求的地方會列出來(可根據所列出的不符要求的項逐一解決),完全符合要求時,點選下一步。
注意 這個地方會爆出我們系統中不符合要求的地方。 我們可以根據提示對系統進行修改,我們解決了一個問題都可以,點選[再次檢查](Check Again),檢視我們是否解決了問題
問題彙總
先決條件檢查過程中 出現的問題.
physical memory 記憶體不足
我們可以用free指令一下
[[email protected] oracle]# free
total used free shared buff/cache available
Mem: 1016488 326380 89264 13408 600844 486276
Swap: 2097148 4 2097144
第一行就是 Mem就是記憶體大小. 記憶體不足,應該是我們建立虛拟機的時候的問題,記憶體給小了.目前我知道的就隻能
通過我們VM的管理軟體,去調整記憶體的大小.必須在關閉虛拟機的情況下,才能修改.
列舉在這一步常見的錯誤資訊。
- Swap Size (Swap 空間的問題)
OS Kernel Parameter 問題
- OS Kernel Parameter: semopm
- OS Kernel Parameter:shmmax
- OS Kernel Parameter:shmall
- OS Kernel Parameter: file-max
- OS Kernel Parameter: rmem_default
- OS Kernel Parameter: rmem_max
- OS Kernel Parameter: wmem_default
- OS Kernel Parameter: wmem_max
Packages
- Package: gcc-xxx
- Package: libaio-devel-xxxx
- Package: compat-libstdc+±xxxx
- Package: elfutils-libelf-devel-xxx
- Package: glibc-devel-xxx
- Package: glibc-headers-xxx
- Package: gcc-c+±xxxx
- Package: libstdc+±devel-xxxx
- Package: pdksh-xxxxx
① Swap Size
this is a perrequisite condition to test whether sufficient total swap space is available on the system
Expected Value: 2.6948GB (1815724.0KB)
Actual Value : 2GB(2097148.0KB)
這個問題是Swap分區的空間,不足以安裝Oracle
-
解決方案:
使用dd指令建立一個swap分區, 先用 free 指令查詢出現在swap分區的大小,再用Expected Value 值- 現在swap分區的值 = count中寫入的分區大小。 swap分區最好稍微大一些。)
建立分區時間稍微有點長。
[[email protected] oracle]# free
total used free shared buff/cache available
Mem: 1883816 753952 70072 3720 1059792 923688
Swap: 2097148 91332 4831536
[[email protected] oracle]# dd if=/dev/zero of=/home/swap bs=1024 count=1000000
格式化剛才建立的分區
[[email protected] oracle]# mkswap /home/swap
再使用swapon指令将這個檔案分區變成swap分區
[[email protected] oracle]# swapon /home/swap
再使用free 檢視已經擴容的了swap分區
[[email protected] oracle]# free
為了能夠讓swap分區自動挂載,修改配置檔案/etc/fstab檔案,在檔案的末尾加上。
再修改/etc/inittab檔案,再檔案最後添加 swapon /home/swap
[[email protected] oracle]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jan 15 11:53:42 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=6eafb221-7d6c-419e-9ae5-555a15b48c4f /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/home/swap swap swap default 0 0
[[email protected] oracle]# vi /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
swapon /home/swap
swap size 問題就解決了。
② OS Kernel Parameter :semopm
this is preequisite condition to test whether the OS kernel paramper"semopm" is properly set.
Expected Value: Current=100; Configured=100
Actual Value: Current=32; Configured=100
-
解決方案:
修改/etc/sysctl.conf檔案,在檔案中添加
kernel.sem=250 32000 100 128
[[email protected] oracle]# vi /etc/sysctl.conf
檔案内容如下
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
fs.aio-max-nr = 1048576
如下指令是檔案生效
[[email protected] oracle]# /sbin/sysctl -p
OS Kernel Parameter :semopm 問題解決完成後,發現連帶着如下問題也解決了。
- OS Kernel Parameter: file-max
- OS Kernel Parameter: rmem_default
- OS Kernel Parameter: rmem_max
- OS Kernel Parameter: wmem_default
- OS Kernel Parameter: wmem_max
OS Kernel Parameter 的大部分問題都是因為/etc/sysctl.conf檔案配置的問題。貼下sysctl.conf檔案的内容。供大家參考。
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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 = 1048576
③ Packages 問題。
-
解決方案
根據下面的安裝順序,既解決依賴的問題。 我安裝的環境沒有外網,是以用rpm包去安裝。 如果有網絡的話,直接用yum去安裝就沒有依賴的問題了。
- mpfr-3.1.1-4.el7.x86_64.rpm
- libmpc-1.0.1-3.el7.x86_64.rpm
- kernel-headers-3.10.0-514.el7.x86_64.rpm
- glibc-headers-2.17-157.el7.x86_64.rpm
- glibc-devel-2.17-157.el7.x86_64.rpm
- cpp-4.8.5-11.el7.x86_64.rpm
- gcc-4.8.5-11.el7.x86_64.rpm
- libstdc+±devel-4.8.5-16.el7.x86_64.rpm
- gcc-c+±4.8.5-16.el7.x86_64.rpm
- libaio-devel-0.3.109-13.el7.x86_64.rpm
- compat-libstdc+±33-3.2.3-69.el6.x86_64.rpm
- zlib-1.2.7-17.el7.x86_64.rpm
- zlib-devel-1.2.7-17.el7.x86_64.rpm
- elfutils-libelf-devel-0.168-8.el7.x86_64.rpm
- pdksh-5.2.14-37.el5.x86_64.rpm
如果安裝 pdksh,出現
試圖安裝 pdksh-5.2.14-30.x86_64 和 pdksh-5.2.14-30.x86_64 會導緻檔案 /usr/bin/ksh 沖突
隻需要下載下傳一個高版本的安裝了就行.
11.20 安裝産品 (Install Product)
在這一步,基本上就是自動安裝階段了。
我在這裡報了一個錯誤:
Error in inwoking target ‘agent_numhs’ of makefile
‘/opt/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent,mk’.
See ‘/opt/app/oralnventory/logs/installActions2019-01-16_11-14-43AM.log’ for details.
-
解決方案:
在makefile中添加連結 lnnz11
修改 O R A C L E H O M E / s y s m a n / l i b / i n s e m a g e n t . m k 将 ORACLE_HOME/sysman/lib/ins_emagent.mk 将 ORACLEHOME/sysman/lib/insemagent.mk将(MK_EMAGENT_NMECTL)修改為:$(MK_EMAGENT_NMECTL) -lnnz11
[[email protected] oracle]# vi /opt/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk
在檔案大概176行左右的位置。
$(SYSMANBIN)emdctl:
$(MK_EMAGENT_NMECTL) -lnnz11
儲存檔案後,在oracle安裝界面中點選REtry 即可。
在程式安裝到94%左右,會提示Execute Configuration scripts
The following configuration scripts need to be executed as the “root” user
Scripts to be executer:
- /opt/oracle/oraInventory/orainsRoot.sh
- /opt/oracle/product/11.2.0/dbhome_1/root
用root使用者執行如下指令:
[[email protected] ~]# /opt/oracle/oraInventory/orainstRoot.sh
Changing permissions of /opt/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /opt/oracle/oraInventory to oinstall.
The execution of the script is complete.
[[email protected] ~]# /opt/oracle/product/11.2.0/dbhome_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
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.
Finished product-specific root actions.
執行這一步後安裝基本就完成了。
配置監聽服務:
修改listener.ora 配置檔案。
[[email protected] admin]# vi /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
将下面的SID_LIST_LISTENER添加到檔案中,ORACLE_HOME 位址是我們安裝的位址。
SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /opt/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
檔案内容如下:
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /opt/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
#将HOST = 192.168.16.40檔案中IP位址修改為自己的IP位址。
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.16.40)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
vim /opt/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.16.6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
在啟動前,重新開機一下伺服器,以確定各個配置都生效.
10. 啟動ORACLE
完成以上操作時,建議重新啟動一次,避免某些設定未生效。重新開機後使用oracle使用者登入.打開終端,鍵入以下指令運作以下指令
啟動監聽:
需要關閉防火牆否則可能會不成功.
[[email protected] oracle]$ lsnrctl start
啟動資料庫和執行個體:
在oracle的bin目錄下執行如下指令
[[email protected] oracle]$sqlplus /nolog
SQL>conn /as sysdba
進入sqlplus後,執行啟動資料庫指令,以下指令将建立、安裝并打開ORACLE執行個體。此時,資料庫系統處于正常工作狀态,可以接受使用者請求。
SQL>startup
恭喜,你的ORACLE資料庫已經啟動成功
11. 建立Oracle使用者。
在Oracle資料庫指令行中執行操作.
建立使用者:
SQL>create user xxx identified by xxx;
給使用者賦權
SQL>grant dba to xxx;
SQL>grant connect,resource to xxx;
SQL>grant select any table to xxx;
SQL>grant delete any table to xxx;
SQL>grant update any table to xxx;
SQL>grant insert any table to xxx;
經過以上操作,就可以使用xxx/xxx 登入了。