Linux服务器Oracle11G安装详细教程(附Oracle11g安装程序)

  • 首先我们使用工具连接到Linux服务器,配置可视化图形界面
--安装图形输出依赖包
[root@yanshi ~]# yum install -y libXft
[root@yanshi ~]# yum install -y libXtst
[root@yanshi ~]# yum install -y xorg-x11-xauth
[root@yanshi ~]# yum install -y kde-l10n-Chinese
[root@yanshi ~]# yum install -y liberation-fonts-common
[root@yanshi ~]# yum install -y cjkuni-uming-fonts
[root@yanshi ~]# yum install -y xhost
[root@yanshi ~]# yum install -y xorg-x11-apps

--配置输出图形的地址为本机(操作服务器的电脑)的IP地址
[root@yanshi ~]# export DISPLAY=172.20.10.2:0.0
[root@yanshi ~]# echo $DISPLAY
172.20.10.2:0.0
[root@yanshi ~]# xhost +
access control disabled, clients can connect from any host
[root@yanshi ~]# xclock
Warning: Missing charsets in String to FontSet conversion
  • 能够输出时钟则配置成功

  • 我们开始检查依赖包是否安装
--安装依赖包(下面代码是一个整体)
yum -y install binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel

--检查依赖包安装情况(下面代码是一个整体)
rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel

--下面是输出结果;发现我们有2个包没有安装
binutils-2.27-34.base.el7.x86_64
未安装软件包 compat-libstdc++-33 
elfutils-libelf-0.172-2.el7.x86_64
elfutils-libelf-devel-0.172-2.el7.x86_64
expat-2.1.0-10.el7_3.x86_64
gcc-4.8.5-36.el7.x86_64
gcc-c++-4.8.5-36.el7.x86_64
glibc-2.17-260.el7.x86_64
glibc-common-2.17-260.el7.x86_64
glibc-devel-2.17-260.el7.x86_64
glibc-headers-2.17-260.el7.x86_64
libaio-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.x86_64
libgcc-4.8.5-36.el7.x86_64
libstdc++-4.8.5-36.el7.x86_64
libstdc++-devel-4.8.5-36.el7.x86_64
make-3.82-23.el7.x86_64
未安装软件包 pdksh 
sysstat-10.1.5-17.el7.x86_64
unixODBC-2.3.1-11.el7.x86_64
unixODBC-devel-2.3.1-11.el7.x86_64
  • 下载我们没有的依赖包,然后传到服务器上,其他依赖包请自行百度下载(楼主缺少的2个依赖包compat-libstdc++-33与pdksh
--安装我们传到服务器的这2个依赖包
[root@yanshi Oracle_11G]# ll
总用量 118488
-rw-r--r--.  1 root root    195388 5月   1 15:55 compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
-rw-r--r--.  1 root root    210877 5月   1 15:55 pdksh-5.2.14-37.el5_8.1.x86_64.rpm

[root@yanshi Oracle_11G]# rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm 
警告:compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:compat-libstdc++-33-3.2.3-72.el7 ################################# [100%]

[root@yanshi Oracle_11G]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm 
警告:pdksh-5.2.14-37.el5_8.1.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID e8562897: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:pdksh-5.2.14-37.el5_8.1          ################################# [100%]
  • 如果要安装Oracle数据库,则需要以下本地操作系统组和用户:
  • Oracle inventory组(通常为 oinstall)
  • OSDBA组 (通常为 dba)
  • Oracle软件所有者(通常为 oracle)
[root@yanshi data]$# groupadd oinstall
[root@yanshi data]$# groupadd dba
[root@yanshi data]$# useradd -g oinstall -G dba oracle

--查看oracle用户是否创建成功
[root@yanshi data]$# id oracle
uid=1000(oracle) gid=1000(oinstall) 组=1000(oinstall),1001(dba)

--给oracle用户创建密码
[root@yanshi data]$# passwd oracle
更改用户 oracle 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新
  • 创建数据库安装目录
[root@yanshi ~]# mkdir -p /opt/oracle/product/11.2.0/dbhome_1
[root@yanshi ~]# mkdir /opt/oracle/oradata
[root@yanshi ~]# mkdir /opt/oracle/oraInventory
[root@yanshi ~]# mkdir /opt/oracle/flash_recovery_area
[root@yanshi ~]# chown -R oracle:oinstall /opt/oracle
[root@yanshi ~]# chmod -R 775 /opt/oracle
  • 将oracle用户加入到sudo群组中
[root@yanshi ~]# vi /etc/sudoers
--输入上面的命令后,打开sudoers文件进行编辑
--找到root ALL=(ALL) ALL这行,并且在底下再加入以下命令:
oracle ALL=(ALL) ALL
  • 修改内核参数
--关闭selinux
[root@yanshi ~]# vi /etc/selinux/config
修改:SELINUX=disabled

--关闭防火墙
#停止服务|firewall
[root@yanshi ~]# systemctl stop firewalld.service
#禁止firewall开机启动
[root@yanshi ~]# systemctl disable firewalld.service

--修改/etc/hosts文件
[root@yanshi ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
--在最后加入本机IP与主机名
192.168.31.128 yanshi

--修改内核参数
[root@yanshi ~]# vi /etc/sysctl.conf
--添加以下内容
kernel.shmall = 2097152
## kernel.shmmax 参数设置为物理内存的一半
kernel.shmmax = 1073741824
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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@yanshi ~]# sysctl -p
  • 限制oracle用户的shell权限
[root@yanshi ~]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
  • 修改用户验证选项
[root@yanshi data]# vi /etc/pam.d/login
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth       substack     system-auth
auth       include      postlogin
account    required     pam_nologin.so
account    include      system-auth
password   include      system-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
session    optional     pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    include      system-auth
session    include      postlogin
-session   optional     pam_ck_connector.so
## 增加下面的内容
session    required     /lib64/security/pam_limits.so
session    required     pam_limits.so
  • 修改/etc/profile文件
[root@yanshi data]# vi /etc/profile
--增加update中间的内容
pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}


