1. 程式人生 > 資料庫 >Linux環境下Oracle安裝引數設定方法詳解

Linux環境下Oracle安裝引數設定方法詳解

前面講了虛擬機器的設定和OracleLinux的安裝,接下來我們來說下Oracle安裝前的準備工作。

1、系統資訊檢視

系統資訊檢視

首先伺服器ip:192.168.8.120

伺服器系統:Oracle Linux Server release 6.5

伺服器主機名:oracle-learn

檢視磁碟空間情況:

[root@oracle-learn ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 32G 4.8G 26G 17% /
tmpfs 3.9G 224K 3.9G 1% /dev/shm
/dev/sdc1 197G 60M 187G 1% /oracle
/dev/sdb1 40G 48M 38G 1% /soft

/oracle目錄用於安置oracle
/soft用於存放oracle等工具安裝包

2、掛載光碟機

在啟動系統後,檢查虛擬機器光碟機設定是否選中已連線,如果沒有,則選中。

掛載光碟機

[root@oracle-learn ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected,mounting read-only

檢查是否掛載成功

[root@oracle-learn ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 32G 4.8G 26G 17% /
tmpfs 3.9G 224K 3.9G 1% /dev/shm
/dev/sdc1 197G 60M 187G 1% /oracle
/dev/sdb1 40G 48M 38G 1% /soft
/dev/sr0 3.7G 3.7G 0 100% /mnt

1、設定yum配置

修改原yum檔案的名稱

[root@oracle-learn ~]# cd /etc/yum.repos.d/
[root@oracle-learn yum.repos.d]# mv public-yum-ol6.repo public-yum-ol6.repofuben
[root@oracle-learn yum.repos.d]# ll

總用量 4

-rw-r--r--. 1 root root 2545 10月 29 2018 public-yum-ol6.repofuben
[root@oracle-learn yum.repos.d]# 

2、設定yum的配置

[root@oracle-learn yum.repos.d]# vim /etc/yum.conf

新增如下內容:

[EL]
name =Oracle Linux 6.5 
baseurl=file:///mnt/Server/
gpgcheck=0
enabled=1

儲存並退出

測試下是否配置成功

[root@oracle-learn yum.repos.d]# yum install binutils -y

如果配置成功

3、安裝Oracle需要的軟體包

yum install binutils -y
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc-devel -y
yum install ksh -y
yum install libgcc -y
yum install libstdc++ -y
yum install libstdc++-devel -y
yum install libaio -y
yum install libaio-devel -y
yum install libXext -y
yum install libXtst -y
yum install libX11 -y
yum install libXau -y
yum install libxcb -y
yum install libXi -y
yum install make -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel –y

4、hosts檔案配置

編輯/etc/hosts檔案,[root@db01 /]# vi /etc/hosts

在最後新增如下內容:
192.168.8.120 oracle-learn
前面是伺服器ip,後面是伺服器主機名

5、新增組與使用者

[root@oracle-learn ~]# /usr/sbin/groupadd -g 60001 oinstall
/usr/sbin/groupadd -g 60002 dba
[root@oracle-learn ~]# /usr/sbin/groupadd -g 60002 dba
/usr/sbin/groupadd -g 60003 oper
[root@oracle-learn ~]# /usr/sbin/groupadd -g 60003 oper
[root@oracle-learn ~]#/usr/sbin/useradd -u 61002 -g oinstall -G dba oracle
[root@oracle-learn ~]# /usr/sbin/useradd -u 61002 -g oinstall -G dba oracle

檢視oracle使用者

[root@oracle-learn ~]# id oracle
uid=61002(oracle) gid=60001(oinstall) 組=60001(oinstall),60002(dba)
[root@oracle-learn ~]# 

設定Oracle使用者密碼

[root@oracle-learn ~]# passwd oracle

更改使用者 oracle 的密碼 。

新的 密碼:

無效的密碼: 它基於字典單詞

無效的密碼: 過於簡單

重新輸入新的 密碼:

passwd: 所有的身份驗證令牌已經成功更新。

[root@oracle-learn ~]#

6、新增檔案系統

建立/oracle用以存放oracle

[root@oracle-learn ~]# cd /oracle
[root@oracle-learn oracle]# mkdir -p /oracle/app/oracle/product/11.2.0/db_1
[root@oracle-learn oracle]# chown -R oracle:oinstall /oracle
[root@oracle-learn oracle]# chmod -R 775 /oracle/
[root@oracle-learn oracle]# 

7、修改作業系統引數

7.1修改/etc/security/limits.conf檔案;

[root@oracle-learn oracle]# vi /etc/security/limits.conf

增加內容如下:

#ORACLE SETTING
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768

7.2修改/etc/security/limits.d/90-nproc.conf檔案內容

[root@oracle-learn oracle]# vi /etc/security/limits.d/90-nproc.conf

註釋掉

#* soft nproc 1024

新增

* - nproc 16384

檢視更改的檔案

[root@oracle-learn oracle]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
#* soft nproc 1024
* - nproc 16384
root soft nproc unlimited
[root@oracle-learn oracle]# 

7.3禁用SELINUX

[root@oracle-learn oracle]# vi /etc/selinux/config

SELINUX=enforcing

改成

SELINUX=disabled

讓SELINUX生效:

[root@oracle-learn oracle]# setenforce 0

7.4關閉iptables防火牆

關閉防火牆

[root@oracle-learn oracle]# service iptables stop
iptables:將鏈設定為政策 ACCEPT:filter [確定]
iptables:清除防火牆規則: [確定]
iptables:正在解除安裝模組: [確定]
[root@oracle-learn oracle]# 

也可以設定永久關閉防火牆

[root@oracle-learn oracle]# chkconfig iptables off
[root@oracle-learn oracle]# 

7.5修改/etc/pam.d/login檔案

[root@oracle-learn oracle]# vi /etc/pam.d/login

新增

#ORACLE SETTING
session required pam_limits.so

7.6修改sysctl.conf配置檔案

[root@oracle-learn ~]# vi /etc/sysctl.conf

註釋

#kernel.shmmax = 68719476736
#kernel.shmall = 4294967296

新增

#ORACLE SETTING
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 8589934592
kernel.shmall = 2097152
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

註釋:

kernel.shmmax和kernel.shmall的計算方法:
kernel.shmmax大於SGA,小於實體記憶體

我這裡伺服器的記憶體是8G

所以kernel.shmmax的值是

`1024*1024*1024*8=8589934592`
`kernel.shmmni = 4096`
`kernel.shmall=kernel.shmmax/4096`

讓配置生效:

[root@oracle-learn ~]# sysctl -p  

8、環境變數設定

切換到oracle使用者下

[root@oracle-learn ~]# su - oracle
[oracle@oracle-learn ~]$

修改環境變數

[oracle@oracle-learn ~]$ vi ~/.bash_profile

新增如下:

#Oracle Settings oracle
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
#export LANG=en_US
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

其中ORACLE_SID=orcl;可以自定義資料庫的sid

退出使用者

[oracle@oracle-learn ~]$ exit
logout
[root@oracle-learn ~]# 

在登入oracle使用者檢查環境變數引數

[root@oracle-learn ~]# su - oracle
[oracle@oracle-learn ~]$ env |grep ORACLE
ORACLE_SID=orcl
ORACLE_BASE=/oracle/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/app/oracle/product/11.2.0
[oracle@oracle-learn ~]$ 

至此,Linux環境下Oracle環境準備完畢。

總結

以上所述是小編給大家介紹的Linux環境下Oracle安裝引數設定方法詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對我們網站的支援!