Thứ Hai, 19 tháng 1, 2026

Khởi động và dừng các dịch vụ Oracle Database 23ai

Bạn có thể khởi động và dừng cơ sở dữ liệu theo cách thủ công hoặc thiết lập để nó tự động dừng hoặc khởi động khi hệ thống tắt hoặc khởi động.
1) Tắt và khởi động thủ công
2) Tự động tắt và khởi động
3) Khởi động và dừng các dịch vụ bằng cách sử dụng tập lệnh cấu hình

1) Tắt và khởi động thủ công:

Dừng  dịch vụ cơ sở dữ liệu và trình lắng nghe
#Đăng nhập với tư cách  người dùng oracle  và cập nhật các biến môi trường.
[oracle@orahost ~]$ id 
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

[oracle@orahost ~]$ . oraenv
ORACLE_SID = [oracle] ? FREE
The Oracle base has been set to /opt/oracle
 
[oracle@orahost ~]$ env | grep ORA
ORACLE_SID=FREE
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree

#Đảm bảo  dịch vụ Cơ sở dữ liệu  đang chạy trên máy chủ.
[oracle@orahost ~]$ ps -ef | grep pmon
oracle 1925 1 0 09:17 ? 00:00:00 db_pmon_FREE
oracle 3758 3711 0 09:39 pts/0 00:00:00 grep --color=auto pmon

#Đảm bảo  dịch vụ LISTENER  đang chạy trên máy chủ.
[oracle@orahost ~]$ ps -ef | grep tns
root 5 2 0 09:16 ? 00:00:00 [netns]
oracle 1730 1 0 09:16 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr LISTENER -inherit
oracle 3762 3711 0 09:40 pts/0 00:00:00 grep --color=auto tns

#Đăng nhập với tư cách  "sqlplus / as sysdba"  và  tắt  cơ sở dữ liệu.
[oracle@orahost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Thu May 16 09:40:06 2024
Version 23.4.0.24.05

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

Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05

SQL> select name,open_mode from v$database;

NAME   OPEN_MODE
--------- --------------------
FREE   READ WRITE

SQL> col name for a20
SQL> select CON_ID,NAME,OPEN_MODE from v$pdbs;

    CON_ID NAME  OPEN_MODE
---------- -------------------- ----------
 2 PDB$SEED READ ONLY
 3 FREEPDB1 READ WRITE

SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05

#Ở cấp độ hệ điều hành, hãy dừng  các dịch vụ LISTENER  bằng cách thực hiện  lệnh "lsnrctl stop"  .
[oracle@orahost ~]$ lsnrctl stop 

LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 16-MAY-2024 09:43:15

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orahost.localhost.localdomain)(PORT=1521)))
The command completed successfully

#Kiểm tra xem cả  dịch vụ Cơ sở dữ liệu  và  dịch vụ LISTENER  có đang chạy trên máy chủ hay không.
[oracle@orahost ~]$ ps -ef | grep pmon
oracle 3826 3711 0 09:43 pts/0 00:00:00 grep --color=auto pmon
[oracle@orahost ~]$ ps -ef | grep tns
root 5 2 0 09:16 ? 00:00:00 [netns]
oracle 3835 3711 0 09:43 pts/0 00:00:00 grep --color=auto tns

Khởi tạo  dịch vụ cơ sở dữ liệu và trình lắng nghe (listener)
#Đăng nhập với tư cách  người dùng oracle  , cập nhật các biến môi trường và khởi động cơ sở dữ liệu bằng  lệnh startup "  .

