Oracle 数据库静默安装
Oracle 数据库静默安装
0.静默安装是什么
Oracle数据库安装方式有图形界面点击下一步下一步安装,也有在命令行下安装。
静默安装就是没有图形界面,在命令行字符终端界面进行安装
。
1.环境介绍
主机名: SZ-V-L-ODB-20
IP地址: 192.168.100.20
数据库软件包:linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
系统平台: CentOS release 6.9
2.主机名
echo "192.168.100.20 SZ-V-L-ODB-20" >> /etc/hosts |
3.关闭Selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config |
4.修改内核参数
修改/etc/sysctl.conf
文件,增加修改以下参数kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
sysctl -p
使配置生效
5.修改/etc/pam.d/login 文件
编辑/etc/pam.d/login
文件,增加以下参数session required /lib64/security/pam_limits.so
session required pam_limits.so
6.创建数据库用户
groupadd oinstall |
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/profile
文件加入如下参数
配置了limits.conf设置,这个设置就不需要了,但也可以添加。if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
9.设置oracle环境变量
*使用oracle账户# su - oracle
$ vim ~/.bash_profile
export ORACLE_BASE=/data/oracle
export ORACLE_SID=orcl
$ source ~/.bash_profile
10.创建oraInst.loc文件
# vim /etc/oraInst.loc |
11.安装数据库目录与授权
mkdir -pv /data/oracle |
11.安装依赖包
yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel compat-libstdc++-33 |
13.解压oracle安装文件
cd /data/down/ |
14.复制响应文件模板
su - oracle |
15.修改db_install.rsp安装文件
编辑修改/home/oracle/etc/db_install.rsp
文件oracle.install.option=INSTALL_DB_SWONLY //安装类型
ORACLE_HOSTNAME=SZ-V-L-ODB-20 //主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall //安装组
INVENTORY_LOCATION=/data/oracle/oraInventory //INVENTORY目录(不填就是默认值)
SELECTED_LANGUAGES=en,zh_CN,zh_TW //选择语言
ORACLE_HOME=/data/oracle/product/11.2.0/db_1 //oracle_home
ORACLE_BASE=/data/oracle //oracle_base
oracle.install.db.InstallEdition=EE //oracle版本
oracle.install.db.isCustomInstall=false //自定义安装,否,使用默认组件
oracle.install.db.DBA_GROUP=dba //dba用户组
oracle.install.db.OPER_GROUP=oinstall //oper用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=orcl //SID
oracle.install.db.config.starterdb.characterSet=ZHS16GBK //字符集
oracle.install.db.config.starterdb.memoryLimit=512 //自动管理内存的内存(M)
oracle.install.db.config.starterdb.password.ALL=ops123456 //设定所有数据库用户使用同一个密码
DECLINE_SECURITY_UPDATES=true //设置安全更新
执行安装$ cd /data/down/database/
$ ./runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp
安装的日志文件在/data/oracle/oraInventory/logs/
目录下
有个报错SEVERE: [FATAL] [INS-13013] Target environment do not meet some mandatory requirements.
解决: 安装命令中加入选项-ignorePrereq$ ./runInstaller -silent -force -ignorePrereq -responseFile /home/oracle/etc/db_install.rsp
脚本执行成功后会有以下提示The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/data/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用户下,执行sh /data/oracle/product/11.2.0/db_1/root.sh
执行完成脚本后,再切换到oracle用户$ vim ~/.bash_profile
# 增加下面变量
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE/lib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
export ORACLE_OWNER=oracle
export SPFILE_PATH=$ORACLE_HOME/dbs
export ORA_NLS10=$ORACLE_HOME/nls/data
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
$ source ~/.bash_profile #变量生效
16.静默配置网络
su - oracle |
可以进行使用sqlplus / as sysdba
进入到数据库系统,但当前还没配置数据库。[oracle@SZ-V-L-ODB-20 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 7 11:57:53 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> select * from v$version;
select * from v$version
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number:
17.静默创建安装数据库
编辑修改/home/oracle/etc/dbca.rsp
响应模板文件的发下几个参数$ vim /home/oracle/etc/dbca.rsp
GDBNAME="orcl.SZ-V-L-ODB-20" //全局数据库的名字=SID+主机域名
SID="orcl" //SID
CHARACTERSET="AL32UTF8" //编码
NATIONALCHARACTERSET="UTF8" //编码
$ dbca -silent -responseFile /home/oracle/etc/dbca.rsp #进行静默安装
# 按回车会提示输入密码 (abc123456)
如果想删除创建的数据库则执行: dbca -silent -deleteDatabase -sourceDB orcl
查看安装日志$ tail -n 2 /data/oracle/cfgtoollogs/dbca/orcl/orcl.log
Global Database Name:orcl.SZ-V-L-ODB-20
System Identifier(SID):orcl
查看验证数据库$ ls -hl /data/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora #tns文件
$ ps -ef | grep ora_ | grep -v grep #查看数据库服务进程
oracle 5156 1 0 12:38 ? 00:00:00 ora_pmon_orcl
oracle 5158 1 0 12:38 ? 00:00:19 ora_vktm_orcl
oracle 5162 1 0 12:38 ? 00:00:00 ora_gen0_orcl
oracle 5164 1 0 12:38 ? 00:00:00 ora_diag_orcl
oracle 5166 1 0 12:38 ? 00:00:00 ora_dbrm_orcl
oracle 5168 1 0 12:38 ? 00:00:00 ora_psp0_orcl
oracle 5170 1 0 12:38 ? 00:00:02 ora_dia0_orcl
oracle 5172 1 0 12:38 ? 00:00:00 ora_mman_orcl
oracle 5174 1 0 12:38 ? 00:00:00 ora_dbw0_orcl
oracle 5176 1 0 12:38 ? 00:00:00 ora_lgwr_orcl
oracle 5178 1 0 12:38 ? 00:00:01 ora_ckpt_orcl
oracle 5180 1 0 12:38 ? 00:00:00 ora_smon_orcl
oracle 5182 1 0 12:38 ? 00:00:00 ora_reco_orcl
oracle 5184 1 0 12:38 ? 00:00:01 ora_mmon_orcl
oracle 5186 1 0 12:38 ? 00:00:01 ora_mmnl_orcl
oracle 5188 1 0 12:38 ? 00:00:00 ora_d000_orcl
oracle 5190 1 0 12:38 ? 00:00:00 ora_s000_orcl
oracle 5264 1 0 12:38 ? 00:00:00 ora_qmnc_orcl
oracle 5278 1 0 12:38 ? 00:00:01 ora_cjq0_orcl
oracle 5283 1 0 12:38 ? 00:00:00 ora_q000_orcl
oracle 5285 1 0 12:38 ? 00:00:00 ora_q001_orcl
oracle 5306 1 0 12:43 ? 00:00:00 ora_smco_orcl
oracle 5788 1 0 14:03 ? 00:00:00 ora_w000_orcl
查看监听器状态信息$ lsnrctl status #查看监听器状态信息
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-MAR-2018 14:27:38
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 07-MAR-2018 11:37:30
Uptime 0 days 2 hr. 50 min. 7 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /data/oracle/diag/tnslsnr/SZ-V-L-ODB-20/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SZ-V-L-ODB-20)(PORT=1521)))
Services Summary...
Service "orcl.SZ-V-L-ODB-20" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.SZ-V-L-ODB-20" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
进入数据库查看数据库本版本$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 7 13:50:59 2018
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> 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
设置界面的进行列高度
SQL> set lines 256 pages 500;
查看数据库路径配置名称信息
1.查看参数文件和网络连接文件SQL> show parameter spfile;
NAME TYPE VALUE
------ ------- ---------------------------------------------------
spfile string /data/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora
2.控制文件SQL> select NAME from v$controlfile;
NAME
---------------------------------------------------
/data/oracle/oradata/orcl/control01.ctl
/data/oracle/flash_recovery_area/orcl/control02.ctl
3.数据库文件SQL> select FILE_NAME from dba_data_files;
FILE_NAME
-----------------------------------------
/data/oracle/oradata/orcl/users01.dbf
/data/oracle/oradata/orcl/undotbs01.dbf
/data/oracle/oradata/orcl/sysaux01.dbf
/data/oracle/oradata/orcl/system01.dbf
4.查看日志文件SQL> select MEMBER from v$logfile;
MEMBER
--------------------------------------
/data/oracle/oradata/orcl/redo03.log
/data/oracle/oradata/orcl/redo02.log
/data/oracle/oradata/orcl/redo01.log
5.查看数据参数信息(有很多)SQL> show parameter;
SQL> show parameter db_domain;
SQL> show parameter service_names;
SQL> show parameter db_unique_name;
SQL> show parameter db_name;
SQL> show parameter spfile;
SQL> show parameter control_files;
SQL> show parameter db_recovery_file_dest;
18.修改oracle启动配置文件
$ vim /etc/oratab |
$ dbstart $ORACLE_HOME #启动所有服务 |
19.配置开机启动
# vim /etc/rc.d/rc.local |
20.删除数据库
rm -rf /data/oracle/ |
本文作者 : 泽泽
原文链接 : http://www.linuxhub.cn/2018/03/08/install-oracle.html
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
知识 & 情怀 | 二者兼得