Oracle_11gR2安装

oracle官方文档:
https://docs.oracle.com/cd/E11882_01/nav/portal_11.htm

一、检查硬件要求系统必须满足以下最低硬件要求:
1、内存要求
内存要求以下是安装Oracle Database 11g第2版(11.2)的内存要求:
最低要求:1 GB RAM
建议:2 GB RAM或更多要确定RAM大小,
请输入以下命令查看内存大小:

]# grep MemTotal /proc/meminfo 

2、系统体系结构

可用RAM所需交换空间
介于1 GB和2 GB之间是RAM大小的1.5倍
介于2 GB和16 GB之间等于RAM的大小
大于16 GB16 GB

查看swap空间大小

]# grep SwapTotal /proc/meminfo 

增加swap空间大小

]# dd if=/dev/zero of=/swapfile bs=1024 count=4194304
]# mkswap /swapfile
]# swapon /swapfile
]# free -m
                    total        used        free      shared  buff/cache   available
Mem:           3933        1524         124          48        2285        2038
Swap:          8191          16        8175

设置开机时自启用 swap 分区
需要修改文件 /etc/fstab 中的 swap 行,添加:/mnt/swapfile swap swap defaults 0 0

]# vi /etc/fstab
...
/mnt/swapfile swap swap defaults 0 0

3、磁盘空间
安装目录中至少有1 GB磁盘空间要确定目录中可用的磁盘空间量。
请输入以下命令:

]#df -h 

二、对操作系统的需求(当前使用linux7版本安装的Oracle)
以下是安装Oracle的依赖包:
各个操作系统安装的不同的依赖包,具体可查看Oracle的官方文档。

]#  yum -y install binutils compat-libstdc gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel

yum源没有的包可以在这个url地址搜索:
http://www.rpmfind.net/linux/rpm2html/
compat-libcap1-1.10-7.el7.x86_64.rpm
compat-libstdc+±33-3.2.3-72.el7.x86_64.rpm

其他依赖包安装完后必须确保安装了以下Oracle相关驱动:
1、Oracle ODBC驱动程序
2、Oracle JDBC / OCI驱动程序
可以从以下URL下载并安装驱动程序管理器
http://www.unixodbc.org
要使用ODBC,还必须安装以下其他ODBC RPM,具体取决于操作系统。
以下包是根据Linux7版本安装的。具体在官方文档有说明。
unixODBC-2.3.1-6.el7.x86_64
unixODBC-2.3.1-6.el7.i686
unixODBC-devel-2.3.1-6.el7.x86_64
unixODBC-devel-2.3.1-6.el7.i686

]# yum provides unixODBC unixODBC-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
unixODBC-2.3.1-14.el7.i686 : A complete ODBC driver manager for Linux
Repo        : base

unixODBC-2.3.1-14.el7.x86_64 : A complete ODBC driver manager for Linux
Repo        : base

unixODBC-devel-2.3.1-14.el7.i686 : Development files for programs which will use the unixODBC library
Repo        : base

unixODBC-devel-2.3.1-14.el7.x86_64 : Development files for programs which will use the unixODBC
                                   : library
Repo        : base

三、创建oracle用户组、用户跟磁盘分配
1、创建Oracle Inventory 组

]# groupadd oinstall  

2、创建OSDBA 组

]# groupadd dba 

3、创建Oracle软件创建者

]#useradd –g oinstall –G dba  –m oracle 

必须加 -m -g 主组 -G副组
要确定oracle用户是否存在并属于正确的组,请输入以下命令:

]# id oracle

4、修改oracle用户的密码

]# echo Password1 | passwd --stdin oracle
Changing password for user oracle.
passwd: all authentication tokens updated successfully.

5、创建磁盘分配目录

]# mkdir /app

6、划分磁盘:/app
注意:磁盘、目录根据实际分配

]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x1549bfc0.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set

Command (m for help): w
The partition table has been altered!

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

7、磁盘更新

]# partprobe /dev/sdb

8、LVM操作
创建PV

]# pvcreate /dev/sdb1

创建VG

]# vgcreate vg_app /dev/sdb1

创建LV

]# lvcreate -L 299G -n lv_app vg_app

9、格式化文件系统

]# mkfs.xfs /dev/mapper/vg_app-lv_app

10、挂载文件系统

]# mount /dev/mapper/vg_app-lv_app /app

11、设置开机自动启动

]# vi /etc/fstab
/dev/mapper/vg_app-lv_app /app                   xfs     defaults        0 0

12、解压Oracle安装包(安装包自行下载)

]# cd /tmp
]# ll
....
-rwxr-xr-x 1 oracle oinstall 1239269270 Nov 27 14:30 linux.x64_11gR2_database_1of2.zip
-rwxr-xr-x 1 oracle oinstall 1111416131 Nov 27 14:29 linux.x64_11gR2_database_2of2.zip

