您好,登录后才能下订单哦!
这篇文章主要介绍了在Linux上如何检查MySQL/MariaDB数据库正常运行时间,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
rocess-monitoring/" class="ext" rel="external nofollow" target="_blank">ps 命令的意思是进程状态。这是最基本的命令之一,它显示了系统正在运行的进程的详细信息。
为此,你首先需要使用 rocess-id-pid-ppid-linux/" class="ext" rel="external nofollow" target="_blank">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 ELAPSED2-08:49:30
或者,在 ps
命令中使用 --lstart
选项来获取指定 PID 的正常运行时间。
# ps -p 2412 -o lstart STARTEDSat May 2 03:02:15 2020
MySQL/MariaDB 进程已经运行了 2 天 03 小时 02 分 15 秒。
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 knownMay 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…resolutionMay 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 knownMay 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 knownMay 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 knownMay 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 knownWarning: 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.
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_64Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Server version 5.7.27Protocol version 10Connection Localhost via UNIX socketUNIX socket /var/lib/mysql/mysql.sockUptime: 1 day 10 hours 44 min 13 sec
感谢你能够认真阅读完这篇文章,希望小编分享的“在Linux上如何检查MySQL/MariaDB数据库正常运行时间”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。