环境:Centos7、linux.x64_11gR2_database_1of2.zip、linux.x64_11gR2_database_2of2.zip

准备工作

1.关闭防火墙

[root@centos7 ~]# systemctl stop firewalld && systemctl disable firewalld

2.关闭selinux

[root@centos7 ~]# vim /etc/selinux/config
设置
SELINUX=disabled

3.安装相关依赖

[root@centos7 ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

# 确认所有包都安装成功
[root@centos7 ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst  make sysstat  unixODBC unixODBC-devel
binutils-2.27-44.base.el7.x86_64
compat-libcap1-1.10-7.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.i686
gcc-4.8.5-44.el7.x86_64
gcc-c++-4.8.5-44.el7.x86_64
glibc-2.17-324.el7_9.x86_64
glibc-2.17-324.el7_9.i686
glibc-devel-2.17-324.el7_9.x86_64
glibc-devel-2.17-324.el7_9.i686
ksh-20120801-142.el7.x86_64
libaio-0.3.109-13.el7.x86_64
libaio-0.3.109-13.el7.i686
libaio-devel-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.i686
libgcc-4.8.5-44.el7.x86_64
libgcc-4.8.5-44.el7.i686
libstdc++-4.8.5-44.el7.x86_64
libstdc++-4.8.5-44.el7.i686
libstdc++-devel-4.8.5-44.el7.x86_64
libstdc++-devel-4.8.5-44.el7.i686
libXi-1.7.9-1.el7.x86_64
libXi-1.7.9-1.el7.i686
libXtst-1.2.3-1.el7.x86_64
libXtst-1.2.3-1.el7.i686
make-3.82-24.el7.x86_64
sysstat-10.1.5-19.el7.x86_64
unixODBC-2.3.1-14.el7.x86_64
unixODBC-2.3.1-14.el7.i686
unixODBC-devel-2.3.1-14.el7.x86_64
unixODBC-devel-2.3.1-14.el7.i686

4.创建用户和组

[root@centos7 ~]# groupadd oinstall
[root@centos7 ~]# groupadd dba
[root@centos7 ~]# useradd -g oinstall -G dba oracle
# 修改密码
[root@centos7 ~]# passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

5.修改内核参数

[root@centos7 ~]# vim /etc/sysctl.conf
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=524288
kernel.shmmax=2147483647
kernel.sem=250 32000 100 128
kernel.shmmni=4096
kernel.panic_on_oops=1
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048576
net.ipv4.conf.all.rp_filter=2
net.ipv4.conf.default.rp_filter=2
fs.aio-max-nr=1048576
net.ipv4.ip_local_port_range=9000 65500

# 使配置文件生效
[root@centos7 ~]# sysctl -p

6.修改其它配置

# 6.1 修改limits.conf 在文件末尾增加
[root@centos7 ~]# 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
oracle hard stack 10240
# 第1行是设置进程数软限制;
# 第2行是设置进程数硬限制;
# 第3行是设置文件数软限制;
# 第4行是设置文件数硬限制



# 6.2 修改login ,在文件末尾增加
[root@centos7 ~]# vim /etc/pam.d/login

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



# 6.3 修改 profile,在文件末尾添加以下内容
if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384 ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
fi
# 使配置文件生效
[root@centos7 ~] source /etc/profile



# 6.4创建数据库目录
[root@centos7 ~]# mkdir -p /database/oracle
[root@centos7 ~]# chown -R oracle:oinstall /database/oracle/ 
[root@centos7 ~]# chmod -R 775 /database/oracle/



# 6.5切换到Oracle用户下
[root@centos7 ~]# su - oracle
# 在文件末尾添加
[oracle@centos7 ~]$ vim ~/.bash_profile
export ORACLE_BASE=/database/oracle/oracle
export ORACLE_SID=orcl
# 使配置文件生效
[oracle@centos7 ~]$ source ~/.bash_profile

安装部署及配置

1.创建文件夹并上传Oracle安装包(Oracle用户下)

[oracle@centos7 ~]# mkdir /home/oracle/oradb

2.如果没有解压工具的话,需要先安装解压工具(root用户下)

yum install -y unzip zip

3.解压缩包

4.复制模板,为了不影响原来的文件内容(后面文件脚本内容会作修改)

[oracle@centos7 ~]$ mkdir etc
[oracle@centos7 ~]$ cp /home/oracle/oradb/database/response/* /home/oracle/etc/

# 切换为root ,进行权限设置
[oracle@centos7 etc]$ su - root
Password: 
Last login: Thu Jun 24 10:19:06 EDT 2021 on pts/0
[root@centos7 ~] chmod 700 /home/oracle/etc/*.rsp

5.修改db_install.rsp文件

[oracle@centos7 ~]$ vim /home/oracle/etc/db_install.rsp
# 修改以下内用,不同版本的Oracle,可能所在行数不一样
29 oracle.install.option=INSTALL_DB_SWONLY
42 UNIX_GROUP_NAME=oinstall
47 INVENTORY_LOCATION=/database/oracle/oraInventory
83 ORACLE_HOME=/database/oracle/oracle/product/11g/db_1
88 ORACLE_BASE=/database/oracle/oracle
99 oracle.install.db.InstallEdition=EE
142 oracle.install.db.DBA_GROUP=dba
147 oracle.install.db.OPER_GROUP=oinstall
160 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE 
165 oracle.install.db.config.starterdb.globalDBName=orcl
170 oracle.install.db.config.starterdb.SID=orcl
200 oracle.install.db.config.starterdb.memoryLimit=81920
233 oracle.install.db.config.starterdb.password.ALL=oracle
238 oracle.install.db.config.starterdb.password.SYS=oracle
243 oracle.install.db.config.starterdb.password.SYSTEM=oracle
248 oracle.install.db.config.starterdb.password.SYSMAN=oracle
253 oracle.install.db.config.starterdb.password.DBSNMP=oracle
376 SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
385 DECLINE_SECURITY_UPDATES=true

6.开始安装,等待执行完毕,如下图

[oracle@centos7 database]$ cd /home/oracle/oradb/database/

[oracle@centos7 database]$ ./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion -silent -responseFile /home/oracle/etc/db_install.rsp

注意:-showProgress Oracle11g貌似没有这个命令

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

执行完毕后,要切换到root用户下,执行这个两个脚本(安装过程中自动生成,无需手动生成)

/database/oracle/oraInventory/orainstRoot.sh

/database/oracle/oracle/product/11g/db_1/root.sh

7.配置环境变量

[oracle@centos7 ~]$ vim ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export ORACLE_BASE=/database/oracle/oracle
export ORACLE_SID=orcl
export ROACLE_PID=oral11
export ORACLE_HOME=$ORACLE_BASE/product/11g/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=$PATH:$ORACLE_HOME/bin
export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'

# 使配置文件生效
[oracle@centos7 ~]$ source ~/.bash_profile

8.创建监听,执行如下命令,等待执行完毕如下图

[oracle@centos7 ~]$ netca /silent /responsefile /home/oracle/etc/netca.rsp

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

9.修改静默建库文件,并执行建库命令,等待创建完毕如下图

# 修改静默建库文件
[oracle@centos7 ~]$ vim /home/oracle/etc/dbca.rsp
78 GDBNAME = "orcl"
149 SID = "orcl"
472 #LISTENERS = "listener1 listener2"
473 LISTENERS="listener"
511 #MEMORYPERCENTAGE = "40"
532 AUTOMATICMEMORYMANAGEMENT = "FALSE"
541 TOTALMEMORY = "0"
416 CHARACTERSET = "AL32UTF8"


# 执行静默建库
[oracle@centos7 ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName orcl -sysPassword oracle -systemPassword oracle

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

查看日志

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

10.优化sqlplus

# 在最后增加 stty erase ^h
[oracle@centos7 ~]$ vim ~/.bash_profile 

# 刷新配置文件
[oracle@centos7 ~]$ source ~/.bash_profile

11.修改listener.ora

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

12.修改tnsnames.ora

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = centos7)(PORT = 1521))

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = centos7)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = centos7)(PORT = 1521))

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.119.140)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

13.重新装载监听、重启Oracle实例

# 重新加载监听
[oracle@centos7 ~]$ lsnrctl reload

# 重启数据库实例
[oracle@centos7 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 6月 24 12:47:34 2021

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


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

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  826753024 bytes
Fixed Size		    2217872 bytes
Variable Size		  486541424 bytes
Database Buffers	  331350016 bytes
Redo Buffers		    6643712 bytes
Database mounted.
Database opened.

14.登录测试

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0dyZWF0RXhwZWN0YXRpb25z,size_16,color_FFFFFF,t_70

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