1. 关闭防火墙和selinux
(centos版本差异,相应的查询命令不同,自行百度)
[root@master opt]# firewall-cmd --state
running
[root@master opt]#
[root@master opt]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-08-25 23:19:37 CST; 6 months 17 days ago
Docs: man:firewalld(1)
Main PID: 781 (firewalld)
CGroup: /system.slice/firewalld.service
└─781 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
Aug 25 23:19:34 master systemd[1]: Starting firewalld - dynamic firewall daemon...
Aug 25 23:19:37 master systemd[1]: Started firewalld - dynamic firewall daemon.
Aug 25 23:19:37 master firewalld[781]: WARNING: AllowZoneDrifting is enabled. This is con...ow.
Hint: Some lines were ellipsized, use -l to show in full.
2. 关闭防火墙:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
[root@master opt]# systemctl stop firewalld.service
[root@master opt]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@master opt]#
[root@master opt]# setenforce Permissive
[root@master opt]# getenforce
Permissive
[root@master opt]# cat /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=enforcing
SELINUX=Permissive
# 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
[root@master opt]#
3. 安装依赖包
[root@master ~]# yum -y install \
binutils \
compat-libstdc++-33 \
compat-libstdc++-33.i686 \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc.i686 \
glibc-common \
glibc-devel \
glibc-devel.i686 \
glibc-headers ksh \
libaio \
libaio.i686 \
libaio-devel \
libaio-devel.i686 \
libgcc \
libgcc.i686 \
libstdc++ \
libstdc++.i686 \
libstdc++-devel \
make \
sysstat \
unixODBC \
unixODBC-devel \
unzip \
lrzsz \
vim \
ksh
[root@master ~]# yum install libXext.so.6
4. 添加oracle用户
[root@master ~]# groupadd oinstall
[root@master ~]# groupadd dba
[root@master ~]# useradd -g oinstall -G dba oracle (主组 oinstall,其它组:dba)
[root@master ~]# passwd oracle
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
5. 修改内核参数
[root@master ~]# vim /etc/sysctl.conf
内存小于64GB,用参数一;大于 64G用参数二 :
参数一:
***********************************
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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 = 1048586
************************************
参数二:
************************************
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 536870912
kernel.shmmax = 270997127168
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 = 1048586
******************************************
6. 执行命令sysctl使其自检并生效
[root@master ~]# sysctl -p
vm.max_map_count = 655360
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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 = 1048586
7. 修改用户资源限制
[root@master ~]# 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
8. 修改/etc/pam.d/login配置文件
# 64位安装
[root@master ~]# vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
9. 修改用户配置文件
[root@localhost data]# vim /etc/profile
# oracle
if [ $USER = "oracle" ];then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384
ulimit -n 65536
fi
fi
10. 生效配置文件
[root@master ~]# source /etc/profile
11. 创建安装目录
[root@master ~]# mkdir -p /u01/oracle /u01/oracle/inventory
[root@master ~]# chown -R oracle:oinstall /u01 /u01/oracle /u01/oracle/inventory
[root@master ~]# chmod -R 775 /u01/oracle /u01/oracle/inventory
12. 通过xshell上传zip文件并解压
##解压缩命令
cd /opt
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
13. 数据库授权
[root@master database]# chmod 777 /opt/database
[root@master database]# chown -R oracle.oinstall /opt/database
[root@master database]#
14. 修改配置 db_install.rsp 文件
直接修改,或者直接替换文件,尽量复制出一份,避免文件异常
[oracle@master response]$ pwd
/opt/database/response
[oracle@master response]$
[oracle@master response]$ ll
total 80
-rw-rw-r--. 1 oracle oinstall 44969 Feb 14 2009 dbca.rsp
-rw-r--r--. 1 oracle oinstall 2886 Mar 14 21:20 db_install.rsp
-rw-rw-r--. 1 oracle oinstall 22557 Aug 14 2009 db_install.rsp_bak
-rwxrwxr-x. 1 oracle oinstall 5740 Feb 26 2009 netca.rsp
[oracle@master response]$ cp db_install.rsp_bak db_install.rsp
【修改以下参数值,对照自己的环境即可。】
[oracle@master response]$ vim db_install.rsp
#文件如下
# 标注响应文件版本-不要修改
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
# 选择安装类型-只安装数据软件
oracle.install.option=INSTALL_DB_SWONLY
# 指定主机名称-环境变量
ORACLE_HOSTNAME=localhost
# 指定oracle oraInventory目录的所有者-oinstall
UNIX_GROUP_NAME=oinstall
# 指定oraInventory 目录的路径
INVENTORY_LOCATION=/u01/oracle/inventory
# 指定数据库语音
SELECTED_LANGUAGES=en,zh_CN
# 指定ORACLE_HOME的路径
ORACLE_HOME=/u01/oracle
# 指定ORACLE_BASE目录的路径
ORACLE_BASE=/u01
# 指定数据库版本-企业版
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
# 指定拥有OSDBS权限的用户组
oracle.install.db.DBA_GROUP=dba
# 指定拥有OSOPER权限的用户组
oracle.install.db.OPER_GROUP=oinstall
# 选择数据库用途-一般用途
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
# 指定数据库的GlobalName(全局名称)
oracle.install.db.config.starterdb.globalDBName=plsdb
# 指定数据库的SID
oracle.install.db.config.starterdb.SID=plsdb
# 指定数据库字符集:ZHS16GBK AL32UTF8
oracle.install.db.config.starterdb.characterSet=ZHS16GBK
# 开启自动内存管理
oracle.install.db.config.starterdb.memoryOption=true
# 是否载入示例模板-false
oracle.install.db.config.starterdb.installExampleSchemas=false
# 是否启用安全设置
oracle.install.db.config.starterdb.enableSecuritySettings=true
# 指定数据库用户使用同一个密码,也可分开指定
oracle.install.db.config.starterdb.password.ALL=cry111111
# 指定 SYS 用户密码
oracle.install.db.config.starterdb.password.SYS=
# 指定 SYSTEM 用户密码
oracle.install.db.config.starterdb.password.SYSTEM=
# 指定 SYSMAN 用户密码
oracle.install.db.config.starterdb.password.SYSMAN=
# 指定 DBSNMP 用户密码
oracle.install.db.config.starterdb.password.DBSNMP=
# 指定数据库本地管理工具
oracle.install.db.config.starterdb.control=DB_CONTROL
# 指定数据库是否开启自动备份-false
oracle.install.db.config.starterdb.automatedBackup.enable=false
# 指定数据库存储方式
oracle.install.db.config.starterdb.storageType=
# 指定数据库数据文件/控制文件/RedoLog的存放目录
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
# 使用文件系统时指定的备份恢复目录
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
# 指定数据库是否设置安全更新-true
DECLINE_SECURITY_UPDATES=true
# 指定数据库更新-SKIP_UPDATES
oracle.installer.autoupdates.option=SKIP_UPDATES
# 创建的文件授权
[oracle@master response]$ chmod 755 db_install.rsp
15 切换至oracle用户
[root@master ~]$ su - oracle
[oracle@master ~]$ vim .bash_profile
# ORACLE_BASE ,ORACLE_HOME ,ORACLE_SID,ORACLE_OWNER 与前文配置一致
export ORACLE_BASE=/u01
export ORACLE_HOME=/u01/oracle
export ORACLE_SID=plsdb
export ORACLE_OWNER=oracle
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
16.保存生效
[oracle@master ~]$ source .bash_profile
17.安装 db_install.rsp
[oracle@master database]$ ll
total 20
drwxr-xr-x. 12 oracle oinstall 203 Aug 17 2009 doc
drwxr-xr-x. 4 oracle oinstall 223 Aug 14 2009 install
drwxrwxr-x. 2 oracle oinstall 87 Mar 14 21:20 response
drwxr-xr-x. 2 oracle oinstall 34 Aug 14 2009 rpm
-rwxr-xr-x. 1 oracle oinstall 4352 Aug 14 2009 runInstaller
drwxrwxr-x. 2 oracle oinstall 29 Aug 14 2009 sshsetup
drwxr-xr-x. 14 oracle oinstall 4096 Aug 14 2009 stage
-rw-r--r--. 1 oracle oinstall 5400 Aug 18 2009 welcome.html
[oracle@master database]$ pwd
/opt/database
[oracle@master database]$ ./runInstaller -silent -force -ignorePrereq -responseFile /opt/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 80 MB. Actual 17231 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2023-03-14_10-26-48PM. Please wait ... [WARNING] [INS-32016] The selected Oracle home contains directories or files.
CAUSE: The selected Oracle home contained directories or files.
ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-32016] The selected Oracle home contains directories or files.
CAUSE: The selected Oracle home contained directories or files.
ACTION: To start with an empty Oracle home, either remove its contents or choose another location.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/u01/oracle/inventory/logs/installActions2023-03-14_10-26-48PM.log
[oracle@master database]$
[oracle@master database]$ The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/oracle/inventory/orainstRoot.sh
/u01/oracle/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
出现两个脚本即为成功。
/u01/oracle/inventory/orainstRoot.sh
/u01/oracle/root.sh
18. 新创建的root窗口内执行以下提示内的脚本, 即
/u01/oracle/inventory/orainstRoot.sh
/u01/oracle/root.sh
[root@master oracle]# sh /u01/oracle/inventory/orainstRoot.sh
Changing permissions of /u01/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/oracle/inventory to oinstall.
The execution of the script is complete.
[root@master oracle]# sh /u01/oracle/root.sh
Check /u01/oracle/install/root_master_2023-03-14_22-41-29.log for the output of root script
自动创建文件为
[root@master etc]# cat oraInst.loc
inventory_loc=/u01/oracle/inventory
inst_group=oinstall
19.监听安装 netca.rsp
[root@master response]# cat netca.rsp |grep -v ^#|grep -v ^$|grep -v "=$"
[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
[oracle@master database]$ netca -silent -responsefile /opt/database/response/netca.rsp
============================ ============================
****DISPLAY environment variable not set!
Oracle Net Configuration Assistant is a GUI tool
which requires that DISPLAY specify a location
where GUI tools can display.
Set and export DISPLAY, then re-run.
========================================================
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /opt/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/oracle/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@master database]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2023 22:54:39
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@master database]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2023 22:54:54
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/oracle/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Log messages written to /u01/diag/tnslsnr/master/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=master)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 14-MAR-2023 22:54:54
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/diag/tnslsnr/master/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=master)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@master database]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2023 22:55:02
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 14-MAR-2023 22:54:54
Uptime 0 days 0 hr. 0 min. 7 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/diag/tnslsnr/master/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=master)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@master database]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2023 22:55:13
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
20.静默创建库,修改配置文件 dbca.rsp
[oracle@master response]$ vim dbca.rsp
[oracle@master response]$ cat dbca.rsp |grep -v ^#|grep -v ^$|grep -v "=$"
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "plsdb"
SID = "plsdb"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "ZHS16GBK"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:plsdb"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "plsdb"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "plsdb"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = plsdb
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "plsdb"
INSTANCENAME = orcl11g
SYSDBAUSERNAME = sys
21.静默创建库 (密码是设置的)
[oracle@master database]$ dbca -silent -responseFile /opt/database/response/dbca.rsp
Enter SYS user password:
Enter SYSTEM user password:
Copying database files
1% complete
2% complete
4% complete
37% complete
Creating and starting Oracle instance
38% complete
40% complete
45% complete
50% complete
51% complete
56% complete
57% complete
61% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
86% complete
98% complete
100% complete
Look at the log file "/u01/cfgtoollogs/dbca/plsdb/plsdb.log" for further details.
[oracle@master database]$
22.验证
[oracle@master database]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 15 16:10:31 2023
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> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 759943168 bytes
Fixed Size 2257112 bytes
Variable Size 503320360 bytes
Database Buffers 247463936 bytes
Redo Buffers 6901760 bytes
Database mounted.
Database opened.
SQL>
23. 创建表空间,用户等操作
移步:
https://blog.csdn.net/weixin_40691089/article/details/81035217
失败删除,重新安装
[root@master bin]# rm -rf /usr/local/bin/coraenv /usr/local/bin/oraenv /usr/local/bin/dbhome
[root@master bin]# rm -rf /etc/oraInst.loc /etc/oratab
[root@master bin]# rm -rf /u01/*
rm -rf /usr/local/bin/coraenv /usr/local/bin/oraenv /usr/local/bin/dbhome
rm -rf /etc/oraInst.loc /etc/oratab
rm -rf /u01/*