Centos7下安装Oracle11g数据库
一、安装的硬件要求
1.内存:
要求:内存最小1G,推荐2G或者更高。呃呃呃2.Swap:
查看命令:# grep MemTotal /proc/meminfo
要求:
RAW Swap二、环境准备 安装包:
1G至2G 1.5倍
2G至16G 同RAW相等
16G以上 16G
- linux.x64_11gR2_database_1of2.zip
- linux.x64_11gR2_database_2of2.zip
Oracle下载地址:[http://www.oracle.com/technetwork/indexes/downloads/index.html#database]
1 [root@localhost]# groupadd oinstall#创建用户组oinstall
2 [root@localhost]# groupadd dba#创建用户组dba
3 [root@localhost]# useradd -g oinstall -g dba -m oracle#创建oracle用户,并加入到oinstall和dba用户组
4 [root@localhost]# passwd oracle#设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
Changing password for user oracle.
New password:# 密码
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:# 确认密码
passwd: all authentication tokens updated successfully.
5 [root@localhost]# id oracle # 查看新建的oracle用户
uid=1001(oracle) gid=1002(dba) groups=1002(dba)
3.2.创建oracle数据库安装目录
[root@D-PWS-DB localrepo]# mkdir -p /oracle/product/11.2.0/db_1#创建oracle安装目录
[root@pwsp-db-server /]# chown -R oracle:oinstall /oracle
[root@D-PWS-DB localrepo]# mkdir -p /ora_data/#创建数据文件目录
[root@D-PWS-DB localrepo]# chown -R oracle:oinstall/ora_data
[root@D-PWS-DB localrepo]# mkdir -p /ora_idx/#创建索引文件目录
[root@D-PWS-DB localrepo]# chown -R oracle:oinstall/ora_idx
[root@D-PWS-DB localrepo]# mkdir -p /ora_flash/#创建归档日志文件目录
[root@D-PWS-DB localrepo]# chown -R oracle:oinstall/ora_flash
3.3修改OS系统标识(oracle默认不支持CentOS系统安装,但是centos其实就是redhat)
[root@oracle-test ~]#cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@oracle-test ~]#vim /etc/redhat-release
[root@oracle-test ~]#cat /etc/redhat-release
redhat-7
3.4.安装oracle数据库所需要的软件包
[root@localhost data]# yum -y install binutils-2.20.*
yum -y install compat-libcap1-1.*
yum -y install compat-libstdc++-33-3.*
yum -y install compat-libstdc++-33-3.*.i686
yum -y install gcc-4.4.*
yum -y install gcc-c++-4.4.*
yum -y install glibc-2.12*.i686
yum -y install glibc-2.12*
yum -y install glibc-devel-2.12-*
yum -y install glibc-devel-2.12-*.i686
yum -y install *ksh*
yum -y install libgcc-4.4.*.i686
yum -y install libgcc-4.4.*
yum -y install libstdc++-4.4.*
yum -y install libstdc++-4.4.*.i686
yum -y install libstdc++-devel-4.4.*
yum -y install libstdc++-devel-4.4.*.i686
yum -y install libaio-0.3.*
yum -y install libaio-0.3.*.i686
yum -y install libaio-devel-0.3.*
yum -y install libaio-devel-0.3.*.i686
yum -y install make-3.*
yum -y install sysstat-9.0.4*
yum -y install unixODBC-2.2.*.i686
yum -y install unixODBC-2.2.*
yum -y install unixODBC-devel-2.2.*.i686
centos7需要的安装包,可以在Oracle上查看:https://docs.oracle.com/cd/E11882_01/install.112/e47689/pre_install.htm#LADBI1085
3.5.关闭防火墙
[root@localhost data]# 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 Wed 2017-09-13 09:23:08 CST;
25min ago
Docs: man:firewalld(1)
Main PID: 641 (firewalld)
CGroup: /system.slice/firewalld.service
└─641 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopidSep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami...
Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost data]# systemctl stop firewalld.service#关闭防火墙
[root@localhost data]# systemctl status firewalld.service#查看防火墙状态(已关闭)
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service;
enabled;
vendor preset: enabled)
Active: inactive (dead) since Wed 2017-09-13 09:48:55 CST;
10s ago
Docs: man:firewalld(1)
Process: 641 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 641 (code=exited, status=0/SUCCESS)Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami...
Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic...
Sep 13 09:48:54 localhost.localdomain systemd[1]: Stopping firewalld - dynami...
Sep 13 09:48:55 localhost.localdomain systemd[1]: Stopped firewalld - dynamic...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost data]# systemctl disable firewalld.service#禁止使用防火墙(重启也是禁止的)
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
3.6.关闭selinux(需重启生效)
[root@oracle-test ~]# vi /etc/selinux/config
[root@oracle-test ~]# 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
3.7、修改内核参数
[root@localhost data]# 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).
#oracle setting
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4100624384
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
#### 参数解释 ####
#一个消息队列中最大的字节数
kernel.msgmnb = 65536
##从一个进程发送到另一个进程的消息的最大长度。进程间的消息传递是在内核的内存中进行,不会交换到磁盘上,所以如果增加该值,则将增加操作系统所使用的内存数量。
kernel.msgmax = 65536
#用于定义单个共享内存段的最大值。设置应该足够大,能在一个共享内存段下容纳下整个的SGA ,设置的过低可能会导致需要创建多个共享内存段,这样可能导致系统性能的下降。64位linux系统:可取的最大值为物理内存值-1byte,建议值为多于物理内存的一半,一般取值大于SGA_MAX_SIZE即可,可以取物理内存-1byte。例如,如果为12GB物理内存,可取12*1024*1024*1024-1=12884901887,SGA肯定会包含在单个共享内存段中。
kernel.shmmax = 68719476736
#最大的并发共享内存段数目,比SGA还要大。该参数表示系统一次可以使用的共享内存总量(以页为单位,一个页大小为4KB)。缺省值就是2097152,通常不需要修改
kernel.shmall = 4294967296#该参数是共享内存段的最大数量。shmmni缺省值4096.
kernel.shmmni = 4096
#是semaphores的缩写,该参数表示设置的信号量。它包含四个值:semmsl、semmns、semopm、semmni
#250是参数semmsl的值:信号灯的最大数量,跟ORACLE的PROCESS数有关。SEMMSL * SEMMNI
#32000是参数semmns的值:系统调用允许的信号量最大个数。至少100;或者等于SEMMSL
#100是参数semopm的值:系统信号量set最大个数。最少128
#128是参数semmni的值:每个信号灯集合中最多的信号灯数目。最小250;对于processes参数设置较大的系统建议设置为processes+10。
kernel.sem = 250 32000 100 128
#该参数决定了系统中所允许的文件句柄最大数目,文件句柄设置代表linux系统中可以打开的文件的数量。
fs.file-max = 153600
#表示应用程序可使用的IPv4端口范围
net.ipv4.ip_local_port_range = 1024 65000
# 表示套接字接收缓冲区大小的缺省值
net.core.rmem_default = 4194304
#表示套接字接收缓冲区大小的最大值
net.core.rmem_max = 4194304
#表示套接字发送缓冲区大小的缺省值
net.core.wmem_default=262144
#表示套接字发送缓冲区大小的最大值
net.core.wmem_max=262144
[root@localhost data]# sysctl -p#立即生效
3.9、对oracle用户设置限制,提高软件运行性能(斜体为添加部分)
[root@localhost data]# cat /etc/security/limits.conf
@student - maxlogins 4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
End of file
3.10、配置用户的环境变量
[root@localhost data]# cat /home/oracle/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ];
then
. ~/.bashrc
fi# User specific environment and startup programsPATH=$PATH:$HOME/.local/bin:$HOME/binexport PATHexport ORACLE_BASE=/oracle #oracle数据库安装目录
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle数据库路径
export ORACLE_SID=orcl #oracle启动数据库实例名
export ORACLE_UNQNAME=orcl
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系统环境变量
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:$ORACLE_HOME/oracm/lib:/usr/local/lib:/usr/lib#添加系统环境变量
export LANG='AMERICAN_AMERICA.ZHS16GBK'#防止安装过程出现乱码
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致[root@localhost data]# source /home/oracle/.bash_profile#使环境变量生效
3.11、将安装包放到/root/home/路径下
[root@localhost ~]# ls
linux.x64_11gR2_database_1of2.ziplinux.x64_11gR2_database_2of2.zip
3.12、解压安装包并设置权限
[root@D-PWS-DB ~]$ unzip linux.x64_11gR2_database_1of2.zip
[root@D-PWS-DB ~]$ unzip linux.x64_11gR2_database_2of2.zip
移动到home目录
[root@oracle-test ~]#mv /root/database//home/oracle/
[root@localhost src]# chown -R oracle:oinstall /home/oracle/database/
四、开始安装Oracle 4.1、进入到虚拟机控制台中,以oracle用户登录,运行安装程序:
切换目录:
[root@oracle-test /oracle]#cd /home/oracle/database/
切换到中文模式
[oracle@D-PWS-DB ~]$ export LANG=en_US.UTF-8
[oracle@D-PWS-DB ~]$ export LC_CTYPE=en_US.iso88591
4.2、执行安装命令
[oracle@oracle-test ~]$./database/runInstaller
Starting Oracle Universal Installer...Checking Temp space: must be greater than 120 MB.Actual 269445 MBPassed
Checking swap space: must be greater than 150 MB.Actual 15999 MBPassed
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.Failed <<<>> Ignoring required pre-requisite failures. Continuing...
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2021-01-04_02-35-30PM. Please wait ...
DISPLAY not set. Please set the DISPLAY and try again.
Depending on the Unix Shell, you can use one of the following commands as examples to set the DISPLAY environment variable:
- For csh:% setenv DISPLAY 192.168.1.128:0.0
- For sh, ksh and bash:$ DISPLAY=192.168.1.128:0.0;
export DISPLAY
Use the following command to see what shell is being used:备注:发现有报错,然后执行:
[root@oracle-test ~]#export DISPLAY=192.168.155.14:0.0#192.168.155.14为本机ip,并非是oracle服务器。
4.3、安装xhost和运行DISPLAY
1. [oracle@11GR2-test ~]$ export DISPLAY=192.168.181.128:1
在虚拟机中安装ORACLE, 设置完DISPLAY变量后,运行xhost +命令无法找到,明显为xhost相对应的rpm包未安装.用yum命令加参数whatprovides 加xhost查到相对应的包为xorg-x11-server-utils-7.7-14.el6.x86_64,如下图.2. [root@11GR2-test ~]# yum whatprovides */xhost
Loaded plugins: refresh-packagekit, security, ulninfo
xorg-x11-server-utils-7.7-14.el6.x86_64 : X.Org X11 X server utilities
Repo: public_ol6_latest
Matched from:
Filename: /usr/bin/xhost3. yum安装xorg-x11-server-utils-7.*.el7.x86_64包[root@oracle-test ~]#yum install -y xorg-x11-server-utils-7.*.el7.x86_64
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-server-utils.x86_64 0:7.7-14.el6 will be installed
--> Processing Dependency: mcpp for package: xorg-x11-server-utils-7.7-14.el6.x86_64
--> Running transaction check
---> Package mcpp.x86_64 0:2.7.2-4.1.el6 will be installed
--> Processing Dependency: libmcpp.so.0()(64bit) for package: mcpp-2.7.2-4.1.el6.x86_64
--> Running transaction check
---> Package libmcpp.x86_64 0:2.7.2-4.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved==================================================================
PackageArchVersionRepositorySize
==================================================================
Installing:
xorg-x11-server-utilsx86_647.7-14.el6public_ol6_latest156 k
Installing for dependencies:
libmcppx86_642.7.2-4.1.el6public_ol6_latest68 k
mcppx86_642.7.2-4.1.el6public_ol6_latest23 kTransaction Summary
====================================================================
Install3 Package(s)Total download size: 246 k
Installed size: 548 k
Downloading Packages:
------------------------------------------------------------------------------------------------------------------------------------
Total11 MB/s | 246 kB00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libmcpp-2.7.2-4.1.el6.x86_641/3
Installing : mcpp-2.7.2-4.1.el6.x86_642/3
Installing : xorg-x11-server-utils-7.7-14.el6.x86_643/3
Verifying: xorg-x11-server-utils-7.7-14.el6.x86_641/3
Verifying: libmcpp-2.7.2-4.1.el6.x86_642/3
Verifying: mcpp-2.7.2-4.1.el6.x86_643/3 Installed:
xorg-x11-server-utils.x86_64 0:7.7-14.el6
Dependency Installed:
libmcpp.x86_64 0:2.7.2-4.1.el6mcpp.x86_64 0:2.7.2-4.1.el6
Complete!4. 安装完xorg-x11-server-utils-7.7-14.el6.x86_64包后,产生了xhost +
[oracle@11GR2-test ~]$ xhost +
access control disabled, clients can connect from any host
4.4、再次执行安装命令:
[oracle@oracle-test ~]$./database/runInstaller
Starting Oracle Universal Installer...Checking Temp space: must be greater than 120 MB.Actual 268850 MBPassed
Checking swap space: must be greater than 150 MB.Actual 15999 MBPassed
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.Failed <<<>> Ignoring required pre-requisite failures. Continuing...
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2021-01-04_03-08-36PM. Please wait ...
4.5、进入图形化安装,操作步骤如下:
步骤一:如下图,去掉对勾:
文章图片
image.png
文章图片
image.png
步骤二:选择跳过:
文章图片
image.png
步骤三:
选择:Install database software only
(只安装数据库软件,稍后使用dbca创建数据库示例)
文章图片
image.png
步骤四:
选择:Single instance database installation
(单实例数据库安装)
文章图片
image.png
步骤五:
添加上:Simplified Chinese 和 Traditional Chinese (简体中文、繁体中文)
文章图片
image.png
步骤六:
选择:Enterprise Edition(企业版)
文章图片
image.png
步骤七:
配置好环境变量后路径自动识别,无需修改:
文章图片
image.png
步骤八:设置路径为: /oracle/oraInventory
文章图片
image.png
点击:Yes
文章图片
image.png
步骤九:把第二个组改为oinstall:
文章图片
image.png
步骤十:安装前检测,先把os参数做了调整,有部分rpm包缺失,需要找到相应包安装:
文章图片
image.png
修改参数,并生效:
文章图片
image.png
[root@oracle-test ~]#sysctl -p
安装对应包:
[root@oracle-test ~]#yum install -y elfutils-libelf-devel-0.*
步骤十一:有一个包没有,但是可以选择跳过,直接安装即可:
文章图片
image.png
文章图片
image.png
步骤十二:安装到86%报错:
文章图片
image.png
步骤十三:
根据以下路径,执行下列的两个脚本:
文章图片
image.png
[root@oracle-test ~]#sh /oracle/oraInventory/orainstRoot.sh
Changing permissions of /oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.Changing groupname of /oracle/oraInventory to dba.
The execution of the script is complete.
[root@oracle-test ~]#sh /oracle/product/11.2.0/db_1/root.sh
Performing root user operation for Oracle 11gThe following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME=/oracle/product/11.2.0/db_1Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
步骤十四:安装数据库完后,关闭。
文章图片
image.png
步骤十五:sqlplus验证
通过sqlplus 连接验证:
(因为还没有创建数据库,所以是连接到空闲实例)
文章图片
image.png 4.6、建立数据库:启动dbca创建数据库
步骤1:进入到虚拟机控制台中,以oracle用户登录,输入:dbca
文章图片
image.png
步骤2:选择:Create a Database
文章图片
image.png
步骤3:选择:General Purpose or Transaction Processing
文章图片
image.png
【Centos7下安装Oracle11g数据库】步骤4:输入数据库实例名称:orcl
文章图片
image.png
步骤5:勾掉:Configure Enterprise Manager
文章图片
image.png
步骤6:
这列需要给数据库管理用户:sys和system设置密码,方便起见点击下方的两个用户设置同一密码:******
文章图片
image.png
文章图片
image.png
步骤7:默认文件系统,并选择数据文件路径:
文章图片
image.png
步骤8:启用数据库归档功能,并设置归档空间路径和空间大小:
文章图片
image.png
步骤9:默认继续:
文章图片
image.png
步骤10:数据库内存设置为系统内存的80%:
文章图片
image.png
步骤11:Process数设置为:1500
文章图片
image.png
步骤12:选择字符集为:AL32UTF8
文章图片
image.png
步骤13:配置完成的信息:
文章图片
image.png
控制文件信息:
文章图片
image.png
数据文件信息:
文章图片
image.png
步骤14:默认继续,并可以勾选中下方的生成建库脚本:
文章图片
image.png
文章图片
image.png
步骤15:数据库重建中:
文章图片
image.png
步骤16:数据库创建完成,点击:Exit
文章图片
image.png 4.7、启动netca建立监听程序
步骤1:进入到虚拟机控制台中,以oracle用户登录,输入:netca
选择:Listener Configuration
文章图片
image.png
步骤2:选择:Add
文章图片
image.png
步骤3:默认继续:
文章图片
image.png
步骤4:默认继续:
文章图片
image.png
步骤5:使用默认端口1521:
文章图片
image.png
步骤6:是否创建其他监听程序,选择:No
文章图片
image.png
步骤7:监听程序创建完成
文章图片
image.png 4.8、创建本地网络服务名
步骤1:选择:Local Net Service Name Configuration
文章图片
image.png
步骤2:选择:Add
文章图片
image.png
步骤3:输入数据库实例名称:orcl
文章图片
image.png
步骤4:默认继续:
文章图片
image.png
步骤5:输入数据库服务器主机名称或者IP地址,这里选择输入IP地址:
文章图片
image.png
步骤5:选择:Yes,perform a test (测试连接)
文章图片
image.png
步骤6:提示错误的用户名或密码,点击下方的:Change Login
文章图片
image.png
步骤7:输入system用户名及密码,连接测试成功::
文章图片
image.png
文章图片
image.png
步骤8:给本地网络服务名起名称,可以自定义,这里依然为:orcl
文章图片
image.png
步骤9:是否创建其他网络服务名,点击:No
文章图片
image.png
步骤10:点击:Next 直到退出
文章图片
image.png 4.9、创建系统用户和表空间
推荐阅读
- 开学第一天(下)
- 【故障公告】周五下午的一次突发故障
- Mac安装Chromedriver
- 生活随笔|好天气下的意外之喜
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- 汇讲-勇于突破
- Android中的AES加密-下
- 说的真好
- 放下心中的偶像包袱吧
- MAC安装Mongo