Ubuntu 16.04.2 LTS安装Oracle11G R2

2017.5.2 0 条评论 4.28k 次阅读 2 人点赞

最近测试在Ubuntu上安装Oracle数据库,折腾了两天才安装成功,下面记录在Ubuntu 16.04.2 LTS上安装Oracle11G R2的整个安装过程。
注意:#为root用户,$为oracle用户。
首先,为了简单起见,关闭防火墙:

root@dbserver:~# ufw disable
Firewall stopped and disabled on system startup

1. 验证软件要求

1.1 操作系统版本

操作系统版本为Ubuntu 16.04.2 LTS,内核版本4.4.0-62-generic,如下:

root@dbserver:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
root@dbserver:~# uname -a
Linux dbserver 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

1.2 操作系统软件

先修改为网易软件源:

root@dbserver:~# vi /etc/apt/sources.list
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
root@dbserver:~# apt-get update

安装依赖的软件包:

root@dbserver:~# apt-get install binutils libcap-dev libstdc++5 gcc g++ libc6 libc6-dev ksh libaio1 libaio-dev lib32gcc1 libgcc1 libstdc++6 libstdc++6-4.7-dev libxi6 libxtst6 make sysstat unzip apt-file

2. 创建OS用户和组

创建oinstall、dba、oper用户组和oracle用户:

root@dbserver:~# groupadd oinstall
root@dbserver:~# groupadd dba
root@dbserver:~# groupadd oper
root@dbserver:~# useradd -g oinstall -G dba,oper oracle
root@dbserver:~# passwd oracle
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
//Ubuntu下需要手动创建主目录:
root@dbserver:~# mkdir /home/oracle
root@dbserver:~# chown oracle:oinstall ~oracle

检查umask变量,使用oracle用户登录:

root@dbserver:~# su - oracle
# su - oracle
$ umask
0022
//确保umask=022,否则修改.bash_profile添加如下行:
$ vi ~/.profile
umask 0022

3. 修改内核参数和资源限制

3.1 调整系统内核参数

调整内核参数大于或等于Oracle推荐的值,如果当前的内核参数比给出的值大则不要修改。对于Ubuntu 16.04.2 LTS,仅需修改以下内核参数:

# vi /etc/sysctl.conf
kernel.panic_on_oops = 1
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 32768 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
//重新加载配置文件:
# /sbin/sysctl -p

3.2 修改安装Oracle的用户的资源限制

对于Ubuntu 16.04.2 LTS仅需添加下面的内容:

root@dbserver:~# vi /etc/security/limits.conf
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle soft memlock 3145728
oracle hard memlock 3145728

4. 创建软件安装目录

创建ORACLE_BASE并授权:

root@dbserver:~# mkdir -p /u01/app/
root@dbserver:~# chown -R oracle:oinstall /u01
root@dbserver:~# chmod -R 775 /u01

5. 获取Oracle安装包

获取Oracle安装包,这里安装的Oracle版本为11.2.0.4:

$ cd
$ mkdir -p orainst/11.2.0.4
$ cd orainst/11.2.0.4
//下载或上传11.2.0.4安装包到此目录
$ ls -l
total 2487208
-rw-r--r-- 1 oracle oinstall 1395582860 May 2 12:26 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r-- 1 oracle oinstall 1151304589 May 2 12:28 p13390677_112040_Linux-x86-64_2of7.zip
$ unzip p13390677_112040_Linux-x86-64_1of7.zip
$ unzip p13390677_112040_Linux-x86-64_2of7.zip

6.安装数据库软件

这里先单独安装Oracle数据库软件,然后再建库:

$ cd /home/oracle/orainst/11.2.0.4/database/
$ ./runInstaller
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 8063 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute /usr/bin/xdpyinfo Failed <<<< Some requirement checks failed. You must fulfill these requirements before continuing with the installation, Continue? (y/n) [n] y >>> Ignoring required pre-requisite failures. Continuing...
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-05-02_12-37-15PM. Please wait ...$

