Ubuntu 16.04 安装 Oracle 12c 踩坑记

准备工作

切换至 root 权限并创建所需用户组和用户:

1
2
3
4
5
6
groupadd -g 502 oinstall
groupadd -g 503 dba
groupadd -g 504 oper
groupadd -g 505 asmadmin
useradd -u 502 -g oinstall -G dba,asmadmin,oper -s /bin/bash -m oracle
passwd oracle

并允许用户 oracle 执行 sudo:

1
2
3
4
su root
sudo visudo
# 将 root ALL=(ALL:ALL) ALL 后追加
# oracle ALL=(ALL:ALL) ALL

创建网络配置:

1
2
3
hostname  # 得到主机名
/sbin/ifconfig # 得到本机地址
cat /etc/hosts # 确保已添加

创建 X Server 连接:

1
xhost +127.0.0.1

可能报错:xhost:  unable to open display ":0.0"

解决办法,在 oracle 用户下执行:

1
export DISPLAY=:0.0

一劳永逸的办法,之后允许任何主机连接 X Server:

1
xhost +

创建需要的文件夹:

1
2
3
mkdir -p /u01/app/oracle/product/12/dbhome_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01

配置启动参数:

编辑 /etc/sysctl.conf 文件,追加如下行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#### Oracle 12c Kernel Parameters ####
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586

编辑 /etc/security/limits.conf 文件,追加如下行:

1
2
3
4
5
6
#### oracle User Settings 4 Oracle 12c ####
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

载入新内核参数:

1
/sbin/sysctl -p

安装依赖

1
2
3
4
5
6
7
8
9
apt-get install alien autoconf automake autotools-dev binutils doxygen \
elfutils expat gawk gcc gcc-multilib g++-multilib libstdc++6:i386 ksh less libtiff5 \
libtiff5-dev lib32z1 libaio1 libaio-dev libc6-dev libc6-dev-i386 libc6-i386 \
libelf-dev libltdl-dev libmotif4 libodbcinstq4-1 libodbcinstq4-1:i386 \
libpthread-stubs0 libpth-dev libstdc++5 lsb-cxx make \
pdksh openssh-server rlwrap rpm sysstat unixodbc unixodbc-dev x11-utils \
zlibc libglapi-mesa:i386 libglu1-mesa:i386 libqt4-opengl:i386 \
libpthread-workqueue0 libpthread-workqueue-dev libzthread-2.3-2 libzthread-dev \
libpthread-stubs0-dev libaio-dev

对其中几个包的说明:

对于 libmotif4 包:

1
2
3
4
5
6
7
sudo su
echo 'deb http://cz.archive.ubuntu.com/ubuntu trusty main universe' >> /etc/apt/sources.list.d/extra.list
apt-get update
apt-get install libmotif4
# 之后可以把额外添加的源去掉或改名备份
mv /etc/apt/sources.list.d/extra.list /etc/apt/sources.list.d/extra.list.backup
apt-get update

对于 pdksh 包:

1
sudo apt-get install mksh  # 替换

对于 libpthread-stubs0 包:

1
2
3
4
5
6
7
8
sudo su
echo 'deb http://cz.archive.ubuntu.com/ubuntu precise main universe' >> /etc/apt/sources.list.d/extra.list
apt-get update
apt-get install libpthread-stubs0
apt-get install libpthread-stubs0-dev
mv /etc/apt/sources.list.d/extra.list /etc/apt/sources.list.d/extra.list.backup
apt-get update
exit

对于 lsb-cxx 包:

暂无方案。安装了 lsb, lsb-core 包,目前未发现影响安装。

创建链接

1
2
3
4
5
6
7
8
9
# 链接二进制文件
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename

# 链接库文件
ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
cd /lib64
ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 .

下载 Oracle 12c

安装

解压安装文件(两个压缩包并不是分卷压缩,需要解压到同一个文件夹下):

1
unzip -d /tmp linuxamd64_12c_database*.zip

添加用户组:

1
chown -R oracle:oinstall /tmp/database

为 oracle 用户配置环境变量:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
su oracle
nano ~/.bashrc
# 追加下列行
# [HOSTNAME] 替换为主机地址,本机为 127.0.0.1
# [DBSID] 设置 SID 名,例如:SID

# Oracle Settings
TMP=/tmp;
export TMP TMPDIR=$TMP;
export TMPDIR ORACLE_HOSTNAME=[HOSTNAME];
export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB12C;
export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle;
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12/dbhome_1;
export ORACLE_HOME
ORACLE_SID=[DBSID];
export ORACLE_SID
PATH=/usr/sbin:$PATH;
export PATH
PATH=$ORACLE_HOME/bin:$PATH;
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64;
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH

载入新配置:

1
bash

启动安装脚本:

1
2
chmod -R +x /tmp/database
/tmp/database/runInstaller

可能会遇到以下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Checking Temp space: must be greater than 500 MB.   Actual 429214 MB    Passed
Checking swap space: must be greater than 150 MB. Actual 4041 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] Y


