Oracle silent installation under Linux
Operating system version: centos7.3-1611_x86-64
Oracle database software version: oracle 11g_r2 11.2.0.4.0
Turn off the firewall, modify selinux
firewall-cmd --permanent --add-port=1521/tcp
success
firewall-cmd --reload
success
vim /etc/sysconfig/selinux
Create users, groups and related folders
groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba oracle
echo "oracle"|passwd --stdin oracle
更改用户 oracle 的密码 。
passwd:所有的身份验证令牌已经成功更新。
mkdir -p /oracle/11g
chown -R oracle:oinstall /oracle/11g
chmod -R 775 /oracle/11g
mkdir -p /opt/11g/oraInventory
chown -R oracle:oinstall /opt/11g/oraInventory
chmod -R 775 /opt/11g/oraInventory
Set environment variables
Switch to the Oracle user
vim /home/oracle/.bash_profile
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/oracle/11g; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=SJZXBJT export ORACLE_SID ##注意这里的SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
umask 022
source ~/.bash_profile
Note: The ORACLE_SID here is best to be consistent with the ORACLE_SID you will build later
Install dependencies
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh numactl-devel glibc-headers
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh numactl-devel glibc-headers
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.huaweicloud.com
软件包 binutils-2.27-44.base.el7.x86_64 已安装并且是最新版本
软件包 compat-libstdc++-33-3.2.3-72.el7.x86_64 已安装并且是最新版本
软件包 elfutils-libelf-0.176-5.el7.x86_64 已安装并且是最新版本
软件包 elfutils-libelf-devel-0.176-5.el7.x86_64 已安装并且是最新版本
软件包 glibc-2.17-317.el7.x86_64 已安装并且是最新版本
软件包 glibc-common-2.17-317.el7.x86_64 已安装并且是最新版本
软件包 glibc-devel-2.17-317.el7.x86_64 已安装并且是最新版本
软件包 gcc-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 gcc-c++-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 libaio-devel-0.3.109-13.el7.x86_64 已安装并且是最新版本
软件包 libaio-0.3.109-13.el7.x86_64 已安装并且是最新版本
软件包 libgcc-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 libstdc++-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 libstdc++-devel-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 1:make-3.82-24.el7.x86_64 已安装并且是最新版本
软件包 sysstat-10.1.5-19.el7.x86_64 已安装并且是最新版本
软件包 unixODBC-2.3.1-14.el7.x86_64 已安装并且是最新版本
软件包 unixODBC-devel-2.3.1-14.el7.x86_64 已安装并且是最新版本
软件包 numactl-devel-2.0.12-5.el7.x86_64 已安装并且是最新版本
软件包 glibc-headers-2.17-317.el7.x86_64 已安装并且是最新版本
无须任何处理
Configure kernel parameters
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1987330048
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 = 1048586
[root@test home]# sysctl -p
Install database software
Unzip the database installation package
unzip linux.x64_11gR2_database_1of2.zip.zip
unzip linux.x64_11gR2_database_2of2.zip.zip
chown -R oracle:oinstall /home/database
Note: The /home/database path here is the path where you decompress the Oracle database
Create a silent installation database response file
vim /home/database/response/db.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/11g/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/oracle/11g/product/11.2.0/dbhome_1
ORACLE_BASE=/oracle/11g
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.config.starterdb.characterSet=ZHS16GBK
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=123456
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oracle/11g/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/oracle/11g/dbrecovery
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
Note: hssjzx in ORACLE_HOSTNAME=hssjzx is the host name of your machine, which can be obtained through the command line: cat /etc/hostname;
512 in oracle.install.db.config.starterdb.memoryLimit=512 is the automatically managed memory set The size cannot exceed half of the system memory. For
specific details of the corresponding file, please refer to: http://meiling.blog.51cto.com/6220221/1783491
chmod 777 /home/database/response/db.rsp
Install database software silently
切换到Oracle用户下
su - oracle
/home/database/runInstaller -ignoreSysPrereqs -ignorePrereq -silent -nowelcome -responseFile /home/database/response/db.rsp
正在启动 Oracle Universal Installer...
检查临时空间: 必须大于 120 MB。 实际为 9479 MB 通过
检查交换空间: 必须大于 150 MB。 实际为 2047 MB 通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2020-11-24_01-59-12PM. 请稍候...
可以在以下位置找到本次安装会话的日志:
/opt/11g/oraInventory/logs/installActions2020-11-24_01-59-12PM.log
Oracle Database 11g 的 安装 已成功。
请查看 '/opt/11g/oraInventory/logs/silentInstall2020-11-24_01-59-12PM.log' 以获取详细资料。
以 root 用户的身份执行以下脚本:
1. /opt/11g/oraInventory/orainstRoot.sh
2. /oracle/11g/product/11.2.0/dbhome_1/root.sh
Successfully Setup Software.
Go to the root user
/opt/11g/oraInventory/orainstRoot.sh && /oracle/11g/product/11.2.0/dbhome_1/root.sh
更改权限/opt/11g/oraInventory.
添加组的读取和写入权限。
删除全局的读取, 写入和执行权限。
更改组名/opt/11g/oraInventory 到 oinstall.
脚本的执行已完成。
Note: The above two commands are prompted to be executed after the silent installation is completed
Configure database monitoring
su - oracle
vim $ORACLE_HOME/network/admin/listener.ora
LISTENER=
(DESCRIPTION_LIST=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.168.107)(PORT=1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SERVICE_NAME = SJZXBJT)
(SID_NAME = SJZXBJT)
)
)
ADR_BASE_LISTENER=/oracle/11g/product/11.2.0/dbhome_1
vim $ORACLE_HOME/network/admin/tnsnames.ora
SJZXBJT=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.168.107)(PORT = 1521))
(CONNECT_DATA =
(SERVER = SJZXBJT)
(SERVICE_NAME = SJZXBJT)
)
)
Note: The database instance name SJZXBJT monitored here needs to be consistent, the HOST address needs to be consistent, and the HOST address can write the host name, but the host name and host name need to be bound in the /etc/hosts file for resolution
chown oracle:oinstall /oracle/11g/product/11.2.0/dbhome_1/network/admin/listener.ora
chown oracle:oinstall /oracle/11g/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
Create database
vim /home/database/response/createdatabase.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "SJZXBJT"
SID = "SJZXBJT"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "123456"
SYSTEMPASSWORD = "123456"
CHARACTERSET = "ZHS16GBK"
NATIONALCHARACTERSET= "UTF8"
TOTALMEMORY = "512"
chown oracle /home/database/response/createdatabase.rsp
chgrp dba /home/database/response/createdatabase.rsp
Note: The GDBNAME and SID here must be consistent with the configuration in the arrow file above. SYSPASSWORD and SYSTEMPASSWORD are the passwords for setting sys and system users, which can be customized. CHARACTERSET is the character set of the database, which needs to be set to ZHS16GBK, otherwise an error will occur when the database is sorted. TOTALMEMORY is the memory for setting the database operation, and it is recommended not to exceed half of the operating system memory
Build a library
su - oracle
/oracle/11g/product/11.2.0/dbhome_1/bin/dbca -silent -responseFile /home/database/response/createdatabase.rsp
Note: The path of /oracle/11g/product/11.2.0/dbhome_1/bin/dbca can be queried through whereis dbca
Set power-on auto-start
vim /etc/init.d/autostartup
#!/bin/bash
#chkconfig:345 61 61
export NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
export ORACLE_BASE=/oracle/11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_USER=oracle
export ORACLE_SID=SJZXBJT
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
EOO
touch /var/lock/subsys/$scriptname
;;
stop)
su - "$ORACLE_USER"<<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
EOO
rm -f /var/lock/subsys/scriptname
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
chmod +x /etc/init.d/autostartup
chkconfig --add autostartup
chkconfig autostartup on
Patch
root user
unzip p6880880_112000_Linux-x86-64_oracle11gR2.zip
unzip p30805461_112040_Linux-x86-64.zip
chown -R oracle:oinstall OPatch
cd /oracle/11g/product/11.2.0/dbhome_1/
mv OPatch OPatch.bak
mv /home/OPatch/ .
chown -R oracle:oinstall 30805461/
Switch to the Oracle user
vim .bash_profile
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH:$ORACLE_HOME/OPatch; export PATH
source .bash_profile
opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/30805461/30670774/ -oh $ORACLE_HOME
Oracle 临时补丁程序安装程序版本 11.2.0.3.21
版权所有 (c) 2020, Oracle Corporation。保留所有权利。
PREREQ session
Oracle 主目录 :/oracle/11g/product/11.2.0/dbhome_1
主产品清单:/opt/11g/oraInventory
来自 :/oracle/11g/product/11.2.0/dbhome_1/oraInst.loc
OPatch 版本 :11.2.0.3.21
OUI 版本 :11.2.0.4.0
日志文件位置:/oracle/11g/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2020-11-24_14-36-24下午_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
cd /home/30805461/30670774/
opatch lsinventory
Oracle 临时补丁程序安装程序版本 11.2.0.3.21
版权所有 (c) 2020, Oracle Corporation。保留所有权利。
Oracle 主目录 :/oracle/11g/product/11.2.0/dbhome_1
主产品清单:/opt/11g/oraInventory
来自 :/oracle/11g/product/11.2.0/dbhome_1/oraInst.loc
OPatch 版本 :11.2.0.3.21
OUI 版本 :11.2.0.4.0
日志文件位置:/oracle/11g/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2020-11-24_14-37-48下午_1.log
Lsinventory Output file location : /oracle/11g/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2020-11-24_14-37-48下午.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: test
ARU platform id: 226
ARU platform description:: Linux x86-64
已安装的顶级产品 (1):
Oracle Database 11g 11.2.0.4.0
此 Oracle 主目录中已安装 1 个产品。
此 Oracle 主目录中未安装任何临时补丁程序。
--------------------------------------------------------------------------------
OPatch succeeded.
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle 临时补丁程序安装程序版本 11.2.0.3.21
版权所有 (c) 2020, Oracle Corporation。保留所有权利。
PREREQ session
Oracle 主目录 :/oracle/11g/product/11.2.0/dbhome_1
主产品清单:/opt/11g/oraInventory
来自 :/oracle/11g/product/11.2.0/dbhome_1/oraInst.loc
OPatch 版本 :11.2.0.3.21
OUI 版本 :11.2.0.4.0
日志文件位置:/oracle/11g/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2020-11-24_14-38-29下午_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
sqlplus / as sysdba
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
lsnrctl stop
root用户下
yum install -y psmisc
opatch napply -oh $ORACLE_HOME -local /home/30805461/30670774/
Open listening port
$ su – oracle
$ sqlplus / as sysdba
sql> startup (一般不需要加参数,只要设置好环境变量)
sql> quit (退出sql模式)
$ lsnrctl start (启动监听器)关闭oracle
$ lsnrctl stop(关闭监听器,在这之前,应该先关闭应用程序)
Import the database
Restore tablespace
#!/bin/bash
su - oracle -c "
export ORACLE_SID=SJZXDB
sqlplus / as sysdba <<EOF
create tablespace TEST datafile '/oracle/11g/oradata/SJZXBJT/BKPLAT01.dbf' size 100M autoextend on next 50M;
create user center_user identified by whbk009 temporary tablespace temp default tablespace BKPLAT;
grant connect,resource,dba to center_user;
alter user center_user identified by "whbk009" account unlock;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
alter system set audit_trail=false scope=spfile;
shutdown immediate;
startup;
exit;
EOF
"
Create table space
create tablespace TEST datafile '/oracle/11g/oradata/SJZXBJT/BKPLAT01.dbf' --数据文件地址
size 100M --存储地址 初始大小1G
autoextend on next 50M; --每次扩展50M
Create user
create user center_user identified by whbk009 --密码
temporary tablespace temp default tablespace BKPLAT; --那个库
Authorization
grant connect,resource,dba to center_user; --授予center_user用户connect、resource、dba的权限
Unlock the user, unlock the locked state of the user
alter user center_user identified by "whbk009" account unlock;
Unlimited password time
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Turn off the oracle audit function
alter system set audit_trail=false scope=spfile;
Restart the database
shutdown immediate;
startup;
Import Data
mv htglsjzxdb20201109.dmp /oracle/11g/admin/SJZXBJT/dpdump/
chown -R oracle:oinstall htglsjzxdb20201109.dmp
Under the Oracle user
impdp system/123456@SJZXBJT dumpfile=data_pump_dir:htglsjzxdb20201109.dmp