《Linux 下安装Oracle数据库 - Oracle 19C By CentOS 8 》(第四部分)

3 数据库使用

3.1 启动数据库

第一次启动失败。报错为:

Since ORACLE_HOME is not set, cannot auto-start Oracle Net Listener.

操作如下:

[oracle@oracent ~]$ lsnrctl start

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 29-JUN-2023 23:25:33

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

TNS-01106: Listener using listener name LISTENER has already been started
[oracle@oracent ~]$ dbstart
Since ORACLE_HOME is not set, cannot auto-start Oracle Net Listener.
Usage: /opt/oracle/product/19c/dbhome_1/bin/dbstart ORACLE_HOME

解决方法,修改环境变量:

//分别修改以下两个文件
[oracle@oracent bin]$ vim $ORACLE_HOME/bin/dbstart
[oracle@oracent bin]$ vim $ORACLE_HOME/bin/dbshut
//修改如下段落
--将ORACLE_HOME=$1  修改为 ORACLE_HOME=$ORACLE_HOME 
--将ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME 
# This is to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
  echo "Since ORACLE_HOME is not set, cannot auto-stop Oracle Net Listener"
  echo "Usage: $0 ORACLE_HOME"
else
  # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
  # a different ORACLE_HOME for each entry in the oratab.
  ORACLE_HOME=$ORACLE_HOME; export ORACLE_HOME
//保存后再次启动,不再报错。
[oracle@oracent bin]$ dbstart
[oracle@oracent bin]$ 

3.2 登录数据库并查询测试

第一次连接数据库报错,如下:

[oracle@oracent bin]$ sqlplus / as sysdba
bash: rlwrap: command not found...

资源下载:rlwrap-0.46.1.tar.gz

//上传文件后解压
[root@oracent rlwrap-0.46.1]# tar -xvzf rlwrap-0.46.1.tar.gz
[root@oracent oracle]# ls -l
total 340
drwxrwxr-x. 8 else else   4096 Jun 29 23:55 rlwrap-0.46.1
-rw-rw-r--. 1 else else 340033 Jun 29 23:49 rlwrap-0.46.1.tar.gz

//进入目录,进行安装
[root@oracent oracle]# cd rlwrap-0.46.1
[root@oracent oracle]# ./configure 

//第一次安装报错:
configure: error: 
You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build
// 安装依赖
[root@oracent oracle]# 
[root@oracent oracle]# yum install readline-devel
Last metadata expiration check: 0:08:57 ago on Thu 29 Jun 2023 11:48:43 PM CST.
Dependencies resolved.
====================================================================================================
 Package                    Architecture     Version                         Repository        Size
====================================================================================================
Installing:
 readline-devel             x86_64           7.0-10.el8                      baseos           204 k
Installing dependencies:
 ncurses-c++-libs           x86_64           6.1-9.20180224.el8              baseos            58 k
 ncurses-devel              x86_64           6.1-9.20180224.el8              baseos           528 k

Transaction Summary
====================================================================================================
Install  3 Packages

Total download size: 790 k
Installed size: 1.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): ncurses-c++-libs-6.1-9.20180224.el8.x86_64.rpm                34 kB/s |  58 kB     00:01    
(2/3): readline-devel-7.0-10.el8.x86_64.rpm                         111 kB/s | 204 kB     00:01    
(3/3): ncurses-devel-6.1-9.20180224.el8.x86_64.rpm                  270 kB/s | 528 kB     00:01    
----------------------------------------------------------------------------------------------------
Total                                                               402 kB/s | 790 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                            1/1 
  Installing       : ncurses-c++-libs-6.1-9.20180224.el8.x86_64                                 1/3 
  Installing       : ncurses-devel-6.1-9.20180224.el8.x86_64                                    2/3 
  Installing       : readline-devel-7.0-10.el8.x86_64                                           3/3 
  Running scriptlet: readline-devel-7.0-10.el8.x86_64                                           3/3 
  Verifying        : ncurses-c++-libs-6.1-9.20180224.el8.x86_64                                 1/3 
  Verifying        : ncurses-devel-6.1-9.20180224.el8.x86_64                                    2/3 
  Verifying        : readline-devel-7.0-10.el8.x86_64                                           3/3 

Installed:
  ncurses-c++-libs-6.1-9.20180224.el8.x86_64         ncurses-devel-6.1-9.20180224.el8.x86_64        
  readline-devel-7.0-10.el8.x86_64                  

Complete!

编译安装