配置安全更新:输入邮箱,选择是否接收安全更新。这里直接点击“Next”忽略安全更新。
下载软件更新:跳过。
安装选项:仅安装数据库软件。
集群安装选项:单实例数据库安装。
产品语言:English和简体中文。
数据库版本:企业版本。
指定安装位置:默认Oracle Base:/u01/app/oracle,Oracle Home:/u01/app/oracle/product/11.2.0/dbhome_1。
创建清单目录:默认清单目录“$ORACLE_BASE/../oraInventory”即/u01/app/oraInventory,所属组“oinstall”。
指定管理员组:OSDBA:dba,OSOPER:oper。
安装前检查:Oracle官方不支持Ubuntu,有很多误报,比如依赖的软件包检查,使用的是rpm命令检查,然而Ubuntu上没有安装rpm软件包,为什么这里不安装rpm软件包呢?因为Ubuntu上很多软件包和RHEL上命名不一样,所以干脆不管了,直接忽略即可。内核参数,这些参数Configured Value=unknown,由于Current Value不小于Expected Value,忽略。
Oracle11gR2-Prerequisite Checks

开始安装,日志位置:

You can find the log of this install session at:
/u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log
//查看日志
$ tail -f /u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log

遇到的错误和解决办法:
错误1:/bin/ld: cannot find /usr/lib64/libpthread_nonshared.a
错误日志:

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/bin/genclntsh

INFO: /usr
INFO: /bin/ld: cannot find /usr/lib64/libpthread_nonshared.a

INFO: collect2: error: ld returned 1 exit status

INFO: genclntsh: Failed to link libclntsh.so.11.1

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk:36: recipe for target 'client_sharedlib' failed

INFO: make: *** [client_sharedlib] Error 1

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'client_sharedlib' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log' for details.
Exception Severity: 1

解决办法:

root@dbserver:~# find /usr -name libpthread_nonshared.a
/usr/lib/x86_64-linux-gnu/libpthread_nonshared.a
root@dbserver:~# ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/libpthread_nonshared.a

如果没有libpthread_nonshared.a文件,查询提供该库文件的软件包,咯,就是libc6-dev:

root@dbserver:~# apt-file search libpthread_nonshared.a
libc6-dev: /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a
…

后面类似的错误解决方法一样:

  • INFO: /usr/bin/ld: cannot find /usr/lib64/libc_nonshared.a
  • 将/usr/lib/x86_64-linux-gnu/libc_nonshared.a链接到/usr/lib64:

    root@dbserver:~# ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64
    

错误2:sysman/lib/ins_emagent.mk:176: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/emdctl' failed
错误日志:

/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib//libnmectl.a(nmectlt.o): In function `nmectlt_genSudoProps':
nmectlt.c:(.text+0x76): undefined reference to `B_DestroyKeyObject'
nmectlt.c:(.text+0x7f): undefined reference to `B_DestroyKeyObject'
nmectlt.c:(.text+0x88): undefined reference to `B_DestroyKeyObject'
nmectlt.c:(.text+0x91): undefined reference to `B_DestroyKeyObject'

INFO: collect2: error: ld returned 1 exit status

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk:176: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/emdctl' failed
make[1]: Leaving directory '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib'

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk:52: recipe for target 'emdctl' failed

INFO: make[1]: *** [/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/emdctl] Error 1

INFO: make: *** [emdctl] Error 2

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'agent nmhs' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'. See '/u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log' for details.
Exception Severity: 1

解决办法:
修改“emdctl”的编译参数,编辑“/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk”文件,将

171 #===========================
172 # emdctl
173 #===========================
174
175 $(SYSMANBIN)emdctl:
176 $(MK_EMAGENT_NMECTL)

改为

171 #===========================
172 # emdctl
173 #===========================
174
175 $(SYSMANBIN)emdctl:
176 $(MK_EMAGENT_NMECTL) -lnnz11

错误3:rdbms/lib/ins_rdbms.mk:1096: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/kfod' failed
错误日志:

INFO: reference to `kgfoControl'
/u01/app/oracle/product/11.2.0/dbhome_1/lib//libocrb11.so: undefined reference to `kgfoCreate2P'
collect2: error: ld returned 1 exit status

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk:1096: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/kfod' failed

INFO: make: *** [/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/kfod] Error 1

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'all_no_orcl' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log' for details.
Exception Severity: 1

解决办法:
修改“kfod”的编译参数,查看“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk”文件的1096行附近:

1095 $(KFOD): $(ALWAYS) $(KFOD_DEPS)
1096 $(SILENT)$(ECHO)
1097 $(SILENT)$(ECHO) "Linking OSM Discovery utility (kfod)"
1098 $(RMF) $@
1099 $(KFOD_LINKLINE)

修改“KFOD_LINKLINE”变量,查找“KFOD_LINKLINE”的定义,然而不在“ins_rdbms.mk”文件中,查找目录下其他.mk文件:

