日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

在 Linux 上檢查 MySQL/MariaDB 數據庫正常運行時間的三種方法

 

每個服務都有自己的命令來檢查服務的正常運行時間。但是你也可以為此使用其他命令。

  • 來源:https://linux.cn/article-12263-1.html
  • 作者:Magesh Maruthamuthu
  • 譯者:geekpi

我們都知道在 Linux 中使用 uptime 命令的目的。它用于檢查 Linux 系統的正常運行時間 以及系統上次啟動以來運行的時間。

而 Linux 管理員的工作是保持系統正常運行。

如果要檢查 Linux 上的其他服務(例如 Apache 、MySQL、MariaDB、sftp 等)運行了多長時間,該怎么做?

每個服務都有自己的命令來檢查服務的正常運行時間。但是你也可以為此使用其他命令。

方法 1:如何使用 ps 命令在 Linux 上檢查 MySQL/MariaDB 數據庫的正常運行時間

ps 命令 的意思是 進程狀態(process status)。這是最基本的命令之一,它顯示了系統正在運行的進程的詳細信息。

為此,你首先需要使用 pidof 命令 查找 MySQL / MariaDB 的 PID。

# pidof mysqld | cut -d" " -f1

2412

獲取 MySQL/MariaDB 的 PID 后,請在 ps 命令中使用 --etime 選項獲得正常運行時間。

  • --etime:自進程啟動以來經過的時間,形式為 [[DD-]hh:]mm:ss。
# ps -p 2412 -o etime

   ELAPSED
2-08:49:30

或者,在 ps 命令中使用 --lstart 選項來獲取指定 PID 的正常運行時間。

# ps -p 2412 -o lstart

                STARTED
Sat May 2 03:02:15 2020

MySQL/MariaDB 進程已經運行了 2 天 03 小時 02 分 15 秒。

方法 2:如何使用 systemctl 命令在 Linux 上檢查 MySQL/MariaDB 數據庫的正常運行時間

systemctl 命令 用于控制 systemd 系統和服務管理器。

systemd 是新的初始化系統和系統管理器,現在大多數 Linux 發行版都淘汰了傳統的 SysVinit 管理器而采用了 systemd。

# systemctl status mariadb
或者
# systemctl status mysql

● mariadb.service - MariaDB 10.1.44 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor     preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Sat 2020-05-02 03:02:18 UTC; 2 days ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 2448 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 2388 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 2386 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 2412 (mysqld)
   Status: "Taking your SQL requests now…"
   CGroup: /system.slice/mariadb.service
           └─2412 /usr/sbin/mysqld

May 03 21:41:26 ns2.2daygeek.com mysqld[2412]: 2020-05-03 21:41:26 140328136861440 [Warning] Host name '1.1.1.1' could not be resolved: … not known
May 04 02:00:46 ns2.2daygeek.com mysqld[2412]: 2020-05-04 2:00:46 140328436418304 [Warning] IP address '1.1.1.1' has been resolved to the host name '2…ss itself.
May 04 03:01:31 ns2.2daygeek.com mysqld[2412]: 2020-05-04 3:01:31 140328436111104 [Warning] IP address '1.1.1.1' could not be resolved: Temporary fai…resolution
May 04 04:03:06 ns2.2daygeek.com mysqld[2412]: 2020-05-04 4:03:06 140328136861440 [Warning] IP address '1.1.1.1' could not be resolved: Name or ser… not known
May 04 07:23:54 ns2.2daygeek.com mysqld[2412]: 2020-05-04 7:23:54 140328435189504 [Warning] IP address '1.1.1.1' could not be resolved: Name or service not known
May 04 08:03:31 ns2.2daygeek.com mysqld[2412]: 2020-05-04 8:03:31 140328436418304 [Warning] IP address '1.1.1.1' could not be resolved: Name or service not known
May 04 08:25:56 ns2.2daygeek.com mysqld[2412]: 2020-05-04 8:25:56 140328135325440 [Warning] IP address '1.1.1.1' could not be resolved: Name or service not known
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Hint: Some lines were ellipsized, use -l to show in full.

方法 3:如何使用 MySQLAdmin 命令在 Linux 上檢查 MySQL/MariaDB 數據庫的正常運行時間

MySQLAdmin 是安裝 MySQL 軟件包時安裝的 MySQL 服務器命令行程序。

MySQLAdmin 客戶端允許你在 MySQL 服務器上執行一些基本的管理功能。

它用于創建數據庫、刪除數據庫、設置 root 密碼、更改 root 密碼、檢查 MySQL 狀態、驗證 MySQL 功能、監視 mysql 進程以及驗證服務器的配置。

# mysqladmin -u root -pPassword version

mysqladmin Ver 8.42 Distrib 5.7.27, for Linux on x86_64
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version 5.7.27
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 1 day 10 hours 44 min 13 sec

via: https://www.2daygeek.com/check-mysql-mariadb-database-server-uptime-linux/

作者: Magesh Maruthamuthu 選題: lujun9972 譯者: geekpi 校對: wxy

本文由 LCTT 原創編譯, Linux中國 榮譽推出

分享到:
標簽:MySQL
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定