oracle11g静默安装

系统 IP 安装软件
centos7.8 192.168.100.101 Oracle11g
1.在/etc/hosts文件中添加主机名、关闭selinux、关闭防火墙
[root@centos ~]# vi /etc/hosts
192.168.100.101 centos	
[root@centos ~]# vi /etc/selinux/config
SELINUX=disabled
[root@centos ~]# systemctl stop firewalld
[root@centos ~]# systemctl disable firewalld
2.上传安装包

安装包可自行提取
链接:https://pan.baidu.com/s/1chTrmweSGNRE7-Z-PJm_Bg
提取码:01ig

[root@centos soft]# ls
p13390677_112040_Linux-x86-64_1of7.zip  p13390677_112040_Linux-x86-64_2of7.zip
3.解压Oracle安装包
[root@centos soft]# unzip p13390677_112040_Linux-x86-64_1of7.zip -d /tmp && unzip p13390677_112040_Linux-x86-64_2of7.zip -d /tmp
等待解压完成后,会在目录下生产一个database文件夹,里面有Oracle 11g安装文件

在这里插入图片描述

4.安装依赖包
[root@centos ~]# yum install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y
5.添加用户和用户组
[root@centos ~]# groupadd oinstall
[root@centos ~]# groupadd dba
[root@centos ~]# useradd -g oinstall -G dba oracle
[root@centos ~]# passwd oracle	#这里密码设置为oracle
[root@centos ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) 组=1000(oinstall),1001(dba)
6.修改内核参数配置文件
添加以下内容
[root@centos ~]# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 2147483648
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@centos ~]# sysctl -p

其中kernel.shmmax = 2147483648为本机物理内存的一半,单位为byte,我这里是4G内存
7.修改用户的限制文件
[root@centos ~]# vi /etc/security/limits.conf
添加以下内容
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536
oracle           soft    stack           10240

修改/etc/pam.d/login文件
[root@centos ~]# vi /etc/pam.d/login
添加以下内容
session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so

修改/etc/profile文件
[root@centos ~]# 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
[root@centos ~]# source /etc/profile
8.创建安装目录和设置文件权限
[root@centos ~]# mkdir -p /u01/app/oracle/product/11.2.0
[root@centos ~]# mkdir /u01/app/oracle/oradata
[root@centos ~]# mkdir /u01/app/oracle/inventory
[root@centos ~]# mkdir /u01/app/oracle/fast_recovery_area
[root@centos ~]# chown -R oracle:oinstall /u01/app/oracle
[root@centos ~]# chmod -R 775 /u01/app/oracle
[root@centos ~]# dd if=/dev/zero of=/home/swapfile bs=1M count=512
[root@centos ~]# mkswap /home/swapfile
[root@centos ~]# swapon /home/swapfile
[root@centos ~]# vi /etc/fstab		#追加
/home/swapfile swap swap defaults 0 0
9.设置oracle用户环境变量
[root@centos ~]# su - oracle
[oracle@centos ~]$ vi .bash_profile
添加内容如下:
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=jcms		#其中实例名自建
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

