oracle 11gR2部署

该文详细描述了在CentOS7.9环境下,如何禁用SELinux和Firewalld,调整系统参数,创建用户和组,设置限制,解压安装包,创建响应文件,以及进行静默安装Oracle11gR2数据库的过程。
摘要由CSDN通过智能技术生成

oracle 11gR2部署

文章目录

  • 安装文档参照:https://jingyan.baidu.com/article/90895e0f29c92164ec6b0bd1.html
  • 安装包提供:https://pan.baidu.com/s/1r57xI5fSVba_Q3biCj06yg
    提取码:xk30

安装环境:

系统ip版本
centos7.9192.168.0.102oracle 11gR2
//基础准备
[root@oracle ~]# 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=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 


[root@oracle ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

May 30 07:30:32 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
May 30 07:30:33 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
May 30 07:30:33 localhost.localdomain firewalld[734]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configurat...t now.
May 29 23:38:15 test systemd[1]: Stopping firewalld - dynamic firewall daemon...
May 29 23:38:16 test systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@oracle ~]# yum -y install unzip 
[root@oracle ~]# yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel
//添加oinstall 、dba 组,新建oracle用户并加入oinstall、dba组中;
[root@oracle ~]# groupadd oinstall
[root@oracle ~]# groupadd dba
[root@oracle ~]# useradd -g  oinstall -G dba oracle
[root@oracle ~]# passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is a palindrome
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@oracle ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
//修改内核参数:编辑 /etc/sysctl.conf
[root@oracle ~]# vi /etc/sysctl.conf 
[root@oracle ~]# cat /etc/sysctl.conf 
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).


io-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@oracle ~]# sysctl -p  //让参数生效
sysctl: cannot stat /proc/sys/io-max-nr: No such file or directory
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
//修改用户的限制文件,编辑 /etc/security/limits.conf
最后添加
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536
oracle           soft    stack           10240
//修改/etc/pam.d/login文件
[root@oracle ~]# vi /etc/pam.d/login 
最后添加
session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so
//修改/etc/profile文件
[root@oracle ~]# vi /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@oracle ~]# mkdir -p /app/oracle/product/11.2.0
[root@oracle ~]# mkdir /app/oracle/oradata
[root@oracle ~]# mkdir /app/oracle/inventory
[root@oracle ~]# mkdir /app/oracle/fast_recovery_area
[root@oracle ~]# chown -R oracle:oinstall /app/oracle
[root@oracle ~]# chmod -R 775 /app/oracle
//解压oracle软件包
[root@oracle tmp]# ls
linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip
[root@oracle tmp]# unzip linux.x64_11gR2_database_1of2.zip 
[root@oracle tmp]# unzip linux.x64_11gR2_database_2of2.zip
[root@oracle ~]# su oracle
[oracle@oracle root]$ cd
[oracle@oracle ~]$ cd /tmp/database/
[oracle@oracle database]$ ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@oracle database]$ cd
[oracle@oracle ~]$ vi .bash_profile 
[oracle@oracle ~]$ cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

