supereagle / experiences

Summary of practical experience in work.
2 stars 0 forks source link

Useful Linux Commands #13

Open supereagle opened 7 years ago

supereagle commented 7 years ago

Category

Reference

supereagle commented 7 years ago

How to rsync

rsync -havAEHXi -n --numeric-ids --stats --progress src_dir/ dst_ip:/dst_dir/
supereagle commented 7 years ago

Install software by rpm

 # rpm -ivh netplugin-1-0.1.20160413.17.x86_64.rpm --force --nodeps
# rpm -ivh netplugin-1-0.1.20160413.17.x86_64.rpm
error: Failed dependencies:
    docker is needed by netplugin-1-0.1.20160413.17.x86_64
rpm -ivh netplugin-1-0.1.20160413.17.x86_64.rpm --nodeps
Preparing...                          ################################# [100%]
    file /etc/sysconfig/netplugin/netplugin from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
    file /usr/local/bin/netplugin from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
    file /etc/sysconfig/netplugin/netmaster from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
    file /usr/local/bin/netmaster from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
    file /usr/lib/systemd/system/netmaster.service from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
    file /usr/lib/systemd/system/netplugin.service from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
    file /usr/local/bin/netctl from install of netplugin-1-0.1.20160413.17.x86_64 conflicts with file from package netplugin-1-0.1.20160413.15.x86_64
supereagle commented 7 years ago

Software dependencies

Check the dependencies of the software

# rpm -qRp docker-engine-1.13.0-1.el7.centos.x86_64.rpm
warning: docker-engine-1.13.0-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
/bin/sh
/bin/sh
/bin/sh
/bin/sh
device-mapper-libs >= 1.02.90-1
docker-engine-selinux >= 1.13.0-1.el7.centos
iptables
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.9)(64bit)
libcgroup
libdevmapper.so.1.02()(64bit)
libdevmapper.so.1.02(Base)(64bit)
libdevmapper.so.1.02(DM_1_02_97)(64bit)
libdl.so.2()(64bit)
libltdl.so.7()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
libseccomp.so.2()(64bit)
libsystemd.so.0()(64bit)
libsystemd.so.0(LIBSYSTEMD_209)(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
selinux-policy >= 3.13.1-23
systemd-units
tar
xz
rpmlib(PayloadIsXz) <= 5.2-1

Uninstall softwares without its dependency

# rpm -e --nodeps docker
supereagle commented 7 years ago

Get network ip

# ifconfig eth0
# ip addr show eth0
supereagle commented 7 years ago

Catch network packages

tcpdump -i eth0 tcp

The network protocol can be tcp, udp, arp and vrrp.

supereagle commented 7 years ago

Check the resources used by process

Check the port used by process

lsof -i :8080

Check the file used by process

# lsof /var/log/messages
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
rsyslogd 573 root    4w   REG  253,1   987941 10197674 /var/log/messages
# ps -ef | grep 573
root       573     1  0 Feb28 ?        01:08:57 /usr/sbin/rsyslogd -n
root     15880 25698  0 18:12 pts/0    00:00:00 grep --color=auto 573
supereagle commented 7 years ago

Check the IO status

# iostat -x 1
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
vdb               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
vdc               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
dm-0              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
dm-1              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
dm-2              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
dm-4              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
dm-3              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00

The IO has errors when: iowait > 50%, or util ~ 100%.

supereagle commented 7 years ago

Debug kernel error

# dmesg
supereagle commented 7 years ago

Disable IPv6

  1. Check current config cat /proc/sys/net/ipv6/conf/all/disable_ipv6
    • 1: Disabled
    • 0: Enabled
  2. Add net.ipv6.conf.all.disable_ipv6 = 1 into /etc/sysctl.conf
  3. Reload the config: sysctl -p
supereagle commented 7 years ago

Sync files between Linux/Unix and local Windows

supereagle commented 7 years ago

Network performance test

# Start server on the default port
$ iperf3 -s

# Run a 30 second tests, giving results every 1 second
$ iperf3 -c ${remotehost} -i 1 -t 30