[oracle@centos ~]$ source .bash_profile
10.编辑静默安装响应文件
[oracle@centos ~]$ cp -R /tmp/database/response/ .
[oracle@centos ~]$ cd response/
[oracle@centos response]$ vi db_install.rsp
29 oracle.install.option=INSTALL_DB_SWONLY
37 ORACLE_HOSTNAME=centos
42 UNIX_GROUP_NAME=oinstall
49 INVENTORY_LOCATION=/u01/app/oracle/inventory
86 SELECTED_LANGUAGES=en,zh_CN
91 ORACLE_HOME=/u01/app/oracle/product/11.2.0
96 ORACLE_BASE=/u01/app/oracle
107 oracle.install.db.InstallEdition=EE
154 oracle.install.db.DBA_GROUP=dba
160 oracle.install.db.OPER_GROUP=dba
400 DECLINE_SECURITY_UPDATES=true
11.根据响应文件静默安装Oracle 11g
[oracle@centos response]$ cd /tmp/database/
[oracle@centos database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
执行开始会有一点时间没反应,稍等会就ok了,Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。

可以在以下位置找到本次安装会话的日志:
/u01/app/oracle/inventory/logs/installActions…log
可以切换终端执行top命令查看后台进程一直是在安装的,/u01目录也在不断增大
oracle11g静默安装_第1张图片

按照要求新打开终端,以root身份登录,执行脚本:

[root@centos ~]# sh /u01/app/oracle/inventory/orainstRoot.sh
[root@centos ~]#  sh /u01/app/oracle/product/11.2.0/root.sh

oracle11g静默安装_第2张图片

12.以静默方式配置监听
[oracle@centos database]$ netca /silent /responsefile /home/oracle/response/netca.rsp

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

成功运行后,在/u01/app/oracle/product/11.2.0/network/admin/中生成listener.ora和sqlnet.ora
通过netstat命令可以查看1521端口正在监听。
[oracle@centos database]$ netstat -tnulp | grep 1521
tcp        0      0 0.0.0.0:1521            0.0.0.0:*               LISTEN      4861/tnslsnr 
13.以静默方式建立新库,同时也建立一个对应的实例。
[oracle@centos database]$ vi /home/oracle/response/dbca.rsp
78 GDBNAME = "jcms"
170 SID = "jcms"
211 SYSPASSWORD = "oracle"
221 SYSTEMPASSWORD = "oracle"
252 SYSMANPASSWORD = "oracle"
262 DBSNMPPASSWORD = "oracle"
360 DATAFILEDESTINATION = /u01/app/oracle/oradata
370 RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area
418 CHARACTERSET = "ZHS16GBK"
553 TOTALMEMORY = "3276"

其中TOTALMEMORY = "3276" 为3276MB,物理内存4G*80%
14.进行静默配置
[oracle@centos database]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp
复制数据库文件
1% 已完成
3% 已完成
11% 已完成
18% 已完成
37% 已完成
正在创建并启动 Oracle 实例
40% 已完成
45% 已完成
50% 已完成
55% 已完成
56% 已完成
60% 已完成
62% 已完成
正在进行数据库创建
66% 已完成
70% 已完成
73% 已完成
85% 已完成
96% 已完成
100% 已完成
有关详细信息, 请参阅日志文件 "/u01/app/oracle/cfgtoollogs/dbca/jcms/jcms.log"。

查看监听状态
[oracle@centos database]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 03-APR-2022 12:44:44

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                03-APR-2022 12:24:09
Uptime                    0 days 0 hr. 20 min. 35 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/centos/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)	(KEY=EXTPROC1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos)(PORT=1521)))
Services Summary...
Service "jcms" has 1 instance(s).
 Instance "jcms", status READY, has 1 handler(s) for this service...
Service "jcmsXDB" has 1 instance(s).
 Instance "jcms", status READY, has 1 handler(s) for this service...
The command completed successfully

登录查看实例状态
[oracle@centos database]$  sqlplus / as sysdba
SQL> select status from v$instance;

STATUS
------------
OPEN
15.创建用户表空间,给予权限,用plsql工具连接
SQL> CREATE TABLESPACE test_data LOGGING DATAFILE '/u01/app/oracle/oradata/jcms/jcms01.dbf'  SIZE 32M  AUTOEXTEND ON  NEXT 32M MAXSIZE 2048M EXTENT MANAGEMENT LOCAL;
Tablespace created.
SQL> CREATE USER jcms IDENTIFIED BY 12345678 DEFAULT TABLESPACE TEST_DATA ;

User created.
SQL> GRANT dba TO jcms;

Grant succeeded.

oracle11g静默安装_第3张图片
命令验证:
oracle11g静默安装_第4张图片

16.Oracle开机自启动设置
1.修改/u01/app/oracle/product/11.2.0/bin/dbstart
[oracle@centos ~]$ vi /u01/app/oracle/product/11.2.0/bin/dbstart
将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME

2.修改/u01/app/oracle/product/11.2.0/bin/dbshut
[oracle@centos ~]$ vi /u01/app/oracle/product/11.2.0/bin/dbshut
将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME

3.修改/etc/oratab文件
将jcms:/u01/app/oracle/product/11.2.0:N中最后的N改为Y,成为jcms:/u01/app/oracle/product/11.2.0:Y