root@dbserver:~# ll /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/*.mk
-rw-r--r-- 1 oracle oinstall 143192 Aug 24 2013 /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk
-rw-r--r-- 1 oracle oinstall 40983 Aug 24 2013 /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk
root@dbserver:~# grep KFOD_LINKLINE /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk
KFOD_LINKLINE=$(LINK) $(S0MAIN) $(SSKFODED) $(SKFODPT) $(KFODOBJ) \

“KFOD_LINKLINE”变量是在“env_rdbms.mk”文件中定义的,修改“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk”文件,将

KFOD_LINKLINE=$(LINK) $(S0MAIN) $(SSKFODED) $(SKFODPT) $(KFODOBJ) \

改为

KFOD_LINKLINE=$(LINK) $(S0MAIN) -Wl,--no-as-needed $(SSKFODED) $(SKFODPT) $(KFODOBJ) \

后面类似的错误解决方法一样:

  • INFO: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk:1102: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/amdu' failed
  • 修改“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk”文件,将

    AMDU_LINKLINE=$(LINK) $(S0MAIN) $(SSKFMUED) $(SKFMUPT) \
            $(LLIBDBTOOLS) $(LLIBCORE) $(LLIBGENERIC) \
            $(LLIBCOMMON) $(LLIBGENERIC) $(LLIBCOMMON) $(LLIBUNLSRTL) \
            $(LLIBNLSRTL) $(LLIBCORE) $(LLIBSAGE) $(LLIBSKGXP) \
            $(LLIBNLSRTL) $(CSSCLNTLIBS_SERVER) $(LLIBASMCLNT) $(LINKTTLIBS)
    

    改为

    AMDU_LINKLINE=$(LINK) $(S0MAIN) -Wl,--no-as-needed $(SSKFMUED) $(SKFMUPT) \
            $(LLIBDBTOOLS) $(LLIBCORE) $(LLIBGENERIC) \
            $(LLIBCOMMON) $(LLIBGENERIC) $(LLIBCOMMON) $(LLIBUNLSRTL) \
            $(LLIBNLSRTL) $(LLIBCORE) $(LLIBSAGE) $(LLIBSKGXP) \
            $(LLIBNLSRTL) $(CSSCLNTLIBS_SERVER) $(LLIBASMCLNT) $(LINKTTLIBS)
    
  • INFO: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk:1114: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/renamedg' failed
  • 修改“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk”文件,将

    KFNDG_LINKLINE=$(LINK) $(S0MAIN) $(SSKFNDGED) $(SKFNDGPT) $(KFNDGOBJ) \
    $(LIBGENERIC) $(DEF_OPT) $(LLIBDBTOOLS) $(LIBGENERIC) \
    $(LIBCORE) $(CSSCLNTLIBS_SERVER) $(ASMCLNT_LIBS) $(LINKTTLIBS)
    

    改为

    KFNDG_LINKLINE=$(LINK) $(S0MAIN) -Wl,--no-as-needed $(SSKFNDGED) $(SKFNDGPT) $(KFNDGOBJ) \
    $(LIBGENERIC) $(DEF_OPT) $(LLIBDBTOOLS) $(LIBGENERIC) \
    $(LIBCORE) $(CSSCLNTLIBS_SERVER) $(ASMCLNT_LIBS) $(LINKTTLIBS)
    
  • INFO: /u01/app/oracle/product/11.2.0/dbhome_1/srvm/lib/ins_srvm.mk:52: recipe for target 'getcrshome' failed
  • 修改“/u01/app/oracle/product/11.2.0/dbhome_1/srvm/lib/env_srvm.mk”文件,将

    GETCRSHOME_LINKLINE=$(LINK) $(LDPATHFLAG)$(RDBMSLIB) $(CDEBUG) $(OPT) \
    $(GETCRSHOME_OBJ1) $(OCRLIBS_DEFAULT) $(LLIBCLNTSH) \
    $(LINKLDLIBS)
    

    改为

    GETCRSHOME_LINKLINE=$(LINK) -Wl,--no-as-needed $(LDPATHFLAG)$(RDBMSLIB) $(CDEBUG) $(OPT) \
    $(GETCRSHOME_OBJ1) $(OCRLIBS_DEFAULT) $(LLIBCLNTSH) \
    $(LINKLDLIBS)
    
  • INFO: /u01/app/oracle/product/11.2.0/dbhome_1/network/lib/ins_net_server.mk:27: recipe for target 'tnslsnr' failed
  • 修改“/u01/app/oracle/product/11.2.0/dbhome_1/network/lib/env_network.mk”文件,将

    TNSLSNR_LINKLINE=$(LINK) $(TNSLSNR_OFILES) $(LINKTTLIBS) $(LLIBONS) \
    $(LOCALNETLIBS) $(MATHLIB) $(TNSLSNR_THREADLIB)
    

    改为

    TNSLSNR_LINKLINE=$(LINK) -Wl,--no-as-needed $(TNSLSNR_OFILES) $(LINKTTLIBS) $(LLIBONS) \
    $(LOCALNETLIBS) $(MATHLIB) $(TNSLSNR_THREADLIB)
    
  • INFO: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk:732: recipe for target '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/oracle' failed
  • 修改“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk”文件,将

    ORACLE_LINKLINE=$(ORACLE_LINKER) $(PL_FLAGS) $(ORAMAI) $(SSORED) $(TTCSOI) \
    $(ORACLE_KERNEL_LIBS) $(LINKLDLIBS)
    

    改为

    ORACLE_LINKLINE=$(ORACLE_LINKER) $(PL_FLAGS) -Wl,--no-as-needed $(ORAMAI) $(SSORED) $(TTCSOI) \
    $(ORACLE_KERNEL_LIBS) $(LINKLDLIBS)
    

