Centos 7下安裝Oracle 12c


SQL Server玩了有些年,最近想玩玩Oracle,於是想到裝一台Oracle server來玩玩。第一次在Linux下安裝Oracle,整個過程參考了一篇文章:http://blog.csdn.net/huangyanlong/article/details/45021171

 

環境:VMWare Workstatrion 8.0.3 

操作系統:CentOS 7 x64

數據庫:Oracle 12c x64

 

1)安裝好Centos 7,這一步跳過

2)從Oracle官網下載12c的安裝包,也跳過

3)把軟件從本地上傳到VM的linux服務器上

這一步的做法是:把虛機的網絡連接方式設置成橋接>>在linux服務器上配置ip地址和本機處在同一個網絡>>把本地機器上的包含Oracle 12c安裝包的目錄共享出來>>確保可以在linux服務器上Ping通本地機器>>用mount命令把共享目錄掛載到linux服務器上>>解壓linuxamd64_12102_database_1of2.zip,linuxamd64_12102_database_2of2.zip這兩個zip包到linux服務器上

 

掛載:mount -t cifs -o username=Jerry,password=password,ip=192.168.1.100 //192.168.1.100/Oracle /mnt/oracle

解壓:unzip ./linuxamd64_12102_database_1of2.zip -d /usr/Oracle; unzip ./linuxamd64_12102_database_2of2.zip -d /usr/Oracle;

 

禁用一些服務,用腳本來做

[root@localhost Oracle Installation]# cat servicestop.sh 
chkconfig iptables off 
chkconfig ip6tables off 
chkconfig cups off 
chkconfig firstboot off 
chkconfig wpa_supplicant off 
chkconfig postfix off 
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config 
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config

 

這一步本來應該要去參考Oracle官方安裝文檔准備好要事先安裝的安裝包,不過由於上面參考的文章中作者已經列出,這里我直接借鑒那份列表

binutils-2.20.51.0.2-5.11.el6 (x86_64)  
compat-libcap1-1.10-1 (x86_64) compat-libstdc++-33-3.2.3-69.el6 (x86_64) gcc-4.4.4-13.el6 (x86_64) gcc-c++-4.4.4-13.el6 (x86_64) glibc-2.12-1.7.el6 (x86_64) glibc-devel-2.12-1.7.el6 (x86_64) ksh libgcc-4.4.4-13.el6 (x86_64) libstdc++-4.4.4-13.el6 (i686) libstdc++-devel-4.4.4-13.el6 (x86_64) libaio-0.3.107-10.el6 (x86_64) libaio-devel-0.3.107-10.el6 (x86_64) libXext-1.1 (x86_64) libXtst-1.0.99.2 (x86_64) libX11-1.3 (x86_64) libXau-1.0.5 (x86_64) libxcb-1.5 (x86_64) libXi-1.3 (x86_64) make-3.81-19.el6 sysstat-9.0.4-11.el6 (x86_64) 

 

這些rpm包估計都在iso鏡像中,要我去一個一個找我覺得太浪費時間,要是下次我要再裝一台豈不是要再找多一次。於是我有了一個想法,就是用一個文件存儲這份列表,然后寫個shell通過關鍵字在安裝盤上查找我們可能需要安裝的包,然后拷貝到某個文件夾下

[root@localhost Oracle Installation]# vi cppkg

binutils
compat-libcap compat-libstdc gcc- gcc-c++ glibc- glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel libXext libXtst libX11 libXau libxcb libXi- make sysstat

保存離開

建立bash_loop_test來拷貝rpm包到本地目錄

[root@localhost Oracle Installation]# cat bash_loop_test 
#!/bin/bash

cat /home/jerry/Desktop/'Oracle Installation'/cppkg | while read line

do
find /mnt/cdrom/Packages/ -name ${line}'*' -exec cp {} /home/jerry/Desktop/'Oracle Installation'/ \;

echo $line

done

[root@localhost Oracle Installation]# sh bash_loop_test 

生成安裝包腳本

[root@localhost Oracle Installation]# echo /dev/null > rpm.sh; find . -name '*.rpm'|xargs -i echo 'rpm -ivh '{} >> rpm.sh ;

 

不過經過實踐發現其實這個方法也不好,因為很多dependency在,所以其實還是要手動去安裝這個包。不過至少自己知道去思考一些方法,算是練習練習shell吧

 

安裝調用圖形化需要的包,注意這里需要機器可以連接到Internet

[root@localhost Packages]#  yum -y install unixODBC
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package unixODBC.x86_64 0:2.3.1-10.el7 will be installed
--> Finished Dependency Resolution
省略

Installed:
unixODBC.x86_64 0:2.3.1-10.el7

Complete!

 

[root@localhost Packages]# yum -y install unixODBC-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirrors.163.com
省略

