使用MYSQL命令查看MYSQL中数据库或表占用空间的大小

 mysql  使用MYSQL命令查看MYSQL中数据库或表占用空间的大小已关闭评论
3月 062019
 

知道每个数据库的大小,使用下面步骤:

1、进入information_schema 数据库

use information_schema;

 

2、根据表名汇总查询各表数据的大小:

select TABLE_SCHEMA as tablename, concat(round(sum(data_length/1024/1024/1024),3),’GB’) as data from tables group by TABLE_SCHEMA;

 

2、查看指定数据库的大小:

比如查看数据库mydb的大小

select concat(round(sum(data_length/1024/1024/1024),3),’GB’) as data from tables where table_schema=’mydb’;

 

4、查看指定数据库的某个表的大小

比如查看数据库mydb中 mytable 表的大小

select concat(round(sum(data_length/1024/1024),3),’MB’) as data from tables where table_schema=’mydb’ and table_name=’mytable’;

curl 查看某web页页面响应时间

 linux  curl 查看某web页页面响应时间已关闭评论
5月 232017
 

近日公司访问微信统一下单接口时间变长了, 通过下面的命令:

[o-u-u@vmhost ~]$   time curl -i -v -s \-o /dev/null \-w “\n\nhttp_code: %{http_code}s\nhttp_connect: %{http_connect}s\ncontent_type: %{content_type}s\ntime_namelookup: %{time_namelookup}s\ntime_redirect: %{time_redirect}s\ntime_pretransfer: %{time_pretransfer}s\ntime_connect: %{time_connect}s\ntime_starttransfer: %{time_starttransfer}s\ntime_total: %{time_total}s\nspeed_download: %{speed_download}KB/s\n” \https://api.mch.weixin.qq.com/pay/unifiedorder

返回结果:

