第一次在linux系統上安裝oracle數據庫,安裝過程不算順利,遇到各種問題,但是最終還是一一解決了,感覺從這次安裝安裝過程,讓我們對oracle的安裝和使用有更深層次的理解,成就感滿滿!
不瞎掰,爲了讓其它人員也能承擔安裝工作,所以把整個安裝過程及遇到哪些問題、怎麼解決的都記錄下來,項目組其它成員按照我的手冊飛快的就能搞定。詳情往下看
Oracle數據庫部署手冊
- Oracle安裝
- Linux安裝Oracle系統要求
內存 必須高於1G的物理內存
交換空間 一般爲內存的2倍,例如:1G的內存可以設置swap 分區爲3G大小
如果8G內存,則swap分區至少8G
若內存空間爲16G以上,則swap分區至少爲16G。
- 修改操作系統核心參數
在Root用戶下執行以下步驟:
1)修改用戶的SHELL的限制,修改/etc/security/limits.conf文件
輸入命令:vi /etc/security/limits.conf,按i鍵進入編輯模式,將下列內容加入該文件。
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
編輯完成後按Esc鍵,輸入“:wq”存盤退出
2)修改/etc/pam.d/login 文件,輸入命令:vi /etc/pam.d/login,按i鍵進入編輯模式,將下列內容加入該文件。
session required /lib/security/pam_limits.so
session required pam_limits.so
編輯完成後按Esc鍵,輸入“:wq”存盤退出
3)修改linux內核,修改/etc/sysctl.conf文件,輸入命令: vi /etc/sysctl.conf ,按i鍵進入編輯模式,將下列內容加入該文件
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
編輯完成後按Esc鍵,輸入“:wq”存盤退出
4)要使 /etc/sysctl.conf 更改立即生效,執行以下命令。 輸入:sysctl -p 顯示如下:
linux:~ # sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
5)編輯 /etc/profile ,輸入命令:vi /etc/profile,按i鍵進入編輯模式,將下列內容加入該文件。
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
編輯完成後按Esc鍵,輸入“:wq”存盤退出
- 創建用戶及用戶組
6)創建相關用戶和組,作爲軟件安裝和支持組的擁有者。
創建用戶,輸入命令:
groupadd oinstall
groupadd dba
創建Oracle用戶和密碼,輸入命令:
useradd -g oinstall -g dba -m oracle
passwd oracle
然後會讓你輸入密碼,密碼任意輸入2次,但必須保持一致,回車確認
- 安裝前準備
7)創建數據庫軟件目錄和數據文件存放目錄,目錄的位置,根據自己的情況來定,注意磁盤空間即可,這裏我把其放到oracle用戶下,例如:
輸入命令:
mkdir /home/oracle/app
mkdir /home/oracle/app/oracle
mkdir /home/oracle/app/oradata
mkdir /home/oracle/app/oracle/product
8)更改目錄屬主爲Oracle用戶所有,輸入命令:
chown -R oracle:oinstall /home/oracle/app
9)配置oracle用戶的環境變量,首先,切換到新創建的oracle用戶下,
輸入:su – oracle ,然後直接在輸入 : vi .bash_profile
按i編輯 .bash_profile,進入編輯模式,增加以下內容:
umask 022
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
編輯完成後按Esc鍵,輸入“:wq”存盤退出
測試環境變量是否有效:
[gis@localhost ~]$ echo $ORACLE_HOME
發現爲空。執行下面命令
[gis@localhost ~]$ . ./.bash_profile
再次測試,ok
[gis@localhost ~]$ echo $ORACLE_HOME
/home/oracle/app/oracle/product/11.2.0/dbhome_1
安裝過程
上傳安裝包到目錄/home/oracle/app,並使用cksum命令檢查包的完整性,與oracle官網上對應的包cksum值比對(下載包路徑那都會有cksum值),如果匹配不上,則需要重新下載按照包。我就因爲包不完整折騰了我一整天。
注:如果包不完整,在按照到圖形化界面會彈出異常:valid entry size(expected ….
也可以直接拷貝:
scp linux.x64_11gR2_database_1of2.zip [email protected]:/home/oracle/app
scp linux.x64_11gR2_database_2of2.zip [email protected]:/home/oracle/app
-bash-4.1$ ls -l -rw-r--r-- 1 oracle oinstall 1111416131 Mar 22 15:44 linux.x64_11gR2_database_2of2.zip -rw-r--r-- 1 oracle oinstall 1239269270 Mar 23 10:05 linux.x64_11gR2_database_1of2.zip -bash-4.1$ -bash-4.1$ cksum linux.x64_11gR2_database_1of2.zip 3152418844 1239269270 linux.x64_11gR2_database_1of2.zip -bash-4.1$ cksum linux.x64_11gR2_database_2of2.zip 3669256139 1111416131 linux.x64_11gR2_database_2of2.zip |
解壓安裝包到 database文件夾
-bash-4.1$ unzip linux.x64_11gR2_database_1of2.zip -bash-4.1$ unzip linux.x64_11gR2_database_2of2.zip |
- 安裝過程
進入目錄/home/oracle/app/database目錄,執行命令 ./runnInstaller
注意:此處一定要用oracle用戶登錄的窗口執行(用root用戶登錄切換到oracle用戶執行可能會報錯。)例如:
正確的要用oracle登陸執行.
-bash-4.1$ ./runInstaller Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 15390 MB Passed Checking swap space: must be greater than 150 MB. Actual 17611 MB Passed Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed #如果此處檢查不過,解決方法: #su – root 切換到root用戶 #xhost 執行xhost命令 #su – oracle 切換到oracle用戶 #export DISPLAY=:0.0 Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-03-23_10-23-20AM. Please wait ...-bash-4.1$ |
注意:如果缺少按照包或者其它條件不符合,不會跳轉到此頁面
此處check點包括
- 環境變量是否已經設置,比如:net.ipv4.ip_local_port_range = 9000 65500 如果範圍不對,會要求修改
- Swap空間大小是否符合要求,增加swap的方法:
一、查看系統當前的分區情況: >free -m total used free shared buffers cached Mem: 438 432 6 0 8 141 -/+ buffers/cache: 282 156 Swap: 2047 1375 671 二、創建用於交換分區的文件:如果要增加2G大小的交換分區,則命令寫法如下,其中的 count 等於想要的塊大小
>dd if=/dev/zero of=/home/swap bs=block_size count=number_of_block dd if=/dev/zero of=/home/swap bs=1024 count=2048000 2048000+0 records in 2048000+0 records out 2097152000 bytes (2.1 GB) copied, 60.4492 seconds, 34.7 MB/s 三、設置交換分區文件: >mkswap /home/swap 四、立即啓用交換分區文件: >swapon /home/swap 五、若要想使開機時自啓用,則需修改文件/etc/fstab中的swap行: /home/swap swap swap defaults 0 0 |
- rpm安裝包
下載缺少的rpm包,上傳到指定目錄,用root用戶登錄,併到指定目錄執行以下命令:
rpm -ivh 包名 --nodeps --force
[root@localhost Downloads]# rpm -ivh unixODBC-2.2.11-7.1.i386.rpm --nodeps --force warning: unixODBC-2.2.11-7.1.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 37017186: NOKEY Preparing... ########################################### [100%] 1:unixODBC ########################################### [100%]
|
[root@esbApp1 dbhome_1]# ./root.sh Running Oracle 11g root.sh script...
The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /home/oracle/app/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]: /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.sh script. Now product-specific root actions will be performed. Finished product-specific root actions |
至此,oracle已經安裝完成。
使用sqlplus測試下。
安裝完成。
啓動數據庫
-bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 23 11:26:17 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORA-00845: MEMORY_TARGET not supported on this system SQL>
|
ORA-00845: MEMORY_TARGET not supported on this system 解決方法
Root用戶登錄,編輯/etc/fstab 修改記錄成以下,增加size=8G
tmpfs /dev/shm tmpfs defaults,size=8G 0 0
重啓生效,或者重新掛載
掛載命令:mount -o remount,size=16G /dev/shm
一般Size大小跟機器內存保持一致。
SQL> startup ORACLE instance started. Total System Global Area 1.3429E+10 bytes Fixed Size 2217992 bytes Variable Size 6845106168 bytes Database Buffers 6576668672 bytes Redo Buffers 4661248 bytes ORA-01102: cannot mount database in EXCLUSIVE mode SQL> |
ORA-01102: cannot mount database in EXCLUSIVE mode解決方法:
[root@esbApp1 dbhome_1]# ipcs -s ------ Semaphore Arrays -------- key semid owner perms nsems 0x00000000 0 root 600 1 0x00000000 65537 root 600 1 0x01ad2954 655362 oracle 660 154 0x62052f41 131075 root 644 1 0xaea4f7b4 786436 oracle 660 154
[root@esbApp1 dbhome_1]# ipcrm -s 655362 [root@esbApp1 dbhome_1]# ipcrm -s 655362 ipcrm: invalid id (655362) [root@esbApp1 dbhome_1]# ipcrm -s 786436 [root@esbApp1 dbhome_1]# |
再次啓動,啓動成功。
-bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 23 11:41:03 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 1.3429E+10 bytes Fixed Size 2217992 bytes Variable Size 6845106168 bytes Database Buffers 6576668672 bytes Redo Buffers 4661248 bytes Database mounted. Database opened. SQL> -bash-4.1$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 23-MAR-2018 11:48:28 Copyright (c) 1991, 2009, Oracle. All rights reserved. TNS-01106: Listener using listener name LISTENER has already been started -bash-4.1$ |
- 創建oracle數據庫實例
Oracle數據庫創建成功,默認的數據庫實例爲orcl,如何實現一個數據庫多實例運行.?下面是創建數據庫實例的步驟
- oracle用戶登錄(一定是oracle用戶登錄,不能su – oracle方式dengl)
- 修改.bash_profile中SID的值爲要增加的實例名,比如:bipdb
- 執行命令dbca,彈出圖形化界面
上圖彈出界面亂碼 ,查看LANG的值。執行export LANG=C,後再執行dbca命令。
注意:此處需要修改默認的數據庫編碼,默認的數據庫編碼格式不支持中文字符.
後面全部默認按鈕就好。
- 啓動多個數據庫實例
循環執行下列命令:
export SID=實例名
sqlplus / as sysdba
startup
- 刪除數據庫實例
orace用戶登錄,執行命令:dbca
注意:有可能會遇到dbca命令執行後,“DELETE A DATABASE”,是灰色的,無法選擇,這時候需要堅持/etc/oratab文件中是否存在“SID:ORACLE_HOME:N” 如:esbdb:/home/oracle/app/oracle/database/11g........:N。
以上就是我們在安裝oracle數據的整個過程所有操作和遇到的一些問題,當然操作系統版本不同和oracle安裝版本不同可能遇到的問題也會不同,我後面用centenos7.5操作系統來安裝oracle,遇到又是另外一些問題,這個在下篇再介紹。