Centos7.2安装Oracle11gR2

1、下载Oracle11g

2、上传并解压,得到database

[root@Oracle home]# unzip p13390677_112040_Linux-x86-64_1of7.zip
[root@Oracle home]# unzip p13390677_112040_Linux-x86-64_2of7.zip
[root@Oracle home]# ll
总用量 2487204
drwxr-xr-x. 7 root root       4096 8月  27 2013 database
-rw-r--r--. 1 root root 1395582860 7月  23 10:00 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--. 1 root root 1151304589 7月  23 10:00 p13390677_112040_Linux-x86-64_2of7.zip

3、关闭selinux

[root@Oracle software]# 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
# 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

4、关闭防火墙

[root@Oracle software]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@Oracle software]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

7月 23 09:57:05 Oracle systemd[1]: Starting firewalld - dynamic firewall daemon...
7月 23 09:57:06 Oracle systemd[1]: Started firewalld - dynamic firewall daemon.
7月 23 10:13:54 Oracle systemd[1]: Stopping firewalld - dynamic firewall daemon...
7月 23 10:13:55 Oracle systemd[1]: Stopped firewalld - dynamic firewall daemon.

5、安装依赖

[root@Oracle software]# yum install gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y

6、添加安装用户和用户组

[root@Oracle software]# groupadd oinstall
[root@Oracle software]# groupadd dba
[root@Oracle software]# useradd -g oinstall -G dba oracle
[root@Oracle software]# passwd oracle
更改用户 oracle 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@Oracle software]# id oracle
uid=1000(oracle) gid=1000(oinstall) 组=1000(oinstall),1001(dba)

7、修改内核参数配置文件

[root@Oracle software]# vim /etc/sysctl.conf

添加内容:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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@Oracle software]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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

8、修改用户限制文件

[root@Oracle software]# vim /etc/security/limits.conf

添加内容:
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile         65536
oracle           soft    stack           10240 

[root@Oracle software]# vim /etc/pam.d/login

添加内容:
session required  /lib64/security/pam_limits.so
session required   pam_limits.so 

[root@Oracle software]# vim /etc/profile

添加内容:
#oracle配置
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
  else
      ulimit -u 16384 -n 65536
  fi
fi

9、创建安装目录和文件夹权限

[root@Oracle software]# mkdir -p /data/oracle/product/11.2.0
[root@Oracle software]# mkdir /data/oracle/oradata
[root@Oracle software]# mkdir /data/oracle/inventory
[root@Oracle software]# mkdir /data/oracle/fast_recovery_area
[root@Oracle software]# chown -R oracle:oinstall /data/oracle
[root@Oracle software]# chmod -R 775 /data/oracle

10、设置Oracle用户环境

[oracle@Oracle ~]$ vim .bash_profile

添加内容:
ORACLE_BASE=/data/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

#orcl为数据库实例名

[oracle@Oracle ~]$ source .bash_profile

11、编辑静默安装响应文件

[oracle@Oracle ~]$ cp -R /home/database/response/ .
[oracle@Oracle ~]$ cd response/
[oracle@Oracle response]$ vim db_install.rsp
更改如下:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=CentOS
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/oracle/product/11.2.0
ORACLE_BASE=/data/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true

12、静默安装

[oracle@Oracle response]$ cd /home/database/
[oracle@Oracle database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。   实际为 11464 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 2047 MB    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2019-11-01_01-14-53PM. 请稍候...[oracle@Oracle database]$ [WARNING] [INS-32055] 主产品清单位于 Oracle 基目录中。
   原因: 主产品清单位于 Oracle 基目录中。
   操作: Oracle 建议将此主产品清单放置在 Oracle 基目录之外的位置中。
可以在以下位置找到本次安装会话的日志:
 /data/oracle/inventory/logs/installActions2019-11-01_01-14-53PM.log
Oracle Database 11g 的 安装 已成功。
请查看 '/data/oracle/inventory/logs/silentInstall2019-11-01_01-14-53PM.log' 以获取详细资料。

以 root 用户的身份执行以下脚本:
	1. /data/oracle/inventory/orainstRoot.sh
	2. /data/oracle/product/11.2.0/root.sh


Successfully Setup Software.

13、以静默方式配置监听

[oracle@Oracle ~]$ netca /silent /responseFile /home/oracle/response/netca.rsp 

正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /home/oracle/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle Net Services 配置:
完成概要文件配置。
Oracle Net 监听程序启动:
    正在运行监听程序控制: 
      /data/oracle/product/11.2.0/bin/lsnrctl start LISTENER
    监听程序控制完成。
    监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置。退出代码是0

14、以静默方式建库

[oracle@Oracle ~]$ vim /home/oracle/response/dbca.rsp
内容如下:
# oracle版本,不能更改
RESPONSEFILE_VERSION = "11.2.0"

# Description   : Type of operation
OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]