4.输入命令dbshut和dbstart测试
[oracle@centos ~]$ dbshut
Processing Database instance "jcms": log file /u01/app/oracle/product/11.2.0/shutdown.log
[oracle@centos ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 03-APR-2022 14:53:34

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)	(HOST=centos)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@centos ~]$ ps -ef |grep ora_ |grep -v grep
[oracle@centos ~]$
Oracle监听停止,进程消失

[oracle@centos ~]$ dbstart
Processing Database instance "jcms": log file /u01/app/oracle/product/11.2.0/startup.log
[oracle@centos ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 03-APR-2022 14:55:50

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                03-APR-2022 14:55:06
Uptime                    0 days 0 hr. 0 min. 43 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/centos/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos)(PORT=1521)))
Services Summary...
Service "jcms" has 1 instance(s).
Instance "jcms", status READY, has 1 handler(s) for this service...
Service "jcmsXDB" has 1 instance(s).
Instance "jcms", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@centos ~]$ ps -ef |grep ora_ |grep -v grep 
oracle    24136      1  0 14:55 ?        00:00:00 ora_pmon_jcms
oracle    24140      1  0 14:55 ?        00:00:00 ora_psp0_jcms
oracle    24144      1  1 14:55 ?        00:00:00 ora_vktm_jcms
oracle    24150      1  0 14:55 ?        00:00:00 ora_gen0_jcms
oracle    24154      1  0 14:55 ?        00:00:00 ora_diag_jcms
oracle    24158      1  0 14:55 ?        00:00:00 ora_dbrm_jcms
oracle    24162      1  0 14:55 ?        00:00:00 ora_dia0_jcms
oracle    24166      1  0 14:55 ?        00:00:00 ora_mman_jcms
oracle    24170      1  0 14:55 ?        00:00:00 ora_dbw0_jcms
oracle    24174      1  0 14:55 ?        00:00:00 ora_lgwr_jcms
oracle    24178      1  0 14:55 ?        00:00:00 ora_ckpt_jcms
oracle    24182      1  0 14:55 ?        00:00:00 ora_smon_jcms
oracle    24186      1  0 14:55 ?        00:00:00 ora_reco_jcms
oracle    24190      1  0 14:55 ?        00:00:00 ora_mmon_jcms
oracle    24194      1  0 14:55 ?        00:00:00 ora_mmnl_jcms
oracle    24198      1  0 14:55 ?        00:00:00 ora_d000_jcms
oracle    24202      1  0 14:55 ?        00:00:00 ora_s000_jcms
oracle    24224      1  0 14:55 ?        00:00:00 ora_qmnc_jcms
oracle    24332      1  0 14:55 ?        00:00:00 ora_q000_jcms
oracle    24336      1  0 14:55 ?        00:00:00 ora_q001_jcms
oracle    24340      1  0 14:55 ?        00:00:00 ora_cjq0_jcms
Oracle监听启动,进程启动

5.切换到root账户建立自启动脚本
[root@centos ~]# vi /etc/rc.d/init.d/oracle
#!/bin/bash

# oracle: Start/Stop Oracle Database 11g R2
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
 . /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0
ORACLE_USER=oracle
case "$1" in
'start')
 if [ -f $LOCKFILE ]; then
  echo $0 already running.
  exit 1
 fi
echo -n $"Starting Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE
 ;;
'stop')
if [ ! -f $LOCKFILE ]; then
  echo $0 already stopping.
  exit 1
fi
echo -n $"Stopping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
;;
'restart')
$0 stop
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
  echo $0 started.
  else
  echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|status]"
exit 1
esac
exit 0

[root@centos ~]# chmod 755 /etc/rc.d/init.d/oracle
[root@centos ~]# chkconfig oracle on
[root@centos ~]# chkconfig --list oracle
oracle         	0:关	1:关	2:开	3:开	4:开	5:开	6:关

service oracle start/stop/restart测试
[root@centos ~]# service oracle stop
Stopping oracle (via systemctl):                           [  确定  ]
[root@centos ~]# service oracle status
/etc/init.d/oracle stopped.

reboot重启查看Oracle监听和实例进程均能自动启动

你可能感兴趣的:(运维,oracle)