开发者社区> 数据库> 正文

Oracle 11g R2安装文档

简介: Oracle 安装文档

一、基本配置要求

  在安装前需进行内存、系统架构以及磁盘的检查,具体请参考官方文档:https://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#i1011296

二、安装步骤

1、在/etc/hosts文件中添加本机IP跟主机名

[root@xsj ~]# cat /etc/hosts
127.0.0.1 localhost  localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.19.56.136 xsj  xsj

2、关闭selinux,编辑vim /etc/sysconfig/selinux文件,将SELINUX设置为SELINUX=disabled

[root@xsj ~]# cat /etc/sysconfig/selinux

# 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

3、关闭防火墙

[root@xsj ~]# systemctl stop firewalld #停止防火墙
[root@xsj ~]# systemctl disable firewalld #关闭自启动防火墙服务
[root@xsj ~]# systemctl status firewalld #查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

4、安装Oracle 11g依赖包

yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

5、添加oinstall 、dba 组,新建oracle用户并加入oinstall、dba组中;

[root@xsj ~]# groupadd oinstall #创建用户组
[root@xsj ~]# groupadd dba #创建用户组
[root@xsj ~]# useradd -g oinstall -G dba oracle #建立用户,设置属组
[root@xsj ~]# passwd oracle #设置oracle用户密码
[root@xsj ~]# id oracle #确认信息

6、修改内核参数:编辑 /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
让参数生效:sysctl –p

7、修改用户的限制文件,编辑 /etc/security/limits.conf

添加以下配置:
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536
oracle           soft    stack           10240

8、修改/etc/pam.d/login文件,添加:

session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so

9、修改/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

10、创建安装目录、修改文件权限

[root@xsj ~]# mkdir -p /u01/app/oracle/product/11.2.0
[root@xsj ~]# mkdir /u01/app/oracle/oradata
[root@xsj ~]# mkdir /u01/app/oracle/inventory
[root@xsj ~]# mkdir /u01/app/oracle/fast_recovery_area
[root@xsj ~]# chown -R oracle:oinstall /u01/app/oracle
[root@xsj ~]# chmod -R 775 /u01/app/oracle

11、解压oracle软件包:

[root@xsj tmp]# unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip

12、切换到oracle用户,设置oracle用户环境变量

[root@xsj database]# su - oracle
[oracle@xsj ~]$ vim .bash_profile
ORACLE_BASE=/u01/app/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

13、编辑静默安装响应文件
(1)切换到root用户进入oracle安装包解压后的目录 /tmp/database/response/下备份db_install.rsp文件。
(2)编辑 /tmp/database/response/db_install.rsp文件

修改以下参数:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=xsj
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true

14、根据响应文件安装oracle 11g

[oracle@xsj database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp

  Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
  此时再打开另外一个终端选项卡,输入提示的会话日志目录:

[root@xsj ~]# tail –f /u01/app/oracle/inventory/logs/installActions2019-08-12_10-31-49PM.log

  看到日志文件会持续输出安装信息没有输入异常信息,则表明安装过程正常;直到输出运行脚本提示以及Successfully Setup Software。
  按照提示切换root用户运行脚本

[oracle@xsj database]$ su
[root@xsj database]# sh /u01/app/oracle/inventory/orainstRoot.sh
[root@xsj database]# sh /u01/app/oracle/product/11.2.0/root.sh

15、切换为oracle用户配置监听

[oracle@xsj ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp

  出现DISPLAY environment variable not set,则需要配置DISPLAY变量,配完之后重新netca:

[oracle@xsj ~]$ export DISPLAY=localhost:0.0

  成功运行后,会在/u01/app/oracle/product/11.2.0/network/admin/ 中生成listener.ora和sqlnet.ora两个文件。

#查看监听端口
[root@xsj admin]# netstat -tnulp | grep 1521

16、建立新库,同时建立对应的实例
  切换到root用户,编辑 /tmp/database/response/dbca.rsp

#修改以下参数:
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"

17、切换到oracle用户进行静默配置

su - oracle
[oracle@xsj ~]$ dbca -silent -responseFile /tmp/database/response/dbca.rsp

18、完成建库后进行实例检查

[oracle@xsj ~]$ ps -ef | grep ora_ | grep -v grep

查看监听状态

[oracle@xsj ~]$ lsnrctl status

登录查看实例状态

[oracle@xsj dbs]$ sqlplus / as sysdba
SQL> startup
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size            2220200 bytes
Variable Size          281022296 bytes
Database Buffers      780140544 bytes
Redo Buffers            5554176 bytes
Database mounted.
Database opened.
SQL> select INSTANCE_NAME from v$instance;

INSTANCE_NAME
----------------
orcl

  安装完成!

版权声明:本文中所有内容均属于阿里云开发者社区所有,任何媒体、网站或个人未经阿里云开发者社区协议授权不得转载、链接、转贴或以其他方式复制发布/发表。申请授权请邮件developerteam@list.alibaba-inc.com,已获得阿里云开发者社区协议授权的媒体、网站,在转载使用时必须注明"稿件来源:阿里云开发者社区,原文作者姓名",违者本社区将依法追究责任。 如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:developer2020@service.aliyun.com 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
上一篇:Redis数据迁移与校验 下一篇:MySQL8.0之快速加列
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

其他文章