LINUX 下使用脚本自动安装ORACLE12C数据库的简单实现

news/2024/10/27 20:27:13/

一.系统环境:

OS:Red Hat Enterprise Linux Server release 7.6 

DB:Oracle Database 12c Enterprise Edition Release 12.2.0.1.0

关闭防火墙,SELINUX,/etc/hosts 文件IP对应好主机名称,先将oracle12C的安装文件拷贝至根目录 /linuxx64_12201_database.zip

执行的内容不详细解释,仅供部署时方便参考

二.root用户运行的内容

这是root执行的脚本

[root@r100 ~]# cat rootexec.sh 
#!/bin/bash
yum install -y binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33.i686 glibc glibc.i686 glibc-devel glibc-devel.i686 ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libX11 libX11.i686 libXau libXau.i686 libXi libXi.i686 libXtst libXtst.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel libstdc++-devel.i686 libxcb libxcb.i686 make nfs-utils net-tools smartmontools sysstat unixODBC unixODBC-devel gcc gcc-c++ libXext libXext.i686 zlib-devel zlib-devel.i686cp /etc/sysctl.conf /etc/sysctl.conf.bak`date +"%Y-%m-%d-%H-%M-%S"`
(
cat <<EOF
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
)>>/etc/sysctl.conf
/sbin/sysctl -pcp /etc/security/limits.conf /etc/security/limits.conf.bak`date +"%Y-%m-%d-%H-%M-%S"`
(
cat <<EOF
oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728
EOF
)>>/etc/security/limits.confgroupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
orapwd='oraclepwd'
echo $orapwd | passwd oracle --stdin > /dev/null 2>&1
mkdir -p /u01/app/oracle/oradata 
mkdir -p /u01/app/oracle/oradata_backmv /linuxx64_12201_database.zip /u01chown -R oracle:oinstall /u01/
chmod -R 775 /u01/

执行效果:

三.oracle用户运行的内容

su - oracle 再执行脚本

[oracle@r100 ~]$ cat oracleexec.sh 
#!/bin/bash
(
cat <<\EOF
export ORACLE_HOSTNAME=r100
export ORACLE_UNQNAME=orcl12.r100.db
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/db_1
export ORACLE_SID=orcl12
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlibEOF
)>>/home/oracle/.bash_profilecd /u01 && unzip linuxx64_12201_database.zipcp /u01/database/response/db_install.rsp /u01/database/response/db_install.rsp.bak.`date +"%Y-%m-%d-%H-%M-%S"`
cp /u01/database/response/dbca.rsp /u01/database/response/dbca.rsp.bak.`date +"%Y-%m-%d-%H-%M-%S"`
cp /u01/database/response/netca.rsp /u01/database/response/netca.rsp.bak.`date +"%Y-%m-%d-%H-%M-%S"`sed -i 's/oracle.install.option=/oracle.install.option=INSTALL_DB_SWONLY/g' /u01/database/response/db_install.rsp
sed -i 's/UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/g' /u01/database/response/db_install.rsp
sed -i 's/INVENTORY_LOCATION=/INVENTORY_LOCATION=\/u01\/app\/oracle\/oraInventory/g' /u01/database/response/db_install.rsp
sed -i 's/ORACLE_HOME=/ORACLE_HOME=\/u01\/app\/oracle\/product\/12.2.0.1\/db_1/g' /u01/database/response/db_install.rsp
sed -i 's/ORACLE_BASE=/ORACLE_BASE=\/u01\/app\/oracle/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.InstallEdition=/oracle.install.db.InstallEdition=EE/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.OSDBA_GROUP=/oracle.install.db.OSDBA_GROUP=dba/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.OSBACKUPDBA_GROUP=/oracle.install.db.OSBACKUPDBA_GROUP=dba/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.OSDGDBA_GROUP=/oracle.install.db.OSDGDBA_GROUP=dba/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.OSKMDBA_GROUP=/oracle.install.db.OSKMDBA_GROUP=dba/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.OSRACDBA_GROUP=/oracle.install.db.OSRACDBA_GROUP=dba/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.config.starterdb.globalDBName=/oracle.install.db.config.starterdb.globalDBName=orcl12.r100.db/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.config.starterdb.SID=/oracle.install.db.config.starterdb.SID=orcl12/g' /u01/database/response/db_install.rsp
sed -i 's/oracle.install.db.config.starterdb.characterSet=/oracle.install.db.config.starterdb.characterSet=ZHS16GBK/g' /u01/database/response/db_install.rsp
sed -i 's/SECURITY_UPDATES_VIA_MYORACLESUPPORT=/SECURITY_UPDATES_VIA_MYORACLESUPPORT=false/g' /u01/database/response/db_install.rsp
sed -i 's/DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/g' /u01/database/response/db_install.rsp

执行效果:

四.开始安装数据库软件

[oracle@r100 ~]$ source ~/.bash_profile 
[oracle@r100 ~]$ echo $ORACLE_SID
orcl12
[oracle@r100 ~]$ cd /u01/database/
[oracle@r100 database]$ ls
install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@r100 database]$ ./runInstaller -force -silent -noconfig -responseFile /u01/database/response/db_install.rsp
Starting Oracle Universal Installer...Checking Temp space: must be greater than 500 MB.   Actual 17844 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3071 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2021-05-27_06-14-06AM. Please wait ...[oracle@r100 database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-13014] Target environment does not meet some optional requirements.CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2021-05-27_06-14-06AM.logACTION: Identify the list of failed prerequisite checks from the log: installActions2021-05-27_06-14-06AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:/u01/app/oracle/oraInventory/logs/installActions2021-05-27_06-14-06AM.log
The installation of Oracle Database 12c was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2021-05-27_06-14-06AM.log' for more details.As a root user, execute the following script(s):1. /u01/app/oracle/oraInventory/orainstRoot.sh2. /u01/app/oracle/product/12.2.0.1/db_1/root.shSuccessfully Setup Software.

