centos7下oracle11g安装

环境说明

os: centos 7.9

oracle: 11.2.04

系统安装要求

内存要求

ram需求

最小: 1 GB

推荐: 2 GB或更多

swap需求

内存大小swap大小
1G到2G之间 内存大小1.5倍
2G到16G之间 与内存大小一致
16G以上 16 GB

磁盘需求

最小1G大小/tmp目录

对64位版本系统而言,依据不同安装版本,所需磁盘大小如下:

安装版本安装后大小 (GB)
Enterprise Edition 4.7
Standard Edition 4.6

依据不同安装版本,所需数据文件大小如下:

安装版本数据文件大小 (GB)
Enterprise Edition 1.7
Standard Edition 1.5

安装前配置

selinux

关闭selinux

vim /etc/selinux/config

修改为

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

firewalld

关闭并禁用firewalld

systemctl stop firewalld
systemctl disable firewalld

修改hostname

修改hostname

hostnamectl set-hostname orcl11g 

编辑/etc/hosts加入一行

192.168.x.xx orcl11g

调整内核参数

vim /etc/sysctl.conf 

修改为:

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 13958643712 //最大共享内存的段大小,不小于物理内存的一半
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

添加用户

groupadd oinstall
groupadd dba
useradd -g oinstall -G dba -m oracle
passwd oracle

 对oracle用户进行限制

vim /etc/security/limits.conf 

 加入:

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft stack 10240

在 /etc/pam.d/login 文件中添加如下内容:

session required pam_limits.so 

修改/etc/profile加入:

if [ $USER = "oracle" ]; then
   if [ $SHELL = "/bin/ksh" ]; then
       ulimit -p 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536 -s 10240
   fi
fi

修改oracle用户环境变量

修改.bash_profile加入:

export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_UNQNAME=orcl 

 安装缺失软件包

yum install -y binutils.x86_64 \
compat-libcap1.x86_64 \
compat-libstdc++-33.i686 \
compat-libstdc++-33.x86_64 \
gcc.x86_64 \
gcc-c++.x86_64 \
glibc.i686 \
glibc.x86_64 \
glibc-devel.i686 \
glibc-devel.x86_64 \
ksh \
libaio.i686 \
libaio.x86_64 \
libaio-devel.i686 \
libaio-devel.x86_64 \
libgcc.i686 \
libgcc.x86_64 \
libstdc++.i686 \
libstdc++.x86_64 \
libstdc++-devel.i686 \
libstdc++-devel.x86_64 \
libXi.i686 \
libXi.x86_64 \
libXtst.i686 \
libXtst.x86_64 \
make.x86_64 \
sysstat.x86_64

建立安装文件夹

mkdir /u01
mkdir -p /u01/oracle
chown -R oracle:oinstall oracle/

开始安装

上传安装包并解压

上传p13390677_112040_Linux-x86-64_1of7.zip和p13390677_112040_Linux-x86-64_2of7.zip到服务器并解压

unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip

修改安装文件

cd database/
cp -R response/ response.bak
vim response/db_install.rsp 

修改如下内容部分

oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/oracle/oraInventory/
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
DECLINE_SECURITY_UPDATES=true

安装oracle

./runInstaller -silent -responseFile /home/oracle/database/response/db_install.rsp -ignorePrereq

监听安装输出日志

tail -f  /tmp/OraInstall2022-04-24_12-45-22AM

 如图,显示安装成功:

单独SSH以root进入系统,执行如下命令:

/u01/oracle/oraInventory/orainstRoot.sh
/u01/oracle/product/11.2.0/dbhome_1/root.sh

至此,数据库软件安装完成。

配置oracle监听

修改response/netca.rsp文件,修改端口号或保留默认端口即可,然后执行:

netca /silent  /responsefile /home/oracle/database/response/netca.rsp

结果如图:

查看是否数据库已经监听:

至此,数据库监听配置完成。

安装数据库实例

修改文件response/dbca.rsp,修改部分内容如下:

GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "sys密码"
SYSTEMPASSWORD = "system密码"
SYSMANPASSWORD = "sysman密码"
DBSNMPPASSWORD = "dbsnmp密码"
DATAFILEDESTINATION = /u01/oracle/oradata
RECOVERYAREADESTINATION=/u01/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "10240" // 单位M,配置成10G内存 

创建数据库实例

dbca -silent -responseFile /home/oracle/database/response/dbca.rsp 

如图:

数据库实例配置成功。

配置开机自启动服务

创建systemd服务文件orcl.service如下:

# /etc/systemd/system/oracle-rdbms.service
# Invoking Oracle scripts to start/shutdown Instances defined in /etc/oratab
# and starts Listener
[Unit]
Description=Oracle Database(s) and Listener
Requires=network.target
[Service]
Type=forking
Restart=no
ExecStart=/u01/oracle/product/11.2.0/dbhome_1/bin/dbstart /u01/oracle/product/11.2.0/dbhome_1
ExecStop=/u01/oracle/product/11.2.0/dbhome_1/bin/dbshut /u01/oracle/product/11.2.0/dbhome_1
User=oracle
[Install]
WantedBy=multi-user.target 

加载服务

cp orcl.service /usr/lib/systemd/system
systemctl daemon-reload
systemctl enable orcl

编辑/etc/oratab,修改为:

orcl:/u01/oracle/product/11.2.0/dbhome_1:Y 

重启,查看是否已经开机自启动:

启用自动内存管理

修改/etc/fstab,加入一行如下:

tmpfs /dev/shm tmpfs defaults,size=13G 0 0    #13G为内存大小 

重启,如图:

通过sqlplus连接系统后执行:

ALTER SYSTEM SET MEMORY_TARGET = 10240M SCOPE=SPFILE;
ALTER SYSTEM SET memory_max_target = 133120M SCOPE=SPFILE;
ALTER SYSTEM SET SGA_TARGET = 0 SCOPE=SPFILE;
ALTER SYSTEM SET SGA_MAX_SIZE=8192M SCOPE=SPFILE;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET = 0 SCOPE=SPFILE;
alter system set pre_page_sga=FALSE scope=spfile 

oracle 11g安装完成。

 

posted @ 2022-04-24 01:49  一朵野生菌  阅读(657)  评论(0编辑  收藏  举报