[root@oracent rlwrap-0.46.1]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make sets $(MAKE)... (cached) yes
checking whether build environment is sane... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking for perl... /usr/bin/perl
checking for strip... strip
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for errno.h... yes
checking for fcntl.h... yes
checking for libgen.h... yes
checking for libutil.h... no
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for sched.h... yes
checking for sys/file.h... yes
checking for sys/ioctl.h... yes
checking for sys/wait.h... (cached) yes
checking for sys/resource.h... yes
checking for stddef.h... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for stdint.h... (cached) yes
checking for time.h... yes
checking for sys/time.h... yes
checking for getopt.h... yes
checking for regex.h... yes
checking for curses.h... yes
checking for stropts.h... no
checking for termcap.h... yes
checking for util.h... no
checking for term.h... yes
checking for ncurses/term.h... yes
checking for gcc options needed to detect all undeclared functions... none needed
checking whether PROC_PIDVNODEPATHINFO is declared... no
checking whether procstat_open_sysctl is declared... no
checking whether procstat_getprocs is declared... no
checking whether procstat_getfiles is declared... no
checking whether STAILQ_FOREACH is declared... no
checking argument type of tputs putc function... int
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking whether gcc needs -traditional... no
checking for getopt_long... yes
checking for basename... yes
checking for dirname... yes
checking for flock... yes
checking for getopt_long... (cached) yes
checking for isastream... yes
checking for mkstemps... yes
checking for pselect... yes
checking for putenv... yes
checking for readlink... yes
checking for sched_yield... yes
checking for setenv... yes
checking for setitimer... yes
checking for setsid... yes
checking for setrlimit... yes
checking for sigaction... yes
checking for snprintf... yes
checking for strlcpy... no
checking for strlcat... no
checking for strnlen... yes
checking for system... yes
checking for openpty in -lutil... yes
checking for openpty... yes
checking for getpty... no
checking for grantpt... yes
checking for unlockpt... yes
checking for getpt... 
checking for pty/tty type... checking for pty.h... yes
OPENPTY
configure: checking for pty ranges
checking for tgetent... no
checking for tgetent in -ltinfo... yes
checking for readline in -lreadline... yes
checking for tigetnum... yes
checking for readline/readline.h... yes
checking whether your readline headers and library know about rl_set_screen_size... yes
checking whether your readline headers and library know about rl_basic_quote_characters... yes
checking whether your readline headers and library know about rl_variable_value... yes
checking whether your readline headers and library know about rl_readline_version... yes
checking whether your readline headers and library know about rl_executing_keyseq... yes
checking whether the private symbol _rl_horizontal_scroll_mode is visble in your readline libs... yes
Will rlwrap find command's working directory under /proc/<commands pid>/cwd? let's see...
checking for /proc/13315/cwd/configure.ac... yes
checking whether we can find command line under <opt_proc_mountpoint>/<pid>/cmdline and mirror it by overwriting our own *argv (this may take a few secs)... yes


checking that generated files are newer than configure... done
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating filters/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating config.h
config.status: executing depfiles commands

Now do:
    make (or gmake)  to build rlwrap
    make check       for instructions how to test it
    make install     to install it

[root@oracent rlwrap-0.46.1]# make
make  all-recursive
make[1]: Entering directory '/home/oracle/rlwrap-0.46.1'
Making all in doc
make[2]: Entering directory '/home/oracle/rlwrap-0.46.1/doc'
sed -e 's#@DATADIR@#/usr/local/share#'  rlwrap.man > rlwrap.1
make[2]: Leaving directory '/home/oracle/rlwrap-0.46.1/doc'
Making all in src
make[2]: Entering directory '/home/oracle/rlwrap-0.46.1/src'
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT signals.o -MD -MP -MF .deps/signals.Tpo -c -o signals.o signals.c
mv -f .deps/signals.Tpo .deps/signals.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT readline.o -MD -MP -MF .deps/readline.Tpo -c -o readline.o readline.c
mv -f .deps/readline.Tpo .deps/readline.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT pty.o -MD -MP -MF .deps/pty.Tpo -c -o pty.o pty.c
mv -f .deps/pty.Tpo .deps/pty.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT completion.o -MD -MP -MF .deps/completion.Tpo -c -o completion.o completion.c
mv -f .deps/completion.Tpo .deps/completion.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT term.o -MD -MP -MF .deps/term.Tpo -c -o term.o term.c
mv -f .deps/term.Tpo .deps/term.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT ptytty.o -MD -MP -MF .deps/ptytty.Tpo -c -o ptytty.o ptytty.c
ptytty.c: In function ‘ptytty_control_tty’:
ptytty.c:257:9: warning: implicit declaration of function ‘isastream’; did you mean ‘system’? [-Wimplicit-function-declaration]
     if (isastream(fd_tty) == 1) {
         ^~~~~~~~~
         system
mv -f .deps/ptytty.Tpo .deps/ptytty.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT utils.o -MD -MP -MF .deps/utils.Tpo -c -o utils.o utils.c
mv -f .deps/utils.Tpo .deps/utils.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT string_utils.o -MD -MP -MF .deps/string_utils.Tpo -c -o string_utils.o string_utils.c
mv -f .deps/string_utils.Tpo .deps/string_utils.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT malloc_debug.o -MD -MP -MF .deps/malloc_debug.Tpo -c -o malloc_debug.o malloc_debug.c
mv -f .deps/malloc_debug.Tpo .deps/malloc_debug.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT multibyte.o -MD -MP -MF .deps/multibyte.Tpo -c -o multibyte.o multibyte.c
mv -f .deps/multibyte.Tpo .deps/multibyte.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT filter.o -MD -MP -MF .deps/filter.Tpo -c -o filter.o filter.c
mv -f .deps/filter.Tpo .deps/filter.Po
gcc -DDATADIR=\"/usr/local/share\"  -g -O2   -o rlwrap main.o signals.o readline.o pty.o completion.o term.o ptytty.o utils.o string_utils.o malloc_debug.o multibyte.o filter.o  -lutil   -lreadline -ltinfo
make[2]: Leaving directory '/home/oracle/rlwrap-0.46.1/src'
Making all in filters
make[2]: Entering directory '/home/oracle/rlwrap-0.46.1/filters'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/oracle/rlwrap-0.46.1/filters'
make[2]: Entering directory '/home/oracle/rlwrap-0.46.1'
make[2]: Leaving directory '/home/oracle/rlwrap-0.46.1'
make[1]: Leaving directory '/home/oracle/rlwrap-0.46.1'

该报错,退出重连可能就好了。

07-01 10:10