centos7.4安装Oracle单实例

环境说明

  • centos7.4
  • Oracle11.2.0.1

下载安装包

  • 先下载安装包, 只不过需要注册账号。迁移前是11G,所以选11G版本。这两个文件都需要下载下来。

  • 文件下载后,解压linux.x64_11gR2_database_*文件到同一个目录,database下。

创建逻辑卷

  • 将硬盘纳入逻辑卷管理
[root@OralceMaster /]# pvcreate /dev/vdc
  • 创建逻辑卷组
[root@OralceMaster /]# vgcreate OracleData /dev/vdc
  • 添加逻辑卷
[root@OralceMaster /]# lvcreate  -L 99.8G -n oracledata OracleData
  • 格式化逻辑卷
[root@OralceMaster /]# mkfs.ext4 /dev/OracleData/oracledata
  • 创建目录并挂载
[root@OralceMaster /]# mkdir ora01
[root@OralceMaster /]# mount /dev/mapper/OracleData-oracledata /ora01/
  • 设置开机自动挂载, 不能直接用/dev/mapper/OracleData-oracledata,会导致无法正常开机,用UUID替换。
[root@OralceMaster ~]# blkid | grep Oracle
/dev/mapper/OracleData-oracledata: UUID="62e8ef14-4fc0-4fd3-94ed-8fd6e22cd8a0" TYPE="ext4" 

[root@OralceMaster /]#  vim /etc/fstab
UUID="62e8ef14-4fc0-4fd3-94ed-8fd6e22cd8a0"    /ora01      ext4    defaults,noatime,barrier=0,data=writeback  0 0
  • 在Linux中屏蔽tmp(让它不能启用)挂载点
 [root@OralceMaster /]#  systemctl mask tmp.mount

配置系统, 准备安装

  • 添加用户组
--required groups
[root@OralceMaster oracle]# /usr/sbin/groupadd -g 501 oinstall
[root@OralceMaster oracle]# /usr/sbin/groupadd -g 502 dba
[root@OralceMaster oracle]# /usr/sbin/groupadd -g 503 oper
  • 添加0racle用户,并加入组
[root@OralceMaster oracle]# /usr/sbin/useradd -u 502 -g oinstall -G dba,oper oracle
  • 添加oracle用户的密码
[root@OralceMaster oracle]# passwd oracle
Changing password for user oracle.
New password:
  • 配置内核参数,需要根据服务器配置做相应的更改
[root@OralceMaster etc]# vim sysctl.conf 
[root@OralceMaster etc]# sysctl -p
kernel.shmmni = 4096
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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
  • 限制oracle用户资源的使用
[root@OralceMaster etc]# vim /etc/security/limits.conf
vim /etc/security/limits.conf
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   nofile   131072
oracle   hard   nofile   131072
oracle   soft   core     unlimited
oracle   hard   core     unlimited
oracle   soft   memlock  50000000
oracle   hard   memlock  50000000
  • 设置host
