centos7.2安裝oracle11g r2
阿新 • • 發佈:2019-02-15
================================================= 一、centos7.2安裝oracle 11g =================================================
groupadd oinstall #建立使用者組oinstall
groupadd dba #建立使用者組dba
useradd -g oinstall -g dba -m oracle
passwd oracle
[[email protected] ~]$ su root
Password:
[[email protected] sonny]# mkdir -p /data/oracle #oracle資料庫安裝目錄
[[email protected] sonny]# mkdir -p /data/oraInventory #oracle資料庫配置檔案目錄
[ [email protected] sonny]# mkdir -p /data/database #oracle資料庫軟體包解壓目錄
[[email protected] sonny]# cd /data
[[email protected] data]# ls #建立完畢檢查一下
database oracle oraInventory
[[email protected] data]# chown -R oracle:oinstall /data/oracle #設定目錄所有者為oinstall使用者組的oracle使用者
[[email protected] data]# chown -R oracle:oinstall /data/oraInventory
[[email protected] data]# chown -R oracle:oinstall /data/database
[[email protected] data]#
vim /etc/redhat-release
改為:redhat-7
yum install binutils-devel.x86_64
yum install compat-libcap1.x86_64
yum install gcc.x86_64
yum install gcc-c++.x86_64
yum install glibc.i686
yum install glibc-devel.i686
yum install glibc-utils.x86_64
yum install glibc-static.i686
yum install glibc-static.x86_64
yum install ksh.x86_64
yum install libaio.i686
yum install libaio-devel.x86_64
yum install libaio-devel.i686
yum install libgcc.i686
yum install libstdc++.i686
yum install libstdc++-devel.i686
yum install libstdc++-static.i686
yum install libstdc++-static.x86_64
yum install libstdc++-docs.x86_64
yum install libXi-devel.i686
yum install libXi-devel.x86_64
yum install libXtst.i686
yum install libXtst-devel.i686
yum install libXtst-devel.x86_64
檢視防火牆狀態:systemctl status firewalld.service
關閉防火牆:systemctl stop firewalld.service
(安裝時一定要關防火牆,oracle執行時本機使用不用關防火牆,遠端連線oracle資料庫時需要關閉防火牆)
關閉selinux(需重啟生效)
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #此處修改為disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
修改核心引數
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.all.rp_filter=1
fs.file-max=6815744 #設定最大開啟檔案數
fs.aio-max-nr=1048576
kernel.shmall=2097152 #共享記憶體的總量,8G記憶體設定:2097152*4k/1024/1024
kernel.shmmax=2147483648 #最大共享記憶體的段大小
kernel.shmmni=4096 #整個系統共享記憶體端的最大數
kernel.sem=250 32000 100 128
net.ipv4.ip_local_port_range=9000 65500 #可使用的IPv4埠範圍
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048576
使配置引數生效:sysctl -p
對oracle使用者設定限制,提高軟體執行效能
追加:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
配置使用者的環境變數(
export ORACLE_BASE=/usr/software/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
生效:source /home/oracle/.bash_profile
chown -R oracle:oinstall database
準備安裝
安裝出現的兩個問題:
1、[INS-06101] IP address of localhost could not be determined,主機名和/etc/hosts 檔案不一致
1)vim /etc/sysconfig/network
加入:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=sunt
2)hostname sunt
2)vim /etc/hosts
加入:127.0.0.1 sunt
2、ins_ctx.mk錯誤:
修改$ORACLE_HOME/ctx/lib/ins_ctx.mk檔案:
ctxhx: $(CTXHXOBJ)
$(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)
修改為:
ctxhx: $(CTXHXOBJ)
-static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/libc.a
3、ins_emagent錯誤:
修改/opt/oracle/product/11.2.0.1/sysman/lib/ins_emagent檔案:(190行)
$(MK_EMAGENT_NMECTL)
修改為:
$(MK_EMAGENT_NMECTL) -lnnz11
完後解鎖scott使用者即可
================================================= 二、安裝完成後常見命令 =================================================
啟動資料庫:
sqlplus / as sysdba
startup
exit
lsnrctl start
關閉資料庫:
sqlplus / as sysdba
shutdown immediate
exit
lsnrctl stop
啟動監聽器:lsnrctl start
停止監聽器:lsnrctl stop
檢視監聽器狀態 :lsnrctl status
groupadd oinstall #建立使用者組oinstall
groupadd dba #建立使用者組dba
useradd -g oinstall -g dba -m oracle
passwd oracle
[[email protected] ~]$ su root
Password:
[[email protected] sonny]# mkdir -p /data/oracle #oracle資料庫安裝目錄
[[email protected] sonny]# mkdir -p /data/oraInventory #oracle資料庫配置檔案目錄
[
[[email protected] sonny]# cd /data
[[email protected] data]# ls #建立完畢檢查一下
database oracle oraInventory
[[email protected] data]# chown -R oracle:oinstall /data/oracle #設定目錄所有者為oinstall使用者組的oracle使用者
[[email protected]
[[email protected] data]# chown -R oracle:oinstall /data/database
[[email protected] data]#
vim /etc/redhat-release
改為:redhat-7
yum install binutils-devel.x86_64
yum install compat-libcap1.x86_64
yum install gcc.x86_64
yum install gcc-c++.x86_64
yum install glibc.i686
yum install glibc-devel.i686
yum install glibc-utils.x86_64
yum install glibc-static.i686
yum install glibc-static.x86_64
yum install ksh.x86_64
yum install libaio.i686
yum install libaio-devel.x86_64
yum install libaio-devel.i686
yum install libgcc.i686
yum install libstdc++.i686
yum install libstdc++-devel.i686
yum install libstdc++-static.i686
yum install libstdc++-static.x86_64
yum install libstdc++-docs.x86_64
yum install libXi-devel.i686
yum install libXi-devel.x86_64
yum install libXtst.i686
yum install libXtst-devel.i686
yum install libXtst-devel.x86_64
檢視防火牆狀態:systemctl status firewalld.service
關閉防火牆:systemctl stop firewalld.service
(安裝時一定要關防火牆,oracle執行時本機使用不用關防火牆,遠端連線oracle資料庫時需要關閉防火牆)
關閉selinux(需重啟生效)
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #此處修改為disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
修改核心引數
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.all.rp_filter=1
fs.file-max=6815744 #設定最大開啟檔案數
fs.aio-max-nr=1048576
kernel.shmall=2097152 #共享記憶體的總量,8G記憶體設定:2097152*4k/1024/1024
kernel.shmmax=2147483648 #最大共享記憶體的段大小
kernel.shmmni=4096 #整個系統共享記憶體端的最大數
kernel.sem=250 32000 100 128
net.ipv4.ip_local_port_range=9000 65500 #可使用的IPv4埠範圍
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048576
使配置引數生效:sysctl -p
對oracle使用者設定限制,提高軟體執行效能
追加:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
配置使用者的環境變數(
export ORACLE_BASE=/usr/software/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
生效:source /home/oracle/.bash_profile
chown -R oracle:oinstall database
準備安裝
安裝出現的兩個問題:
1、[INS-06101] IP address of localhost could not be determined,主機名和/etc/hosts 檔案不一致
1)vim /etc/sysconfig/network
加入:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=sunt
2)hostname sunt
2)vim /etc/hosts
加入:127.0.0.1 sunt
2、ins_ctx.mk錯誤:
修改$ORACLE_HOME/ctx/lib/ins_ctx.mk檔案:
ctxhx: $(CTXHXOBJ)
$(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)
修改為:
ctxhx: $(CTXHXOBJ)
-static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/libc.a
3、ins_emagent錯誤:
修改/opt/oracle/product/11.2.0.1/sysman/lib/ins_emagent檔案:(190行)
$(MK_EMAGENT_NMECTL)
修改為:
$(MK_EMAGENT_NMECTL) -lnnz11
完後解鎖scott使用者即可
================================================= 二、安裝完成後常見命令 =================================================
啟動資料庫:
sqlplus / as sysdba
startup
exit
lsnrctl start
關閉資料庫:
sqlplus / as sysdba
shutdown immediate
exit
lsnrctl stop
啟動監聽器:lsnrctl start
停止監聽器:lsnrctl stop
檢視監聽器狀態 :lsnrctl status