>>> Ignoring required pre-requisite failures. Continuing...
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-10-27_11-15-08PM. Please wait ...oracle@v3nky-HP-Pavilion-dv6-Notebook-PC:~$ No protocol specified
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at java.awt.Toolkit$2.run(Toolkit.java:834)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
at com.jgoodies.looks.LookUtils.isLowResolution(LookUtils.java:484)
at com.jgoodies.looks.LookUtils.<clinit>(LookUtils.java:249)
at com.jgoodies.looks.plastic.PlasticLookAndFeel.<clinit>(PlasticLookAndFeel.java:135)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1852)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:557)
at oracle.install.commons.util.Application.startup(Application.java:792)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:198)
at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:355)
at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:130)
at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:161)

此时应检查 X Server 是否正确可连接,检查上述准备工作相关部分。

解决后可以看到安装窗口:

跳出提示环境不满足最低要求,选择继续:

之后选择安装 Install Software Only 选项;

继续下一步选择语言等安装,进入安装过程。

安装过程会遇到一些库文件连接错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
su oracle
rm -rf $ORACLE_HOME/lib/stubs/
nano $ORACLE_HOME/rdbms/lib/env_rdbms.mk

# 搜索 'LINKTTLIBS' 替换为
LINKTTLIBS=$(LLIBCLNTSH) $(ORACLETTLIBS) $(LINKLDLIBS) -lons

# 搜索 'LINK=$(FORT' 替换为
LINK=$(FORT_CMD) $(PURECMDS) $(ORALD) $(LDFLAGS) $(COMPSOBJS) -Wl,--no-as-needed
LINK32=$(FORT_CMD) $(PURECMDS) $(ORALD) $(LDFLAGS32) $(COMPSOBJS) -Wl,--no-as-needed

# 搜索 'TG4PWD_LINKLINE' 替换为

TG4PWD_LINKLINE= $(LINK) $(OPT) $(TG4PWDMAI) \
$(LLIBTHREAD) $(LLIBCLNTSH) $(LINKLDLIBS) -lnnz12

# 搜索 'RMAN_LINKLINE=' 替换为

RMAN_LINKLINE=$(LINK) $(OPT) $(S0MAIN) $(SSKRMED) $(SKRMPT) \
$(LLIBDBTOOLS) $(LLIBCLIENT) $(LLIBSQL) $(LLIBPLSQL) \
$(LLIBSNLSRTL) $(LLIBUNLSRTL) $(LLIBNLSRTL) \
$(LLIBSLAX) $(LLIBPLSQL) $(LIBPLCN) $(LINKTTLIBS) -lons

保存退出,点 Retry

解决 ins_net_server.mk 文件问题

1
2
3
4
nano $ORACLE_HOME/network/lib/ins_net_server.mk

# 搜索 'TNSLSNR_LINKLINE' 替换为
$(TNSLSNR_LINKLINE) -lnnz12 -lons

保存退出,点 Retry

Error in ‘irman ioracle’ of Makefile

1
2
3
4
5
6
7
8
9
su oracle
sudo ln -s $ORACLE_HOME/lib/libocrutl12.so /usr/lib

nano $ORACLE_HOME/rdbms/lib/env_rdbms.mk

# 搜索 'ORACLE_LINKLINE' 找到
ORACLE_LINKLINE=$(ORACLE_LINKER) $(PL_FLAGS) $(ORAMAI) $(SSORED) $(TTCSOI) \
# 替换为
ORACLE_LINKLINE=$(ORACLE_LINKER) -Wl,--no-as-needed $(PL_FLAGS) $(ORAMAI) $(SSORED) $(TTCSOI) \

保存推出,点 Retry

完成安装。

参考资料

  1. http://blog.csdn.net/u010286751/article/details/51975741
  2. http://tutorialforlinux.com/2014/09/30/oracle-12c-database-linux-installation-troubleshooting-error-in-invoking-target-irman-ioracle-of-makefile/
  3. http://tutorialforlinux.com/2016/01/08/solving-oracle-12c-some-database-installation-issues-for-ubuntu-15-10-wily-64bit/
  4. http://www.cnblogs.com/fzhujia/p/4398088.html
  5. http://tutorialforlinux.com/2016/03/28/how-to-install-libmotif4-for-ubuntu-16-04-xenial-lts-linux-easy-guide/
  6. http://askubuntu.com/questions/542485/oracle-12c-installation-error-exception-could-not-initialize-class-sun-awt
  7. https://community.oracle.com/thread/298443?start=15&tstart=0
  8. http://tutorialforlinux.com/2016/03/28/how-to-install-pdksh-for-ubuntu-16-04-xenial-lts-linux-easy-guide/
  9. http://www.cnblogs.com/junnyfeng/archive/2013/01/09/2853705.html
  10. http://askubuntu.com/questions/772739/unable-to-install-libmotif4
  11. http://askubuntu.com/questions/804546/error-while-installing-oracle-12c-database-on-ubuntu-16-04
本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明出处! © 雨落
  1. 1. 准备工作
  2. 2. 安装依赖
  3. 3. 创建链接
  4. 4. 下载 Oracle 12c
  5. 5. 安装
    1. 5.1. Error in invoking target “links proc gen_pcscfg procob” of makefile
    2. 5.2. 解决 ins_net_server.mk 文件问题
    3. 5.3. Error in ‘irman ioracle’ of Makefile
  6. 6. 参考资料