[oracle@orahost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Thu May 16 09:48:55 2024
Version 23.4.0.24.05

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

Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area  844226552 bytes
Fixed Size     5365752 bytes
Variable Size   343932928 bytes
Database Buffers   490733568 bytes
Redo Buffers     4194304 bytes
Database mounted.
Database opened.
 
SQL> select name,open_mode from v$database;

NAME   OPEN_MODE
--------- --------------------
FREE   READ WRITE

SQL> col name for a20
SQL> select CON_ID,NAME,OPEN_MODE from v$pdbs;

    CON_ID NAME  OPEN_MODE
---------- -------------------- ----------
 2 PDB$SEED READ ONLY
 3 FREEPDB1 READ WRITE

#Thực hiện lệnh bên dưới để mở tất cả các cơ sở dữ liệu có thể cắm thêm. Ở đây, PDB đã được mở sẵn.

SQL> ALTER PLUGGABLE DATABASE ALL OPEN;

Pluggable database altered.

SQL> select CON_ID,NAME,OPEN_MODE from v$pdbs;

    CON_ID NAME  OPEN_MODE
---------- -------------------- ----------
 2 PDB$SEED READ ONLY
 3 FREEPDB1 READ WRITE

#Khởi động  các dịch vụ LISTENER  bằng cách thực hiện  lệnh "lsnrctl start"  .
[oracle@orahost ~]$ lsnrctl start

LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 16-MAY-2024 09:51:16

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

Starting /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 23.0.0.0.0 - Production
System parameter file is /opt/oracle/product/23ai/dbhomeFree/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/orahost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orahost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orahost.localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production
Start Date                16-MAY-2024 09:51:16
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           FREE
Listener Parameter File   /opt/oracle/product/23ai/dbhomeFree/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/orahost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orahost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

Wait for 2 minutes...See the status now.

[oracle@orahost ~]$ lsnrctl status

LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 16-MAY-2024 09:52:31

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orahost.localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production
Start Date                16-MAY-2024 09:51:16
Uptime                    0 days 0 hr. 1 min. 14 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           FREE
Listener Parameter File   /opt/oracle/product/23ai/dbhomeFree/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/orahost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orahost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "189011a1798d7228e0650a0027822869" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREE" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREEXDB" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "freepdb1" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
The command completed successfully


2) Tự động tắt và khởi động
Nên cấu hình hệ thống để tự động khởi động/dừng Oracle Database Free và LISTENER khi hệ thống khởi động/dừng. 

Để tự động hóa quá trình khởi động và tắt trình lắng nghe và cơ sở dữ liệu, hãy chạy các lệnh sau với quyền  người dùng root  :
[root@orahost ~]# systemctl daemon-reload
[root@orahost ~]# systemctl enable oracle-free-23ai

#Đảm bảo  dịch vụ Oracle Database 23ai  đang chạy trên máy chủ.
[oracle@orahost ~]$ ps -ef | grep pmon
oracle 3895 2849 0 09:49 ? 00:00:00  db_pmon_FREE
oracle 4564 3711 0 10:05 pts/0 00:00:00 grep --color=auto pmon

#Đảm bảo  dịch vụ LISTENER  đang chạy trên máy chủ.
[oracle@orahost ~]$ ps -ef | grep tns
root 5 2 0 09:16 ? 00:00:00 [netns]
oracle 4294 2849 0 09:51 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr  LISTENER  -inherit
oracle 4567 3711 0 10:05 pts/0 00:00:00 grep --color=auto tns

#Kiểm tra trạng thái dịch vụ bằng lệnh systemctl.
[root@orahost ~]# systemctl status oracle-free-23ai
● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
   Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated)
   Active: active (exited) since Thu 2024-05-16 09:18:00 EDT; 47min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 774 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 16807)
   Memory: 0B
   CGroup: /system.slice/oracle-free-23ai.service

May 16 09:16:45 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its>
May 16 09:16:47 orahost.localdomain oracle-free-23ai[774]: Starting Oracle Net Listener.
May 16 09:16:47 orahost.localdomain su[829]: (to oracle) root on none
May 16 09:16:59 orahost.localdomain oracle-free-23ai[774]: Oracle Net Listener started.
May 16 09:16:59 orahost.localdomain oracle-free-23ai[774]: Starting Oracle Database instance FREE.
May 16 09:16:59 orahost.localdomain su[1733]: (to oracle) root on none
May 16 09:16:59 orahost.localdomain su[1733]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 09:18:00 orahost.localdomain oracle-free-23ai[774]: Oracle Database instance FREE started.
May 16 09:18:00 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >
 
Bạn cũng có thể xác minh dịch vụ bằng cách thực hiện lệnh dưới đây.
[root@orahost ~]# /etc/init.d/oracle-free-23ai status
Status of the Oracle FREE 23ai service:

