Mar*_*ogi 8 oracle software-installation 18.04
自 Oracle 18c 发布以来,这个问题没有答案。除了 Ubuntu Linux 平台,其他大部分 Linux 平台都支持 Oracle 18c 安装。我本人对此进行了测试,CentOS 7
并且安装了 oracle 18c,没有出现任何故障!
不幸的是,Oracle Corporation没有专门记录 .NET 的安装过程Ubuntu Linux platform
,但一件好事是映像文件db_home.zip
是通用的,可在所有 Linux 平台上安装。
那么如何在 Ubuntu 18.04 上安装 Oracle 18c(企业版)?
让我们从答题环节的第一部分开始。
1.1. 所需存储空间
db_home.zip
的大小为 4.3 GB。如果您在$HOME
目录或 中
没有那么多存储空间/tmp
,您可以使用至少 8GB 容量的 Pendrive 来保存下载的文件,db_home.zip
直到提取完成。/opt
,它应该有至少 13 GB 的未使用可用空间,因为 oracle 提取本身将消耗大约 9.3 GB 的存储空间。使用以下命令验证/opt
分区存储空间:$ df -h /opt
Figure-1: Amount of free space available under "/opt" partition.
1.2. JDK-11 已安装在您的计算机中。
$ echo $JAVA_HOME
Figure-2: Installation of JDK-11 is already done.
1.3. 启用多架构支持 (32-bit support).
在启用32-bit support
64 位 Ubuntu 18.04 之前,让我们验证您是否拥有 64 位内核架构:
$ dpkg --print-architecture
Figure-3: This Computer system has 64-bit Kernel Architecture.
多架构支持允许您将 32 位库与 64 位库一起使用。
$ dpkg --print-foreign-architectures
Figure-4: This Computer system also supports i386 Architecture (i.e. supports 32-bit Libraries too).
如果你得到类似图 4 的输出,那么你应该中断这一步并继续下一步 1.4。
通过键入以下内容启用多架构支持:
$ sudo dpkg --add-architecture i386
$ sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
它开始下载更新并运行。之后,您给出以下命令:
$ sudo apt-get dist-upgrade
现在通过键入以下内容来验证对 i386 的支持,您应该得到类似图 4 的输出:
$ dpkg --print-foreign-architectures
1.4. 安装 Oracle 安装所需的依赖包。
发出以下命令来安装依赖包:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential libaio1 libaio-dev rpm rpm-common ndctl
Run Code Online (Sandbox Code Playgroud)
1.5. 创建符号链接。
创建所需的软链接,以便安装可以在它期望的位置找到它需要的文件:
$ sudo mkdir -p /usr/lib64
$ sudo ln -s /usr/bin/rpm /bin/
$ sudo ln -s /usr/bin/awk /bin/
$ sudo ln -s /usr/bin/basename /bin/
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libndctl.so.6.10.1 /usr/lib64/libndctl.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libnuma.so.1.0.0 /usr/lib64/libnuma.so
Run Code Online (Sandbox Code Playgroud)
找出/bin/sh
指向谁:
$ ls -l /bin/sh
Figure-5: '/bin/sh' points towards 'dash' shell
如果/bin/sh
是指向dash
shell(参考上面的图5),那么你很好!现在,您打破这一步并继续下一步 - 1.6。
Figure-6: /bin/sh points towards 'bash' shell
如果它是bash
如图 6 所示的 shell,则创建以下符号链接:
$ sudo ln -s /usr/lib/x86_64-linux-gnu/crti.o /usr/lib64/
$ sudo ln -s /usr/lib/x86_64-linux-gnu/crtn.o /usr/lib64/
$ sudo ln -s /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib64/
Run Code Online (Sandbox Code Playgroud)
1.6. 配置内核参数/etc/sysctl.conf
:
要配置内核参数,只需按照以下步骤操作:
$ sudo cp /etc/sysctl.conf /etc/sysctl.conf.back
$ sudo vi /etc/sysctl.conf
将以下内容复制并粘贴到文件中。
# ------------------------------------------------
# kernel parameter configuration for 18c installation
# 1. Configure kernel shared memory segment
# Calculate shmmax and shmall based on your Computer system RAM (physical memory).
# shmmax = (half the size of RAM in bytes) = (16 GB / 2) * 1024*1024*1024 = 8589934592 bytes
# (or) = (one quarter of RAM in bytes) = 4294967296 bytes
# shmall = shmmax/pagesize = 8589934592 / 4096 = 2097152 pages
# 2. Configure kernel semaphore parameters which are semmsl, semmns, semopm and semmni respectively.
# kernel.sem = semmsl semmns semopm semmni = 250 32000 100 128
#
# to display all kernel parameters, issue this command: sysctl -a
# to display current kernel parameters, issue this command: sysctl -p
# -------------------------------------------------------
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.shmmax = 8589934592
kernel.sem = 250 32000 100 128
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
Run Code Online (Sandbox Code Playgroud)
保存并退出 vi 编辑器。
运行以下命令以显示当前内核参数。
$ sudo sysctl -p
Figure-7: The list of Kernel Parameters configured in "/etc/sysctl.conf" file.
1.7. 为用户配置 shell 限制oracle
历史上,进程的资源限制在 中定义/etc/security/limits.conf
。对于使用 PAM(通过 file pam_limits.so
)登录的用户,在登录时读取此文件。但是,通过启动的系统服务systemd
不使用PAM登录,因此/etc/security/limits.conf
忽略了限制。
进行 GUI 登录并使用Ctrl+Alt+T
以下命令打开终端:
$ ulimit -n -s -u -l
Figure-8: Limits for a GUI login with empty '/etc/systemsd/user.conf' file.
通过命令进行非 GUI 登录su <username>
,然后发出ulimit
命令:
$ su krishna
$ ulimit -n -s -u -l
Run Code Online (Sandbox Code Playgroud)
Figure-9: Limits for a non-GUI login with empty '/etc/security/limits.conf' file.
1.7.1. 使用/etc/systemd/user.conf
文件为 GUI 登录配置限制参数:
要配置限制参数system.conf
,只需按照以下步骤操作:
$ sudo cp /etc/systemd/system.conf /etc/systemd/system.conf.back
$ sudo vi /etc/systemd/system.conf
Run Code Online (Sandbox Code Playgroud)
将以下几行复制并粘贴到文件中。
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535
Run Code Online (Sandbox Code Playgroud)
保存并退出vi
编辑器。
要在 中配置限制参数user.conf
,只需按照以下步骤操作:
$ sudo cp /etc/systemd/user.conf /etc/systemd/user.conf.back
$ sudo vi /etc/systemd/user.conf
Run Code Online (Sandbox Code Playgroud)
将以下几行复制并粘贴到文件中。
DefaultLimitNOFILE=65000
DefaultLimitNPROC=65000
Run Code Online (Sandbox Code Playgroud)
保存并退出vi
编辑器。
重新启动计算机以使更改生效。
观察:当我尝试将“/etc/systemd/system.conf”和“/etc/systemd/user.conf”中的 DefaultLimitSTACK参数更改为各种值时,系统在重新启动时冻结或崩溃。虽然我大部分时间都成功恢复了系统,但两次我不得不从头开始重新安装 Ubuntu 操作系统,这真的很困难!
进行 GUI 登录并使用Ctrl+Alt+T
以下命令打开终端:
$ ulimit -n -s -u -l
Figure-10: Limits for a GUI login with parameters configured in '/etc/systemsd/user.conf' file.
通过命令进行非 GUI 登录su <username>
,然后发出ulimit
命令:
$ su krishna
$ ulimit -n -s -u -l
Run Code Online (Sandbox Code Playgroud)
Figure-11: Limits for a non-GUI login with empty '/etc/security/limits.conf' file.
1.7.2. 使用/etc/security/limits.conf
file为非 GUI 登录配置限制参数:
要在 中配置限制参数limits.conf
,只需按照以下步骤操作:
$ sudo cp /etc/security/limits.conf /etc/security/limits.conf.back
$ sudo vi /etc/security/limits.conf
Run Code Online (Sandbox Code Playgroud)
将以下内容复制并粘贴到文件中。
#-------------------------------------------------------------------------------------------------
# shell limits for users of oracle 18c
# [domain] is either username or group or the wildcard *, for default entry or
# the wildcard %, can be also used with %group syntax, for maxlogin limit
# [type] is either soft (enforcing soft limits) or hard (enforcing hard limits)
# [item] is among core, data, fsize, memlock, nofile, rss, stack, cpu, nproc, as,
# maxlogin, maxsyslogins, priority, locks, sigpending, msgqueue, nice, rtprio
#[domain][type] [item] [value]
#-------------------------------------------------------------------------------------------------
krishna soft nofile 60000
krishna hard nofile 65535
krishna soft nproc 60000
krishna hard nproc 65535
krishna soft stack 30000
krishna hard stack 32768
krishna soft memlock 3000000
krishna hard memlock 3145728
Run Code Online (Sandbox Code Playgroud)
保存并退出vi
编辑器。
重新启动计算机以使更改生效。进行 GUI 登录并使用Ctrl+Alt+T
以下命令打开终端:
$ ulimit -n -s -u -l
Figure-12: Limits for a GUI login with parameters configured in '/etc/systemsd/user.conf' file.
通过命令进行非 GUI 登录su <username>
,然后发出ulimit
命令:
$ su krishna
$ ulimit -n -s -u -l
Run Code Online (Sandbox Code Playgroud)
Figure-13: Limits for a non-GUI login with parameters configured in '/etc/security/limits.conf' file.
使用 vi 编辑器和编辑/etc/security/limits.conf
以更改"krishna"
为,"oracle"
因为用户名krishna
用于生成屏幕截图和解释概念。以下是 Oracle 安装所需的设置:
oracle soft nofile 60000
oracle hard nofile 65535
oracle soft nproc 60000
oracle hard nproc 65535
oracle soft stack 30000
oracle hard stack 32768
oracle soft memlock 3000000
oracle hard memlock 3145728
Run Code Online (Sandbox Code Playgroud)
1.7.3. 如何显示用户进程的限制?
要显示用户进程的限制,您所要做的只是"cat"
限制文件,如下所示:
$ sudo cat /proc/PID/limits
在哪里PID
可以使用ps
命令找到。
$ ps -a | grep -v tty2 | grep gnome-shell
Figure-14: PID for gnome-shell.
$ sudo cat /proc/1202/limits
Figure-15: Soft limits for gnome-shell (marked in red).
MaxStackSize
是 8,192 KB (8388608 % 1024)、MaxProcess
63,077、1,024MaxOpenFile
和MaxLockedMemory
16,384 KB (16777216 % 1024)。将这些值与图 11 进行比较。
$ ps -a | grep -v tty2 | grep bash
Figure-16: PID for 'bash'.
$ sudo cat /proc/2697/limits
Figure-17: Soft limits for 'bash' (marked in red).
MaxStackSize
是 30,000 KB (30720000 % 1024),MaxProcess
是 60,000,MaxOpenFile
是 60,000 和MaxLockedMemory
3,000,000 KB (3072000000 % 1024)。将这些值与图 13 进行比较。
1.7.4. 将 pam_limits 添加到您的 PAM(可插拔身份验证模块)配置中。
/etc/security/limits.conf
允许为通过 PAM 登录的用户设置资源限制。这是一种很有用的方法,例如可以防止 fork-bombs 耗尽所有系统资源。由于/etc/security/limits.conf
由 读取pam_limits.so
,您需要检查文件中是否启用了此模块:login, common-session, common-session-noninteractive, su
. 在进行更改之前进行备份:
$ sudo cp /etc/pam.d/login /etc/pam.d/login.back
$ sudo cp /etc/pam.d/common-session /etc/pam.d/common-session.back
$ sudo cp /etc/pam.d/common-session-noninteractive /etc/pam.d/common-session-noninteractive.back
$ sudo cp /etc/pam.d/su /etc/pam.d/su.back
Run Code Online (Sandbox Code Playgroud)
发出以下命令:
$ echo 'session required pam_limits.so' | sudo tee -a /etc/pam.d/login
$ echo 'session required pam_limits.so' | sudo tee -a /etc/pam.d/common-session
$ echo 'session required pam_limits.so' | sudo tee -a /etc/pam.d/common-session-noninteractive
$ echo 'session required pam_limits.so' | sudo tee -a /etc/pam.d/su
Run Code Online (Sandbox Code Playgroud)
注意:/var/log/auth.log
有关任何与限制相关的错误,请参阅文件。
1.8. 配置安全的 Linux。
要确定计算机已配置为secured linux
,请键入命令:
$ sestatus
Figure-18: Output confirms that secured linux is not installed which is good.
如果您得到类似图 18 所示的输出,那么您很好!现在,您打破这一步并继续下一步 - 1.9。
如果你安装了这个包policycoreutils
,如果你得到如下图 19 所示的输出,那么你也很好!你打破这一步并进入下一步 - 1.9。
$ sudo sestatus
Figure-19: Output of 'sestatus' command.
由于您已经配置了安全的 Linux,因此SELINUX
通过编辑/etc/selinux/config
文件将标志更改为许可:
$ sudo cp /etc/selinux/config /etc/selinux/config.back
$ sudo vi /etc/selinux/config
Run Code Online (Sandbox Code Playgroud)
现在,将SELINUX
标志设置为permissive
:
SELINUX=permissive
保存并退出vi
编辑器。
要确认您的更改,请发出以下命令:
$ sudo sestatus
注意:由于我的计算机没有配置为secure linux
,我无法为上述命令生成屏幕截图!
1.9. 禁用透明大页面。
Transparent Huge Pages (THP) 是一种 Linux 内存管理系统,它通过使用更大的内存页面来减少在具有大量内存的机器上进行翻译后备缓冲区 (TLB) 查找的开销。
然而,数据库工作负载在使用 THP 时通常表现不佳,因为它们往往具有稀疏而不是连续的内存访问模式。对于整体推荐MySQL
,MongoDB
,Oracle
,等是在Linux机器上禁用THP,以确保最佳的性能。
您可以通过运行以下命令来检查 THP 是否已启用:
$ cat /sys/kernel/mm/transparent_hugepage/enabled
Figure-20: The output shows THP 'enabled' is set to default value '[madvise]' in this computer at present.
$ cat /sys/kernel/mm/transparent_hugepage/defrag
Figure-21: The output shows THP 'defrag' is set to default value '[madvise]' in this computer at present.
如果图 20 和图 21 显示类似 的输出[never]
,则 THP 既未启用也未运行。
如何在整个当前会话期间关闭 THP?
现在,发出以下命令:
$ su -
# echo never > /sys/kernel/mm/transparent_hugepage/enabled
# exit
$ cat /sys/kernel/mm/transparent_hugepage/enabled
Run Code Online (Sandbox Code Playgroud)
Figure-22: The output shows THP enabled is stopped from this computer as indicated by the value '[never]'.
$ su -
# echo never > /sys/kernel/mm/transparent_hugepage/defrag
# exit
$ cat /sys/kernel/mm/transparent_hugepage/defrag
Run Code Online (Sandbox Code Playgroud)
Figure-23: The output shows THP 'defrag' is stopped from this computer as indicated by the value '[never]'.
如何永久永久关闭THP?
但是,一旦系统重新启动,它将再次恢复为默认值。要使设置在 Ubuntu 18.04 上保持不变,您可以通过制作systemd
单元文件在系统启动时禁用 THP :
$ sudo vi /etc/systemd/system/disable-thp.service
将以下内容复制并粘贴到文件中/etc/systemd/system/disable-thp.service
:
# ---------------------------------------------------
# Disable THP in Ubuntu 18.04:
# ---------------------------------------------------
[Unit]
Description=Disable Transparent Huge Pages (THP)
[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
要/etc/systemd/system/disable-thp.service
在启动时启用并运行文件,请键入以下命令:
$ sudo systemctl daemon-reload
$ sudo systemctl start disable-thp
$ sudo systemctl enable disable-thp
Run Code Online (Sandbox Code Playgroud)
Figure-24: The THP disable service is enabled to start up at boot time.
$ sudo systemctl status disable-thp
Figure-25: The THP disable service has started successfully.
现在,要验证 THP 已永久关闭,请键入以下命令:
$ cat /sys/kernel/mm/transparent_hugepage/enabled
Figure-26: The output shows THP 'enabled' is turned off persistently as indicated by the value '[never]'.
$ cat /sys/kernel/mm/transparent_hugepage/defrag
Figure-27: The output shows THP 'defrag' is turned off persistently as indicated by the value '[never]'.
1.10.1. 使用以下命令确定服务器上的物理 RAM 大小:
$ grep MemTotal /proc/meminfo
Figure-28: Abundant Physical RAM is available (16 GB).
注意:如果系统中安装的物理 RAM 的大小小于所需大小 (2 GB),则必须安装更多内存才能继续。
1.10.2. 确定配置的交换空间的大小:
$ grep SwapTotal /proc/meminfo
Figure-29: Abundant Memory is available for swap partition (16 GB).
注意:如果系统中交换内存的大小小于所需大小(见下表recommended by oracle
),则必须配置更多内存才能继续。
RAM Swap Space
Between 1 GB and 2 GB 1.5 times the size of RAM
Between 2 GB and 16 GB Equal to the size of RAM
More than 16 GB 16 GB
Run Code Online (Sandbox Code Playgroud)
1.10.3. 确定配置/tmp
空间的大小:
$ df -h /tmp
Figure-30: Abundant Memory is available for '/tmp' partition (16 GB).
回答环节的第三部分现在开始。
runInstaller
.3.1. 清理目录/tmp
:/tmp
在安装开始前,
发出以下命令清理目录:
$ cd /tmp
$ sudo rm -rf *
Run Code Online (Sandbox Code Playgroud)
3.2. 开始安装:
runInstaller
仅从 Oracle 主目录运行命令。不要使用runInstaller
驻留在$ORACLE_HOME/oui/bin/
或任何其他位置的命令来安装Oracle Database, Oracle Database Client, or Oracle Grid Infrastructure
.
从 Oracle 主目录,运行runInstaller
命令以启动 Oracle 数据库安装向导。
$ cd /oracle18c/app/oracle/product/18.0.0/dbhome_1
$ ./runInstaller
Run Code Online (Sandbox Code Playgroud)
Figure-64: Execute 'runInstaller' from '/oracle18c/app/oracle/product/18.0.0/dbhome_1/' directory.
Figure-65: Launching Oracle Database 18c Installer.
Figure-66: Hit button Yes and go ahead with installation.
Figure-67: Select 'Set up Software Only' option and press Next.
Figure-68: Select 'Single instance database installation' option and press Next.
Figure-69: Select 'Enterprise edition' option and press Next.
Figure-70: Accept the default 'Intallation Location' and press Next.
Figure-71: Accept the default Oracle Inventor directory/oracle18c/app/oralInventory and hit Next.
Figure-72: Select Operating System Groups and press Next.
Figure-73: This is Summary screen and Click button 'Save Response File' to take a copy of 'db.rsp' file.
Figure-74: Double-click "Documents" folder and then save a copy of 'db.rsp' file by clicking "Save" button.
请将响应文件保存db.rsp
在~/Documents
目录中。这是供您参考。
Figure-75: Now click Install button on the Summary Screen to proceed further.
Figure-76: Now Install Product is under progress…...
Figure-77: Execute both the scripts one after another with "root" login.
通过键入打开第二个终端Ctrl+AlT+T
。输入以下命令以 root 用户身份登录到命令行su –
:
$ su -
复制第一个脚本的整个路径orainstRoot.sh
并将其粘贴到终端上(前缀命令为". "
)
# . /oracle18c/app/oraInventory/orainstRoot.sh
Figure-78: Execution of first script orainstRoot.sh with "root" login.
现在,复制第二个脚本的整个路径root.sh
并将其粘贴到终端上(使用 前缀命令". "
)并点击<CR>
。
# . /oracle18c/app/oracle/product/18.0.0/dbhome_1/root.sh
在执行此脚本期间,您将被询问"Enter the full pathname of the local bin directory: /usr/local/bin:"
。您只需"default bin directory"
按<return>
键接受此路径。
随后会有另一个问题"Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes [no] : "
,您输入"y"
并安装它。
Figure-79: Execution of second script root.sh with "root" login.
使用"root"
登录完成两个脚本的执行后,您应该返回安装程序并点击OK
按钮以继续安装(请参阅下图 80 的屏幕截图)。
Figure-80: After the execution of scripts hit OK button and proceed further.
Figure-81: Click Close button to finish Database software Installation.
Figure-82: Congratulations! You have successfully installed database software using runInstaller interactively!!
通过按下Ctrl+Alt+T
并键入以下命令打开终端:
$ cp /oracle18c/app/oracle/product/18.0.0/dbhome_1/network/install/netca_typ.rsp ~/Documents/.
Run Code Online (Sandbox Code Playgroud)
键入cat netca_typ.rsp
命令以列出netca_typ.rsp
文件内容:
$ cat ~/Documents/netca_typ.rsp
Figure-83: The contents of typical 'netca_typ.rsp' capable of generating 'listener.ora' and 'sqlnet.ora'
响应文件虽然能够创建listener.ora
,sqlnet.ora
但不能创建tnsnames.ora
. 所以,让我们明智netca_typ.rsp
地转成"custom"
type来生成TNS别名吧!
首先从netca_typ.rsp
to复制一份netca.rsp
,然后随后发出命令:
$ cp ~/Documents/netca_typ.rsp ~/Documents/netca.rsp
$ sed -i 's/TYPICAL/CUSTOM/' ~/Documents/netca.rsp
$ sed -i 's/typical/custom/' ~/Documents/netca.rsp
Run Code Online (Sandbox Code Playgroud)
使用vi
编辑器,将以下内容复制并附加到netca.rsp
:
#---------------------------------------------------------
# Instructions to create tnsnames.ora having TNS alias list
#----------------------------------------------------------
NSN_NUMBER=1
NSN_NAMES={"orcl"}
NSN_SERVICE={"orcl"}
NSN_PROTOCOLS={"TCP;UBUNTU-H170N-WIFI;1521"}
Run Code Online (Sandbox Code Playgroud)
警告:请不要忘记UBUNTU-H170N-WIFI
用您的Computer Hostname
.
注 1:要打印您的computer hostname
,请发出以下命令:$ hostname
注 2:要打印您的computer FQDN
,请发出以下命令:$ hostname -f
或$ hostname -A
保存并退出vi
编辑器。
netca.rsp
现在可以生成的 wised up who的内容tnsnames.ora
如下所示:
$ cat ~/Documents/netca.rsp
Figure-84: The wised up 'netca.rsp' now generates not only 'listener.ora' and 'sqlnet.ora' but also 'tnsnames.ora'.
运行网络配置辅助工具netca
:
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/netca -silent -responseFile ~/Documents/netca.rsp
Run Code Online (Sandbox Code Playgroud)
Figure-85: NETCA has configured Listener as well as Net Services successfully executed in silent mode.
通过键入以下命令检查侦听器状态:
$ export ORACLE_HOME=/oracle18c/app/oracle/product/18.0.0/dbhome_1
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/lsnrctl status
Run Code Online (Sandbox Code Playgroud)
Figure-86: Output of 'lsnrctl status' command.
将Trace Level
被设置off
在上述图86所示。痕量级的允许值是off
,user
,admin
和support
。使用vi
编辑器并将以下内容复制并粘贴到listener.ora
.
$ cd /oracle18c/app/oracle/product/18.0.0/dbhome_1/network/admin
$ vi listener.ora
#---------------------------------------------------------------------
# To prevent "Warning: Subscription for node down event still pending"
#---------------------------------------------------------------------
SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER=off
#-------------------------------------------------------------------------------
# Permitted values for trace level are "off", "user", "admin" and "support".
# OFF (equivalent to 0) provides no tracing.
# USER (equivalent to 4) traces to identify user-induced error conditions.
# ADMIN (equivalent to 6) traces to identify installation-specific problems.
# SUPPORT (equivalent to 16) provides trace information for troubleshooting
# information for support.
#--------------------------------------------------------------------------------
DIAG_ADR_ENABLED_LISTENER=off
TRACE_TIMESTAMP_LISTENER=true
TRACE_LEVEL_LISTENER=support
TRACE_DIRECTORY_LISTENER=/tmp
TRACE_FILE_LISTENER=listener.trc
LOG_DIRECTORY_LISTENER=/tmp
LOG_FILE_LISTENER=listener.log
Run Code Online (Sandbox Code Playgroud)
保存并退出vi
编辑器。
发出以下命令以显示listener.ora
文件的内容:
$ cd /oracle18c/app/oracle/product/18.0.0/dbhome_1/network/admin
$ cat listener.ora
Run Code Online (Sandbox Code Playgroud)
Figure-87: 'listener.ora' contains the server-side network configuration parameters.
使用vi
编辑器打开sqlnet.ora
并将以下内容复制并粘贴到文件中:
$ cd /oracle18c/app/oracle/product/18.0.0/dbhome_1/network/admin
$ vi sqlnet.ora
#----------------------------------------
# set trace and log parameters for client
#----------------------------------------
DIAG_ADR_ENABLED=off
TRACE_UNIQUE_CLIENT=off
TRACE_TIMESTAMP_CLIENT=true
TRACE_FILELEN_CLIENT=100
TRACE_LEVEL_CLIENT=support
TRACE_DIRECTORY_CLIENT=/tmp
TRACE_FILE_CLIENT=sqlnet_client.trc
LOG_DIRECTORY_CLIENT=/tmp
LOG_FILE_CLIENT=sqlnet_client.log
#----------------------------------------
# set trace and log parameters for server
#----------------------------------------
TRACE_TIMESTAMP_SERVER=true
TRACE_FILELEN_SERVER=100
TRACE_LEVEL_SERVER=support
TRACE_DIRECTORY_SERVER=/tmp
TRACE_FILE_SERVER=sqlnet_server.trc
LOG_DIRECTORY_SERVER=/tmp
LOG_FILE_SERVER=sqlnet_server.log
#----------------------------------------
# set TNSPING Diagnostic Parameters
#----------------------------------------
TNSPING.TRACE_LEVEL=support
TNSPING.TRACE_DIRECTORY=/tmp
Run Code Online (Sandbox Code Playgroud)
保存并退出vi
编辑器。
发出以下命令以显示sqlnet.ora
文件的内容:
$ cd /oracle18c/app/oracle/product/18.0.0/dbhome_1/network/admin
$ cat sqlnet.ora
Run Code Online (Sandbox Code Playgroud)
Figure-88: 'sqlnet.ora' is a profile configuration file that contain parameters used by both client and server.
Names.directory_path: 此参数指定客户端尝试连接到数据库时使用的命名方法的顺序。可能的值包括:LDAP
,TNSNAMES
,HOSTNAME
,ONAMES
,和EZCONNECT
。
发出以下命令以显示tnsnames.ora
文件的内容:
$ cd /oracle18c/app/oracle/product/18.0.0/dbhome_1/network/admin
$ cat tnsnames.ora
Run Code Online (Sandbox Code Playgroud)
Figure-89: 'tnsnames.ora' file contains alias list.
要使对listener.ora
和所做的更改生效sqlnet.ora
,请listener
通过以下命令重新加载:
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/lsnrctl reload
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/lsnrctl status
Run Code Online (Sandbox Code Playgroud)
Figure-90: Listener Parameters are set up successfully (compare with figure-86).
这是第三部分的结尾,即将到来的第四部分包括:
1) Generate database scripts by DBCA.
2) Create Orcale 18c database by running scripts.
Run Code Online (Sandbox Code Playgroud)
问答环节的第四部分现在开始。
4.1. 运行 DBCA :
通过按下Ctrl+Alt+T
并运行数据库配置辅助工具打开终端dbca
:
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/dbca
Figure-91: Run database configuration assistance tool 'dbca'
Figure-93: Select 'Create a database operation' and press 'Next'.
Figure-94: Select 'Advanced configuration' mode and press 'Next'.
Figure-95: Select 'Deployment type' and press 'Next'.
Figure-96: Enter 'Global database name', 'SID', 'PDB name' then click 'Next' button.
Figure-97: Select storage option "Use template file for database storage attributes" and click 'Next'.
Figure-98: Select Fast Recovery Option "Specify Fast Recovery Area" and click 'Next'
Figure-99: Choose listener to register database and click 'Next'.
Figure-100: Configure Database Vault and Label Security and click 'Next'.
Figure-101: Choose Memory option " Use Automatic Shared Memory Management (ASMM)" and configure "SGA" and "PGA" shared memory size and then hit menu 'Sizing'.
Figure-102: Specify "Processes" Number then hit menu "Character Sets".
Figure-103: Select "Unicode character" set and hit menu "Connection mode"
Figure-104: Select Dedicated server mode and hit "Sample Schemas"
Figure-105: Mark checkbox to "add sample schemas to the database" and then hit "Next".
Figure-106: Select "Configure Enterprise Manager (EM) database express " and specify port. Click 'Next'
Figure-107: Specify passwords for SYS, SYSTEM, PDBADMIN separately or select "Use the same passwords for all accounts". Click 'Next'.
Figure-108: Uncheck "Create database" checkbox to avoid creation of a database and check "Generate database creation scripts" checkbox. Click "Next" button.
Figure-109: Click "Save Response File " button.
Figure-110: Double-click "Documents" folder and then save a copy of dbca.rsp file by clicking "Save" button.
将响应文件保存dbca.rsp
在~/Documents
目录中。rsp
稍后需要此文件。
Figure-111: After saving "dbca.rsp" file, click "Finish" button.
Figure-112: Finish database script generation by clicking "Close" button.
DBCA
以下生成的脚本来创建 Oracle 18c 数据库:通过按下Ctrl+Alt+T
并执行 shell 脚本打开终端,该脚本orcl.sh
将提示为用户输入密码SYS
,SYSTEM
并且您选择的密码足够安全以确保安全。
Scripts path is: {ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/scripts
$ cd /oracle18c/app/oracle/admin/orcl/scripts
$ . orcl.sh | tee ~/Documents/create_database_scripts.log
Run Code Online (Sandbox Code Playgroud)
现在create_database_scripts.log
使用vi
编辑器打开日志文件:
$ vi ~/Documents/create_database_scripts.log
您将看到"ORA-12547: TNS:lost contact"
如下图 113 所示的错误:更改
Figure-113: "Error: ORA-12547: TNS:lost contact".
现在,我们必须找出是谁造成了这个麻烦。
shell 脚本从实际操作开始的地方orcl.sh
调用orcl.sql
脚本。该orcl.sql
调用一组其他的sql
依次脚本。让我们把周围的第一sql脚本跟踪语句CloneRmanRestore.sql
称为由oracl.sql
图-114如下图所示:
Figure-114: Trace statements in 'orcl.sql' file around 'CloneRmanRestore.sql' at the point of calling.
如果orcl.sh
再次运行,那么trace点的执行状态如下图115所示:
Figure-115: "Error: ORA-12547: TNS:lost contact" appears soon after entering into 'CloneRmanRestore.sql'.
因此,开拓CloneRmanRestore.sql
各地文件和地点跟踪语句CONNECT
该语句very first one upon entry
图-116的打击,如下所示:
Figure-116: Trace statements in 'CloneRmanRestore.sql' file around 'CONNECT' Statement.
当您orcl.sh
再次运行 shell 脚本时,在执行状态进入CloneRmanRestore.sql
文件的那一刻,出现如下图 117 所示的错误:
Figure-117: Trace statements around 'CONNECT' prove that error occurred while executing 'CONNECT' statement.
了解point of origination
错误是很好的,它是CONNECT
导致错误的SQL 语句。现在是时候清理failed installation
并重做安装,直到调用orcl.sh
. 因此,让我们继续下面的下一步 [第 4.3 节]。
4.3 . 尝试安装失败后清理系统。
在尝试再次安装之前,应先清理系统。通过按下Ctrl+Alt+T
并发出以下命令打开终端:
$ su -
# rm -f /etc/oraInst.loc
# rm -f /etc/oratab
# cd /oracle18c
# rm -rf *
# cd /opt/oracle
# rm -rf *
# cd /opt
# rm -rf ORCLfmap
# cd /tmp
# rm -rf *
# exit
Run Code Online (Sandbox Code Playgroud)
现在重新启动计算机,然后转到下一步 [第 4.4 节] 重新安装 oracle。
4.4.1. 提取 Oracledb_home.zip
图像文件。
清理系统后,让我们再次尝试安装。请按照以下步骤操作:
$ mkdir -p /oracle18c/app/oracle/product/18.0.0/dbhome_1
$ unzip /mnt/ShareMe/'Software(downloaded)'/'MySQL & Oracle'/'Oracle 18.c LINUX.X64_180000_db_home.zip' -d /oracle18c/app/oracle/product/18.0.0/dbhome_1/
$ chmod -R 775 /oracle18c
Run Code Online (Sandbox Code Playgroud)
回想一下在 [ section - 2.2.10 ] 中,omkfix.sh
文件被创建并保存在~/scripts/
目录下,现在运行脚本:
$ . ~/scripts/omkfix.sh
4.4.2. 安装数据库软件。
安装数据库软件,按照【3.2节】从图64到图82。
4.4.3. 安装监听器。
返回 [第 3.3 节],完成LISTENER 安装并立即返回此处。
要验证侦听器是否处于活动状态,请发出以下命令:
$ ps -ef | grep tnslsnr
Figure-118: 'Listener' is alive and active in the background.
4.4.4. 生成脚本以创建数据库。
要生成安装数据库所需的脚本,请以dbca
交互方式运行dbca.rsp
(请参阅figure-110
显示响应文件dbca.rsp
已保存在~/Documents
我们现在要使用的文件夹中!):
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/dbca -responseFile /home/oracle/Documents/dbca.rsp
Run Code Online (Sandbox Code Playgroud)
重复 [第 4.1 节] 中的指令figure-92
直到figure-112
以生成用于创建数据库的脚本。
这是第四部分的结尾,最后一节第五部分开始介绍“故障排除和安装后”。
答案会话的最后和结束的第五部分现在开始。
5.1. 创建密码文件。
现在,创建位于"$ORACLE_HOME/dbs"
其名称应解析如下的密码文件:
密码文件名公式:orapw
+ ORACLE_SID
= orapw
+ orcl
= orapworcl
.
发出命令orapwd
以创建用户并将用户与密码一起添加SYS
到密码文件中,如下所示:'orapworcl'
'oracle18c'
$ /oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/orapwd file=/oracle18c/app/oracle/product/18.0.0/dbhome_1/dbs/orapworcl password=oracle18c ENTRIES=30 FORCE=Y IGNORECASE=Y format=12
Run Code Online (Sandbox Code Playgroud)
5.2. 设置 Oracle 环境。
要设置 oracle 环境,请创建一个文件~/scripts/oenv.sh
并复制和粘贴本节中给出的内容:
$ vi ~/scripts/oenv.sh
#!/bin/sh
#--------------------------------------------------------------------
# Oracle Environment Variables Settings
#--------------------------------------------------------------------
export ORACLE_BASE=/oracle18c/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/18.0.0/dbhome_1
export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export ORACLE_LIBPATH=$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$CLASSPATH
export ORACLE_HOSTNAME=$HOSTNAME
export ORA_INVENTORY=/oracle18c/app/oraInventory
export DATA_DIR=$ORACLE_BASE/oradata
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ADR_HOME=$ORACLE_BASE/diag
#--------------------------------------------------------------------
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export PDB_NAME=pdb
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
#--------------------------------------------------------------------
export TMP=/tmp; export TMPDIR=$TMP; export TEMP=$TMP
#--------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
更改文件权限:
$ chmod +x ~/scripts/oenv.sh
~/.bashrc
通过此命令添加以下内容:
$ echo '# Environment settings for Oracle ' | tee -a ~/.bashrc
$ echo '. ~/scripts/oenv.sh' | tee -a ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
现在,重新启动计算机并返回此处继续进行。
5.3. 创建目录。
打开vi
编辑器并复制并粘贴以下内容:
$ vi ~/scripts/ocdir.sh
#!/bin/sh
umask 0027
mkdir -p /oracle18c/app/oracle
mkdir -p /oracle18c/app/oracle/admin/orcl/adump
mkdir -p /oracle18c/app/oracle/admin/orcl/dpdump
mkdir -p /oracle18c/app/oracle/admin/orcl/pfile
mkdir -p /oracle18c/app/oracle/audit
mkdir -p /oracle18c/app/oracle/cfgtoollogs/dbca/orcl
mkdir -p /oracle18c/app/oracle/fast_recovery_area/ORCL
mkdir -p /oracle18c/app/oracle/oradata/ORCL
mkdir -p /oracle18c/app/oracle/oradata/ORCL/pdb
mkdir -p /oracle18c/app/oracle/oradata/ORCL/pdbseed
mkdir -p /oracle18c/app/oracle/product/18.0.0/dbhome_1/dbs
Run Code Online (Sandbox Code Playgroud)
更改文件权限:
$ chmod +x ~/scripts/ocdir.sh
执行脚本文件ocdir.sh
:
$ . ~/scripts/ocdir.sh
5.4. 检查listener
状态。
使用以下命令确保侦听器已启动并在后台侦听:
$ ss -elpunt | grep -E "^Net|tnslsnr"
Figure-119: Oracle listener is up and running.
如果侦听器未运行,则通过以下命令启动它:
$ lsnrctl start LISTENER
5.5. ORA-12547
错误的意思。
让我们先了解一下“什么ORA-12547
意思”。ORA-12547
通过运行oerr
输出预先记录的描述的oracle 二进制文件找出错误的含义。
$ cd $ORACLE_HOME/bin
$ ./oerr ORA 12547
Run Code Online (Sandbox Code Playgroud)
Figure-120: The Meaning of error 'ORA-12547' displayed by oracle binary utility 'oerr'.
ORA-12547
oracle 实用程序对错误的描述oerr
,似乎有点奇怪。简单的说,ORA-12547
就是通信通道被破坏了。它最常被抛出,因为过程的另一端意外消失了。此错误ORA-12547
可能由多种原因导致。我们将一一看到。
5.6. oracle
二进制权限设置
二进制文件oracle
不仅要有6751
权限,还要有non-zero
文件大小,如下图 121 所示:
$ cd $ORACLE_HOME/bin
$ ls -l oracle
Run Code Online (Sandbox Code Playgroud)
Figure-121: oracle binary has '6751' privileges set and 'non-zero' files size which are good.
如果设置了错误的权限,则发出以下命令:
$ chmod 6751 oracle
如果 oracle 文件显示zero file size
,则发出以下命令进行重建:
$ cd $ORACLE_HOME/bin
$ ./relink all
Run Code Online (Sandbox Code Playgroud)
5.7. config.o
二进制文件的非零文件大小:
目标文件config.o
应该具有非零文件大小。要验证,请发出以下命令:
$ cd $ORACLE_HOME/rdbms/lib
$ ls -l config.o
Run Code Online (Sandbox Code Playgroud)
Figure-122: The screen displays that 'object.o' file has non-zero file size which is good.
如果有zero file size
,则发出以下命令进行重建:
$ mv config.o config.o.bad
$ cd $ORACLE_HOME/bin
$ ./relink all
Run Code Online (Sandbox Code Playgroud)
5.8. 文件中的 Oracle Base 和 Home 设置orabasetab
:
显示用于验证oracleBase
和Home
设置的文件内容。
$ cd $ORACLE_HOME/install
$ cat orabasetab
Run Code Online (Sandbox Code Playgroud)
Figure-123: Display of content of 'orabasetab' file showing the settings of oracle 'Base' and 'Home' which are good.
如果发现不完整或错误的设置,则$ORACLE_HOME/install/orabasetab
使用vi
编辑器编辑文件并更正Base
和Home
值。
5.9. Oracle 基础设置:
运行orabase
二进制文件以确保正确设置了 Oracle 基目录。
$ cd $ORACLE_HOME/bin
$ ./orabase
Run Code Online (Sandbox Code Playgroud)
Figure-124: Oracle Base directory setting is shown by binary 'orabase' which is good.
5.10. /proc
目录权限设置:
确保在/proc
目录上设置了正确的权限。发出以下命令:
$ ls -l /
Figure-125: The correct privilege settings 555 for /proc directory.
如果权限设置错误,则通过以下命令手动更正:
$ cd /
$ sudo chmod 555 proc
Run Code Online (Sandbox Code Playgroud)
5.11. /dev/null
目录权限设置:
确保在/dev/null
应该是0666
. 发出以下命令:
$ ls -l /
Figure-126: The correct privilege settings '666' for '/dev/null' directory.
如果权限设置错误,则通过以下命令手动更正:
$ cd /
$ sudo chmod 666 /dev/null
Run Code Online (Sandbox Code Playgroud)
5.12. 文件中的 Oracle 二进制相关子系统设置/ect/fstab
:
/etc/fstab
文件中每个条目的结构主要由以下 6 个字段组成:
[Device] [Mount point] [Files System Type] [options] [Backup operations] [File System check order]
Run Code Online (Sandbox Code Playgroud)
oracle软件已经安装在/opt
挂载点下的文件系统中。找到/etc/fstab
文件中与/opt
挂载点对应的记录并检查第 4 个字段,即[options]
. 如果此字段包含,"nosuid"
则将其更改为"suid"
。
发出以下命令,定位入口对应的/opt
挂载点:
$ cat /etc/fstab | grep /opt
Figure-127: The 4th field '[options]' contains "defaults" corresponding to '/opt' file systems which is good.
第 4 个字段的[options]
值为"defaults"
a shortcut
,其扩展为:
"rw,suid,dev,exec,auto,nouser,async"
因此,存在"defaults"
不会造成任何麻烦。在没有 的情况下"defaults"
,如果"nosuid"
显式存在,则使用编辑器将其更改为"suid"
手动在/etc/fstab
文件中vi
。更改后,只需重新启动系统。
5.13. 取消设置EXTSHM
环境变量。
由于 oracle 不支持Extended Shared Memory
,环境变量EXTSHM
应该是未设置的。发出以下命令:
$ env | grep EXTSHM
Figure-128: The output shows that the Environment variable 'EXTSHM' is undefined which is good.
如果EXTSHM
设置了变量,则unset
使用以下命令:
$ unset EXTSHM
5.14. Stack 的 ulimit 设置不足:
请参阅[第 1-7 节]“为用户 oracle 配置 shell 限制”以增加堆栈限制。
5.15. "ORA-12547: TNS:lost contact"
使用sqlplus
二进制模拟错误:
已确定ORA-12547
在尝试通过运行从 DBCA 生成的脚本创建 Oracle 18c 数据库时发生错误 [请参阅第 4.2 节和图 113 ]。我们发现这个错误的根本原因是CONNECT
语句。因此,让我们通过CONNECT
直接从sqlplus
二进制调用语句来再次重现此错误。
发出sqlplus
如下所示的命令:
$ $ORACLE_HOME/bin/sqlplus /nolog
CONNECT
在SQL
提示符处发出语句如下:
SQL> connect sys/oracle18c as sysdba;
Figure-129: Simulation of "ORA-12547: TNS:lost contact" error by directly invoking 'sqlplus' binary.
现在可以确定通过执行sqlplus
二进制文件可以重新创建错误。在没有源代码的情况下,我们应该用我们武器库中剩下的任何武器来解决问题。作为第一步,让我们尝试生成描述sqlplus
二进制中发生的事件序列的跟踪信息。
5.16. 运行strace
命令以生成进一步挖掘所需的跟踪信息:
为了生成进一步调查CONNECT
语句所需的跟踪文件,让我们使用strace
命令和sqlplus
如下所示:
$ strace -f -o /tmp/strace.log $ORACLE_HOME/bin/sqlplus /nolog
CONNECT
在SQL
提示符处发出语句如下:
SQL> connect sys/oracle18c as sysdba;
Figure-130: Use 'strace' command to investigate into 'CONNECT' statement invoked from 'sqlplus' binary.
现在,使用gedit
打开/tmp/strace.log
文件。跟踪整个文件后,发现问题区域如下图131所示:
Figure-131: "core dump" is found recorded in the 'strace.log' file.
在进行"core dump"
进一步分析之前,让我们使用以下命令检查core
文件是否已生成default directory
:
$ pwd
$ ls
Run Code Online (Sandbox Code Playgroud)
Figure-132: The output confirms that no 'core' file was generated in '/home/oracle' directory.
使用以下命令查看内核是否已启用:
$ ulimit -c
Figure-133: Output shows that 'core' is not enabled.
要启用核心,请发出以下命令:
$ ulimit -c unlimited
Figure-134: Enable core file generation.
确保通过以下命令启用核心:
$ ulimit -c
Figure-135: Ouput shows that 'core' file generation is successfully enabled.
再次运行strace
本节 5.16开头所示的命令并检查core
文件是否已成功生成:
$ pwd
$ ls
Run Code Online (Sandbox Code Playgroud)
Figure-136: Output shows that 'core' file is generated successfully
现在,gdb
按如下方式运行调试器:
$ gdb -c core
Figure-137: Undefined Symbol in 'libpython3.6m.so.1.0' while invoking debugger 'gdb'.
要解决symbol lookup error
,请发出以下命令以检查 的依赖关系gdb
:
$ ldd /usr/bin/gdb
Figure-138: Output shows that only shared object 'libexpat.so.1' has been loaded wrongly from '$ORACLE_HOME/lib'.
从上图 138 中的 about 输出,可以很容易地推断出问题与LD_LIBRARY_PATH
环境变量有关。
首先,发出以下命令来定位 的正确路径libexpat.so.1
:
$ locate libexpat.so.1
Figure-139: The correct library path for 'libexpat.so.1' is '/lib/x86_64-linux-gnu/'
确定环境变量的当前值LD_LIBRARY_PATH
:
$ echo $LD_LIBRARY_PATH
Figure-140: '$ORACLE_HOME/lib' appears as the first member in the 'value' of environment variable 'LD_LIBRARY_PATH'
由于$ORACLE_HOME/lib
似乎是 中的第一个成员LD_LIBRARY_PATH
,因此依赖库libexpat.so.1
已加载 from$ORACLE_HOME/lib
而不是 from /lib/x86_64-linux-gnu
。这LD_LIBRARY_PATH
直至核心转储分析是在必须给予取消。稍后,这个环境变量LD_LIBRARY_PATH
应该恢复到原来的状态。
编辑~/scripts/oenv.sh
文件(参见第 5.2 节)并注释掉包含 的行LD_LIBRARY_PATH
,以便在重新启动后该变量将自动取消设置。
使用以下命令验证该行是否已正确注释掉:
$ cat ~/scripts/oenv.sh | grep LD_LIBRARY_PATH
Figure-141: The comment symbol "#" appears in front of line containing 'LD_LIBRARY_PATH'.
重新启动系统。
LD_LIBRARY_PATH
使用以下命令找出它是否为空的值:
$ echo $LD_LIBRARY_PATH
Figure-142: Output shows that 'LD_LIBRARY_PATH' is empty, thus properly unset which is good.
再次发出以下命令以检查依赖项列表,gdb
以确保libexpat.so.1
从正确的路径加载:
$ ldd /usr/bin/gdb
Figure-143: Output shows that 'libexpat.so.1' is loaded correctly from '/lib/x86_64-linux-gnu'.
现在,运行调试器gdb
并检查它是否正常工作:
$ gdb -c core
Figure-144: Debugger 'gdb' is found to be working perfectly.
bt
在gdb
提示符下发出命令,如下所示:
(gdb) bt
Figure-145: The screen shows the output of 'bt' command and observe that the result is too poor to analyze.
bt
命令的结果太差,我们need more information
进行分析。让我们尝试another method
使用以下命令:
$ gdb --core=core --exec=/oracle18c/app/oracle/product/18.0.0/dbhome_1/bin/oracle
Run Code Online (Sandbox Code Playgroud)
bt
在gdb
提示符下发出命令:
(gdb) bt
Figure-146: The result produced by the above command is more promising than in figure-145.
该tzset()
函数设置localtime()
相关函数使用的时间转换信息。此外,localtime()
它不是线程安全的,因为它返回一个指向保存结果(struct tm *)
的静态数据结构的指针(<time.h>
有关更多详细信息,请参阅标头)。让我们/tmp/strace.log
再次回顾一下:
Figure-147: The file "/etc/localtime" was the last one accessed before crash (core dump).
该文件"/etc/localtime"
是崩溃前最后访问的文件(核心转储)。从开始到核心转储,这个文件"/etc/localtime"
被访问了两次。这显示了死锁的情况,因为localtime()
由于正在处理某些信号而递归(第二次)进入并且localtime()
不是可重入或线程安全的,因此它会阻塞锁。
我们可以得出结论,Oracle kernel
在各种libc
函数 ( Standard Library for C Programming Language
)中都崩溃了,例如localtime().
什么是 Oracle 内核?
在 Ubuntu linux 上,每个 oracle 客户端进程,例如sqlplus or Toad
, 都连接到tnslsnr
,fork()'s
然后exec()'s
是一个二进制文件 "$ORACLE_HOME/bin/oracle"
,称为oracle kernel program
. 这个二进制文件也被普遍称为Oracle Server Process
. 请参阅 figure-121
[第 5.6 节]。
让我们显示execve
调用oracle
由strace
命令记录的二进制文件的系统调用/tmp/strace.log
。
Figure-148: The Oracle Kernel binary "oracle" invoked by "execve" system call.
因此,是Oracle kernel program
谁导致core dump
并解决了这个问题,需要删除libc*
存根,然后重新构建 oracle 内核二进制文件$ORACLE_HOME/bin/oracle
。
要完成此任务,请发出以下命令:
$ cd $ORACLE_HOME/lib/stubs
$ ls -l libc*
$ rm libc*
$ cd $ORACLE_HOME/bin
$ ./relink all
Run Code Online (Sandbox Code Playgroud)
Figure-149: Rebuild oracle kernel program "$ORACLE_HOME/bin/oracle" afresh by issuing "./relink all" command and observe the resulting log file.
重建后,检查其日志文件$ORCALE_HOME/install/relink_2019-02-26_08-27.log
以确保所有重建成功。
strace
再次运行命令,让我们检查我们的大坏蛋是否"ORA-12547: TNS:lost contact"
仍然存在!
$ strace -f -o /tmp/strace.log $ORACLE_HOME/bin/sqlplus /nolog
CONNECT
在 SQL 提示符下发出语句如下:
SQL> connect sys/oracle18c as sysdba;
Figure-150: Our arch-villain "ORA-12547: TNS:lost contact" has vanished at last and replaced by "an idle instance".
答对了! 我们的大反派"ORA-12547: TNS:lost contact"
终于消失了!
该connect
声明被成功执行和idle instance
也产生。
5.17. 重新运行生成的脚本DBCA
以创建 Oracle 18c 数据库:
要显示创建数据库所需的脚本列表,请发出以下命令:
$ cd /oracle18c/app/oracle/admin/orcl/scripts
$ ls -l *.sql
归档时间: |
|
查看次数: |
29930 次 |
最近记录: |