本文介绍了如何在CentOS7.9上安装Oracle11g。首先,需要设置主机名并配置本地解析。接着,安装依赖,包括libnsl、libnsl2-devel、libaio-devel、libcap-devel、xorg-x11-uti...
上一篇,如何在CentOS7.9下安装Oracle11g?(一)
一、环境准备
1、设置主机名(可以跳过)
# 修改主机名为db
> vim /etc/hosts
> hostnamectl set-hostname db && bash
# 查看
> hostname
# 配置本地解析
> vim /etc/hosts
# 增加/修改
> 192.168.0.88 db
2、安装依赖
[root@db ~]# yum install libnsl libnsl2-devel libaio-devel libcap-devel xorg-x11-utils xauth gcc make libstdc++-devel sysstat smartmontools glibc-compat-2.17
# 查看libaiobaio版本
[root@db ~]# rpm -qa libaio
# libaio-0.3.109-13.el7.x86_64
3、关闭selinux
# 查看是否启动
[root@db ~]# setenforce 0
# 修改
[root@db ~]# vim /etc/selinux/config
二、安装配置
1、创建组、用户
添加oinstall 、dba 组,新建oracle用户并加入oinstall、dba组中
[root@db ~]# groupadd oinstall
[root@db ~]# groupadd dba
[root@db ~]# useradd -g oinstall -G dba oracle
[root@db ~]# passwd oracle
2、修改内核参数
[root@db ~]# vim /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
# 让参数生效:
[root@db ~]# /sbin/sysctl -p
3、配置Oracle用户参数
[root@db ~]# vim /etc/security/limits.conf
# 在文档最后加入以下内容:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
4、修改/etc/pam.d/login 文件
[root@db ~]# vim /etc/pam.d/login
# 在文档最后加入以下内容:
session required /lib64/security/pam_limits.so
session required pam_limits.so
5、修改/etc/profile 文件
[root@db ~]# vim /etc/profile
# 在文档最后加入以下内容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
# 重新加载配置
[root@db ~]# source /etc/profile
6、创建数据库相关目录
[root@db ~]# mkdir -p /apps/oracle/app/
[root@db ~]# mkdir -p /apps/oracle/etc/
[root@db ~]# chown -R oracle:oinstall /apps/oracle
[root@db ~]# chmod 775 /apps/oracle
7、安装包上传、解压
# 切换oracle用户、上传安装包并解压
[root@db ~]# su - oracle
[oracle@db app]$ unzip p13390677_112040_Linux-x86-64_1of7.zip
[oracle@db app]$ unzip p13390677_112040_Linux-x86-64_2of7.zip
# 安装包下载链接:
https://updates.oracle.com/Orion/Services/download/p13390677_112040_Linux-x86-64_1of7.zip?aru=16716375&patch_file=p13390677_112040_Linux-x86-64_1of7.zip
https://updates.oracle.com/Orion/Services/download/p13390677_112040_Linux-x86-64_2of7.zip?aru=16716375&patch_file=p13390677_112040_Linux-x86-64_2of7.zip
[oracle@db app]$ cp /apps/oracle/app/database/response/* /apps/oracle/etc/
8、添加环境变量
# 切换oracle用户
[root@db ~]# su - oracle
# 编辑环境变量,并生效
[oracle@db app]$ vim ~/.bash_profile
# 内容如下:
# oracle安装目录
export ORACLE_BASE=/apps/oracle/app
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
# oracle实例SID名称
export ORACLE_SID=orcl
# 同SID
export ORACLE_TERM=orcl
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
# 同SID
export ORACLE_UNQNAME=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export PATH
export SQLPATH=/apps/oracle/labs
# 使得生效
[oracle@db app]$ source ~/.bash_profile
# 验证是否生效
[oracle@db app]$ echo $ORACLE_HOME
/apps/oracle/app/product/11.2.0
三、安装程序
1、修改db_install.rsp
# 根据实际情况修改
[oracle@db app]$ cd /apps/oracle/etc/
[oracle@db app]$ cat /apps/oracle/etc/db_install.rsp | grep -v "#" | grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=db
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/apps/oracle/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/apps/oracle/app/product/11.2.0
ORACLE_BASE=/apps/oracle/app
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=
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
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.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
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=
2、安装数据库
2.1、oracle用户执行命令
[oracle@db bin]$ cd /apps/oracle/app/database/
[oracle@db bin]$ ./runInstaller -silent -force -responseFile /apps/oracle/etc/db_install.rsp -ignorePrereq
2.2、切换root用户执行(有时候可能只有一个root.sh)
[root@db ~]# /apps/oracle/app/oraInventory/orainstRoot.sh
[root@db ~]# /apps/oracle/app/product/11.2.0/root.sh
3、监听安装
[oracle@db database]$ cd /apps/oracle/app/product/11.2.0/bin
[oracle@db bin]$ ./netca /silent /responsefile /apps/oracle/etc/netca.rsp
4、监听状态查看
[oracle@db bin]$ lsnrctl status
5、静默建库
5.1、修改dbca.rsp
[oracle@db ~]$ cd /apps/oracle/etc/
# 根据实际情况修改
[oracle@db ~]$ cat /apps/oracle/etc/dbca.rsp | grep -v '#' | grep -v '^$'
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "sysdba"
SYSTEMPASSWORD = "sysdba"
SYSMANPASSWORD = "sysdba"
DBSNMPPASSWORD = "sysdba"
CHARACTERSET = "ZHS16GBK"
TEMPLATENAME = "General_Purpose.dbc"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl"
NODELIST=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl"
INSTANCENAME = "orcl"
SYSDBAUSERNAME = "sys"
5.2、执行建库命令:
[oracle@db bin]$ cd /apps/oracle/app/product/11.2.0/bin
[oracle@db bin]$ ./dbca -silent -responseFile /apps/oracle/etc/dbca.rsp
顺利通过,安装成功
6、登录查看
[oracle@db bin]$ sqlplus / as sysdba
# 创建用户
CREATE USER test IDENTIFIED BY pass20240725;
# 授予权限
grant connect,resource to test;
四、系统服务注册
1、dbstart文件修改
[oracle@db ~]$ echo $ORACLE_HOME
/apps/oracle/app/product/11.2.0
[oracle@db ~]$ cd /apps/oracle/app/product/11.2.0/bin/
[oracle@db ~]$ vi dbstart
# 将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=/apps/oracle/app/product/11.2.0
2、dbshut文件修改
[oracle@db ~]$ cd /apps/oracle/app/product/11.2.0/bin/
[oracle@db ~]$ vi dbshut
# 将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=/apps/oracle/app/product/11.2.0
3、oratab文件修改
[oracle@db ~]$ vi /etc/oratab
# orcl:/apps/oracle/app/product/11.2.0:N 修改为
# orcl:/apps/oracle/app/product/11.2.0:Y
4、系统服务文件编写
[root@db ~]# cd /etc/systemd/system/
[root@db ~]# vi oracle.service
# 内容如下
[Unit]
Description=Oracle Database 11g Startup/Shutdown Service
After=syslog.target network.target
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=oneshot
RemainAfterExit=yes
User=oracle
Environment="ORACLE_HOME=/apps/oracle/app/product/11.2.0"
ExecStart=/apps/oracle/app/product/11.2.0/bin/dbstart $ORACLE_HOME >> 2>&1 &
ExecStop=/apps/oracle/app/product/11.2.0/bin/dbshut $ORACLE_HOME 2>&1 &
[Install]
WantedBy=multi-user.target
# 开机自启动oracle服务
[root@db ~]# systemctl enable oracle
# 查看oracle服务状态
[root@db ~]# systemctl status oracle
# 手动启动oracle服务
[root@db ~]# systemctl start oracle
# 手动停止oracle服务
[root@db ~]# systemctl stop oracle
# 禁止oracle服务开机自启动
[root@db ~]# systemctl disable oracle
来源:本文内容搜集或转自各大网络平台,并已注明来源、出处,如果转载侵犯您的版权或非授权发布,请联系小编,我们会及时审核处理。
声明:江苏教育黄页对文中观点保持中立,对所包含内容的准确性、可靠性或者完整性不提供任何明示或暗示的保证,不对文章观点负责,仅作分享之用,文章版权及插图属于原作者。
Copyright©2013-2024 JSedu114 All Rights Reserved. 江苏教育信息综合发布查询平台保留所有权利
苏公网安备32010402000125 苏ICP备14051488号-3技术支持:南京博盛蓝睿网络科技有限公司
南京思必达教育科技有限公司版权所有 百度统计