LISTENER status: RUNNING
FREE Database status:   RUNNING

#Thực hiện lệnh bên dưới để tải lại tiến trình nền dịch vụ. Thao tác này sẽ không hiển thị bất kỳ thông tin nào trên cửa sổ dòng lệnh.
[root@orahost ~]# systemctl daemon- reload
[root@orahost ~]#

#Thực hiện lệnh dưới đây để  kích hoạt  dịch  vụ Oracle Database 23ai  .
[root@orahost ~]# systemctl enable oracle-free-23ai
oracle-free-23ai.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable oracle-free-23ai

Để kiểm tra trường hợp trên, bạn có thể thực hiện  lệnh "init 6"  trên máy chủ của mình để khởi động lại máy chủ và xem liệu cả  dịch vụ Oracle Database 23ai  và  LISTENER  có khởi động cùng với máy chủ hay không.

[root@orahost ~]# init 6









[root@orahost ~]# id
uid=0(root) gid=0(root) groups=0(root)

[root@orahost ~]# uptime
 10:11:04 up 2 min,  1 user,  load average: 4.15, 1.64, 0.61

[root@orahost ~]# ngày
Thứ Năm, ngày 16 tháng 5 năm 2024, 10:11:07 EDT

[root@orahost ~]# ps -ef | grep pmon
oracle 1750 1 0 10:09 ? 00:00:00  db_pmon_FREE
root 3304 3196 0 10:11 pts/0 00:00:00 grep --color=auto pmon
 
[root@orahost ~]# ps -ef | grep tns
root 5 2 0 10:08 ? 00:00:00 [netns]
oracle 1740 1 0 10:09 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr  LISTENER  -inherit
root 3319 3196 0 10:11 pts/0 00:00:00 grep --color=auto tns

#Kiểm tra trạng thái dịch vụ bằng lệnh systemctl.
● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
   Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated)
   Active: active (exited) since Thu 2024-05-16 10:10:39 EDT; 1min 28s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 792 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 16807)
   Memory: 0B
   CGroup: /system.slice/oracle-free-23ai.service

May 16 10:09:31 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its>
May 16 10:09:32 orahost.localdomain oracle-free-23ai[792]: Starting Oracle Net Listener.
May 16 10:09:33 orahost.localdomain su[821]: (to oracle) root on none
May 16 10:09:45 orahost.localdomain oracle-free-23ai[792]: Oracle Net Listener started.
May 16 10:09:45 orahost.localdomain oracle-free-23ai[792]: Starting Oracle Database instance FREE.
May 16 10:09:45 orahost.localdomain su[1743]: (to oracle) root on none
May 16 10:09:45 orahost.localdomain su[1743]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 10:10:39 orahost.localdomain oracle-free-23ai[792]: Oracle Database instance FREE started.
May 16 10:10:39 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >

[root@orahost ~]# /etc/init.d/oracle-free-23ai status
Status of the Oracle FREE 23ai service:

LISTENER status: RUNNING
FREE Database status:   RUNNING

#Đăng nhập với tư cách người dùng oracle và xác minh thời gian khởi động cơ sở dữ liệu.
[root@orahost ~]# su - oracle

[oracle@orahost ~]$ . oraenv
ORACLE_SID = [oracle] ? FREE
The Oracle base has been set to /opt/oracle

#Kiểm tra chế độ mở và thời gian khởi động của cơ sở dữ liệu. 
[oracle@orahost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Thu May 16 10:12:34 2024
Version 23.4.0.24.05

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

Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05

SQL> select name,open_mode from v$database;

NAME   OPEN_MODE
--------- --------------------
FREE   READ WRITE

SQL> alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';

Session altered.

SQL> select sysdate from dual;

SYSDATE
--------------------
16-MAY-2024 10:13:29

SQL> select instance_name,startup_time from v$instance;

INSTANCE_NAME  STARTUP_TIME
---------------- --------------------
FREE  16-MAY-2024 10:09:49

SQL> col open_time for a35
SQL> col name for a16
SQL> select con_id,name,open_mode,OPEN_TIME from v$pdbs;

    CON_ID NAME      OPEN_MODE  OPEN_TIME
---------- ---------------- ---------- -----------------------------------
 2 PDB$SEED     READ ONLY  16-MAY-24 10.10.10.157 AM -04:00
 3 FREEPDB1     READ WRITE 16-MAY-24 10.10.23.121 AM -04:00

#Xác minh  trạng thái LISTENER  .
oracle@orahost ~]$ lsnrctl status

LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 16-MAY-2024 10:29:07

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orahost.localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production
Start Date                16-MAY-2024 10:09:44
Uptime                    0 days 0 hr. 19 min. 23 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           FREE
Listener Parameter File   /opt/oracle/product/23ai/dbhomeFree/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/orahost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orahost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "189011a1798d7228e0650a0027822869" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREE" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREEXDB" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "freepdb1" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
The command completed successfully

Bạn có thể thấy rằng các dịch vụ cơ sở dữ liệu và trình lắng nghe được dừng và khởi động lại tự động sau khi máy chủ khởi động lại.


3) Khởi động và dừng các dịch vụ bằng cách sử dụng tập lệnh cấu hình

Dừng  dịch vụ cơ sở dữ liệu và trình lắng nghe
Đăng nhập với  quyền người dùng root  và thực hiện các lệnh bên dưới.
[root@orahost ~]# id
uid=0(root) gid=0(root) groups=0(root)
 
#Kiểm tra xem  dịch vụ Oracle Database 23ai  có đang chạy trên máy chủ hay không.
[root@orahost ~]# ps -ef | grep pmon
oracle 1750 1 0 10:09 ? 00:00:00  db_pmon_FREE
root 4166 3196 0 10:36 pts/0 00:00:00 grep --color=auto pmon

#Kiểm tra xem  dịch vụ LISTENER  có đang chạy trên máy chủ hay không.
[root@orahost ~]# ps -ef | grep tns
root 5 2 0 10:08 ? 00:00:00 [netns]
oracle 1740 1 0 10:09 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr  LISTENER  -inherit
root 4186 3196 0 10:36 pts/0 00:00:00 grep --color=auto tns

[root@orahost ~]# /etc/init.d/oracle-free-23ai  status
Status of the Oracle FREE 23ai service:

LISTENER status: RUNNING
FREE Database status:   RUNNING
 
[root@orahost ~]# systemctl  status  oracle-free-23ai
● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
   Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated)
   Active: active (exited) since Thu 2024-05-16 10:10:39 EDT; 26min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 792 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 16807)
   Memory: 0B
   CGroup: /system.slice/oracle-free-23ai.service

May 16 10:09:31 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its>
May 16 10:09:32 orahost.localdomain oracle-free-23ai[792]: Starting Oracle Net Listener.
May 16 10:09:33 orahost.localdomain su[821]: (to oracle) root on none
May 16 10:09:45 orahost.localdomain oracle-free-23ai[792]: Oracle Net Listener started.
May 16 10:09:45 orahost.localdomain oracle-free-23ai[792]: Starting Oracle Database instance FREE.
May 16 10:09:45 orahost.localdomain su[1743]: (to oracle) root on none
May 16 10:09:45 orahost.localdomain su[1743]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 10:10:39 orahost.localdomain oracle-free-23ai[792]: Oracle Database instance FREE started.
May 16 10:10:39 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >

#Dừng  dịch vụ Oracle Database 23ai  và  LISTENER  :
[root@orahost ~]# systemctl  stop  oracle-free-23ai
[root@orahost ~]# 

#Đảm bảo  dịch vụ Oracle Database 23ai  không đang chạy trên máy chủ.
[root@orahost ~]# ps -ef | grep pmon
root 4271 3196 0 10:37 pts/0 00:00:00 grep --color=auto pmon
=

#Kiểm tra xem  dịch vụ LISTENER  có đang chạy trên máy chủ hay không.
[root@orahost ~]# ps -ef | grep tns
root 5 2 0 10:08 ? 00:00:00 [netns]
root 4285 3196 0 10:37 pts/0 00:00:00 grep --color=auto tns


Khởi tạo  dịch vụ cơ sở dữ liệu và trình lắng nghe
[root@orahost ~]# systemctl  start  oracle-free-23ai
[root@orahost ~]# 

