这篇文章主要介绍“Linux下怎么安装Oracle 11g”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux下怎么安装Oracle 11g”文章能帮助大家解决问题。
oracle 11g客户端是一款出自甲骨文公司之手的专业化关系数据库管理系统,oracle 11g客户端功能强劲,具有高效性、安全性、稳定性和延展性等特点,世界上的几乎所有大型信息化系统都在应用Oracle数据库技术。
1.1.配置本地yum源
#因公司内网环境,没有互联网,所以需要配置本地yum源,安装所需依赖包等。#挂载ios镜像centos7.5-1804[root@oracle ~]#mount /dev/cdrom /mnt#备份原配置文件[root@oracle ~]#cd /etc/yum.repos.d/[root@oracle ~]#mkdir bak[root@oracle ~]#mv * bak#创建yum配置文件[root@oracle ~]#vi /etc/yum.repos.d/local.repo#添加以下内容[local] name=localbaseurl=file:///mnt gpgcheck=0 enabled=1#清空yum所有源信息[root@oracle ~]#yum clean all#查看本地源的所有软件[root@oracle ~]#yum list
1.2上传解压oracle 11g安装包
#将下载的linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip解压到/usr/local/apps/oracle目录[root@oracle ~]# mkdir -p /usr/local/apps/oracle[root@oracle ~]# cd /usr/local/apps/oracle[root@oracle oracle]# unzip p13390677_112040_Linux-x86-64_1of7.zip && unzip p13390677_112040_Linux-x86-64_2of7.zip#没有安装unzip命令工具的安装一下[root@oracle ~]# yum install unzip –y#解压后会产生一个database目录,即/usr/local/apps/oracle/database,目录里面是oracle11g企业版的安装文件
1.3.给本机服务IP地址作个映射
#添加本机IP地址和主机名[root@oracle oracle]# vim /etc/hosts10.0.0.10 oracle
1.4.关闭selinux
#修改SELINUX=disabled[root@oracle ~]#vi /etc/selinux/configSELINUX=disabled [root@oracle ~]#setenforce 0setenforce: SELinux is disabled
1.5.关闭防火墙
[root@oracle ~]#service iptables stop[root@oracle ~]#systemctl stop firewalld[root@oracle ~]#systemctl disable firewalld
1.6.安装Oracle 11g依赖包
[root@oracle ~]#yum install gcc make ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y
1.7.添加安装用户和用户组
#创建用户组[root@oracle ~]#groupadd oinstall[root@oracle ~]#groupadd dba#创建oracle用户并指定用户组[root@oracle ~]#useradd -g oinstall -G dba oracle#为oracle用户设置密码[root@oracle ~]#passwd oracle#查看用户信息[root@oracle ~]#id oracle uid=1001(oracle) gid=1001(oinstall) 组=1001(oinstall),1002(dba)#如显示以上类似信息则表示添加用户和用户组成功
1.8.修改内核参数
[root@oracle ~]#vi /etc/sysctl.conf#添加以下内容fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 1073741824 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 = 1048576#其中shmmax是单个共享内存段的最大值,一般设置为本机物理内存的一半,单位为byte,可根据自己的实际情况做相应调整#使新内核参数生效[root@oracle ~]#sysctl –p
1.9.修改用户的限制文件
[root@oracle ~]#vi /etc/security/limits.conf#添加以下内容oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240
1.10.修改/etc/pam.d/login文件
[root@oracle ~]#vi /etc/pam.d/login#添加以下内容session required /lib64/security/pam_limits.sosession required pam_limits.so
1.11.修改/etc/profile文件
[root@oracle ~]#vi /etc/profile#添加以下内容if [ $USER = "oracle" ]; thenif [ $SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifi#使之生效[root@oracle ~]#source /etc/profile
1.12.创建安装目录和设置文件权限
[root@oracle ~]#mkdir -p /usr/local/apps/oracle/product/11.2.0[root@oracle ~]#mkdir /usr/local/apps/oracle/oradata[root@oracle ~]#mkdir /usr/local/apps/oracle/inventory[root@oracle ~]#mkdir /usr/local/apps/oracle/fast_recovery_area[root@oracle ~]#chown -R oracle:oinstall /usr/local/apps/oracle[root@oracle ~]#chmod -R 775 /usr/local/apps/oracle
1.13.设置oracle用户环境变量
[root@oracle ~]#su - oracle#此处注意,切换用户时切记要加"-",加-会拥有目标用户的环境变量,不加"-"则没有,详细的可自行网上搜索找解答[oracle@oracle ~]$vi .bash_profile#添加如下内容ORACLE_BASE=/usr/local/apps/oracleORACLE_HOME=$ORACLE_BASE/product/11.2.0ORACLE_SID=orclPATH=$PATH:$ORACLE_HOME/binexport ORACLE_BASEexport ORACLE_HOMEexport ORACLE_SIDexport PATH#使配置生效[oracle@oracle ~]$source .bash_profile
1.14.编辑静默安装响应文件
[oracle@oracle ~]$cp -R /usr/local/apps/oracle/database/response/ /home/oracle[oracle@oracle ~]$cd /home/oracle/response[oracle@oracle ~]$vi db_install.rsp#需要设置的选项如下,注意只修改以下设置,其他设置不变,否则会报错。oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=oracleUNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/usr/local/apps/oracle/inventorySELECTED_LANGUAGES=en,zh_CNORACLE_HOME=/usr/local/apps/oracle/product/11.2.0ORACLE_BASE=/usr/local/apps/oracleoracle.install.db.InstallEdition=EEoracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=dbaDECLINE_SECURITY_UPDATES=true
[oracle@oracle ~]$cd /usr/local/apps/oracle/database[oracle@oracle ~]$./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq#Oracle开始在后台静默安装,如果提示Successfully则表示安装成功#按照要求执行脚本,打开终端,以root用户登录,执行脚本[root@oracle ~]#/usr/local/apps/oracle/inventory/orainstRoot.sh[root@oracle ~]#/usr/local/apps/oracle/product/11.2.0/root.sh
#以oracle用户登录,执行[oracle@oracle ~]$netca /silent /responsefile /home/oracle/response/netca.rsp#通过netstat命令查看1521端口是否在监听中[oracle@oracle ~]$ss -tnulp | grep 1521
4.1.修改dbca.rsp配置文件
[oracle@oracle ~]$vim /home/oracle/response/dbca.rsp#设置以下参数[CREATEDATABASE]GDBNAME = "orcl"SID = "orcl"SYSPASSWORD = "123456"SYSTEMPASSWORD = "123456"SYSMANPASSWORD = "123456"DBSNMPPASSWORD = "123456"DATAFILEDESTINATION =/usr/local/apps/oracle/oradataRECOVERYAREADESTINATION=/usr/local/apps/oracle/fast_recovery_areaCHARACTERSET = "AL32UTF8"TOTALMEMORY = "800"#其中TOTALMEMORY = "800"为800MB,一般设置为物理内存的80%
4.2.进行静默配置创建实例
[oracle@oracle ~]$dbca -silent -responseFile /home/oracle/response/dbca.rsp#建库后进行实例进程检查[oracle@oracle ~]$ps -ef | grep ora_ | grep -v grep#查看监听状态[oracle@oracle ~]$lsnrctl status#登录查看实例状态[oracle@oracle ~]$sqlplus / as sysdbaSQL> select status from v$instance;#如显示STATUS------------OPEN#则表示实例是启动状态#查看数据库编码SQL> select userenv('language') from dual;#查看数据库版本SQL> select * from v$version;
5.1.修改启动脚本文件
#修改/usr/local/apps/oracle/product/11.2.0/bin/dbstart[oracle@oracle ~]$vi /usr/local/apps/oracle/product/11.2.0/bin/dbstart#将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME#修改/usr/local/apps/oracle/product/11.2.0/bin/dbshut[oracle@oracle ~]$vi /usr/local/apps/oracle/product/11.2.0/bin/dbshut#将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
5.2.修改/etc/oratab文件
[oracle@oracle ~]$vi /etc/oratab#将orcl:/usr/local/apps/oracle/product/11.2.0:N中最后的N改为Y,成为orcl:/usr/local/apps/oracle/product/11.2.0:Y#输入dbshut和dbstart测试[oracle@oracle ~]$dbshut#Oracle监听停止,进程消失[oracle@oracle ~]$dbstart#Oracle监听启动,进程启动5.3.切换到root账户建立自启动脚本 [oracle@oracle ~]$su - [root@oracle ~]#vim /etc/rc.d/init.d/oracle#添加以下内容(有些值如ORA_HOME和ORA_USER等根据实际情况可以修改):#!/bin/sh# chkconfig: 35 80 10# description: Oracle auto start-stop script.## Set ORA_HOME to be equivalent to the $ORACLE_HOME# from which you wish to execute dbstart and dbshut;## Set ORA_OWNER to the user id of the owner of the# Oracle database in ORA_HOME.ORA_HOME=/usr/local/apps/oracle/product/11.2.0 ORA_OWNER=oracleif [ ! -f $ORA_HOME/bin/dbstart ]then echo "Oracle startup: cannot start" exitficase "$1" in'start')# Start the Oracle databases:echo "Starting Oracle Databases ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracleecho "Done"# Start the Listener:echo "Starting Oracle Listeners ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracleecho "Done."echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle touch /var/lock/subsys/oracle ;;'stop')# Stop the Oracle Listener:echo "Stoping Oracle Listeners ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracleecho "Done."rm -f /var/lock/subsys/oracle# Stop the Oracle Database:echo "Stoping Oracle Databases ... "echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracleecho "Done."echo ""echo "-------------------------------------------------" >> /var/log/oracle date +" %T %a %D : Finished." >> /var/log/oracleecho "-------------------------------------------------" >> /var/log/oracle ;;'restart')$0 stop$0 start ;;esac
5.4.修改/etc/init.d/oracle服务文件权限
[root@oracle ~]#chmod 755 /etc/init.d/oracle
5.5.添加开机自启服务
[root@oracle ~]#chkconfig oracle on
5.6.需要在关机或重启机器之前停止数据库,做一下操作
#关机[root@oracle ~]ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle#重启[root@oracle ~]ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle #进行测试[root@oracle ~]# service oracle start #启动oracle[root@oracle ~]# service oracle stop #关闭oracle
5.7.重启查看Oracle监听和实例进程是否均能自动启动
[root@oracle ~]#reboot
关于“Linux下怎么安装Oracle 11g”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注亿速云行业资讯频道,小编每天都会为大家更新不同的知识点。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。