两个压缩包解压后就是database目录

]# unzip linux.x64_11gR2_database_1of2.zip -d /app
]# unzip linux.x64_11gR2_database_2of2.zip -d /app
]# cd /app
]# ll
drwxr-xr-x 8 root root        128 Aug 21  2009 database

5、创建安装Oracle软件所需要的目录、设置所有者跟所属组、分配权限

]# mkdir /app/oracle
]# chown -R oracle:oinstall /app
]# chmod -R 775 /app

四、配置系统内核参数值跟Oracle资源限制
1、编辑/etc/sysctl.conf文件 /etc/sysctl.conf文件主要是配置一些系统信息(可用于系统调优)
free -m
shmall=内存除以4
shmmax=内存乘以0.8乘以1024

]# vim /etc/sysctl.conf  
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  

改变当前系统内核参数值(让/etc/sysctl.conf立即生效)

]# sysctl -p  

2、查Oracle安装用户(oracle)资源限制
说明:这个文件主要是用来限制用户对系统资源的使用,具体的使用方法 man 5 limits.conf,里面给出了详细的用法
要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。
查看 /etc/pam.d/login 文件中有:

]# ls /etc/pam.d/login 	
session required /lib/security/pam_limits.so

具体可查看linux /etc/security/limits.conf 相关说明

修改/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  
oracle              soft    stack   10240  

五、设置环境变量(ORACLE_HOME 设置为安装目录product下默认目录)

]# vim /etc/profile
......
#oracle
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=/app/oracle/product/11.2.0/db_1/bin:$PATH
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

修改Oracle用户环境变量

]# vim /home/oracle/.bash_profile
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_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 NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

配置生效

]# source /home/oracle/.bash_profile

六、通过图形化界面安装Oracle

]# yum provides xhost xclock
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
xorg-x11-server-utils-7.7-20.el7.x86_64 : X.Org X11 X server utilities
Repo        : base
Matched from:
Provides    : xhost = 1.0.7

xorg-x11-apps-7.7-7.el7.x86_64 : X.Org X11 applications
Repo        : base
Matched from:
Provides    : xclock

远程窗口

]# yum -y install xorg-x11-server-utils-7.7-20.el7.x86_64 xorg-x11-apps-7.7-7.el7.x86_64

桌面包

]# yum -y groups install "GNOME Desktop"

完成安装后,使用如下命令启动桌面

]# startx 

首次启动,进行一些初始设置
1、选择系统语言
2、选择键盘类型
3、添加在线用户(可选)
4、开始使用

启动后的桌面环境,如下所示:
在这里插入图片描述
如何使用GNOME Shell?

CentOS 7的默认GNOME桌面以经典模式开始,但如果您想使用GNOME Shell,请设置如下:

方式一:如果以 startx 命令启动GNOME,设置如下:

]# echo "exec gnome-session" >> ~/.xinitrc
]# startx 

方式二:通过 systemctl set-default graphical.target 命令设置图形化界面登陆并重启系统。
系统启动后单击“登录”按钮旁边的按钮。
在列表中选择“GNOME”。(默认为GNOME Classic模式)
使用GNOME Shell登录。

查看root用户下是否已设置DISPLAY变量
]# echo $DISPLAY

如果有值出现,则说明已设置DISPLAY变量;否则,就需要手动设置DISPLAY

]# export DISPLAY=localhost:10.0

以下用oracle用户登录执行

]$ cd database/
]$ ./runInstaller 

1):订阅邮件这些就直接跳过不填了。
在这里插入图片描述2):这里选择忽略更新
在这里插入图片描述3):这里选择仅安装数据库,稍后再配置初始化数据。
在这里插入图片描述
4):选择单实例安装。
在这里插入图片描述
5):语言,默认英文。
在这里插入图片描述6):选择企业版(也是功能最全的)
在这里插入图片描述
7):这里就出现最开始创建的相应目录信息了,会自动读取。
在这里插入图片描述
8):下一步(创建日志目录)
在这里插入图片描述9):选择group 组为之前创建好的oinstall
在这里插入图片描述10)其他的一些依赖组件提示,其实我们已经安装好了,只是centos7上yum安装的依赖包要比oracle 11g 所需的包更新,版本更高,所以可以直接忽略这些提示(勾选 ignore all)。
在这里插入图片描述
11)、安装到最后的时候会出现一个提示:需要用root权限执行2个shell脚本,那么我们在之前的root用户终端下运行提示中的对应脚本文件即可。
在这里插入图片描述用root用户执行上面的两个脚本

]# cd /app/oraInventory/
]# ./orainstRoot.sh
]# cd $ORACLE_HOME
]# ./root.sh

