首页 > 数据库 > Oracle > 正文

centos7.7安装oracle11g脚本(推荐)

2020-07-26 13:26:09
字体:
来源:转载
供稿:网友

最近需要安装oracle,然后网上查了一下教程,在centos7.7上安装成功,运行正常。这里记录一下。

环境:

硬件4核/8G RAM/100G 存储

centos7.7(64bit)

oracle11g(官网下载的)

步骤(转载):

第一个脚本preinstalloracle.sh,以root用户运行。执行完后需要重启电脑,需要注意看一下hostname是否修改好了

 #!/bin/bash#以root用户运行#注意修改第三行的ip为自己的ip地址echo "172.16.1.110 orcl orcl" >> /etc/hostscat >> /etc/sysconfig/network <<EOFnetwork=yeshostname=orclEOF

第二个脚本secinstalloracle.sh,以root用户运行

 #!/bin/bash#以root用户运行#内核参数设置kernel.shmall=2097152其中16G物理内存建议设为4194304类推8G应为2097152#kernel.shmmax=4294967296一般设置为物理内存的一半,8G:4294967296也可以全部用完8*1024*1024*1024yum install -y 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 ksh numactl-devel zip unzipcat >> /etc/sysctl.conf <<EOFfs.file-max = 6815744fs.aio-max-nr = 1048576kernel.shmall = 2097152    kernel.shmmax = 4294967296  kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 4194304net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576EOFsysctl -p #使配置文件生效cat >> /etc/security/limits.conf <<EOForacle      soft  nproc      2047oracle      hard  nproc      16384oracle      soft  nofile     1024oracle      hard  nofile     65536EOFcat >> /etc/pam.d/login <<EOFsession  required   /lib/security/pam_limits.sosession  required   pam_limits.soEOFcat >> /etc/profile <<EOFif [ $USER = "oracle" ]; then  if [ $SHELL = "/bin/ksh" ]; then   ulimit -p 16384   ulimit -n 65536  else   ulimit -u 16384 -n 65536  fifiEOFgroupadd oinstallgroupadd dbauseradd -g oinstall -G dba oracle mkdir -p /u01/app/oracle/product/11.2.0/db_1mkdir -p /u01/app/oracle/oradatamkdir -p /u01/app/oraInventorymkdir -p /u01/app/oracle/fast_recovery_areachown -R oracle:oinstall /u01/app/oraclechown -R oracle:oinstall /u01/app/oraInventorychmod -R 755 /u01/app/oraclechmod -R 755 /u01/app/oraInventorysystemctl disable firewalldsystemctl stop firewalldsetenforce 0sed -i 's/=enforcing/=disabled/g' /etc/selinux/configmv p13390677_112040_Linux-x86-64_1of7.zip /home/oracle  mv p13390677_112040_Linux-x86-64_2of7.zip /home/oraclecp thiinstalloracle.sh /home/oracle/cp fouinstalloracle.sh /home/oracle/

第三个脚本thiinstalloracle.sh,以oracle用户运行,su - oracle

 #!/bin/bash#以oracle用户运行,su - oraclecat >> .bash_profile <<EOFORACLE_BASE=/u01/app/oracleORACLE_HOME=/$ORACLE_BASE/product/11.2.0/db_1ORACLE_SID=orcl export NLS_LANG=AMERICAN_AMERICA.UTF8PATH=/$PATH:/$ORACLE_HOME/binexport ORACLE_BASE ORACLE_HOME ORACLE_SID PATHumask 022EOFsource .bash_profileunzip p13390677_112040_Linux-x86-64_1of7.zip unzip p13390677_112040_Linux-x86-64_2of7.zipchown -R oracle:oinstall databasecd database/responsecp db_install.rsp db_install.rsp.baksed -i "s/^oracle.install.option=/oracle.install.option=INSTALL_DB_SWONLY/g" db_install.rspsed -i "s/^ORACLE_HOSTNAME=/ORACLE_HOSTNAME= orcl/g" db_install.rspsed -i "s/^UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/g" db_install.rspsed -i "s/^INVENTORY_LOCATION=/INVENTORY_LOCATION=//u01//app//oraInventory/g" db_install.rspsed -i "s/^SELECTED_LANGUAGES=en/SELECTED_LANGUAGES=en,zh_CN/g" db_install.rspsed -i "s/^ORACLE_HOME=/ORACLE_HOME=//u01//app//oracle//product//11.2.0//db_1/g" db_install.rspsed -i "s/^ORACLE_BASE=/ORACLE_BASE=//u01//app//oracle/g" db_install.rspsed -i "s/^oracle.install.db.InstallEdition=/oracle.install.db.InstallEdition=EE/g" db_install.rspsed -i "s/^oracle.install.db.DBA_GROUP=/oracle.install.db.DBA_GROUP=dba/g" db_install.rspsed -i "s/^oracle.install.db.OPER_GROUP=/oracle.install.db.OPER_GROUP=dba/g" db_install.rspsed -i "s/^DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/g" db_install.rspcd ..