#Đảm bảo  dịch vụ Oracle Database 23ai  đang chạy trên máy chủ.
[root@orahost ~]# ps -ef | grep pmon
oracle 4609 1 0 10:43 ? 00:00:00 db_pmon_FREE
root 5110 3196 0 10:50 pts/0 00:00:00 grep --color=auto pmon

#Kiểm tra xem  dịch vụ LISTENER  có đang chạy trên máy chủ hay không.
[root@orahost ~]# ps -ef | grep tns
root 5 2 0 10:08 ? 00:00:00 [netns]
oracle 4566 1 0 10:43 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr LISTENER -inherit
root 5118 3196 0 10:50 pts/0 00:00:00 grep --color=auto tns

Bạn cũng có thể kiểm tra trạng thái của cơ sở dữ liệu và  dịch vụ LISTENER  bằng cách thực hiện lệnh dưới đây.
root@orahost ~]# /etc/init.d/oracle-free-23ai status
Status of the Oracle FREE 23ai service:

LISTENER status: RUNNING
FREE Database status:   RUNNING

Bạn cũng có thể kiểm tra  trạng thái dịch vụ Oracle Database 23ai  bằng cách thực hiện lệnh sau.
[root@orahost ~]# systemctl status oracle-free-23ai
● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
   Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated)
   Active: active (exited) since Thu 2024-05-16 10:44:12 EDT; 7min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4237 ExecStop=/etc/rc.d/init.d/oracle-free-23ai stop (code=exited, status=0/SUCCESS)
  Process: 4543 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 16807)
   Memory: 0B
   CGroup: /system.slice/oracle-free-23ai.service

May 16 10:43:13 orahost.localdomain oracle-free-23ai[4543]: Starting Oracle Net Listener.
May 16 10:43:13 orahost.localdomain su[4550]: (to oracle) root on none
May 16 10:43:13 orahost.localdomain su[4550]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 10:43:13 orahost.localdomain su[4550]: pam_unix(su:session): session closed for user oracle
May 16 10:43:13 orahost.localdomain oracle-free-23ai[4543]: Oracle Net Listener started.
May 16 10:43:13 orahost.localdomain oracle-free-23ai[4543]: Starting Oracle Database instance FREE.
May 16 10:43:13 orahost.localdomain su[4572]: (to oracle) root on none
May 16 10:43:13 orahost.localdomain su[4572]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 10:44:14 orahost.localdomain oracle-free-23ai[4543]: Oracle Database instance FREE started.
May 16 10:44:12 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >

#Đăng nhập với tư cách  người dùng oracle  và kiểm tra thời gian khởi động của instance.
[root@orahost ~]# su - oracle
[oracle@orahost ~]$ . oraenv
ORACLE_SID = [oracle] ? FREE
The Oracle base has been set to /opt/oracle
[oracle@orahost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Thu May 16 10:51:32 2024
Version 23.4.0.24.05

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

Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05

SQL> select instance_name,to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') from v$instance;

INSTANCE_NAME  TO_CHAR(STARTUP_TIME,'DD-MON-
---------------- -----------------------------
FREE  16-MAY-2024 10:43:14  


Khởi động lại  dịch vụ cơ sở dữ liệu và trình lắng nghe.
Bạn cũng có thể dừng và khởi động lại  các dịch vụ Oracle Database 23ai  và  LISTENER  chỉ bằng một lệnh duy nhất bằng cách thực hiện lệnh  "systemctl  restart  oracle-free-23ai".

[[root@orahost ~]# date
Thu May 16 11:01:03 EDT 2024

[root@orahost ~]# id
uid=0(root) gid=0(root) groups=0(root)

#Ensure Oracle Database 23ai service is running on server before restarting.
[root@orahost ~]# ps -ef | grep pmon
oracle      5823       1  0 10:59 ?        00:00:00 db_pmon_FREE
root        6864    3196  0 11:01 pts/0    00:00:00 grep --color=auto pmon

#Đảm bảo  dịch vụ Oracle Database 23ai  đang chạy trên máy chủ trước khi khởi động lại.
[root@orahost ~]# ps -ef | grep pmon
oracle 5823 1 0 10:59 ? 00:00:00  db_pmon_FREE
root 6864 3196 0 11:01 pts/0 00:00:00 grep --color=auto pmon

#Đảm bảo  dịch vụ LISTENER  đang chạy trên máy chủ  trước khi khởi động lại . 
[root@orahost ~]# ps -ef | grep tns
root 5 2 0 10:08 ? 00:00:00 [netns]
oracle 5814 1 0 10:59 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr  LISTENER  -inherit
root 6878 3196 0 11:01 pts/0 00:00:00 grep --color=auto tns

Bạn cũng có thể kiểm tra  trạng thái dịch vụ Oracle Database 23ai  bằng cách thực hiện lệnh sau.
[root@orahost ~]# systemctl status oracle-free-23ai
● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
   Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated)
   Active: active (exited) since Thu 2024-05-16 11:00:15 EDT; 1min 6s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5783 ExecStop=/etc/rc.d/init.d/oracle-free-23ai stop (code=exited, status=0/SUCCESS)
  Process: 5800 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS)

May 16 10:59:43 orahost.localdomain systemd[1]: oracle-free-23ai.service: Succeeded.
May 16 10:59:43 orahost.localdomain systemd[1]: Stopped SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >
May 16 10:59:43 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its>
May 16 10:59:43 orahost.localdomain oracle-free-23ai[5800]: Starting Oracle Net Listener.
May 16 10:59:44 orahost.localdomain oracle-free-23ai[5800]: Oracle Net Listener started.
May 16 10:59:44 orahost.localdomain oracle-free-23ai[5800]: Starting Oracle Database instance FREE.
May 16 10:59:44 orahost.localdomain su[5817]: (to oracle) root on none
May 16 10:59:44 orahost.localdomain su[5817]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 11:00:15 orahost.localdomain oracle-free-23ai[5800]: Oracle Database instance FREE started.
May 16 11:00:15 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >

Bạn cũng có thể kiểm tra trạng thái dịch vụ Oracle Database 23ai  bằng cách thực hiện lệnh dưới đây.
[root@orahost ~]# /etc/init.d/oracle-free-23ai status
Status of the Oracle FREE 23ai service:

LISTENER status: RUNNING
FREE Database status:   RUNNING

[root@orahost ~]# date
Thu May 16 11:01:32 EDT 2024
Để dừng và khởi động lại các dịch vụ Oracle Database 23ai và LISTENER, hãy thực hiện lệnh " restart " duy nhất.
[root@orahost ~]# systemctl  restart  oracle-free-23ai
[root@orahost ~]# 


#Kiểm tra trạng thái của cơ sở dữ liệu và dịch vụ lắng nghe sau khi khởi động lại.
[root@orahost ~]# date
Thu May 16 11:02:40 EDT 2024

#Đảm bảo  dịch vụ Oracle Database 23ai  đang chạy trên máy chủ sau khi khởi động lại.
[root@orahost ~]# ps -ef | grep pmon
oracle 7015 1 0 11:01 ? 00:00:00  db_pmon_FREE
root 7427 3196 0 11:02 pts/0 00:00:00 grep --color=auto pmon

#Đảm bảo  dịch vụ LISTENER  đang chạy trên máy chủ sau khi khởi động lại.
[root@orahost ~]# ps -ef | grep tns
root 5 2 0 10:08 ? 00:00:00 [netns]
oracle 7006 1 0 11:01 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr  LISTENER  -inherit

#Bạn cũng có thể kiểm tra  trạng thái dịch vụ Oracle Database 23ai  sau khi khởi động lại. 
[root@orahost ~]# systemctl status oracle-free-23ai
● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services.
   Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated)
   Active: active (exited) since Thu 2024-05-16 11:02:07 EDT; 50s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6976 ExecStop=/etc/rc.d/init.d/oracle-free-23ai stop (code=exited, status=0/SUCCESS)
  Process: 6993 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS)