ORACLE_BASE=/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
//刷新一下环境变量
[oracle@oracle ~]$ source .bash_profile
//编辑静默安装响应文件
[root@oracle tmp]# cd  database/
[root@oracle database]# ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[root@oracle database]# cd response/
[root@oracle response]# cp db_install.rsp db_install.rsp.bak //进行备份
[root@oracle response]# vi db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=txl
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/app/oracle/product/11.2.0
ORACLE_BASE=/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
//根据响应文件安装oracle 11g
[oracle@oracle database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 41478 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 2047 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2023-06-14_04-47-35AM. Please wait ...[oracle@oracle database]$ [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.

[oracle@oracle database]$ [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:
 /app/oracle/inventory/logs/installActions2023-06-14_04-47-35AM.log
//可以通过看日志文件有没有报错信息
[root@oracle response]# tail -f /app/oracle/inventory/logs/installActions2023-06-14_04-47-35AM.log

//这个执行完[oracle@oracle database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
看到下面的代表成功了
/app/oracle/inventory/orainstRoot.sh
/app/oracle/product/11.2.0/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.
//按照提示切换root用户运行脚本
[root@oracle response]# sh /app/oracle/inventory/orainstRoot.sh
Changing permissions of /app/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /app/oracle/inventory to oinstall.
The execution of the script is complete.
[root@oracle response]# sh /app/oracle/product/11.2.0/root.sh 
Check /app/oracle/product/11.2.0/install/root_oracle_2023-06-14_04-56-19.log for the output of root script
//用oracle用户登录配置监听
[oracle@oracle ~]$ netca -silent -responseFile /tmp/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.    
[oracle@oracle ~]$ export DISPLAY=localhost:0.0 //出现上面情况执行这条
[oracle@oracle ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp   
Exception in thread "main" java.lang.UnsatisfiedLinkError: /app/oracle/product/11.2.0/jdk/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
	at java.lang.Runtime.load0(Runtime.java:769)
	at java.lang.System.load(System.java:968)
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668)
	at java.lang.Runtime.loadLibrary0(Runtime.java:822)
	at java.lang.System.loadLibrary(System.java:993)
	at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
	at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
	at java.awt.Component.<clinit>(Component.java:547)
[oracle@oracle ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp

[root@oracle ~]# yum install -y libXext  //出现上面情况执行这条
[oracle@oracle ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /tmp/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
//看到这个代表成功

//查看监听端口1521
[root@oracle ~]# ss -antl
State       Recv-Q Send-Q                        Local Address:Port                                       Peer Address:Port              
LISTEN      0      128                                       *:22                                                    *:*                  
LISTEN      0      100                               127.0.0.1:25                                                    *:*                  
LISTEN      0      128                                    [::]:1521                                               [::]:*                  
LISTEN      0      128                                    [::]:22                                                 [::]:*                  
LISTEN      0      100                                   [::1]:25                                                 [::]:*                  
//建立新库,同时建立对应的实例
[root@oracle ~]# vi /tmp/database/response/dbca.rsp //修改以下参数
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/app/oracle/oradata
RECOVERYAREADESTINATION=/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"

// 进行静默配置
[oracle@oracle ~]$ dbca -silent -responseFile /tmp/database/response/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
//完成建库后进行实例检查 查看监听状态 登录查看实例状态 启动数据库
[oracle@oracle ~]$ ps -ef | grep ora_ | grep -v grep
oracle    21872      1  0 05:19 ?        00:00:00 ora_pmon_orcl
oracle    21874      1  0 05:19 ?        00:00:00 ora_vktm_orcl
oracle    21879      1  0 05:19 ?        00:00:00 ora_gen0_orcl
oracle    21881      1  0 05:19 ?        00:00:00 ora_diag_orcl
oracle    21883      1  0 05:19 ?        00:00:00 ora_dbrm_orcl
oracle    21885      1  0 05:19 ?        00:00:00 ora_psp0_orcl
oracle    21887      1  0 05:19 ?        00:00:00 ora_dia0_orcl
oracle    21889      1  0 05:19 ?        00:00:00 ora_mman_orcl
oracle    21891      1  0 05:19 ?        00:00:00 ora_dbw0_orcl
oracle    21893      1  0 05:19 ?        00:00:00 ora_lgwr_orcl
oracle    21895      1  0 05:19 ?        00:00:00 ora_ckpt_orcl
oracle    21897      1  0 05:19 ?        00:00:00 ora_smon_orcl
oracle    21899      1  0 05:19 ?        00:00:00 ora_reco_orcl
oracle    21901      1  0 05:19 ?        00:00:00 ora_mmon_orcl
oracle    21903      1  0 05:19 ?        00:00:00 ora_mmnl_orcl
oracle    21905      1  0 05:19 ?        00:00:00 ora_d000_orcl
oracle    21907      1  0 05:19 ?        00:00:00 ora_s000_orcl
oracle    21918      1  0 05:19 ?        00:00:00 ora_qmnc_orcl
oracle    21934      1  0 05:19 ?        00:00:00 ora_cjq0_orcl
oracle    21944      1  0 05:19 ?        00:00:00 ora_q000_orcl
oracle    21946      1  0 05:19 ?        00:00:00 ora_q001_orcl
[oracle@oracle ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-JUN-2023 05:21:38

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                14-JUN-2023 05:02:29
Uptime                    0 days 0 hr. 19 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 14 05:21:50 2023

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.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
//遇到这个问题是无法启动已在运行的oracle
SQL> shutdown immediate  //关闭
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size		    2220200 bytes
Variable Size		  281022296 bytes
Database Buffers	  780140544 bytes
Redo Buffers		    5554176 bytes
Database mounted.
Database opened.   //看到这个代表成功
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值