错误4:gcc: error: /lib64/libgcc_s.so.1: No such file or directory;gcc: error: /usr/lib64/libstdc++.so.6: No such file or directory
错误日志:

INFO: - Linking liborasdkbase

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/bin/genorasdksh -base

INFO: $Id: genorasdksh.sh /linuxamd64/15 2010/04/28 22:10:13 aime Exp $

INFO: Generating BASE ORASDK library...

INFO: Creating /u01/app/oracle/product/11.2.0/dbhome_1/lib/liborasdkbase.so.11.1

INFO: gcc: error: /lib64/libgcc_s.so.1: No such file or directory
gcc: error: /usr/lib64/libstdc++.so.6: No such file or directory

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/bin/genorasdksh: Failed to link liborasdkbase.so.11.1

INFO: make: *** [liborasdkbase] Error 1

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk:1309: recipe for target 'liborasdkbase' failed

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'all_no_orcl' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log' for details.
Exception Severity: 1

解决办法:

root@dbserver:~# find / -name libgcc_s.so.1
/u01/app/oracle/product/11.2.0/dbhome_1/lib/stubs/libgcc_s.so.1
/usr/lib32/libgcc_s.so.1
/lib/x86_64-linux-gnu/libgcc_s.so.1
root@dbserver:~# find / -name libstdc++.so.6
/u01/app/oracle/product/11.2.0/dbhome_1/lib/stubs/libstdc++.so.6
/usr/lib64/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
root@dbserver:~# ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib64/libgcc_s.so.1
root@dbserver:~# ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib64/libstdc++.so.6

注意,千万不要使用“/usr/lib32/libgcc_s.so.1”,因为它是32位的库文件,否则会报“/lib64/libgcc_s.so.1: error adding symbols: File in wrong format”错误。
错误5:bin/genorasdksh: Failed to link liborasdk.so.11.1
错误日志:

