静默安装oracle11g

1、查看交换分区情况

[root@VM-0-7-centos database]# free
              total        used        free      shared  buff/cache   available
Mem:        1860868      187256       90348        1964     1583264     1503652
Swap:       2006420         268     2006152

如果swap分区大小为0,则执行下面命令

[root@VM-0-7-centos database]# dd if=/dev/zero of=/swapadd bs=1024 count=2006424
[root@VM-0-7-centos database]# mkswap /swapadd
[root@VM-0-7-centos database]# swapon /swapadd
[root@VM-0-7-centos database]# free

重启系统后,swap交换分区会消失,建议写在配置文件 /etc/fstab

[root@VM-0-7-centos database]# vim /etc/fstab
#添加如下配置
/swap swap swap defaults 0 0 

2、查看主机名,selinux,防火墙情况,后续会用到

[root@VM-0-7-centos database]# hostname
lyl

[root@VM-0-7-centos database]# getenforce 
Disabled
[root@VM-0-7-centos database]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset>
   Active: inactive (dead)
     Docs: man:firewalld(1)
lines 1-4/4 (END)

安装下面的包,已安装可以忽略 (软件目录下还有三个包)

binutils-2.23.52.0.1-12.el7.x86_64 
compat-libcap1-1.10-3.el7.x86_64 
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64 
gcc-c++-4.8.2-3.el7.x86_64 
glibc-2.17-36.el7.i686 
glibc-2.17-36.el7.x86_64 
glibc-devel-2.17-36.el7.i686 
glibc-devel-2.17-36.el7.x86_64 
ksh
libaio-0.3.109-9.el7.i686 
libaio-0.3.109-9.el7.x86_64 
libaio-devel-0.3.109-9.el7.i686 
libaio-devel-0.3.109-9.el7.x86_64 
libgcc-4.8.2-3.el7.i686 
libgcc-4.8.2-3.el7.x86_64 
libstdc++-4.8.2-3.el7.i686 
libstdc++-4.8.2-3.el7.x86_64 
libstdc++-devel-4.8.2-3.el7.i686 
libstdc++-devel-4.8.2-3.el7.x86_64 
libXi-1.7.2-1.el7.i686 
libXi-1.7.2-1.el7.x86_64 
libXtst-1.2.2-1.el7.i686 
libXtst-1.2.2-1.el7.x86_64 
make-3.82-19.el7.x86_64 
sysstat-10.1.5-1.el7.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.3.1-6.el7.i686 or later

若担心系统包比较旧可考虑先更新程序包:yum -y upgrade,(提示:等待时间比较长!)

用yum进行安装所需服务:

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

检查31个包是否都有安装,版本号只能大于规定的版本

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

创建oracle用户和oinstall,dba的组

[root@VM-0-7-centos database]# groupadd oinstall
[root@VM-0-7-centos database]# groupadd dba
[root@VM-0-7-centos database]# 
[root@VM-0-7-centos database]# useradd -g oinstall -G dba oracle
[root@VM-0-7-centos database]# echo oracle | passwd --stdin oracle
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
[root@VM-0-7-centos database]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)

配置内核参数

最后面添加如下参数

[root@VM-0-7-centos database]# vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 7516192768 #7G
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@VM-0-7-centos database]# /sbin/sysctl -p

参数含义

shmmax=物理内存*80%*80%,单位是字节
kernel.shmmax:表示单个共享内存段的最大值,以字节为单位,此值一般为物理内存的一半,不过大一点也没关系,这里设定的为4GB,即“4294967295/1024/1024/1024=4G”。
kernel.shmmin:表示单个共享内存段的最小值,默认为1byte
kernel.shmall:表示整个系统范围内可用共享内存页的总量,单位是页(page),在32位系统上一页等于4kB,也就是4096字节。计算公式是:shmmax/PAGE_SIZE
kernel.shmmni:表示整个系统范围内内存段的最大数量,一般为4096.
ip_local_port_range  :表示端口的范围。在监听器帮助客户端进程和服务器进程建立连接时,会用到指定范围内的端口。
kernel.sem  :表示设置的信号量,这4个参数内容大小固定。
net.core.rmem_default  :表示接收套接字缓冲区大小的缺省值(以字节为单位)。
net.core.rmem_max  :表示接收套接字缓冲区大小的最大值(以字节为单位)
net.core.wmem_default  :表示发送套接字缓冲区大小的缺省值(以字节为单位)。
net.core.wmem_max  :表示发送套接字缓冲区大小的最大值(以字节为单位)。

修改用户的权限

[root@VM-0-7-centos database]# 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

修改/etc/pam.d/login文件

[root@VM-0-7-centos database]# vim /etc/pam.d/login
#末尾添加
session required /lib64/security/pam_limits.so
session required pam_limits.so

修改/etc/profile文件

[root@VM-0-7-centos database]# vim /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

配置生效

[root@VM-0-7-centos database]# source /etc/profile

创建安装目录

[root@VM-0-7-centos database]# mkdir -p /u01/app/oracle/product/11.2.0
[root@VM-0-7-centos database]# mkdir /u01/app/oracle/inventory
[root@VM-0-7-centos database]# mkdir /u01/app/oracle/fast_recovery_area
[root@VM-0-7-centos database]# mkdir /u01/app/oracle/oradata
[root@VM-0-7-centos database]# chown -R oracle:oinstall /u01/app/
[root@VM-0-7-centos database]# chmod -R 775 /u01/app/oracle/

