原文地址:https://time.geekbang.org/column/article/70476 对应的github地址:https://github.com/feiskyer/linux-perf-examples/blob/master/nginx-short-process/README.md
由于公司的测试环境无法访问外网,因此,本文采用腾讯的云主机进行测试。 下载代码:
sudo su - javaops
mkdir git-codes
cd git-codes
git clone https://github.com/feiskyer/linux-perf-examples.git
安装docker采取yum进行,在root账户: yum install docker
root@haibo ~]# yum install docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> Processing Dependency: docker-common = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: docker-client = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Running transaction check
---> Package docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
---> Package docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.48-1.el7.centos will be installed
--> Running transaction check
---> Package atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 will be installed
--> Processing Dependency: python-pytoml for package: 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 will be installed
---> Package containers-common.x86_64 1:0.1.40-11.el7_8 will be installed
--> Processing Dependency: subscription-manager for package: 1:containers-common-0.1.40-11.el7_8.x86_64
--> Processing Dependency: slirp4netns for package: 1:containers-common-0.1.40-11.el7_8.x86_64
--> Processing Dependency: fuse-overlayfs for package: 1:containers-common-0.1.40-11.el7_8.x86_64
---> Package oci-register-machine.x86_64 1:0-6.git2b44233.el7 will be installed
---> Package oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 will be installed
---> Package oci-umount.x86_64 2:2.5-3.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-34.el7 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 will be installed
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
---> Package subscription-manager.x86_64 0:1.24.48-1.el7.centos will be installed
--> Processing Dependency: subscription-manager-rhsm = 1.24.48 for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-dmidecode >= 3.12.2-2 for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-syspurpose for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-inotify for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-ethtool for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Processing Dependency: python-dateutil for package: subscription-manager-1.24.48-1.el7.centos.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.5-4.el7 for package: audit-libs-python-2.8.5-4.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-29.el7_6.1 will be updated
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be an update
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package python-dateutil.noarch 0:1.5-7.el7 will be installed
---> Package python-dmidecode.x86_64 0:3.12.2-4.el7 will be installed
---> Package python-ethtool.x86_64 0:0.8-8.el7 will be installed
---> Package python-inotify.noarch 0:0.9.4-4.el7 will be installed
---> Package python-syspurpose.x86_64 0:1.24.48-1.el7.centos will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
---> Package subscription-manager-rhsm.x86_64 0:1.24.48-1.el7.centos will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.8.4-4.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.4-4.el7 for package: audit-2.8.4-4.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.8.4-4.el7 will be updated
---> Package audit.x86_64 0:2.8.5-4.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
docker x86_64 2:1.13.1-208.git7d71120.el7_9 extras 17 M
Installing for dependencies:
atomic-registries x86_64 1:1.22.1-33.gitb507039.el7_8 extras 36 k
audit-libs-python x86_64 2.8.5-4.el7 os 76 k
checkpolicy x86_64 2.5-8.el7 os 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
container-storage-setup noarch 0.11.0-2.git5eaf76c.el7 extras 35 k
containers-common x86_64 1:0.1.40-11.el7_8 extras 43 k
docker-client x86_64 2:1.13.1-208.git7d71120.el7_9 extras 3.9 M
docker-common x86_64 2:1.13.1-208.git7d71120.el7_9 extras 101 k
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
libcgroup x86_64 0.41-21.el7 os 66 k
libsemanage-python x86_64 2.5-14.el7 os 113 k
oci-register-machine x86_64 1:0-6.git2b44233.el7 extras 1.1 M
oci-systemd-hook x86_64 1:0.2.0-1.git05e6923.el7_6 extras 34 k
oci-umount x86_64 2:2.5-3.el7 extras 33 k
policycoreutils-python x86_64 2.5-34.el7 os 457 k
python-IPy noarch 0.75-6.el7 os 32 k
python-dateutil noarch 1.5-7.el7 os 85 k
python-dmidecode x86_64 3.12.2-4.el7 os 83 k
python-ethtool x86_64 0.8-8.el7 os 34 k
python-inotify noarch 0.9.4-4.el7 os 49 k
python-pytoml noarch 0.1.14-1.git7dea353.el7 extras 18 k
python-syspurpose x86_64 1.24.48-1.el7.centos updates 274 k
setools-libs x86_64 3.3.8-4.el7 os 620 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
subscription-manager x86_64 1.24.48-1.el7.centos updates 1.1 M
subscription-manager-rhsm x86_64 1.24.48-1.el7.centos updates 333 k
subscription-manager-rhsm-certificates x86_64 1.24.48-1.el7.centos updates 237 k
Updating for dependencies:
audit x86_64 2.8.5-4.el7 os 256 k
audit-libs x86_64 2.8.5-4.el7 os 102 k
policycoreutils x86_64 2.5-34.el7 os 917 k
Transaction Summary
=================================================================================================================================================================================================================
Install 1 Package (+28 Dependent packages)
Upgrade ( 3 Dependent packages)
Total download size: 28 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/32): atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64.rpm | 36 kB 00:00:00
(2/32): audit-libs-2.8.5-4.el7.x86_64.rpm | 102 kB 00:00:00
(3/32): audit-2.8.5-4.el7.x86_64.rpm | 256 kB 00:00:00
(4/32): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(5/32): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(6/32): container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm | 35 kB 00:00:00
(7/32): containers-common-0.1.40-11.el7_8.x86_64.rpm | 43 kB 00:00:00
(8/32): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(9/32): docker-client-1.13.1-208.git7d71120.el7_9.x86_64.rpm | 3.9 MB 00:00:00
(10/32): docker-common-1.13.1-208.git7d71120.el7_9.x86_64.rpm | 101 kB 00:00:00
(11/32): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(12/32): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(13/32): oci-register-machine-0-6.git2b44233.el7.x86_64.rpm | 1.1 MB 00:00:00
(14/32): oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm | 34 kB 00:00:00
(15/32): oci-umount-2.5-3.el7.x86_64.rpm | 33 kB 00:00:00
(16/32): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(17/32): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(18/32): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(19/32): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(20/32): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00:00
(21/32): python-dateutil-1.5-7.el7.noarch.rpm | 85 kB 00:00:00
(22/32): python-dmidecode-3.12.2-4.el7.x86_64.rpm | 83 kB 00:00:00
(23/32): python-ethtool-0.8-8.el7.x86_64.rpm | 34 kB 00:00:00
(24/32): python-inotify-0.9.4-4.el7.noarch.rpm | 49 kB 00:00:00
(25/32): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(26/32): python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm | 18 kB 00:00:00
(27/32): python-syspurpose-1.24.48-1.el7.centos.x86_64.rpm | 274 kB 00:00:00
(28/32): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(29/32): subscription-manager-rhsm-1.24.48-1.el7.centos.x86_64.rpm | 333 kB 00:00:00
(30/32): subscription-manager-rhsm-certificates-1.24.48-1.el7.centos.x86_64.rpm | 237 kB 00:00:00
(31/32): docker-1.13.1-208.git7d71120.el7_9.x86_64.rpm | 17 MB 00:00:02
(32/32): subscription-manager-1.24.48-1.el7.centos.x86_64.rpm | 1.1 MB 00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 7.0 MB/s | 28 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : audit-libs-2.8.5-4.el7.x86_64 1/35
Updating : policycoreutils-2.5-34.el7.x86_64 2/35
Installing : python-dateutil-1.5-7.el7.noarch 3/35
Installing : subscription-manager-rhsm-certificates-1.24.48-1.el7.centos.x86_64 4/35
Installing : subscription-manager-rhsm-1.24.48-1.el7.centos.x86_64 5/35
Installing : audit-libs-python-2.8.5-4.el7.x86_64 6/35
Installing : python-syspurpose-1.24.48-1.el7.centos.x86_64 7/35
Installing : libcgroup-0.41-21.el7.x86_64 8/35
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 9/35
Installing : checkpolicy-2.5-8.el7.x86_64 10/35
Installing : 1:oci-register-machine-0-6.git2b44233.el7.x86_64 11/35
Installing : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64 12/35
Installing : libsemanage-python-2.5-14.el7.x86_64 13/35
Installing : fuse3-libs-3.6.1-4.el7.x86_64 14/35
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 15/35
Installing : setools-libs-3.3.8-4.el7.x86_64 16/35
Installing : python-pytoml-0.1.14-1.git7dea353.el7.noarch 17/35
Installing : 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64 18/35
Installing : 2:oci-umount-2.5-3.el7.x86_64 19/35
Installing : python-dmidecode-3.12.2-4.el7.x86_64 20/35
Installing : python-IPy-0.75-6.el7.noarch 21/35
Installing : policycoreutils-python-2.5-34.el7.x86_64 22/35
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 23/35
setsebool: SELinux is disabled.
Installing : python-inotify-0.9.4-4.el7.noarch 24/35
Installing : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch 25/35
Installing : python-ethtool-0.8-8.el7.x86_64 26/35
Installing : subscription-manager-1.24.48-1.el7.centos.x86_64 27/35
Installing : 1:containers-common-0.1.40-11.el7_8.x86_64 28/35
Installing : 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64 29/35
Installing : 2:docker-client-1.13.1-208.git7d71120.el7_9.x86_64 30/35
Installing : 2:docker-1.13.1-208.git7d71120.el7_9.x86_64 31/35
Updating : audit-2.8.5-4.el7.x86_64 32/35
Cleanup : audit-2.8.4-4.el7.x86_64 33/35
Cleanup : policycoreutils-2.5-29.el7_6.1.x86_64 34/35
Cleanup : audit-libs-2.8.4-4.el7.x86_64 35/35
Verifying : 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64 1/35
Verifying : python-ethtool-0.8-8.el7.x86_64 2/35
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 3/35
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 4/35
Verifying : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch 5/35
Verifying : python-inotify-0.9.4-4.el7.noarch 6/35
Verifying : 1:containers-common-0.1.40-11.el7_8.x86_64 7/35
Verifying : audit-libs-2.8.5-4.el7.x86_64 8/35
Verifying : subscription-manager-rhsm-certificates-1.24.48-1.el7.centos.x86_64 9/35
Verifying : python-IPy-0.75-6.el7.noarch 10/35
Verifying : python-dateutil-1.5-7.el7.noarch 11/35
Verifying : policycoreutils-2.5-34.el7.x86_64 12/35
Verifying : python-dmidecode-3.12.2-4.el7.x86_64 13/35
Verifying : 2:oci-umount-2.5-3.el7.x86_64 14/35
Verifying : policycoreutils-python-2.5-34.el7.x86_64 15/35
Verifying : python-pytoml-0.1.14-1.git7dea353.el7.noarch 16/35
Verifying : setools-libs-3.3.8-4.el7.x86_64 17/35
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 18/35
Verifying : audit-2.8.5-4.el7.x86_64 19/35
Verifying : libsemanage-python-2.5-14.el7.x86_64 20/35
Verifying : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64 21/35
Verifying : 1:oci-register-machine-0-6.git2b44233.el7.x86_64 22/35
Verifying : checkpolicy-2.5-8.el7.x86_64 23/35
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 24/35
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 25/35
Verifying : subscription-manager-rhsm-1.24.48-1.el7.centos.x86_64 26/35
Verifying : 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64 27/35
Verifying : 2:docker-1.13.1-208.git7d71120.el7_9.x86_64 28/35
Verifying : 2:docker-client-1.13.1-208.git7d71120.el7_9.x86_64 29/35
Verifying : libcgroup-0.41-21.el7.x86_64 30/35
Verifying : python-syspurpose-1.24.48-1.el7.centos.x86_64 31/35
Verifying : subscription-manager-1.24.48-1.el7.centos.x86_64 32/35
Verifying : policycoreutils-2.5-29.el7_6.1.x86_64 33/35
Verifying : audit-2.8.4-4.el7.x86_64 34/35
Verifying : audit-libs-2.8.4-4.el7.x86_64 35/35
Installed:
docker.x86_64 2:1.13.1-208.git7d71120.el7_9
Dependency Installed:
atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 containers-common.x86_64 1:0.1.40-11.el7_8
docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7
oci-register-machine.x86_64 1:0-6.git2b44233.el7 oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 oci-umount.x86_64 2:2.5-3.el7
policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 python-dateutil.noarch 0:1.5-7.el7
python-dmidecode.x86_64 0:3.12.2-4.el7 python-ethtool.x86_64 0:0.8-8.el7 python-inotify.noarch 0:0.9.4-4.el7
python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 python-syspurpose.x86_64 0:1.24.48-1.el7.centos setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8 subscription-manager.x86_64 0:1.24.48-1.el7.centos subscription-manager-rhsm.x86_64 0:1.24.48-1.el7.centos
subscription-manager-rhsm-certificates.x86_64 0:1.24.48-1.el7.centos
Dependency Updated:
audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7 policycoreutils.x86_64 0:2.5-34.el7
Complete!
之后需要启动docker服务端:
[root@haibo ~]# service docker start
root@haibo ~]# ps -aux |grep docker
root 6784 1.3 2.3 509088 23552 ? Ssl 15:15 0:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root 6795 0.1 0.9 283580 9596 ? Ssl 15:15 0:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root 6909 0.0 0.0 112812 968 pts/0 R+ 15:16 0:00 grep --color=auto docker
切换用户执行docker,出错:
sudo su - javaops
[javaops@haibo ~]$ docker version
Client:
Version: 1.13.1
API version: 1.26
Package version:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.26/version: dial unix /var/run/docker.sock: connect: permission denied
解决办法:
[root@haibo ~]# groupadd docker
[root@haibo ~]# gpasswd -a javaops docker
Adding user javaops to group docker
之后需要重启docker服务
[root@haibo ~]# service docker restart
现在就可以解决上述问题了:
[javaops@haibo ~]$ docker version
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-208.git7d71120.el7_9.x86_64
Go version: go1.10.3
Git commit: 7d71120/1.13.1
Built: Mon Jun 7 15:36:09 2021
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-208.git7d71120.el7_9.x86_64
Go version: go1.10.3
Git commit: 7d71120/1.13.1
Built: Mon Jun 7 15:36:09 2021
OS/Arch: linux/amd64
Experimental: false
安装测试工具httpd-tools
[root@haibo ~]# yum -y install httpd-tools
测试
[root@haibo ~]# ab -c 10 -n 100 http://192.168.0.10:10000/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.0.10 (be patient)...apr_pollset_poll: The timeout specified has expired (70007)
[root@haibo ~]# ab -c 10 -n 100 http://127.27.0.13:10000/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.27.0.13 (be patient).....done
Server Software: nginx/1.15.4
Server Hostname: 127.27.0.13
Server Port: 10000
Document Path: /
Document Length: 9 bytes
Concurrency Level: 10
Time taken for tests: 11.153 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 17200 bytes
HTML transferred: 900 bytes
Requests per second: 8.97 [#/sec] (mean)
Time per request: 1115.260 [ms] (mean)
Time per request: 111.526 [ms] (mean, across all concurrent requests)
Transfer rate: 1.51 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 0
Processing: 114 1070 201.6 1116 1410
Waiting: 114 1070 201.7 1116 1410
Total: 114 1071 201.6 1116 1410
Percentage of the requests served within a certain time (ms)
50% 1116
66% 1136
75% 1147
80% 1158
90% 1183
95% 1205
98% 1389
99% 1410
100% 1410 (longest request)
ab -c 10 -n 10000 http://172.27.0.13:10000/
之后执行top
top - 16:11:33 up 594 days, 1:19, 2 users, load average: 2.97, 0.89, 0.44
Tasks: 95 total, 6 running, 89 sleeping, 0 stopped, 0 zombie
%Cpu0 : 99.7 us, 0.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1014888 total, 131012 free, 305876 used, 578000 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 503052 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
19581 bin 20 0 336684 7596 1856 R 19.6 0.7 0:07.82 php-fpm
19582 bin 20 0 336684 7592 1848 R 19.6 0.7 0:07.58 php-fpm
19584 bin 20 0 336684 7588 1848 R 19.6 0.7 0:07.46 php-fpm
19591 bin 20 0 336684 7588 1848 R 19.6 0.7 0:07.36 php-fpm
19583 bin 20 0 336684 7588 1848 R 19.3 0.7 0:07.46 php-fpm
6531 root 20 0 1014816 73652 7236 S 0.7 7.3 320:53.40 YDService
16012 101 20 0 33128 2272 964 S 0.7 0.2 0:00.14 nginx
1299 root 20 0 88244 6480 6144 S 0.3 0.6 27:00.30 systemd-journal
3073 root 20 0 863576 70144 1748 S 0.3 6.9 55:50.84 rsyslogd
9056 root 20 0 742704 13844 1956 S 0.3 1.4 154:00.78 barad_agent
15972 root 20 0 264800 2980 1712 S 0.3 0.3 0:00.03 docker-containe
1 root 20 0 51748 3308 1976 S 0.0 0.3 106:23.90 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:14.39 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 20:49.46 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 98:32.25 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 4:19.65 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
15 root 20 0 0 0 0 S 0.0 0.0 0:10.39 khungtaskd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 edac-poller
24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 watchdogd
30 root 20 0 0 0 0 S 0.0 0.0 1:05.24 kswapd0
可以看到此时cpu使用率接近饱和。
安装perf
[root@haibo ~]# yum -y install perf
之后用perf分析效果:
perf top -g -p 19591
应对cpu使用率高的程序,可以使用top定位cpu使用率高的进程。之后再通过perf进行分析。