[root@OralceMaster etc]#vim /etc/hosts
127.0.0.1 centos7 centos7.dbaora.com localhost localhost.localdomain
[root@OralceMaster oracle]# ping -c 1 centos7
PING centos7 (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.017 ms

--- centos7 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.017/0.017/0.017/0.000 ms
  • 为oracle用户定义环境变量
[root@OralceMaster oracle]# su - oracle
[oracle@OralceMaster ~]$ vim .bash_profile       # 需要修改SID
### start oracle settings ###
export TMP=/tmp
# 下次安装,记得修改hostname, 运行"emctl status dbconsole"不会报错
export ORACLE_HOSTNAME=centos7.dbaora.com
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/ora01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

umask 022
### end oracle settings ###
  • 检查哪些包缺失
[root@OralceMaster ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \
> elfutils-libelf \
> elfutils-libelf-devel \
> gcc \
> gcc-c++ \
> glibc \
> glibc-common \
> glibc-devel \
> glibc-headers \
> ksh \
> libaio \
> libaio-devel \
> libgcc \
> libstdc++ \
> libstdc++-devel \
> make \
> sysstat \
> unixODBC \
> unixODBC-devel
binutils-2.25.1-31.base.el7(x86_64)
elfutils-libelf-0.168-8.el7(x86_64)
package elfutils-libelf-devel is not installed
package gcc is not installed
package gcc-c++ is not installed
glibc-2.17-196.el7(x86_64)
glibc-common-2.17-196.el7(x86_64)
package glibc-devel is not installed
package glibc-headers is not installed
package ksh is not installed
libaio-0.3.109-13.el7(x86_64)
package libaio-devel is not installed
libgcc-4.8.5-16.el7(x86_64)
libstdc++-4.8.5-16.el7(x86_64)
package libstdc++-devel is not installed
make-3.82-23.el7(x86_64)
package sysstat is not installed
package unixODBC is not installed
package unixODBC-devel is not installed

[root@OralceMaster ~]# yum install -y elfutils-libelf-devel \
 gcc \
 gcc-c++ \
 glibc-devel \
 glibc-headers \
 ksh \
 libaio-devel \
 libstdc++-devel \
 sysstat \
 unixODBC \
 unixODBC-devel \
 elfutils-libelf-devel \
 xorg-x11-server-utils-7.7-20.el7.x86_64
  • 创建数据库的目录结构
[root@OralceMaster /]#  mkdir -p /ora01/app
[root@OralceMaster /]#  chown oracle:oinstall /ora01/app
[root@OralceMaster /]#  chmod 775 /ora01/app
  • 关闭防火墙
[root@OralceMaster /]#  vim /etc/selinux/config
SELINUX=disabled
  • 为oracle设置变量
[root@OralceMaster /]# su - oracle
Last login: Tue Jul  7 11:30:48 CST 2020 on pts/3
[oracle@OralceMaster ~]$ vim .bash_profile 
alias envo='env | grep ORACLE'
alias cdob='cd $ORACLE_BASE'
alias cdoh='cd $ORACLE_HOME'
alias tns='cd $ORACLE_HOME/network/admin'

终端安装

  • 运行runInstaller会报错。
[oracle@OralceMaster database]$ ./runInstaller 
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 6655 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 8191 MB    Passed
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 <<<<

Some requirement checks failed. You must fulfill these requirements before

continuing with the installation,

Continue? (y/n) [n] n
  • yum -y install xdpyinfo 使用xdpyinfo这个命令可以查看显式系统的具体信息。这个必须要装,不然Xstart可以远程服务器,但是Oracle安装页面无法弹出,报错如下。


  • 网上查资料提示缺少安装包yum install -y xorg-x11-server-utils-7.7-20.el7.x86_64,之后通过VNC连接,安装不报错,但是不会弹出图形用户界面。

  • 注意:export DISPLAY=localhost:1,端口1也可能是2,根据vnc服务起来的端口号来指定端口。

  • 运行xhost +说明root账户端配置成功,切换到oracle账户,运行runInstaller无法正常安装。

  • 日志中只有Moved to state <getOCMDetails>

[root@OralceMaster ~]#  yum install tigervnc-server 
[root@OralceMaster ~]# vncserver

New 'OralceMaster:5 (root)' desktop is OralceMaster:5

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/OralceMaster:5.log

[root@OralceMaster ~]# export DISPLAY=:5
[root@OralceMaster ~]# xhost +
access control disabled, clients can connect from any host
[root@OralceMaster ~]# su - oracle
[oracle@OralceMaster ~]$ export DISPLAY=172.20.16.100:2

改用mate desktop 和Xmanager安装

  • 服务端安装mate desktop图形用户界面,默认源没有Mate桌面
[root@OralceMaster ~]# yum install epel-release 
[root@OralceMaster ~]# yum groups install "MATE Desktop"
[root@OralceMaster ~]# systemctl set-default graphical.target
[root@OralceMaster ~]# echo "exec /usr/bin/mate-session" >> ~/.xinitrc
  • 客户端安装Xmanager, 提取码:ln3l
  • 启动Xmanager,设置Xstart, 文件--新建--Xstart会话
  • 执行命令: /usr/bin/mate-session --display $DISPLAY


用户界面弹出,正式安装Oracle

  • 取消I wish to receive security updates via My Oracle Support, 下一步

  • 忽略提示信息,按yes


  • 跳过软件更新,稳定版本就好


  • 创建和配置数据库


  • 选择服务器类


  • 选择单实例安装


  • 典型安装


  • 设置数据库安装目录,设置密码


  • 忽略所有失败提示


  • 安装,可以保持配置说明文件



  • 提示ins_net_client.mk文件报错, 缺少包。

  • 安装依然无法解决问题,


[root@OralceMaster oracle]# yum install -y compat-libstdc++-33 compat-libstdc++-33.i686

[root@OralceMaster oracle]# rpm --all --query --queryformat "%{NAME}-%{VERSION}-%{RELEASE}-(%{ARCH})\n" | grep glibc
glibc-headers-2.17-307.el7.1-(x86_64)
glibc-2.17-307.el7.1-(x86_64)
glibc-devel-2.17-307.el7.1-(x86_64)
glibc-common-2.17-307.el7.1-(x86_64)
[root@OralceMaster oracle]# yum install glibc-devel.i686
  • 问题依旧~~~ 安装包后,retry, 通过,但是报ins_ctx.mk的错误

  • 报这个错误的原因是由于缺少compat_libstdc包所导致。


[root@oraclemaster Documents]# yum install -y binutils.x86_64 gcc.x86_64 kernel-headers.x86_64
  • 查看日志
[root@OralceMaster logs]# cd /ora01/app/oraInventory/logs
[root@OralceMaster logs]# vim installActions2020-07-07_10-50-36AM.log
INFO: //usr/lib64/libstdc++.so.5: undefined reference to `memcpy@GLIBC_2.14'
INFO: collect2: error: ld returned 1 exit status
INFO: make: *** [ctxhx] Error 1

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'install' of makefile '/ora01/app/oracle/product/11.2.0/db_1/ctx/lib/ins_ctx.mk'.
  • 下载、安装依赖,retry,提示ins_emagent.mk报错
修改/u01/app/oracle/product/11.2.0/db_1/ctx/lib/ins_ctx.mk,将
ctxhx: $(CTXHXOBJ)
      $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)
修改为:
ctxhx: $(CTXHXOBJ)
      -static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/stdc.a
可以先retry试试,如果不行再安装依赖包

rpm -ivh glibc-common-2.17-55.el7_0.5.x86_64.rpm \
    glibc-2.17-55.el7_0.5.i686.rpm \
    glibc-2.17-55.el7_0.5.x86_64.rpm
    

rpm -ivh glibc-devel-2.17-55.el7.x86_64.rpm \
    glibc-headers-2.17-55.el7.x86_64.rpm \
    glibc-static-2.17-55.el7.x86_64.rpm \
    glibc-2.17-55.el7.i686.rpm \
    glibc-2.17-55.el7.x86_64.rpm  \
    glibc-common-2.17-55.el7.x86_64.rpm \ 
  • ins_emagent.mk文件报错报错,修改$ORACLE_HOME/sysman/lib/ins_emagent.mk, 修改好,retry重试。
[root@OralceMaster ~]# su - oracle
Last login: Tue Jul  7 13:15:33 CST 2020 on pts/4
[oracle@OralceMaster ~]$ cdoh
[oracle@OralceMaster db_1]$ cd sysman/lib/
[oracle@OralceMaster lib]$ vim ins_emagent.mk
# before
$(SYSMANBIN)emdctl:
        $(MK_EMAGENT_NMECTL)

# after
$(SYSMANBIN)emdctl:
        $(MK_EMAGENT_NMECTL) -lnnz11
  • 安装成功



  • 执行两个脚本,点击OK
[root@OralceMaster ~]# /ora01/app/oraInventory/orainstRoot.sh
[root@OralceMaster ~]# /ora01/app/oracle/product/11.2.0/db_1/root.sh
  • 安装成功,关闭窗口


查看数据库状态

  • 查看监听状态
lsnrctl status LISTENER
lsnrctl start LISTENER
lsnrctl stop LISTENER
  • 查看数据库管理平台, 查看状态时提示错误。
emctl status dbconsole
emctl start dbconsole
emctl stop dbconsole

[oracle@OralceMaster ~]$ emctl status dbconsole
OC4J Configuration issue. /ora01/app/oracle/product/11.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_centos7.dbaora.com_ORA11G not found.

解决

  • OC4J_DBConsole_OralceMaster_orcl名重命名为OC4J_DBConsole_centos7.dbaora.com_orcl
[oracle@OralceMaster ~]$ cd /ora01/app/oracle/product/11.2.0/db_1/oc4j/j2ee/
[oracle@OralceMaster j2ee]$ cp -Rf OC4J_DBConsole_OralceMaster_orcl OC4J_DBConsole_centos7.dbaora.com_orcl

[oracle@OralceMaster j2ee]$ emctl status dbconsole
EM Configuration issue. /ora01/app/oracle/product/11.2.0/db_1/centos7.dbaora.com_orcl not found.
  • 进入db_1目录,将OralceMaster_orcl重命名为centos7.dbaora.com_orcl。查看dbconsole状态,deamon未运行,但是OEM是运行的。
[oracle@OralceMaster j2ee]$ cdoh
[oracle@OralceMaster db_1]$ cp -Rf OralceMaster_orcl centos7.dbaora.com_orcl

[oracle@oraclemaster db_1]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0 
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://OracleMaster:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is running. 
------------------------------------------------------------------
Logs are generated in directory /ora01/app/oracle/product/11.2.0/db_1/centos7.dbaora.com_ORA11G/sysman/log  

[oracle@OralceMaster db_1]$  emctl stop dbconsole
[oracle@OralceMaster db_1]$  emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0 
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
http://OralceMaster:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control .... started. 



  • stop dbconsole后 重新配置EM,问题依然没有解决
[oracle@OralceMaster db_1]$  emctl stop dbconsole
[oracle@OralceMaster db_1]$ emca -deconfig dbcontrol db -repos drop
STARTED EMCA at Jul 8, 2020 10:29:37 AM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: orcl     
Listener port number: 1521
Password for SYS user:  
Password for SYSMAN user:  

Do you wish to continue? [yes(Y)/no(N)]: y
Jul 8, 2020 10:30:01 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /ora01/app/oracle/cfgtoollogs/emca/orcl/emca_2020_07_08_10_29_37.log.
Jul 8, 2020 10:30:01 AM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be performed.
Jul 8, 2020 10:30:01 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Jul 8, 2020 10:30:43 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jul 8, 2020 10:30:43 AM
- de-configure Database Control and create a new Database Control repository

[oracle@OralceMaster db_1]$ emca -deconfig dbcontrol db -repos create
[oracle@OralceMaster db_1]$  emctl start dbconsole
- EM Daemon is not running.
[oracle@OralceMaster db_1]$  emctl status dbconsole

EM Daemon is not running的解决方案

  • Google后得知,这个是时区不一致导致的。

The Problem " Error Starting Database Control Please execute the following command(s) " faced at the end of installation of Oracle 10g / 11g is caused due to Time Zone Values in different files, tables and services of Oracle. Interestingly, these values do not change automatically with the change in OS time zone and you have to do it manually.

  • 添加时区设置,报错ORACLE not available。 只能继续解决问题。
[oracle@OralceMaster db_1]$ cd sysman/config/
[oracle@OralceMaster config]$ vim emd.properties
agentTZRegion=UTC+08:00

[oracle@OralceMaster config]$ sqlplus / as sysdba
SQL> ALTER DATABASE SET TIME_ZONE='UTC+08:00';
ALTER DATABASE SET TIME_ZONE='UTC+08:00'
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SQL> shutdown immediate;
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory

SQL> startup mount;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/ora01/app/oracle/product/11.2.0/db_1/dbs/initORA11G.ora'
  • 发现没有initORA11G.ora文件,一查不得了,发现自己傻逼了!!~/.bash_profile里面设置的SID是ORA11G,但是我安装的时候设置的是orcl。修改Oracle用户的环境变量,ORA11G改成orcl
[oracle@OralceMaster ~]$ vim  ~/.bash_profile
export ORACLE_UNQNAME=orcl
export ORACLE_SID=orcl
[oracle@OralceMaster ~]$ source  ~/.bash_profile

[oracle@OralceMaster ~]$ sqlplus / as sysdba
SQL> ALTER DATABASE SET TIME_ZONE='UTC+08:00';
ORA-30079: cannot alter database timezone when database has TIMESTAMP WITH
LOCAL TIME ZONE columns

// 查看数据库时区
SQL> select dbtimezone from dual ;
DBTIME
------
+00:00
 //查看当前时间和时区 
SQL> select systimestamp from dual;
SYSTIMESTAMP
---------------------------------------------------------------------------
08-JUL-20 11.48.09.137716 AM +08:00
  • 可以看出数据库中一些表的列的数据类型为:TIMESTAMP WITH LOCAL TIME ZONE ,需要将这些列删除后,才能更改。此问题解决方案
SQL> alter table oe.orders drop column order_date;

Table altered.

SQL> alter database set time_zone='+8:00';

Database altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 3273641984 bytes
Fixed Size          2217792 bytes
Variable Size        1795164352 bytes
Database Buffers     1459617792 bytes
Redo Buffers           16642048 bytes
Database mounted.
SQL> select dbtimezone from dual;
DBTIME
------
+08:00
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342