目录
环境准备
- Oracle 安装路径:
/u01/app/oracle/product/11.2.0/db_1
- 数据存储路径:
/u01/app/oracle/oradata
- 安装信息目录:
/u01/app/oraInventory
- 恢复区域路径:
/u01/app/oracle/fast_recovery_area
安装包下载
Oracle 11.2.0.4 x86_64系统安装包共7个zip文件,若只安装Oracle仅需前两个zip文件。
从以下官网地址下载Oracle 11.2.0.4 x86_64位安装包。
Oracle 11.2.0.4 Linux x86-64 (American English)下载地址:
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 安装包上传至/home/soft目录,并解压。
mkdir /home/soft
mv p* /home/soft
cd /home/soft
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
chmod -R 777 /home/soft
创建组和用户
创建安装Oracle数据库所需的用组和用户
groupadd -g 600 oinstall
groupadd -g 601 dba
useradd -u 600 -g oinstall -G dba oracle
# 设置Oracle用户密码
passwd oracle
创建目录及设置权限
# 创建数据库对应目录,并修改目录权限
mkdir -p /u01/app/oracle/product/11.2.0/db_1
mkdir /u01/app/oracle/oradata
mkdir /u01/app/oracle/inventory
mkdir /u01/app/oraInventory
mkdir /u01/app/oracle/fast_recovery_area
chown -R oracle:oinstall /u01/app/
chmod -R 775 /u01/app/oracle
编辑用户环境变量
# 切换至Oracle用户
[root@oracle ~]# su - oracle
# 编辑.bash_profile环境变量文件,添加如下内容
[oracle@oracle ~]$ cat .bash_profile --内容如下
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
# export path
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
# 使环境变量生效
[oracle@oracle ~]$ source .bash_profile
编辑资源限制
root用户操作,编辑 /etc/security/limits.conf
cat >> /etc/security/limits.conf <<EOF
oracle hard nproc 16384
oracle soft nofile 10240
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
* soft memlock 104857600
* hard memlock 104857600
EOF
修改内核参数
root用户操作
#change system parameter
cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo "#oracle" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf
echo "vm.swappiness = 10" >> /etc/sysctl.conf
echo "kernel.shmmax= $(free|grep Mem |awk '{print int($2*1024*0.85)}')" >> /etc/sysctl.conf
echo "kernel.shmall = $(free|grep Mem |awk '{print int(($2*1024*0.85)/4096)}')" >> /etc/sysctl.conf
echo "vm.nr_hugepages = $(free -m|grep Mem |awk '{print int(($2*0.8*0.8)/2)}')" >> /etc/sysctl.conf
free -m
sysctl -p
echo "#oracle" >> /etc/security/limits.conf
echo "oracle soft nproc 2047" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "oracle soft nofile 1024" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
echo "* soft memlock $(free |grep Mem|awk '{print int($2*0.90*1024)}')" >> /etc/security/limits.conf
echo "* hard memlock $(free |grep Mem|awk '{print int($2*0.90*1024)}')" >> /etc/security/limits.conf
#add oracle profile
cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -u 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
编辑/etc/pam.d/login文件
root用户操作
cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF
安装依赖包
由于是离线环境依赖包我这里提前下载到下来了
tar -xf oracle_repo.tar.gz
cd my_oracle_repo
rpm -ivh *.rpm --nodeps --force
关闭防火墙selinux
service iptables stop
systemctl stop firewalld
systemctl disable firewalld
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
cat /etc/selinux/config
setenforce 0
安装数据库软件
准备db_install.rsp响应文件
切换至Oracle用户操作
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ cp -R /home/soft/database/response/ .
[oracle@oracle ~]$ ll
total 0
drwxr-xr-x. 2 oracle oinstall 61 May 23 22:04 response
[oracle@192 ~]$ cd response/
# 编辑 db_install.rsp响应文件,主要修改以下内容
# 响应文件的格式版本,这里指定的版本为 "/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
# 安装选项,这里设置为 "INSTALL_DB_SWONLY",表示仅安装数据库软件,而不创建或配置数据库实例
oracle.install.option=INSTALL_DB_SWONLY
# Oracle数据库所在的主机名
ORACLE_HOSTNAME=xxx-db
# 用于安装和管理Oracle软件的Unix组名,这里设置为"oinstall"
UNIX_GROUP_NAME=oinstall
# Oracle Inventory(安装目录)的路径,这里设置为 "/u01/app/oraInventory"。
INVENTORY_LOCATION=/u01/app/oraInventory
# 选择的语言,这里设置为 "en,zh_CN",表示英文和简体中文
SELECTED_LANGUAGES=en,zh_CN
# Oracle软件的安装路径(数据库主目录)
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
# Oracle软件的基本路径
ORACLE_BASE=/u01/app/oracle
# 安装的Oracle数据库版本。这里设置为 "EE",表示企业版
oracle.install.db.InstallEdition=EE
# 是否选择了企业版选项,这里设置为"false",表示未选择任何企业版选项
oracle.install.db.EEOptionsSelection=false
# 用于数据库管理员(DBA) 组的名称,这里设置为 "dba"
oracle.install.db.DBA_GROUP=dba
# 用于操作员组的名称,这里设置为 "dba",与DBA组相同
oracle.install.db.OPER_GROUP=dba
# 是否拒绝安装安全更新,这里设置为 "true",表示拒绝安装安全更新
DECLINE_SECURITY_UPDATES=true
# 自动更新选项,这里设置为 "SKIP_UPDATES",表示跳过自动更新
oracle.installer.autoupdates.option=SKIP_UPDATES
运行runInstaller进行安装
[oracle@oracle response]$ cd /home/soft/database/
[oracle@oracle database]$ ./runInstaller -silent -noconfig -ignorePrereq -responseFile /home/oracle/response/db_install.rsp
等待一段时间后提示以 root 用户的身份执行以下脚本
创建监听
# 使用Oracle用户执行
[oracle@oracle ~]$ netca /silent -responsefile /home/oracle/response/netca.rsp
创建数据库
准备dbca.rsp响应文件
# 使用Oracle用户执行,编辑dbca.rsp响应文件,主要修改如下内容
[oracle@oracle database]$ cd /home/oracle/response/
[oracle@oracle response]$ ll
总用量 80
-rwxr-xr-x 1 oracle oinstall 44533 8月 20 22:33 dbca.rsp
-rwxr-xr-x 1 root root 25248 8月 20 22:33 db_install.rsp
-rwxr-xr-x 1 oracle oinstall 5871 8月 20 22:33 netca.rsp
[oracle@localhost response]$ vim dbca.rsp
# 全局数据库名
GDBNAME = "orcl"
# 数据库实例名
SID = "orcl"
# SYS用户的密码
SYSPASSWORD = "oracle"
# SYSTEM用户的密码
SYSTEMPASSWORD = "oracle"
# SYSMAN用户(用于Enterprise Manager)的密码
SYSMANPASSWORD = "oracle"
# DBSNMP用户(用于SNMP管理)的密码
DBSNMPPASSWORD = "oracle"
# 数据文件存储路径
DATAFILEDESTINATION =/u01/app/oracle/oradata
# 恢复区域存储路径
RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area
# 数据库字符集
CHARACTERSET = "ZHS16GBK"
# 数据库实例使用的总内存大小(以MB为单位)
TOTALMEMORY = "3276"
创建数据库
[oracle@oracle response]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp
查看监听状态
[oracle@oracle response]$ lsnrctl status
查看实例状态
[oracle@oracle response]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 20 22:44:27 2024
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
修改local_listener
[oracle@oracle ~]$ sqlplus / as sysdba
SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521))';
SQL> alter system register;
标签:app,Oacle,0.4,11.2,echo,Oracle,etc,conf,oracle
From: https://www.cnblogs.com/Unstoppable9527/p/18369441