# Description   : Global database name of the database
# 全局数据库的名字=SID+主机域名
# 第三方工具链接数据库的时候使用的service名称
GDBNAME = "orcl"

# Description   : System identifier (SID) of the database
# 对应的实例名字
SID = "orcl"

# Description   : Name of the template
# 建库用的模板文件
TEMPLATENAME = "General_Purpose.dbc"

# Description   : Password for SYS user
# SYS管理员密码
SYSPASSWORD = "sys"

# Description   : Password for SYSTEM user
# SYSTEM管理员密码
SYSTEMPASSWORD = "system"

# Description   : Password for SYSMAN user
# SYSMAN管理员密码
SYSMANPASSWORD = "sysman"

# Description   : Password for DBSNMP user
# DBSNMP管理员密码
DBSNMPPASSWORD = "dbsnmp"

# Description   : Location of the data file's
# 数据文件存放目录
DATAFILEDESTINATION =/data/oracle/oradata

# Description   : Location of the data file's
# 恢复数据存放目录
RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area

# Description   : Character set of the database
# 字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。
# (CHARACTERSET = "AL32UTF8" NATIONALCHARACTERSET= "UTF8")
CHARACTERSET = "ZHS16GBK"

# Description   : total memory in MB to allocate to Oracle
# oracle内存1638MB,物理内存2G*80%
TOTALMEMORY = "1638" 

[oracle@Oracle ~]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp
复制数据库文件
1% 已完成
3% 已完成
11% 已完成
18% 已完成
26% 已完成
37% 已完成
正在创建并启动 Oracle 实例
40% 已完成
45% 已完成
50% 已完成
55% 已完成
56% 已完成
60% 已完成
62% 已完成
正在进行数据库创建
66% 已完成
70% 已完成
73% 已完成
85% 已完成
96% 已完成
100% 已完成
有关详细信息, 请参阅日志文件 "/data/oracle/cfgtoollogs/dbca/orcl/orcl.log"。

查看监听:

[oracle@Oracle ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-NOV-2019 13:59:13

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date                01-NOV-2019 13:18:20
Uptime                    0 days 0 hr. 40 min. 53 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/Oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle)(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

15、创建一个用户

[oracle@Oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 23 12:28:31 2019

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> CREATE USER kettle IDENTIFIED BY kettle;

User created.

SQL> grant dba to kettle;

Grant succeeded.

SQL> quit

16、异常处理

16.1 异常类型一

[oracle@Oracle database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。   实际为 11465 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 2047 MB    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2019-11-01_01-03-04PM. 请稍候...[oracle@Oracle database]$ [FATAL] PRVF-0002 : 无法检索本地节点名
此会话的日志当前已保存为: /tmp/OraInstall2019-11-01_01-03-04PM/installActions2019-11-01_01-03-04PM.log。如果要保留此日志, Oracle 建议将它从临时位置移动到更持久的位置。

解决方案:/etc/hosts里添加主机名

17、Oracle关闭

17.1、以SYS用户身份登录Oracle

[oracle@Oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 1 14:15:02 2019

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

17.2、关闭数据库

SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

17.3、关闭监听

[oracle@Oracle ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-NOV-2019 14:16:55

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully

18、Oracle启动

18.1、启动监听

[oracle@Oracle ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-NOV-2019 14:17:30

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

Starting /data/oracle/product/11.2.0/bin/tnslsnr: please wait...

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                01-NOV-2019 14:17:30
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/Oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle)(PORT=1521)))
The listener supports no services
The command completed successfully

18.2、查看监听状态

[oracle@Oracle ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-NOV-2019 14:18:17

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date                01-NOV-2019 14:17:30
Uptime                    0 days 0 hr. 0 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/Oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Oracle)(PORT=1521)))
The listener supports no services
The command completed successfully

18.3、以SYS用户身份登录Oracle

[oracle@Oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 1 14:19:09 2019

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

Connected to an idle instance.

SQL> 

18.4、启动数据库

SQL> startup
ORACLE instance started.

Total System Global Area 1286066176 bytes
Fixed Size		    2252904 bytes
Variable Size		  402657176 bytes
Database Buffers	  872415232 bytes
Redo Buffers		    8740864 bytes
Database mounted.
Database opened.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值