返回列表 发帖

Oracle Linux6.9安装Oracle11gR2

笺注:
服务器本机IP地址为192.168.168.163/24,以下是无图形界面安装Oracle11gR2

相关软件下载链接:https://pan.baidu.com/s/1Bq3U2b86IlLTKJq-uf4g6w  提取码:1e3r


主机名:
[root@oracle ~]# hostname
oracle.zhuohua.store
[root@oracle ~]#
[root@oracle ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oracle.zhuohua.store
[root@oracle ~]#

[root@oracle ~]# echo '192.168.168.163 oracle.zhuohua.store' >> /etc/hosts



物理内存为2G:
[root@oracle ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1743        146       1596          0          6         55
-/+ buffers/cache:         84       1658
Swap:         2015          0       2015
[root@oracle ~]#

[root@oracle ~]# free -k
             total       used       free     shared    buffers     cached
Mem:       1784872     357808    1427064        228      15220     243248
-/+ buffers/cache:      99340    1685532
Swap:      2064380          0    2064380
[root@oracle ~]#



查看当前语言环境:(英文)
[root@oracle ~]# echo $LANG
en_US.UTF-8
[root@oracle ~]#



关闭SELinux:
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config



先安装以下的RPM软件包:
[root@oracle ~]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
warning: pdksh-5.2.14-37.el5_8.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID e8562897: NOKEY
Preparing...                ########################################### [100%]
   1:pdksh                  ########################################### [100%]

[root@oracle ~]#


使用Yum安装以下RPM软件包:(使用本地光盘作为Yum源即可)
[root@oracle ~]# yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel unzip psmisc


添加Oracle用户组和用户等:
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
echo '123' | passwd --stdin oracle



优化系统内核:
[root@oracle ~]# vi /etc/sysctl.conf
修改:
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 913854464
注释:参数kernel.shmmax设置为物理内存的一半,以字节为单位

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 524288
注释:假如物理内存为1G时,kernel.shmall参数设置为262144,以此类推

追加:
fs.aio-max-nr=1048576
fs.file-max=6815744
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


[root@oracle ~]# 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
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 913854464
kernel.shmall = 524288
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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
[root@oracle ~]#



######

[root@oracle ~]# vi /etc/security/limits.conf
追加:
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536


[root@oracle ~]# vi /etc/pam.d/login
追加:
session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so


[root@oracle ~]# 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相关目录等:
mkdir -p /db/app/oracle/product/11.2.0
mkdir /db/app/oracle/oradata
mkdir /db/app/oracle/inventory
mkdir /db/app/oracle/fast_recovery_area
chown -R oracle:oinstall /db/app/oracle
chmod -R 775 /db/app/oracle
mkdir -p /u01/app/oracle/inventory
chown -R oracle:oinstall /u01/app/oracle/inventory



######

配置Oracle用户环境变量:
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ whoami
oracle
[oracle@oracle ~]$
[oracle@oracle ~]$ vi .bash_profile
追加:
umask 022
export ORACLE_HOSTNAME=oracle.zhuohua.store
export ORACLE_BASE=/db/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"



######

解压安装包:(使用系统用户root)
[oracle@oracle ~]$ exit
logout
[root@oracle ~]# whoami
root
[root@oracle ~]#
[root@oracle ~]# unzip linux.x64_11gR2_database_1of2.zip -d /db
[root@oracle ~]# unzip linux.x64_11gR2_database_2of2.zip -d /db

[root@oracle ~]# mkdir /db/etc/
[root@oracle ~]# cp /db/database/response/* /db/etc/


[root@oracle ~]# vi /db/etc/db_install.rsp
修改:
oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=oracle.zhuohua.store
ORACLE_HOME=/db/app/oracle/product/11.2.0
ORACLE_BASE=/db/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba


笺注:来到这里最好重启一下系统
[root@oracle ~]# reboot





############
############

正式开始安装:
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ cd /db/database/
[oracle@oracle database]$ ./runInstaller -silent -ignorePrereq -responseFile /db/etc/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 41738 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2015 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-08-12_06-56-19AM. Please wait ...[oracle@oracle database]$ You can find the log of this install session at:
/u01/app/oracle/inventory/logs/installActions2019-08-12_06-56-19AM.log


另外打开一个会话,使用系统用户root动态查看安装日志信息:
[root@oracle ~]# tail -f /u01/app/oracle/inventory/logs/installActions2019-08-12_06-56-19AM.log
图片1.png
5 天前 10:07



等出现以下提示:
图片2.png
5 天前 10:08



另外打开一个会话,使用系统用户root运行脚本:
[root@oracle ~]# /u01/app/oracle/inventory/orainstRoot.sh
Changing permissions of /u01/app/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oracle/inventory to oinstall.
The execution of the script is complete.
[root@oracle ~]#


[root@oracle ~]# /db/app/oracle/product/11.2.0/root.sh
Check /db/app/oracle/product/11.2.0/install/root_oracle.zhuohua.store_2019-08-12_07-12-50.log for the output of root script
[root@oracle ~]#


以上两个脚本运行后,在这个界面按回车键结束安装:
图片3.png
5 天前 10:08






############
############

配置静默监听:
su - oracle
netca /silent /responsefile /db/etc/netca.rsp
图片4.png
5 天前 10:09






############
############

静默创建数据库:
另外打开一个会话,使用系统用户root修改文件:
[root@oracle ~]# vi /db/etc/dbca.rsp
修改:
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION = /db/app/oracle/oradata
RECOVERYAREADESTINATION = /db/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1394"

注释:其中TOTALMEMORY设置为物理内存的80%左右。



[root@oracle ~]# chown -R oracle:oinstall /db/etc/dbca.rsp
[root@oracle ~]#



执行静默建库:
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ dbca -silent -responseFile /db/etc/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/db/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
[oracle@oracle ~]$





############
############

查看Oracle的监听状态:       
[oracle@oracle ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-AUG-2019 07:45:43

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                12-AUG-2019 07:16:26
Uptime                    0 days 0 hr. 29 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /db/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /db/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle.zhuohua.store)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle ~]$





############
############

登录Oracle,进行测试:
[oracle@oracle ~]$ whoami
oracle
[oracle@oracle ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 12 07:47:40 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL>
SQL> conn /as sysdba;
Connected to an idle instance.
SQL>
SQL> startup;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/dbs/initORCL.ora'

SQL>

解决方法,另外打开一个会话:
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ cp /db/app/oracle/admin/orcl/pfile/init.ora.712201973810 $ORACLE_HOME/dbs/initORCL.ora
[oracle@oracle ~]$

注释:红色字体那串数字可能不一样。


再次启动Oracle:
SQL> startup;
ORACLE instance started.

Total System Global Area  910266368 bytes
Fixed Size                  2218672 bytes
Variable Size             247465296 bytes
Database Buffers          654311424 bytes
Redo Buffers                6270976 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode

SQL>

解决方法:
SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL>


再另外打开一个会话,使用系统用户root:
[root@oracle ~]# cd /db/app/oracle/product/11.2.0/dbs
[root@oracle dbs]# fuser -k lkORCL
[root@oracle dbs]# fuser -u lkORCL


成功启动Oracle:
SQL> startup;
ORACLE instance started.

Total System Global Area  910266368 bytes
Fixed Size                  2218672 bytes
Variable Size             247465296 bytes
Database Buffers          654311424 bytes
Redo Buffers                6270976 bytes
Database mounted.
Database opened.
SQL>





############
############

查看数据库版本信息:
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL>



查看数据库编码:
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
--------------------------------------------------------------------------------
AMERICAN_AMERICA.AL32UTF8

SQL>





############
############

查看Oracle的进程:
[root@oracle ~]# ps -ef | grep ora_ | grep -v grep
oracle    5063     1  0 07:38 ?        00:00:07 ora_vktm_orcl
oracle    5069     1  0 07:38 ?        00:00:00 ora_diag_orcl
oracle    5075     1  0 07:38 ?        00:00:00 ora_dia0_orcl
oracle    5093     1  0 07:38 ?        00:00:00 ora_d000_orcl
oracle    5095     1  0 07:38 ?        00:00:00 ora_s000_orcl
oracle    5255     1  0 08:07 ?        00:00:00 ora_pmon_ORCL
oracle    5257     1  0 08:07 ?        00:00:00 ora_vktm_ORCL
oracle    5261     1  0 08:07 ?        00:00:00 ora_gen0_ORCL
oracle    5263     1  0 08:07 ?        00:00:00 ora_diag_ORCL
oracle    5265     1  0 08:07 ?        00:00:00 ora_dbrm_ORCL
oracle    5267     1  0 08:07 ?        00:00:00 ora_psp0_ORCL
oracle    5269     1  0 08:07 ?        00:00:00 ora_dia0_ORCL
oracle    5271     1  0 08:07 ?        00:00:00 ora_mman_ORCL
oracle    5273     1  0 08:07 ?        00:00:00 ora_dbw0_ORCL
oracle    5275     1  0 08:07 ?        00:00:00 ora_lgwr_ORCL
oracle    5277     1  0 08:07 ?        00:00:00 ora_ckpt_ORCL
oracle    5279     1  0 08:07 ?        00:00:00 ora_smon_ORCL
oracle    5281     1  0 08:07 ?        00:00:00 ora_reco_ORCL
oracle    5283     1  0 08:07 ?        00:00:00 ora_mmon_ORCL
oracle    5285     1  0 08:07 ?        00:00:00 ora_mmnl_ORCL
oracle    5287     1  0 08:07 ?        00:00:00 ora_d000_ORCL
oracle    5289     1  0 08:07 ?        00:00:00 ora_s000_ORCL
oracle    5297     1  0 08:07 ?        00:00:00 ora_qmnc_ORCL
oracle    5311     1  0 08:07 ?        00:00:00 ora_cjq0_ORCL
oracle    5313     1  0 08:07 ?        00:00:00 ora_q000_ORCL
oracle    5315     1  0 08:07 ?        00:00:00 ora_q001_ORCL
[root@oracle ~]#



检测Oracle的端口:(Oracle正常运行时)
[root@oracle ~]# netstat -anp |grep 1521
tcp        0      0 192.168.168.135:30306       192.168.168.135:1521        ESTABLISHED 5255/ora_pmon_ORCL  
tcp        0      0 :::1521                     :::*                        LISTEN      4688/tnslsnr        
tcp        0      0 ::ffff:192.168.168.135:1521 ::ffff:192.168.168.13:30306 ESTABLISHED 4688/tnslsnr        
unix  2      [ ACC ]     STREAM     LISTENING     16292  4688/tnslsnr        /var/tmp/.oracle/sEXTPROC1521
[root@oracle ~]#
[root@oracle ~]#
[root@oracle ~]# echo $?
0
[root@oracle ~]#



添加防火墙规则:
[root@oracle ~]# iptables -I INPUT -p tcp --dport 1521 -j ACCEPT
[root@oracle ~]# iptables-save > /etc/sysconfig/iptables

[root@oracle ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Mon Aug 12 08:15:17 2019
*filter
:INPUT ACCEPT [2:132]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2:232]
-A INPUT -p tcp -m tcp --dport 1521 -j ACCEPT
COMMIT
# Completed on Mon Aug 12 08:15:17 2019
[root@oracle ~]#












#############
#############

Oracle11gR2的启动和关闭

启动Oracle listener:(系统重启后,需要手动开启)
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-AUG-2019 08:22:01

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /db/app/oracle/product/11.2.0//bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /db/app/oracle/product/11.2.0/network/admin/listener.ora
Log messages written to /db/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle.zhuohua.store)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                12-AUG-2019 08:22:03
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /db/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /db/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle.zhuohua.store)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@oracle ~]$



关闭Oracle listener:(一般都要开启)
[oracle@oracle ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-AUG-2019 08:23:22

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@oracle ~]





先启动Oracle listener后,再登录Oracle,启动Oracle:
[oracle@oracle ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 12 08:25:24 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn /as sysdba;
Connected to an idle instance.
SQL>
SQL> startup;
ORACLE instance started.

Total System Global Area  910266368 bytes
Fixed Size                  2218672 bytes
Variable Size             247465296 bytes
Database Buffers          654311424 bytes
Redo Buffers                6270976 bytes
Database mounted.
Database opened.
SQL>



正常关闭Oracle:
shutdown immediate;
图片5.png
5 天前 10:16



如果无法正常关闭Oracle时,可以使用下面的命令:
shutdown abort;  
图片6.png
5 天前 10:16


笺注:关闭系统前,最好先关闭Oracle





相关文章:
Oracle Linux6.9的安装
使用Navicat连接Oracle11gR2

PuTTY远程管理Oracle Linux6.9
CentOS6_RPM软件包管理器(screen+mailx)

返回列表