安装过程中切换至root用户执行两个脚本

[root@r100 ~]# /u01/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.Changing groupname of /u01/app/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@r100 ~]# /u01/app/oracle/product/12.2.0.1/db_1/root.sh
Check /u01/app/oracle/product/12.2.0.1/db_1/install/root_r100_2021-05-27_06-21-29-398109441.log for the output of root script

五.配置数据库监听

[oracle@r100 database]$ netca -silent -responsefile /u01/database/response/netca.rspParsing command line arguments:Parameter "silent" = trueParameter "responsefile" = /u01/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/12.2.0.1/db_1/bin/lsnrctl start LISTENERListener Control complete.Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

六.使用脚本自动用静默的方式建库

[oracle@r100 ~]$ cat oracledbca.sh 
#!/bin/bash
dbca -silent -createDatabase \
-templateName /u01/app/oracle/product/12.2.0.1/db_1/assistants/dbca/templates/General_Purpose.dbc \
-gdbname orcl12.r100.db -sid orcl12 -responseFile /u01/database/response/dbca.rsp \
-characterSet ZHS16GBK \
-sysPassword Yourtestpwd1* \   #测试密码
-systemPassword Yourtestpwd1* \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName orcl12pdb1 \
-pdbAdminPassword Yourtestpwd1* \
-automaticMemoryManagement false \
-ignorePreReqs

执行建库的过程

七.连接测试

sqlplus命令行连接

[oracle@r100 ~]$ sqlplus / as sysdbaSQL*Plus: Release 12.2.0.1.0 Production on Thu May 27 07:41:47 2021Copyright (c) 1982, 2016, Oracle.  All rights reserved.Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit ProductionSQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@r100 ~]$ 
[oracle@r100 ~]$ sqlplus system/密码@192.168.252.100/orcl12.r100.dbSQL*Plus: Release 12.2.0.1.0 Production on Thu May 27 07:43:20 2021Copyright (c) 1982, 2016, Oracle.  All rights reserved.Last Successful login time: Thu May 27 2021 07:37:40 -07:00Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit ProductionSQL> 

使用Navicat连接


http://www.ppmy.cn/news/132176.html

相关文章

2021年化工自动化控制仪表考试题及化工自动化控制仪表证考试

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 化工自动化控制仪表考试题参考答案及化工自动化控制仪表考试试题解析是安全生产模拟考试一点通题库老师及化工自动化控制仪表操作证已考过的学员汇总&#xff0c;相对有效帮助化工自动化控制仪表证考试学员顺利通过考…

电磁AI组细则建议

车模 限定使用C车模&#xff0c;限定车模只能正向运行&#xff0c;比赛任务侧重点不同&#xff0c;C车模的组装和调校最为简单&#xff0c;降低车模机械因素带来更多的不确定性&#xff1b; 赛道及环境 第一届建议仍然采用在室内PVC赛道&#xff08;材料与前几届比赛相同&am…

铂电阻温度传感器计算

6.一个铂电阻传感器被用来测量0到200摄氏度的温度&#xff0c;已知当温度为 T ∘ C T^{\circ}C T∘C时传感器对应电阻为 R T Ω R_T\Omega RT​Ω&#xff0c; R T R_T RT​满足的方程为 R T R 0 ( 1 α T β T 2 ) R_TR_0(1\alpha T \beta T^2) RT​R0​(1αTβT2)&#xf…

斜探头的校准原理

1&#xff0c;斜探头的结构 ,2&#xff0c;斜探头入射零点的校准 在斜探头的校准过程中&#xff0c;找到R50和R100的最大回波&#xff0c;这时斜探头的入射位置大概就是R50 和 R100的圆点。 超声波探伤仪根据R50和R100的回波时间t1、t2和它们之间的距离差S150mm&#xff0c;可…

STM3使用光敏传感器计算光照度Lux,而不是仅仅打印个电压值或者电阻值

点击上方蓝字关注我吧 最近项目中用到了光敏电阻。搜索资料&#xff0c;发现很多人都使用光敏电阻&#xff0c;只是用了AD读取了电压值&#xff0c;或者算出了电阻值&#xff0c;就发送给上位机或者服务器&#xff0c;美其名曰获取了光照度。 搜索一番&#xff0c;也没找到用光…

Angr入门(一)

Angr学习 Top Level Interfaces基本信息Basic Block Loading a Binary基本信息Symbols and Relocations Program StateCFG 之前一直做静态代码检测&#xff0c;主要是针对未编译过的源代码文本&#xff0c;不过在文本层面能分析的问题只是一小部分&#xff0c;有些问题还得在执…

在LTSPICE中导入模型(Murata 电容)

LTSPICE是一款很实用的SPICE软件&#xff0c;免费且功能实用。在仿真过程中&#xff0c;其自带的模型往往不能满足需求&#xff0c;而大的芯片供应商都会提供免费的SPICE模型供下载&#xff0c;我们可以把这些模型导入LTSPICE中进行仿真。 接下来&#xff0c;是具体步骤。 首先…

联想ThinkServer服务器安装CentOS7 Redhat7系统 驱动R110i RAID卡

1、下载对应版本的驱动&#xff08;因为联想没有CentOS的驱动用redhat的驱动就可以&#xff09;。 2、进入BIOS里&#xff0c;在高级设置里找到SATA设置&#xff0c;把SATA模式改成RAID(重启后配置raid)&#xff0c;sSATA模式改成IDE&#xff0c;最后把引导模式改成UEFI引导&a…