最近需要安装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/hosts cat >> /etc/sysconfig/network <<eof network=yes hostname=orcl eof
第二个脚本secinstalloracle.sh,以root用户运行
#!/bin/bash #以root用户运行 #内核参数设置kernel.shmall=2097152其中16g物理内存建议设为4194304类推8g应为2097152 #kernel.shmmax=4294967296一般设置为物理内存的一半,8g:4294967296也可以全部用完8*1024*1024*1024 yum 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 unzip cat >> /etc/sysctl.conf <<eof fs.file-max = 6815744 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 kernel.shmmax = 4294967296 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 eof sysctl -p #使配置文件生效 cat >> /etc/security/limits.conf <<eof oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 eof cat >> /etc/pam.d/login <<eof session required /lib/security/pam_limits.so session required pam_limits.so eof cat >> /etc/profile <<eof if [ $user = "oracle" ]; then if [ $shell = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi eof groupadd oinstall groupadd dba useradd -g oinstall -g dba oracle mkdir -p /u01/app/oracle/product/11.2.0/db_1 mkdir -p /u01/app/oracle/oradata mkdir -p /u01/app/orainventory mkdir -p /u01/app/oracle/fast_recovery_area chown -r oracle:oinstall /u01/app/oracle chown -r oracle:oinstall /u01/app/orainventory chmod -r 755 /u01/app/oracle chmod -r 755 /u01/app/orainventory systemctl disable firewalld systemctl stop firewalld setenforce 0 sed -i 's/=enforcing/=disabled/g' /etc/selinux/config mv p13390677_112040_linux-x86-64_1of7.zip /home/oracle mv p13390677_112040_linux-x86-64_2of7.zip /home/oracle cp thiinstalloracle.sh /home/oracle/ cp fouinstalloracle.sh /home/oracle/
第三个脚本thiinstalloracle.sh,以oracle用户运行,su – oracle
#!/bin/bash #以oracle用户运行,su - oracle cat >> .bash_profile <<eof oracle_base=/u01/app/oracle oracle_home=$oracle_base/product/11.2.0/db_1 oracle_sid=orcl export nls_lang=american_america.utf8 path=$path:$oracle_home/bin export oracle_base oracle_home oracle_sid path umask 022 eof source .bash_profile unzip p13390677_112040_linux-x86-64_1of7.zip unzip p13390677_112040_linux-x86-64_2of7.zip chown -r oracle:oinstall database cd database/response cp db_install.rsp db_install.rsp.bak sed -i "s/^oracle.install.option=/oracle.install.option=install_db_swonly/g" db_install.rsp sed -i "s/^oracle_hostname=/oracle_hostname= orcl/g" db_install.rsp sed -i "s/^unix_group_name=/unix_group_name=oinstall/g" db_install.rsp sed -i "s/^inventory_location=/inventory_location=\/u01\/app\/orainventory/g" db_install.rsp sed -i "s/^selected_languages=en/selected_languages=en,zh_cn/g" db_install.rsp sed -i "s/^oracle_home=/oracle_home=\/u01\/app\/oracle\/product\/11.2.0\/db_1/g" db_install.rsp sed -i "s/^oracle_base=/oracle_base=\/u01\/app\/oracle/g" db_install.rsp sed -i "s/^oracle.install.db.installedition=/oracle.install.db.installedition=ee/g" db_install.rsp sed -i "s/^oracle.install.db.dba_group=/oracle.install.db.dba_group=dba/g" db_install.rsp sed -i "s/^oracle.install.db.oper_group=/oracle.install.db.oper_group=dba/g" db_install.rsp sed -i "s/^decline_security_updates=/decline_security_updates=true/g" db_install.rsp cd ..
./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.sh sh /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.ora cd /home/oracle/database/response cp dbca.rsp db sed -i '78s/.*/gdbname= "orcl"/' dbca.rsp sed -i '170s/.*/sid = "orcl"/' dbca.rsp sed -i '211s/.*/syspassword = "123456"/' dbca.rsp sed -i '221s/.*/systempassword = "123456"/' dbca.rsp sed -i '252s/.*/sysmanpassword = "123456"/' dbca.rsp sed -i '262s/.*/dbsnmppassword = "123456"/' dbca.rsp sed -i '360s/.*/datafiledestination=\/u01\/app\/oracle\/oradata/' dbca.rsp sed -i '370s/.*/recoveryareadestination=\/u01\/app\/oracle\/fast_recovery_area/' dbca.rsp sed -i '418s/.*/characterset= "zhs16gbk"/' dbca.rsp sed -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密码test grant connect to test; grant resource to test;
总结
以上所述是www.887551.com给大家介绍的centos7.7安装oracle11g脚本,希望对大家有所帮助!