./runInstaller -silent -responseFile /home/oracle/database/response/db_install.rsp    #可能会包INS-13014目标不满足一些可选要求,查看日志,如果是pdksh缺少的话,可以忽略直接进行下一步。没有异常,不报错的话会在三两分钟后出现使用root用户执行orainstRoot.sh和root.sh的提示

第三脚本执行结果截图,需要等到最后那行提示success才可以回车,大概需要三四分钟

查看/tmp/OraInstall2019-05-10_03-42-57PM/installActions2019-05-10_03-42-57PM.log,可以看到其中一部分内容如下,如果只有这个报错,可以忽略跳过

所以,我们接着另开一个端口,以root用户身份执行

sh /u01/app/oraInventory/orainstRoot.shsh /u01/app/oracle/product/11.2.0/db_1/root.sh

第四个脚本fouinstalloracle.sh,以oracle用户运行,执行以下脚本之前需要先检测以下oracle用户环境变量是否设置正确,测试方法输入netc然后tab补全,如果不能自动补全为netca,则需要再次执行

source .bash_profile,直到可以自动补全netca和dbca等命令为止

#/bin/bash#以oracle用户运行netca /silent /responseFile /home/oracle/database/response/netca.rsp #静默方式配置监听ls $ORACLE_HOME/network/admin/  #正常情况下会自动生成listener.ora sqlnet.oracd /home/oracle/database/responsecp dbca.rsp dbsed -i '78s/.*/GDBNAME= "orcl"/' dbca.rspsed -i '170s/.*/SID = "orcl"/' dbca.rspsed -i '211s/.*/SYSPASSWORD = "123456"/' dbca.rspsed -i '221s/.*/SYSTEMPASSWORD = "123456"/' dbca.rspsed -i '252s/.*/SYSMANPASSWORD = "123456"/' dbca.rspsed -i '262s/.*/DBSNMPPASSWORD = "123456"/' dbca.rspsed -i '360s/.*/DATAFILEDESTINATION=//u01//app//oracle//oradata/' dbca.rspsed -i '370s/.*/RECOVERYAREADESTINATION=//u01//app//oracle//fast_recovery_area/' dbca.rspsed -i '418s/.*/CHARACTERSET= "ZHS16GBK"/' dbca.rspsed -i '553s/.*/TOTALMEMORY= "3276"/' dbca.rsp  #值设置为物理内存的60%dbca -silent -responseFile /home/oracle/database/response/dbca.rsp #开始静默安装,安装结束后会提示100%,数据库也跟着起来了ps -ef | grep ora_ | grep -v grep #检测oracle进程lsnrctl status 

最后,我们尝试创建一个用户,从外部进行连接,如果可以正常连接,说明没有问题了

 sqlplus / as sysdba #进入数据库select status from v$instance;  #查看数据库运行状态create user test identified by test; #创建数据库用户,连接时数据库实例名为orcl,用户名test密码testgrant connect to test;grant resource to test;

总结

以上所述是小编给大家介绍的centos7.7安装oracle11g脚本,希望对大家有所帮助!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表