查看MySQL已经运行的时长

mysql> show global status like 'uptime';
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| Uptime        | 508718 |
+---------------+--------+
1 row in set (0.00 sec)
uptime的单位为妙。
mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.15, for linux-glibc2.5 (x86_64) using  EditLine wrapper

Connection id:          110946
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.15-log MySQL Community Server (GPL)
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /tmp/mysql_trading.sock
Uptime:                 5 days 21 hours 18 min 39 sec

Threads: 919  Questions: 110671873  Slow queries: 9309  Opens: 139712983  Flush tables: 1  Open tables: 0  Queries per second avg: 217.550
uptime这个显示的为运行的天数 时分秒,换算为运行时间s则需要计算下。
通过查询进程查看进程运行的开始时间,不过这个查询方法不准确:
[root@node1 ~]# ps -ef | grep -i mysql
mysql    14881     1  0 Mar26 ?        02:12:22 /usr/local/mysql/bin/mysqld --user=mysql --datadir=/data/mysql/common --port=3306 --pid-file=/tmp/mysql_common.pid --socket=/tmp/mysql_common.sock --server-id=1 --default-storage-engine=InnoDB --character-set-client-handshake=FALSE --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --init_connect=SET NAMES utf8mb4 --performance-schema-instrument=memory/% COUNTED --interactive_timeout=172800 --wait_timeout=172800 --tmp-table-size=8M --max-heap-table-size=4M --query-cache-type=0 --query-cache-size=64M --max-connections=8000 --thread-cache-size=50 --open-files-limit=65535 --table-definition-cache=4096 --table-open-cache=10 --innodb-flush-method=O_DIRECT --innodb-log-files-in-group=2 --innodb-log-file-size=256M --innodb-flush-log-at-trx-commit=1 --innodb-file-per-table=1 --innodb-buffer-pool-size=2G --log-error=/data/mysql/common/common_error.log --slow-query-log=1 --slow-query-log-file=/data/mysql/common/common_slow.log --long_query_time=0.2 --min_examined_row_limit=100 --max-allowed-packet=16M --max-connect-errors=1000000 --skip-name-resolve --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION --sysdate-is-now=1 --innodb-strict-mode=1 --sort_buffer_size=2M --join_buffer_size=2M --key_buffer_size=64M --read_buffer_size=512K --read_rnd_buffer_size=256K --binlog_cache_size=2M --thread_stack=256K --bulk_insert_buffer_size=64M --lower_case_table_names=1 --relay-log=/data/mysql/common/common_relay.log --relay_log_recovery=1 --slave-net-timeout=60 --relay_log_purge=0 --sync_binlog=1 --log-bin=/data/mysql/common/common_bin.log --binlog_format=ROW --expire-logs-days=3 --relay_log_recovery=1 --slave_skip_errors=ddl_exist_errors --explicit_defaults_for_timestamp=true --log_slave_updates=on
上述中的Mar26即为mysql实例启动的时间!

通过查询MySQL的状态也可以大致查询出运行的时间:

# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-06-15 11:32:35 CST; 2h 15min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 12713 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 12737 (mysqld)
   Status: "SERVER_OPERATING"
   CGroup: /system.slice/mysqld.service
           └─12737 /usr/sbin/mysqld

Jun 15 11:29:51 node2 systemd[1]: Starting MySQL Server...
Jun 15 11:32:35 node2 systemd[1]: Started MySQL Server.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值