May 16 11:01:44 orahost.localdomain oracle-free-23ai[6993]: Starting Oracle Net Listener.
May 16 11:01:44 orahost.localdomain su[7002]: (to oracle) root on none
May 16 11:01:44 orahost.localdomain su[7002]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 11:01:44 orahost.localdomain su[7002]: pam_unix(su:session): session closed for user oracle
May 16 11:01:44 orahost.localdomain oracle-free-23ai[6993]: Oracle Net Listener started.
May 16 11:01:44 orahost.localdomain oracle-free-23ai[6993]: Starting Oracle Database instance FREE.
May 16 11:01:44 orahost.localdomain su[7009]: (to oracle) root on none
May 16 11:01:44 orahost.localdomain su[7009]: pam_unix(su:session): session opened for user oracle by (uid=0)
May 16 11:02:07 orahost.localdomain oracle-free-23ai[6993]: Oracle Database instance FREE started.
May 16 11:02:07 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its >

#Bạn  cũng có thể kiểm tra trạng thái dịch vụ Oracle Database 23ai  bằng cách thực hiện lệnh dưới đây sau khi khởi động lại. 
[root@orahost ~]# /etc/init.d/oracle-free-23ai  status
Status of the Oracle FREE 23ai service:

LISTENER status: RUNNING
FREE Database status:   RUNNING
 
#Đăng nhập với tư cách  người dùng oracle  và kiểm tra thời gian khởi động của instance.
[root@orahost ~]# su - oracle
[oracle@orahost ~]$ . oraenv
ORACLE_SID = [oracle] ? FREE
The Oracle base has been set to /opt/oracle

[oracle@orahost ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Thu May 16 11:03:15 2024
Version 23.4.0.24.05

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

Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05

SQL> select instance_name,to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') from v$instance;

INSTANCE_NAME  TO_CHAR(STARTUP_TIME,'DD-MON-
---------------- -----------------------------
FREE  16-MAY-2024 11:01:44

SQL> exit



Cảm ơn bạn đã đọc bài viết này! Hãy bình luận nếu bạn thích bài viết này! Nhấn vào nút THEO DÕI để nhận thông báo về các bài viết tiếp theo!
=============================
TƯ VẤN: Click hoặc Hotline/Zalo 090.29.12.888
=============================
Website không chứa bất kỳ quảng cáo nào, mọi đóng góp để duy trì phát triển cho website (donation) xin vui lòng gửi về STK 90.2142.8888 - Ngân hàng Vietcombank Thăng Long - TRAN VAN BINH
=============================
Nếu bạn không muốn bị AI thay thế và tiết kiệm 3-5 NĂM trên con đường trở thành DBA chuyên nghiệp hay làm chủ Database thì hãy đăng ký ngay KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE, được Coaching trực tiếp từ tôi với toàn bộ bí kíp thực chiến, thủ tục, quy trình của gần 20 năm kinh nghiệm (mà bạn sẽ KHÔNG THỂ tìm kiếm trên Internet/Google) từ đó giúp bạn dễ dàng quản trị mọi hệ thống Core tại Việt Nam và trên thế giới, đỗ OCP.
- CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
- Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
2 khóa học online qua video giúp bạn nhanh chóng có những kiến thức nền tảng về Linux, Oracle, học mọi nơi, chỉ cần có Internet/4G:
- Oracle cơ bản: https://bit.ly/admin_1200
- Linux: https://bit.ly/linux_1200
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: https://www.youtube.com/@binhguru
👨 Tiktok: https://www.tiktok.com/@binhguru
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhguru
👨 Podcast: https://www.podbean.com/pu/pbblog-eskre-5f82d6
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
cơ sở dữ liệu, cơ sở dữ liệu quốc gia, database, AI, trí tuệ nhân tạo, artificial intelligence, machine learning, deep learning, LLM, ChatGPT, DeepSeek, Grok, oracle tutorial, học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,sql tutorial, khóa học pl/sql tutorial, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c/21c/23c/23ai, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail,oracle RAC, ASM, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, postgresql tutorial, mysql tutorial, mariadb tutorial, ms sql server tutorial, nosql, mongodb tutorial, oci, cloud, middleware tutorial, docker, k8s, micro service, hoc solaris tutorial, hoc linux tutorial, hoc aix tutorial, unix tutorial, securecrt, xshell, mobaxterm, putty

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master