if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`/usr/bin/id -u`
        UID=`/usr/bin/id -ru`
    fi
    USER="`/usr/bin/id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

## update(这里是增加的内容)
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
   ulimit -p 16384
   ulimit -n 65536
  else
   ulimit -u 16384 -n 65536
  fi
fi
## update(这里是增加的内容)

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

--使配置立即生效
[root@yanshi data]# source /etc/profile
  • 准备工作已经做完了,下面开始正式安装oracle(Oracle安装包
--把我们上传的Oracle11G安装包进行解压
[root@yanshi data]$# unzip p13390677_112040_Linux-x86-64_1of7.zip
[root@yanshi data]$# unzip p13390677_112040_Linux-x86-64_2of7.zip

--对安装包文件夹授权
[root@yanshi data]$# chown -R oracle.oinstall database/ 

--配置环境变量
--切换到oracle用户
[root@yanshi data]# su - oracle
[oracle@yanshi ~]$ vi /home/oracle/.bash_profile
--在最后增加两行配置
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
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"

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

--使设置生效
[oracle@yanshi ~]$ source /home/oracle/.bash_profile
  • 开始安装oracle
--切换到oracle用户
[root@yanshi data]# su - oracle
上一次登录:一 5月  4 16:08:46 CST 2020pts/0 上

[oracle@yanshi data]$ cd /data/database/

--用oracle用户再次配置图形
[root@yanshi ~]# export DISPLAY=172.20.10.2:0.0
[root@yanshi ~]# echo $DISPLAY
172.20.10.2:0.0
[root@yanshi ~]# xhost +
access control disabled, clients can connect from any host
[root@yanshi ~]# xclock
Warning: Missing charsets in String to FontSet conversion

--linux安装Oracle安装界面乱码解决方法
export NLS_LANG=AMERICAN_AMERICA.UTF8
export LC_ALL=C

[oracle@yanshi database]$ ./runInstaller
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。   实际为 9297 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 2047 MB    通过
检查监视器: 监视器配置至少必须显示 256 种颜色。    实际为 16777216    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2020-05-04_06-31-46PM. 请稍候...

--接下来我们的图形就出来了
  • 取消勾选【I wish to receive security updates via My Oracle Support】

  • 选择【Skip software updates】

  •  选择第一个,创建数据库

  •  选择第一个,创建桌面类数据库

  • 创建全局数据库名称:我这里用的orcl,输入密码:Ab123456(密码不合规下面会报错)

  • 继续下一步,修改路径为我们创建的路径

  •  等待进度条完成

  • 完事后有2个警告
  • 第一个:创建虚拟机时的Swap空间分小了(自己用不影响)
  • 第二个:oracle的可用内存不够(自己用不影响)
  • 勾选忽略全部,继续进行下一步

  •  点击安装

  •  等待进度条完成

  •  我这里报了一个错:Error in invoking target 'agent nmhs' of makefile

--进入到/dbhome_1/sysman/lib目录下
[oracle@yanshi database]$ cd /opt/oracle/product/11.2.0/dbhome_1/sysman/lib

--备份ins_emagent.mk文件
[oracle@yanshi lib]$ cp ins_emagent.mk ins_emagent.mk.bak

--编辑文件ins_emagent.mk
[oracle@yanshi lib]$ vi ins_emagent.mk
--进入vi编辑器后  命令模式输入/NMECTL 进行查找,快速定位要修改的行
在后面追加参数-lnnz11        第一个是字母l   后面两个是数字1
保存退出后Retry
  • 修改完成后回到刚才的界面点击重试

  •  等待弹出下面的弹窗(还是说我们内存不足),点击第一个按钮【lgnore】进行忽略

  •  等待创建完成

 

  •  创建完成后我们可以在密码管理中修改用户密码

  •  密码修改后点击OK

  •  等待都完成后复制下面语句用root执行

 

[root@yanshi data]# /opt/oracle/oraInventory/orainstRoot.sh
Changing permissions of /data/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@yanshi data]# /opt/oracle/product/11.2.0/dbhome_1/root.sh
Performing root user operation for Oracle 11g 

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /opt/oracle/product/11.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: /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.
  • 等待全部完成后点击close

--查看监听
[oracle@yanshi ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-MAY-2020 19:19:22

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date                19-MAY-2020 18:55:36
Uptime                    0 days 0 hr. 23 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/yanshi/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(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

--配置监听
--编辑listener.ora文件
[oracle@yanshi oracle]$ vim /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
--把里面内容修改为:
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=orcl)
      (ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1)
      (SID_NAME=orcl)
    )
  )
LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.31.128)(PORT=1521)))
ADR_BASE_LISTENER =/opt/oracle

--修改tnsnames.ora
[oracle@yanshi oracle]$ vim /opt/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
--把内容修改为
LISTENER_ORCL =
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.31.128)(PORT=1521))
    )
    (CONNECT_DATA =
      (SID=orcl)
    )
  )

--启动监听
[oracle@yanshi oracle]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-MAY-2020 19:54:55

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

Starting /data/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/yanshi/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.128)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.31.128)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                19-MAY-2020 19:54:55
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/yanshi/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.128)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
  • 从数据库工具连接数据库进行测试即可
posted @ 2022-09-09 09:56  洋芋不是土豆  阅读(10121)  评论(4编辑  收藏  举报