Installed:
unixODBC-devel.x86_64 0:2.3.1-10.el7

Complete!

[root@localhost Packages]# yum install -y xterm
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirrors.163.com
省略
Installed:
  xterm.x86_64 0:295-3.el7                                                      

Dependency Installed:
  libXaw.x86_64 0:1.0.11-6.1.el7                                                

Complete!

 

 添加用戶和用戶組,建立主目錄

[root@localhost Packages]# groupadd oinstall
groupadd: group 'oinstall' already exists [root@localhost Packages]# groupadd dba groupadd: group 'dba' already exists [root@localhost Packages]# useradd -g oinstall -G dba oracle useradd: user 'oracle' already exists [root@localhost Packages]# passwd oracle Changing password for user oracle. New password: BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word Retype new password: passwd: all authentication tokens updated successfully. [root@localhost Packages]# id oracle uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba) [root@localhost Packages]# mkdir -p /u01/app/oracle/product/12.1.0/db_1 [root@localhost Packages]# mkdir -p /u01/app/oraInventory [root@localhost Packages]# chown -R oracle:oinstall /u01/app [root@localhost Packages]# chmod -R 775 /u01/app [root@localhost Packages]# vi /etc/sysctl.conf [root@localhost Packages]# vi /etc/sysctl.conf [root@localhost Packages]# sysctl -p fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 4294967295 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

[jerry@localhost Desktop]$ cat /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# 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 = 4294967295
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

[root@localhost Packages]# vi /etc/security/limits.conf

把下面的內容添加到文件尾部

oracle              soft    nproc   2047  

oracle              hard    nproc   16384  

oracle              soft    nofile  1024  

oracle              hard    nofile  65536 

[root@localhost Packages]# vi /etc/pam.d/login

把下面的內容添加到文件尾部

session    required     /lib/security/pam_limits.so  

session    required     pam_limits.so  

[root@localhost Packages]# vi /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  

 

切換到oracle用戶,修改.bash_profile文件

[root@localhost database]# su oracle
[oracle@localhost ~]$vi .bash_profile
[oracle@localhost ~]$ cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/.local/bin:$HOME/bin

#export PATH

ORACLE_BASE=/u01/app/oracle  
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1  
ORACLE_SID=jerrychen
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin  
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib  
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH  
[oracle@localhost ~]$ source .bash_profile
 

 

然而似乎一切順利可以進入安裝階段時

[oracle@localhost database]$ ./runInstaller 
./runInstaller: line 83: [: /usr/oracle/Oracle: binary operator expected
./runInstaller: line 247: [: too many arguments
./runInstaller: line 251: /usr/oracle/Oracle: No such file or directory

一時搞不懂出了什么情況。Google了一下有了頭緒,原因是安裝目錄的名字叫Oracle \Installation。這個命名包含了\符號,就是這個原因導致了runInstaller安裝腳本報錯,我把目錄的名稱修改了一下,去除空格和特殊符號好就沒報這個錯誤了。但是,出現了另一個錯誤,Display變量相關

[oracle@localhost database]$ ./runInstaller 
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 19938 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2045 MB    Passed
Checking monitor: must be configured to display at least 256 colors
    >>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.    Failed <<<<

Some requirement checks failed. You must fulfill these requirements before

continuing with the installation,

Continue? (y/n) [n] n

 

用[oracle@localhost database]$ export DISPLAY=192.168.1.120:0.0設置一下這個變量,然后開啟另一個終端來運行runInstaller

[oracle@localhost database]$ ./runInstaller 
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 19938 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2045 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-06-21_10-44-42PM. Please wait ...[oracle@localhost database]$ 

 

終於進入安裝階段了

 

 

 

 

 

 

 

 

 

有個包前面漏安裝了。查了一下安裝光盤沒有找到這個包。原來linux 7上沒有,要到linux 6上才有。但是我不可能跑去download一個linux 6的鏡像嘛。用yum來安裝咯。至於swap文件和oracle建議的2.8G差了800mb,我想這個不影響整個安裝過程,可以等安裝完再修改swap文件的大小。跳過(忽略)這項檢查。

 

 

[root@localhost Packages]# yum -y install compat-libstdc++-33
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package compat-libstdc++-33.x86_64 0:3.2.3-72.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                    Arch          Version             Repository   Size
================================================================================
Installing:
 compat-libstdc++-33        x86_64        3.2.3-72.el7        base        191 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 191 k
Installed size: 811 k
Downloading packages:
compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm                | 191 kB   00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : compat-libstdc++-33-3.2.3-72.el7.x86_64                      1/1 
  Verifying  : compat-libstdc++-33-3.2.3-72.el7.x86_64                      1/1 

Installed:
  compat-libstdc++-33.x86_64 0:3.2.3-72.el7                                     

Complete!

 

 


免責聲明!

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



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