记一次| centos7单机安装oracle11g

2024年 4月 15日 158.3k 0

准备环境:Centos7、上传oracle11g安装包

[root@zsglptdb ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[root@zsglptdb ~]# ls -lh /u01/soft/p13390677_112040_Linux-x86-64_*
-rw-r--r--. 1 root root 1.3G 4月 12 16:36 /u01/soft/p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--. 1 root root 1.1G 4月 12 16:46 /u01/soft/p13390677_112040_Linux-x86-64_2of7.zip

1、 配置hostname

hostnamectl set-hostname zsglptdb
echo "127.0.0.1 zsglptdb" >>/etc/hosts

2、关闭selinux

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

3、检查软件依赖环境

注意:从Oracle 11g 11.2.0.2版本开始,在Linux x86_64上安装时,只需要安装64位的软件包

#需要安装的依赖包(版本号只能大于规定的版本,不能小于) 安装命令:
yum -y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel

#安装完成后,检查依赖是否安装成功
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel | grep "not installed"

4、创建所需的操作系统组和用户

[root@zsglptdb ~]# groupadd oinstall
[root@zsglptdb ~]# groupadd dba
[root@zsglptdb ~]# useradd -g oinstall -g dba -m oracle
[root@zsglptdb ~]# passwd oracle
更改用户 oracle 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@zsglptdb ~]# groups oracle
oracle : dba

5、配置内核参数和资源限制

在/etc/sysctl.conf添加如下参数,并根据系统调整数值,以优化系统性能
fs.aio-max-nr = 1048576
fs.file-max = 6815744 #设置最大打开文件数
kernel.shmall = 8388608 #单位为页,共享内存的总量,32G内存设置:83886084k/1024/1024
kernel.shmmax = 34359738368 #单位字节,最大共享内存的段大小,32G内存设置:32102410241024
kernel.shmmni = 4096 #整个系统共享内存端的最大数
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