INFO: : In function `ttctzRcv':
ttctz.c:(.text+0x3e8): undefined reference to `LdiInterFromArray'
/u01/app/oracle/product/11.2.0/dbhome_1/lib/libcommon11.a(kdzu.o): In function `kdzu_dump_header':
kdzu.c:(text.unlikely+0x6171): undefined reference to `lbivffs'
kdzu.c:(text.unlikely+0x61a9): undefined reference to `lbivffs'
/u01/app/oracle/product/11.2.0/dbhome_1/lib/libcommon11.a(kdxd4.o): In function `kdxd4bu':
kdxd4.c:(text.hot+0x2587): undefined reference to `lnxren'
collect2: error: ld returned 1 exit status

INFO: /u01/app/oracle/product/11.2.0/dbhome_1/bin/genorasdksh: Failed to link liborasdk.so.11.1
make: *** [liborasdksh] Error 1

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'all_no_orcl' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/u01/app/oraInventory/logs/installActions2017-05-02_12-37-15PM.log' for details.
Exception Severity: 1

解决办法:
查看“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk”文件关于liborasdksh的命令行:

1313 liborasdksh: $(LIBORASDKSH_DEPS)
1314 $(SILENT)$(ECHO)
1315 $(SILENT)$(ECHO) " - Linking liborasdk"
1316 $(GENORASDKSH)

查看“/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/env_rdbms.mk”文件中变量GENORASDKSH的定义:

GENORASDKSH=$(BINHOME)genorasdksh

直接修改“/u01/app/oracle/product/11.2.0/dbhome_1/bin/genorasdksh”文件,将

289 $LD $LD_RUNTIME $LD_OPT $LD_OUT $LD_SELF_CONTAINED $BASE_LIB \
290 $LD_OBJS $LD_SYMS $OLIBS $SYSLIBS $USRLIBS

改为

289 $LD $LD_RUNTIME $LD_OPT -Wl,--no-as-needed $LD_OUT $LD_SELF_CONTAINED $BASE_LIB \
290 $LD_OBJS $LD_SYMS $OLIBS $SYSLIBS $USRLIBS

安装完成后,执行Root Scripts。
执行orainstRoot.sh:

root@dbserver:~# /u01/app/oraInventory/orainstRoot.sh
/u01/app/oraInventory/orainstRoot.sh: 1: /u01/app/oraInventory/orainstRoot.sh: /bin/awk: not found
/u01/app/oraInventory/orainstRoot.sh: 1: /u01/app/oraInventory/orainstRoot.sh: /bin/awk: not found
/u01/app/oraInventory/orainstRoot.sh: 9: [: !=: unexpected operator
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

找不到/bin/awk,解决办法:

root@dbserver:~# which awk
/usr/bin/awk
root@dbserver:~# ln -s /usr/bin/awk /bin/awk

再执行一遍orainstRoot.sh脚本:

root@dbserver:~# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

执行root.sh脚本:

root@dbserver:~# /u01/app/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= /u01/app/oracle/product/11.2.0/dbhome_1

Enter 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.

安装完成!设置OS变量:

root@dbserver:~# su - oracle
$ vi ~/.profile
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
ORACLE_SID=jxq11g
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
$ source ~/.profile

7.配置监听

使用oracle帐号登录,执行netca命令:
选择监听配置。
选择添加。
输入监听器的名称:LISTENER。
选择协议:TCP。
设置监听端口:默认1521。
是否配置其他监听器:选择否,结束配置:

Oracle Net Services Configuration:
Configuring Listener:LISTENER
Listener configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Oracle Net Services configuration successful. The exit code is 0

8.创建数据库

使用oracle帐号登录,执行dbca命令:
选择创建数据库。
数据库模板:选择一般用途或事务处理。
数据库SID:全局数据库名:jxq11g.jianxiangqiao.com。SID:jxq11g。
配置EM。
设置统一的管理员密码。
存储类型和存储位置:文件系统,默认的文件位置。
快速恢复区:{ORACLE_BASE}/fast_recovery_area,4182MB。
不配置Sample和Custom Scripts。
初始化参数:Memory:默认。Processes:150太小,调到300。Database Character Set:ZHS16GBK。Default Territory:China。Connection Model:默认。

开始建库,建库完成之后:
Oracle11gR2-Finish Installation
到此,数据库软件安装完毕,并且已经创建完数据库,下一步配置环境以便提高效率。

9.配置高效环境

9.1 自定义OS命令提示符

对于Bash shell,修改oracle用户的.profile,添加如下信息:

$ vi ~/.profile
PS1='[\h:\u:${ORACLE_SID}]$ '
$ source ~/.profile
[dbserver:oracle:jxq11g]$

9.2 自定义SQL提示符

设置SQL*Plus在登陆时自动运行set SQLPROMPT命令:
1)设置OS变量SQLPATH,编辑.profile,添加如下信息:

$ vi ~/.profile
export SQLPATH=$HOME/scripts
$ source ~/.profile

2)在SQLPATH中创建login.sql文件,添加下面的代码:

$ mkdir $HOME/scripts
$ vi $HOME/scripts/login.sql
set SQLPROMPT '&_USER.@&_CONNECT_IDENTIFIER.> '

3)查看结果

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 2 18:29:34 2017

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@jxq11g>

9.3 安装rlwrap工具

在linux/unix平台的sqplus中,输出字符后按Backspace键删除时,会出现^H,这对习惯了按Backspace键删除的用户来说,感觉非常别扭,虽然可以通过Ctrl+Backspace组合键实现删除功能。还有方向键也会出现同样的问题。解决这个问题最好的方法是安装rlwrap工具。

root@dbserver:~# apt-get install rlwrap

编辑.profile,在文件头部添加如下信息:

$ vi ~/.profile
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'

参考资料:
http://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm
————————————————
本文永久地址http://www.jianxiangqiao.com/install-oracle11gr2-on-ubuntu-16-04/,转载请注明出处。

健翔桥的奇迹

IT工程师/摄影历史/跑步骑行