配置oracle用户的环境变量

[oracle@VM-0-7-centos ~]$ vim ~/.bash_profile
#末尾添加 
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export PATH=$PATH:$ORACLE_HOME/bin

配置生效

[oracle@VM-0-7-centos ~]$ source ~/.bash_profile

修改软件包的目录归属

[root@VM-0-7-centos ~]# chown -R oracle:oinstall /mnt/database
[root@VM-0-7-centos ~]# chmod -R 775 /mnt/database

修改安装oracle软件的响应文件

[root@lyl ~]# su - oracle
Last login: Wed Oct 20 14:24:45 CST 2021 on pts/0
[oracle@lyl ~]$ 
[oracle@lyl ~]$ vim /mnt/database/response/db_install.rsp 
oracle.install.option=INSTALL_DB_SWONLY     // 安装类型
ORACLE_HOSTNAME=docker        // 主机名称(hostname查询得到的)
UNIX_GROUP_NAME=oinstall     // 安装组,和上面创建的组一致
ORACLE_BASE=/u01/app/oracle
ORACLE_home=/u01/app/oracle/product/11.2.0
SELECTED_LANGUAGES=en,zh_CN   // 选择语言
oracle.install.db.DBA_GROUP=dba /  / dba用户组
oracle.install.db.OPER_GROUP=oinstall // oper用户组
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=orcl      //SID,与前面的SID要一致
oracle.install.db.config.starterdb.password.ALL=oracle //设定所有数据库用户使用同一个密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false      
DECLINE_SECURITY_UPDATES=true 

检查一下是否安装了Java的jdk

[root@lyl ~]# java -version
openjdk version "1.8.0_302"
#若没有执行下面操作查一个jdk的包,yum装一下,第一个就行
[root@lyl ~]# yum search java| grep jdk
Last metadata expiration check: 0:35:24 ago on Wed 20 Oct 2021 02:23:39 PM CST.
openjdk-asmtools-javadoc.noarch : Javadoc for openjdk-asmtools
java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK 8 accessibility connector
java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos
。。。。。。

开始静默安装

[oracle@lyl ~]$ /mnt/database/runInstaller -silent -responseFile /mnt/database/response/db_install.rsp 

我这安装时有下面的报错,解决该问题只需用root安装libnsl这个包就能解决

Please check your installation, HotSpot does not work correctly
when installed in the JDK 1.2 Linux Production Release, or
with any JDK 1.1.x release.
Could not create the Java virtual machine.

还出现过下面的情况,看着是目录的权限的问题,用root修改/data目录的所有者和所属组为oracle:oinstall

[oracle@lyl ~]$ /mnt/database/runInstaller -silent -responseFile /mnt/database/response/db_install.rsp 
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 37355 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 1942 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2021-10-20_03-03-21PM. Please wait ...
 [FATAL] [INS-32012] Unable to create directory: /u01/app/oracle.
   CAUSE: Either proper permissions were not granted to create the directory or there was no space left in the volume.
   ACTION: Check your permission on the selected directory or choose another directory.
[FATAL] [INS-32012] Unable to create directory: /u01/app/oracle/product/11.2.0.

修改目录权限

[root@lyl ~]# chown -R oracle:oinstall /u01/app

有以下提示说明安装完成,你可以查看提示的日志文件

The installation of Oracle Database 11g was successful.
Please check '/u01/app/oracle/inventory/logs/silentInstall2021-10-20_03-08-48PM.log' for more details.
As a root user, execute the following script(s):
	1. /u01/app/oracle/inventory/orainstRoot.sh
	2. /u01/app/oracle/product/11.2.0/root.sh
Successfully Setup Software.

用root执行脚本文件

[root@lyl ~]# /u01/app/oracle/inventory/orainstRoot.sh
 
Changing permissions of /data/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /data/oracle/inventory to oinstall.
The execution of the script is complete.

[root@lyl ~]# /u01/app/oracle/product/11.2.0/root.sh 

Check /u01/app/oracle/product/11.2.0/install/root_lyl_2021-10-20_15-19-01.log for the output of root script

配置监听,netca.rsp文件是传到oracle用户的文件

[oracle@lyl ~]$ netca -silent -responsefile /mnt/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /mnt/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

查看监听

[oracle@lyl ~]$ lsnrctl start 
[oracle@lyl ~]$ lsnrctl status
初始化数据库实例

编辑dbca建库文件

[oracle@lyl ~]$ vim /mnt/database/response/dbca.rsp

[CREATEDATABASE]
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"
[oracle@lyl ~]$ dbca -silent -responsefile /mnt/database/response/dbca.rsp

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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
登录数据库
[oracle@lyl ~]$ sqlplus / as sysdba

创建用户并授权

create user aa identified by 123456
grant connect,resource to aa

远程连接时可能存在的问题
当一切都部署完成后还是不能访问的时候,可能是 /etc/hosts没有配置

127.0.0.1 VM-0-7-centos VM-0-7-centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 VM-0-7-centos VM-0-7-centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
172.21.0.7 localhost localhost
127.0.0.1 lyl lyl     ###lyl是主机名,这一条一定要写

当不写时lsnrctl status查看监听时HOST是127.0.0.1
写上这一条lsnrctl status 查看监听HOST是主机名 lyl

Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) ##ip回环地址
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lyl)(PORT=1521)))  ##主机名
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值