* About to connect() to api.mch.weixin.qq.com port 443 (#0)
*   Trying 140.207.69.102… connected
* Connected to api.mch.weixin.qq.com (140.207.69.102) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS: client certificate not found (nickname not specified)
* SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
*       subject: CN=payapp.weixin.qq.com,OU=R&D,O=Tencent Technology (Shenzhen) Company Limited,L=shenzhen,ST=guangdong,C=CN
*       start date: Mar 22 00:00:00 2017 GMT
*       expire date: Jun 21 23:59:59 2018 GMT
*       common name: payapp.weixin.qq.com
*       issuer: CN=GeoTrust SSL CA – G3,O=GeoTrust Inc.,C=US
> GET /pay/unifiedorder HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: api.mch.weixin.qq.com
> Accept: */*

< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 23 May 2017 06:13:59 GMT
< Content-Type: text/plain
< Content-Length: 112
< Connection: keep-alive
< Keep-Alive: timeout=8

{ [data not shown]
* Connection #0 to host api.mch.weixin.qq.com left intact

http_code: 200s
http_connect: 000s
content_type: text/plains
time_namelookup: 15.015s
time_redirect: 0.000s
time_pretransfer: 15.180s
time_connect: 15.020s
time_starttransfer: 15.188s
time_total: 15.188s
speed_download: 7.000KB/s
* Closing connection #0

real    0m15.207s
user    0m0.076s
sys     0m0.091s

可以发现 time_namelookup: 15.015s  , 说明dns解析就花了15秒,问题找到。


******************************************************************************************************************

附:

关于curl  -w 参数下显示格式的参数有哪些(比如time_namelookup, time_pretransfer等),可参考这里:https://curl.haxx.se/docs/manpage.html


content_type The Content-Type of the requested document, if there was any.

filename_effective The ultimate filename that curl writes out to. This is only meaningful if curl is told to write to a file with the -O, –remote-name or -o, –output option. It’s most useful in combination with the -J, –remote-header-name option. (Added in 7.26.0)

ftp_entry_path The initial path curl ended up in when logging on to the remote FTP server. (Added in 7.15.4)

http_code The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.

http_connect The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)

http_version The http version that was effectively used. (Added in 7.50.0)

local_ip The IP address of the local end of the most recently done connection – can be either IPv4 or IPv6 (Added in 7.29.0)

local_port The local port number of the most recently done connection (Added in 7.29.0)

num_connects Number of new connects made in the recent transfer. (Added in 7.12.3)

num_redirects Number of redirects that were followed in the request. (Added in 7.12.3)

proxy_ssl_verify_result The result of the HTTPS proxy’s SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.52.0)

redirect_url When an HTTP request was made without -L to follow redirects, this variable will show the actual URL a redirect would take you to. (Added in 7.18.2)

remote_ip The remote IP address of the most recently done connection – can be either IPv4 or IPv6 (Added in 7.29.0)

remote_port The remote port number of the most recently done connection (Added in 7.29.0)

scheme The URL scheme (sometimes called protocol) that was effectively used (Added in 7.52.0)

size_download The total amount of bytes that were downloaded.

size_header The total amount of bytes of the downloaded headers.

size_request The total amount of bytes that were sent in the HTTP request.

size_upload The total amount of bytes that were uploaded.

speed_download The average download speed that curl measured for the complete download. Bytes per second.

speed_upload The average upload speed that curl measured for the complete upload. Bytes per second.

ssl_verify_result The result of the SSL peer certificate verification that was requested. 0 means the verification was successful. (Added in 7.19.0)

time_appconnect The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)

time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.

time_namelookup The time, in seconds, it took from the start until the name resolving was completed.

time_pretransfer The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.

time_redirect The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)

time_starttransfer The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.

time_total The total time, in seconds, that the full operation lasted.

url_effective The URL that was fetched last. This is most meaningful if you’ve told curl to follow location: headers.


查看Linux操作系统信息的相关命令

 linux  查看Linux操作系统信息的相关命令已关闭评论
12月 152016
 

记录下

# uname -a # 查看内核/操作系统/CPU信息 
# head  /etc/issue # 查看操作系统版本 
# cat /proc/cpuinfo # 查看CPU信息 
# hostname # 查看计算机名 
# lspci -tv # 列出所有PCI设备 
# lsusb -tv # 列出所有USB设备 
# lsmod # 列出加载的内核模块 
# env # 查看环境变量资源 
# free -m # 查看内存使用量和交换区使用量 
# df -h # 查看各分区使用情况 
# du -sh <目录名> # 查看指定目录的大小 
# grep MemTotal /proc/meminfo # 查看内存总量 
# grep MemFree /proc/meminfo # 查看空闲内存量 
# uptime # 查看系统运行时间、用户数、负载 
# cat /proc/loadavg # 查看系统负载磁盘和分区 
# mount | column -t # 查看挂接的分区状态 
# fdisk -l # 查看所有分区 
# swapon -s # 查看所有交换分区 
# hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备) 
# dmesg | grep IDE # 查看启动时IDE设备检测状况网络 
# ifconfig # 查看所有网络接口的属性 
# iptables -L # 查看防火墙设置 
# route -n # 查看路由表 
# netstat -lntp # 查看所有监听端口 
# netstat -antp # 查看所有已经建立的连接 
# netstat -s # 查看网络统计信息进程 
# ps -ef # 查看所有进程 
# top # 实时显示进程状态用户 
# w # 查看活动用户 
# id <用户名> # 查看指定用户信息 
# last # 查看用户登录日志 
# cut -d: -f1 /etc/passwd # 查看系统所有用户 
# cut -d: -f1 /etc/group # 查看系统所有组 
# crontab -l # 查看当前用户的计划任务服务 
# chkconfig –list # 列出所有系统服务 
# chkconfig –list | grep on # 列出所有启动的系统服务程序 
# rpm -qa # 查看所有安装的软件包

9月 142015
 

Linux下查看系统版本号信息的方法,记录下

一、查看Linux内核版本命令(两种方法):

1、cat /proc/version

[root@localhost ~]# cat /proc/version
Linux version 2.6.18-194.8.1.el5.centos.plus (mockbuild@builder17.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Wed Jul 7 11:50:45 EDT 2010

2、uname -a

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-194.8.1.el5.centos.plus #1 SMP Wed Jul 7 11:50:45 EDT 2010 i686 i686 i386 GNU/Linux

二、查看Linux系统版本的命令(3种方法):

1、lsb_release -a,即可列出所有版本信息:

[root@localhost ~]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.5 (Final)
Release: 5.5
Codename: Final

这个命令适用于所有的Linux发行版,包括Redhat、SuSE、Debian…等发行版。

2、cat /etc/redhat-release,这种方法只适合Redhat系的Linux:

[root@localhost ~]# cat /etc/redhat-release
CentOS release 5.5 (Final)

3、cat /etc/issue,此命令也适用于所有的Linux发行版。

[root@localhost ~]# cat /etc/issue
CentOS release 5.5 (Final)
Kernel r on an m

转自http://www.ha97.com/2987.html