[root@zsglptdb ~]# vim /etc/sysctl.conf
[root@zsglptdb ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608
kernel.shmmax = 34359738368
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

6、在/etc/security/limits.conf中添加如下参数

vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

7、/etc/profile 文件中添加如下内容

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
source /etc/profile

8、在/etc/pam.d/login文件中,添加下面内容

vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so

9、禁用使用Transparent HugePages(启用Transparent HugePages,可能会导致造成内存在运行时的延迟分配,Oracle官方建议使用标准的HugePages)

查看是否启用 如果显示 [always]说明启用了

[root@zsglptdb ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
##开机
[root@zsglptdb ~]# vim /etc/rc.d/rc.local
**echo never > /sys/kernel/mm/transparent_hugepage/enabled
**
[root@zsglptdb ~]# chmod +x /etc/rc.d/rc.local
[root@zsglptdb ~]# ls -lh /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 530 4月 15 15:20 /etc/rc.d/rc.local

10、开启大页

#查看大页是否开启HugePages_Total: 0 表示未开启大页
[root@zsglptdb ~]# cat /proc/meminfo |grep -i huge
AnonHugePages: 260096 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB

vim /etc/sysctl.conf
vm.nr_hugepages=16384
sysctl -p

11、创建oracle安装目录,配置权限

[root@zsglptdb ~]# mkdir -p /u01/app/oracle
[root@zsglptdb ~]# mkdir -p /u02/ora_data
[root@zsglptdb ~]# chown -R oracle:oinstall /u01/app/oracle
[root@zsglptdb ~]# chown -R oracle:oinstall /u02/ora_data/
[root@zsglptdb ~]# chown -R oracle:oinstall /u01/database/

[oracle@zsglptdb etc]$ mkdir /u01/database/inventory

12、配置oracle用户环境变量

在文件/home/oracle/.bash_profile里添加下面内容(具体值根据实际情况修改)
umask 022
export ORACLE_HOSTNAME=cwai
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=ORACLEBASE/product/11.2.0/exportORACLESID=cwaiexportLCALL="enUS"exportLANG="enUS"exportNLSLANG="AMERICANAMERICA.ZHS16GBK"exportNLSDATEFORMAT="YYYY−MM−DDHH24:MI:SS"PATH=.:ORACLE_BASE/product/11.2.0/
export ORACLE_SID=cwai
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
PATH=.:ORACLEB​ASE/product/11.2.0/exportORACLES​ID=cwaiexportLCA​LL="enU​S"exportLANG="enU​S"exportNLSL​ANG="AMERICANA​MERICA.ZHS16GBK"exportNLSD​ATEF​ORMAT="YYYY−MM−DDHH24:MI:SS"PATH=.:ORACLE_HOME/bin:ORACLEHOME/OPatch:ORACLE_HOME/OPatch:ORACLEH​OME/OPatch:ORACLE_HOME/jdk/bin:$PATH

[oracle@zsglptdb ~]$ vim .bash_profile
[oracle@zsglptdb ~]$ source .bash_profile

13、在~/etc/db_install.rsp修改以下变量的值

oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/database/inventory
SELECTED_LANGUAGES=en,zh_CN
#ORACLE_HOSTNAME=zsglptdb
ORACLE_HOME=/u01/app/oracle/product/11.2.0
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba

[oracle@zsglptdb ~]$ mkdir etc
[oracle@zsglptdb ~]$ cd etc/
[oracle@zsglptdb etc]$ cp /u01/database/response/* ./

14、解压下载好的安装包

unzip -q linux.x64_11gR2_database_1of2.zip -d /u01
unzip -q linux.x64_11gR2_database_2of2.zip -d /u01

15、开始安装

su - oracle
cd /u01/database
./runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp -ignorePrereq

Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 39465 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2024-04-15_04-30-53PM. Please wait ...[oracle@zsglptdb database]$ You can find the log of this install session at:
/u01/database/inventory/logs/installActions2024-04-15_04-30-53PM.log
[oracle@zsglptdb database]$ The installation of Oracle Database 11g was successful.
Please check '/u01/database/inventory/logs/silentInstall2024-04-15_04-30-53PM.log' for more details.

As a root user, execute the following script(s):
1. /u01/database/inventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0/root.sh

16、安装期间可以使用tail命令监看oracle的安装日志

[root@zsglptdb ~]# tail -f /u01/database/inventory/logs/installActions2024-04-15_04-30-53PM.log

17、使用root用户执行脚本

sh /u01/database/inventory/orainstRoot.sh
sh /u01/app/oracle/product/11.2.0/root.sh

18、配置监听程序

[oracle@zsglptdb database]$ netca -silent -responsefile /home/oracle/etc/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
Listener Control complete.
[oracle@zsglptdb admin]$ netstat -tnpl | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::1521 :::* LISTEN 31241/tnslsnr

18、静默创建数据库

编辑应答文件/home/oracle/etc/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = “11.2.0”
OPERATION_TYPE = “createDatabase”
[CREATEDATABASE]
GDBNAME = “orcl11g.ccwai”
SID = “cwai”
SYSPASSWORD = “oracle”
SYSTEMPASSWORD = “oracle”
SYSMANPASSWORD = “oracle”
DBSNMPPASSWORD = “oracle”
DATAFILEDESTINATION =/u02/ora_data
RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area
CHARACTERSET = “AL32UTF8”
TOTALMEMORY = “1638”
vim /home/oracle/etc/dbca.rsp
dbca -silent -responseFile /home/oracle/etc/dbca.rsp
#查看进程
ps -ef | grep ora_ | grep -v grep
#查看监听状态
$ lsnrctl status
su - oracle

[oracle@zsglptdb etc]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Mon Apr 15 17:07:55 2024

Copyright © 1982, 2013, Oracle. All rights reserved.

SQL> conn /as sysdba
Connected.
SQL> select status from v$instance;

STATUS

OPEN

## 19、安装rlwrap工具

[root@zsglptdb opt]# tar -zxvf /u01/soft/rlwrap-0.43.tar.gz
[root@zsglptdb rlwrap-0.43]# yum install readline* -y
[root@zsglptdb rlwrap-0.43]# ./configure && make && make install
[oracle@zsglptdb ~]$ vim .bash_profile
alias sqlplus=‘rlwrap sqlplus’
alias rman=‘rlwrap rman’

## 20、安装补丁包

[oracle@zsglptdb ~]$ cd ORACLEHOME/rdbms/admin[oracle@zsglptdbadmin]ORACLE_HOME/rdbms/admin
[oracle@zsglptdb admin]ORACLEH​OME/rdbms/admin[oracle@zsglptdbadmin] sqlplus /nolog
SQL> conn /as sysdba
Connected.
SQL> @dbmsjdev.sql

SQL> conn /as sysdba
Connected.
SQL> select action_time,action,id,version from dba_registry_history;

ACTION_TIME

ACTION ID

VERSION

24-AUG-13 12.03.45.119862 PM
APPLY 0
11.2.0.4

15-APR-24 04.59.48.840440 PM
APPLY 0
11.2.0.4

ACTION_TIME

ACTION ID

VERSION

[oracle@zsglptdb 11.2.0]$ mv OPatch OPatch_2024
[oracle@zsglptdb 11.2.0]$ mv /u01/database/bding/OPatch/ ./
[oracle@zsglptdb 11.2.0]$ vim ~/.bash_profile
[oracle@zsglptdb 11.2.0]$ opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.23
Copyright © 2024, Oracle Corporation. All rights reserved.

Oracle Home : /u01/app/oracle/product/11.2.0
Central Inventory : /u01/database/inventory
from : /u01/app/oracle/product/11.2.0//oraInst.loc
OPatch version : 11.2.0.3.23
OUI version : 11.2.0.4.0
Log file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch2024-04-15_17-30-13PM_1.log

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/lsinv/lsinventory2024-04-15_17-30-13PM.txt

Local Machine Information::
Hostname: localhost
ARU platform id: 226
ARU platform description:: Linux x86-64

Installed Top-level Products (1):

Oracle Database 11g 11.2.0.4.0
There are 1 products installed in this Oracle Home.

There are no Interim patches installed in this Oracle Home.

OPatch succeeded.
[oracle@zsglptdb 11.2.0]$ cd -
/u01/database/bding

[oracle@zsglptdb 31718723]$ cd 31537677/
[oracle@zsglptdb 31537677]$ opatch apply

[oracle@zsglptdb 31537677]$ opatch lsinventory
Oracle Interim Patch Installer version 11.2.0.3.23
Copyright © 2024, Oracle Corporation. All rights reserved.

Oracle Home : /u01/app/oracle/product/11.2.0
Central Inventory : /u01/database/inventory
from : /u01/app/oracle/product/11.2.0//oraInst.loc
OPatch version : 11.2.0.3.23
OUI version : 11.2.0.4.0
Log file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch2024-04-15_17-53-59PM_1.log

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/cfgtoollogs/opatch/lsinv/lsinventory2024-04-15_17-53-59PM.txt

Local Machine Information::
Hostname: localhost
ARU platform id: 226
ARU platform description:: Linux x86-64

Installed Top-level Products (1):

Oracle Database 11g 11.2.0.4.0
There are 1 products installed in this Oracle Home.

Interim patches (2) :

Patch 31537677 : applied on Mon Apr 15 17:52:52 CST 2024
Unique Patch ID: 23828543

## 21、修改参数

SQL> alter system set processes=1000 scope=spfile;
SQL> alter system set pga_aggregate_target=4G scope=spfile;
SQL> alter system set sga_max_size=26G scope=spfile;
SQL> alter system set sga_target=26G scope=spfile;

## 21、修改端口

cd $ORACLE_HOME/network/admin
vim listener.ora
vim tnsnames.ora

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论