12)安装完成在这里插入图片描述13)安装完成后还需要创建数据库,还是同样在Oracle用户下,重新打开一个终端,输入 dbca 命令即可弹出相应的数据库创建向导。
先配置监听(默认即可)

~]$ netca
Oracle Net Services Configuration:

在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

]$ netca
Oracle Net Services Configuration:
Configuring Listener:ORCL_LISTENER
Listener configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /app/oracle/product/11.2.0/db_1/bin/lsnrctl start ORCL_LISTENER
    Listener Control complete.
    Listener started successfully.
Oracle Net Services configuration successful. The exit code is 0

#查看监听状态

]$ lsnrctl status 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-DEC-2020 14:07:50

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

Message 1053 not found; No message file for product=network, facility=TNSMessage 1020 not found; No message file for product=network, facility=TNSMessage 1021 not found; No message file for product=network, facility=TNSMessage 1022 not found; No message file for product=network, facility=TNSMessage 1023 not found; No message file for product=network, facility=TNSMessage 1026 not found; No message file for product=network, facility=TNSMessage 1034 not found; No message file for product=network, facility=TNSMessage 1024 not found; No message file for product=network, facility=TNSMessage 1025 not found; No message file for product=network, facility=TNSMessage 1040 not found; No message file for product=network, facility=TNSMessage 1033 not found; No message file for product=network, facility=TNSMessage 1028 not found; No message file for product=network, facility=TNSMessage 1415 not found; No message file for product=network, facility=TNS  Message 1050 not found; No message file for product=network, facility=TNS
Message 1030 not found; No message file for product=network, facility=TNSMessage 1052 not found; No message file for product=network, facility=TNS

#查看监听端口

]$ netstat -nulpt | 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.)
tcp        0      0 0.0.0.0:1521            0.0.0.0:*               LISTEN      16679/tnslsnr       

#创建数据库实例orcl

]$ dbca
Cannot create directory "/ora/oracle/cfgtoollogs/dbca".

在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
密码都设置为Password1
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述数据库创建完成

查看oracle进程
ps -ef | grep ora_

]$ ps -ef | grep ora_
oracle     354 20434  0 18:00 pts/0    00:00:00 grep --color=auto ora_
oracle   31754     1  0 17:44 ?        00:00:00 ora_pmon_orcl
oracle   31756     1  0 17:44 ?        00:00:00 ora_vktm_orcl
oracle   31761     1  0 17:44 ?        00:00:00 ora_gen0_orcl
oracle   31763     1  0 17:44 ?        00:00:00 ora_diag_orcl
oracle   31765     1  0 17:44 ?        00:00:00 ora_dbrm_orcl
oracle   31767     1  0 17:44 ?        00:00:00 ora_psp0_orcl
oracle   31769     1  0 17:44 ?        00:00:00 ora_dia0_orcl
oracle   31771     1  0 17:44 ?        00:00:01 ora_mman_orcl
oracle   31773     1  0 17:44 ?        00:00:00 ora_dbw0_orcl
oracle   31775     1  0 17:44 ?        00:00:00 ora_lgwr_orcl
oracle   31777     1  0 17:44 ?        00:00:00 ora_ckpt_orcl
oracle   31779     1  0 17:44 ?        00:00:00 ora_smon_orcl
oracle   31781     1  0 17:44 ?        00:00:00 ora_reco_orcl
oracle   31783     1  0 17:44 ?        00:00:00 ora_mmon_orcl
oracle   31785     1  0 17:44 ?        00:00:00 ora_mmnl_orcl
oracle   31852     1  0 17:44 ?        00:00:00 ora_qmnc_orcl
oracle   31881     1  0 17:44 ?        00:00:00 ora_q000_orcl
oracle   31883     1  0 17:44 ?        00:00:00 ora_q001_orcl
oracle   32464     1  0 17:54 ?        00:00:00 ora_smco_orcl
oracle   32470     1  0 17:54 ?        00:00:00 ora_w000_orcl

说明实例已经正常启动

查看数据库是正常

]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 11 18:02:10 2020

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> 

查看实例/数据库状态

SQL> select status from v$instance;

STATUS
------------
OPEN

open状态说明启动正常。

SQL> desc v$database;
 Name					   Null?    Type
 ----------------------------------------- -------- ----------------------------
 DBID						    NUMBER
 NAME						    VARCHAR2(9)
 CREATED					    DATE
 RESETLOGS_CHANGE#				    NUMBER
 RESETLOGS_TIME 				    DATE
........

查看数据库状态是否为读写状态

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

数据库状态正常。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值