码迷,mamicode.com
首页 > 数据库 > 详细

oracle11g静默安装

时间:2020-04-12 16:49:46      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:number   _for   info   netstat   shmall   uri   ppa   hugepage   ISE   

  安装前的环境准备:Linux版本7.6,内核版本:3.10.0-957.el7.x86_64,如果没有swap交换分区,需要添加交换分区

dd if=/dev/zero of=/swap bs=1024 count=2048000
mkswap /swap
chmod 600 /swap
swapon /swap
echo "/swap swap swap default 0 0">>/etc/fstab  #设置成自动挂载

  修改主机名称:

    hostnamectl set-hostname oracledb
修改主机配置文件
vi /etc/hosts
    在末尾添加ip地址,主机名称
127.0.0.1     oracledb #此处ip可以为127.0.0.1,也可为192.168.xx.xx

技术图片

  关闭selinux

vi /etc/selinux/config
将SELINUX改为disabled

技术图片

   然后是安装oracle安装依赖

联网环境下:
yum -y install 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
未联网环境下:
yum install --downloadonly + --downloaddir=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
通过scp命令拷贝到目标主机
如:scp -r ./    root@192.168.xx.xx:/data/res/
进入res文件夹下执行安装
yum localinstall -y ./*
安装完成后,检查依赖是否安装成功
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 | grep "not installed"

  创建组合用户,将用户添加到组

groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba oracle
修改oracle用户密码
passwd oracle
输入两次密码

  修改内核参数

vi /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 8589934592
kernel.shmmni = 4096
kernel.sem = 1010 4136960 1010 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

net.ipv4.icmp_echo_ignore_broadcasts = 1
#开启反向路径过滤
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 6815744 #设置最大打开文件数
fs.aio-max-nr = 1048576
#所有内存大小(单位:页,1页 = 4Kb),计算公式8G*1024*1024*1024/4*1024(页)
kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024
#单个共享内存段的大小(单位:字节)限制,计算公式8G*1024*1024*1024(字节)
kernel.shmmax = 8589934592 #最大共享内存的段大小
kernel.shmmni = 4096 #整个系统共享内存端的最大数
#SEMMSL、SEMMNS、SEMOPM和SEMMNI
#数据库最大PROCESS+10  SEMMSL * SEMMNI SEMOPM等于SEMMSL   SEMMNI的值设置为不少于 100
kernel.sem = 5010 641280 5010 128
#增加系统IP端口限制
net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576

  使内核参数生效

sysctl -p

  修改所需软件硬件参数

vi /etc/security/limits.conf

*              soft     nproc   1024000
*              hard    nproc   1024000
*              soft     nofile    1024000
*              hard    nofile    1024000
此参数设定,在安装elasticsearch时就可以不用再修改
vi /etc/pam.d/login
末尾添加下面内容
session required /lib64/security/pam_limits.so
session required pam_limits.so
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


保存后,通过命令
source /etc/profile
生效

  禁用使用Transparent HugePages

查看是否启用 如果显示 [always]说明启用了
cat /sys/kernel/mm/transparent_hugepage/enabled
禁用Transparent HugePages,在/etc/grub.conf添加如下内容
echo never > /sys/kernel/mm/transparent_hugepage/enabled

然后重启系统reboot

  创建oracle安装目录

mkdir -p /data/app/
chown -R oracle:oinstall /data/app/
chmod -R 775 /data/app/

  配置oracle用户环境变量

vi  /home/oracle/.bash_profile
umask 022
export ORACLE_HOSTNAME=oracledb
export ORACLE_BASE=/data/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL=" en_US.UTF-8"
export LANG=" en_US.UTF-8"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
使生效
source /home/oracle/.bash_profile

重启系统reboot

  创建data文件夹,将oracle安装文件上传data文件夹

mkdir -p /data/etc
cd /data/
通过rz命令上传文件,没有rz命令可以执行
yum -y install lrzsz
然后解压文件
unzip -q linux.x64_11gR2_database_1of2.zip -d /data
unzip -q linux.x64_11gR2_database_2of2.zip -d /data

cp /data/database/response/* /data/etc/

  修改参数值

vi /data/etc/db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=oracledb
ORACLE_HOME=/data/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/data/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba

  开始安装oracle

su - oracle
cd /data/database
./runInstaller -silent -responseFile /data/etc/db_install.rsp -ignorePrereq

如果执行报没有足够权限,需要切换到root用户,修改文件执行权限
chmod  755 /data/database

  查看安装日志

tail -f /data/app/oracle/inventory/logs/installActionsxxxx-xx-xx_xx-xx-xxPM.log

  安装完成后终端界面会显示

The following configuration scripts need to be executed as the "root" user. 
#!/bin/sh 
#Root scripts to run

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window 
2. Log in as "root" 
3. Run the scripts 
4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

  切换到root用户执行脚本

su - root

sh /data/app/oracle/inventory/orainstRoot.sh
sh /data/app/oracle/product/11.2.0/db_1/root.sh

  配置监听器

su - oracle
netca /silent /responsefile /data/etc/netca.rsp

#输出结果
[oracle@oracledb ~]$ netca /silent /responsefile /data/etc/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /data/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control:
      /data/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
查看监听端口
netstat -tnpl | grep 1521

  创建数据库

vi  /data/etc/dbca.rsp

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/data/app/oracle/oradata
RECOVERYAREADESTINATION=/data/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "6553"
其中TOTALMEMORY ="1638" 为6553MB,物理内存8G*80%。

  开始建库

su - oracle
dbca -silent -responseFile /data/etc/dbca.rsp
执行过程如下
[oracle@oracledb ~]$ dbca -silent -responseFile /data/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 "/data/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
查看进程
ps -ef | grep ora_ | grep -v grep

# 执行结果
[oracle@oracledb ~]$ ps -ef | grep ora_ | grep -v grep
oracle   19304     1  0 18:33 ?        00:00:00 ora_pmon_orcl
oracle   19306     1  0 18:33 ?        00:00:00 ora_vktm_orcl
oracle   19310     1  0 18:33 ?        00:00:00 ora_gen0_orcl
oracle   19312     1  0 18:33 ?        00:00:00 ora_diag_orcl
oracle   19314     1  0 18:33 ?        00:00:00 ora_dbrm_orcl
oracle   19316     1  0 18:33 ?        00:00:00 ora_psp0_orcl
oracle   19318     1  0 18:33 ?        00:00:00 ora_dia0_orcl
oracle   19320     1  0 18:33 ?        00:00:00 ora_mman_orcl
oracle   19322     1  0 18:33 ?        00:00:00 ora_dbw0_orcl
oracle   19324     1  0 18:33 ?        00:00:00 ora_lgwr_orcl
oracle   19326     1  0 18:33 ?        00:00:00 ora_ckpt_orcl
oracle   19328     1  0 18:33 ?        00:00:00 ora_smon_orcl
oracle   19330     1  0 18:33 ?        00:00:00 ora_reco_orcl
oracle   19332     1  0 18:33 ?        00:00:00 ora_mmon_orcl
oracle   19334     1  0 18:33 ?        00:00:00 ora_mmnl_orcl
oracle   19336     1  0 18:33 ?        00:00:00 ora_d000_orcl
oracle   19338     1  0 18:33 ?        00:00:00 ora_s000_orcl
oracle   19361     1  0 18:34 ?        00:00:00 ora_qmnc_orcl
oracle   19376     1  0 18:34 ?        00:00:00 ora_cjq0_orcl
oracle   19396     1  0 18:34 ?        00:00:00 ora_q000_orcl
oracle   19398     1  0 18:34 ?        00:00:00 ora_q001_orcl
查看监听状态
$ lsnrctl status

#结果
[oracle@oracledb ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 02-JAN-2020 12:06:21

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                02-JAN-2020 11:50:45
Uptime                    0 days 0 hr. 15 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(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@oracledb ~]$

  到此数据库安装成功,但是可能还存在部分问题

su - oracle
sqlplus / as sysdba
select status from v$instance;
执行select时,全出现以下情况
SQL> select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
解决方式:
1.输入startup,
#startup的输出提示:
SQL> statup
SP2-0042: unknown command "statup" - rest of line ignored.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ‘/data/app/oracle/product/11.2.0/dbs/initORCL.ora‘

2.根据提示,将ORACLEBASE/admin/数据库名称/pfile目录下的init.ora.xxx形式的文件copy到 ORACLE_BASE/admin/数据库名称/pfile目录下的init.ora.xxx形式的文件copy到ORACLE 
BASE/admin/数据库名称/pfile目录下的init.ora.xxx形式的文件copy到ORACLE_HOME/dbs目录下initOracle.ora(根据startup提示)即可
cp /data/app/oracle/admin/orcl/pfile/init.ora.022019183329 initORCL.ora
查看数据库编码
select userenv(‘language‘) from dual;

# 输出结果:
SQL> select userenv(‘language‘) from dual;

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

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

#结果
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
激活scott用户
alter user scott account unlock;
alter user scott identified by tiger;
select username,account_status from dba_users;

ORA-01102: cannot mount database in EXCLUSIVE mode
GOOGLE一下,发现是lk<SID>文件造成的,该文件位于ORALCE_HOME下的dbs目录下,马上检查该文件:
[oracle@bgsbtsp0010-dqf:dbs]# fuser -u lkORCL11G 
/u01/app/oracle/product/11.2.0/db_1/dbs/lkORCL11G: 29365(oracle) 29371(oracle) 29375(oracle) 29377(oracle) 29381(oracle) 29383(oracle) 29385(oracle) 29387(oracle) 29389(oracle) 29391(oracle) 29393(oracle) 29395(oracle) 29397(oracle) 29399(oracle) 29455(oracle) 29490(oracle) 29576(oracle) 29578(oracle) 33195(oracle) 33218(oracle)
 
# 果然该文件没释放,用fuser命令kill掉:
[oracle@bgsbtsp0010-dqf:dbs]#  fuser -k lkORCL11G 
/u01/app/oracle/product/11.2.0/db_1/dbs/lkORCL11G: 29365 29371 29375 29377 29381 29383 29385 29387 29389 29391 29393 29395 29397 29399 29455 29490 29576 29578 33195 33218

然后:
SQL> shutdown   
ORA-01507: database not mounted
ORACLE instance shut down.
 
SQL> startup
ORACLE instance started.
 
Total System Global Area 1603411968 bytes
Fixed Size            2213776 bytes
Variable Size          402655344 bytes
Database Buffers     1191182336 bytes
Redo Buffers            7360512 bytes
Database mounted.
Database opened.

  修改密码不过期

SELECT * FROM dba_profiles s WHERE s.profile=‘DEFAULT‘ AND resource_name=‘PASSWORD_LIFE_TIME‘;
可以看到默认密码有效期是180天

技术图片

SQL>ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
修改为无限期

  设置数据库开启自启动

修改dbstart、dbshut文件
# $ORACLE_HOME/bin/dbshut是一样的,这里不重复了
[oracle@node1 ~]# vi $ORACLE_HOME/bin/dbstart
ORACLE_HOME_LISTNER=$1
修改为:
ORACLE_HOME_LISTNER=$ORACLE_HOME
修改/etc/oratab文件
#/data/app/oracle/product/11.2.0/db_1/这个是自己安装路径,只需要将N改为Y
[oracle@node1 ~]# vi /etc/oratab
orcl:/data/app/oracle/product/11.2.0/db_1/:N
修改为:
orcl:/data/app/oracle/product/11.2.0/db_1/:Y

把lsnrctl start和dbstart添加到rc.local文件中
#将下面两句加入到rc.local文件中,路径换成自己的;
oracle用户下如果没有权限可以切换到root用户
[root@node1 ~]# vi /etc/rc.d/rc.local
su - oracle -lc "/data/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"
su - oracle -lc "/data/app/oracle/product/11.2.0/db_1/bin/dbstart"

添加执行权限
[oracle@node1 ~]$ su root
[root@node1 ~]# chmod +x /etc/rc.d/rc.local

 

oracle11g静默安装

标签:number   _for   info   netstat   shmall   uri   ppa   hugepage   ISE   

原文地址:https://www.cnblogs.com/zhuifenglang/p/12685433.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!