In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Technical background
Linuxs uses Cgroup to restrict the resources of the container, but the / proc directory of procfs on the host is still mounted by default inside the container, which contains resource information such as meminfo, cpuinfo,stat, uptime and so on. Some monitoring tools such as free/top or legacy applications also rely on the contents of the above files for resource configuration and usage. When they run in the container, they will read out the resource status of the host, causing errors and inconvenience.
Introduction to 2.LXCFS
A common practice in the CNCF community is to use lxcfs to provide resource visibility in containers. Lxcfs is an open source FUSE (user mode file system) implementation to support LXC containers, it can also support Docker containers.
Githup website: https://github.com/lxc/lxcfs
LXCFS provides the following procfs files in the container through the user-mode file system.
/ proc/cpuinfo/proc/diskstats/proc/meminfo/proc/stat/proc/swaps/proc/uptime
Schematic diagram of 3.LXCFS:
For example, after the / var/lib/lxcfs/proc/memoinfo file of the host is mounted to the / proc/meminfo location of the Docker container. When the process in the container reads the contents of the corresponding file, the FUSE implementation of LXCFS reads the correct memory limit from the corresponding Cgroup of the container. So that the application can get the correct resource constraint setting.
4.Docker improves the visibility of container resources
Note:
In this paper, CentOS 7.2 is used as the test environment, and FUSE module support has been enabled.
Fuse purpose:
The traditional file system is a part of the operating system and is implemented in the operating system kernel. Fuse (Filesystem in Userspace), a user space file system framework, provides us with a set of API for implementing a file system, so that we can implement our own file system in user mode.
Due to the highly tailored operating system, Docker for Mac/Minikube and other development environments can not support FUSE, and run LXCFS for testing.
Install the RPM package for lxcfs
4.1. Environmental Information:
System version kernel version software depends on software version remarks
CentOS Linux 7.2.151
3.10.0-1062.4.1.el7.x86_64
Fuse-libs
Fuse
Fuse-devel
Fuse-devel-2.9.2-7.el7.x86_64
Fuse-libs-2.9.2-7.el7.x86_64
Fuse-2.9.2-7.el7.x86_64
The user mode implements its own file system.
Dockerdocker-1.13.1-102.git7f2769b.el7.centos.x86_64docker service lxcfslxcfs-3.1.2-0.2.el7.x86_64.rpmLXCFS main program package
4.2 install dependency get package and start the service
Yum-y install fuse-devel fuse dockerlxc-templates wget https://copr-be.cloud.fedoraproject.org/results/ganto/lxc3/epel-7-x86_64/01041891-lxcfs/lxcfs-3.1.2-0.2.el7.x86_64.rpmrpm-ivh lxcfs-3.1.2-0.2.el7.x86_64.rpmsystemctl start dockerlxcfs / var/lib/lxcfs &
4.3 run the docker test image
Docker run-itd-m 256m\-v / var/lib/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw\-v / var/lib/lxcfs/proc/diskstats:/proc/diskstats:rw\-v / var/lib/lxcfs/proc/meminfo:/proc/meminfo:rw\-v / var/lib/lxcfs/proc/stat:/proc/stat:rw\-v / var/lib/lxcfs/proc/swaps:/proc/swaps:rw\-v / var/lib/lxcfs / proc/uptime:/proc/uptime:rw\ ubuntu:16.04 / bin/bash
Note:
Container_linux.go:247: starting container process caused "process_linux.go:258: applying cgroup configuration for process caused\" Cannot set property TasksAccounting, or unknown property.\ "/ usr/bin/docker-current: Error response from daemon: oci runtime error: starting container process caused" process_linux.go:258: applying cgroup configuration for process caused\ "Cannot set property TasksAccounting, or unknown property.\".
Solution: the main reason is the compatibility of centos system version, if the system is updated and upgraded
Yum update
4.4 query the experimental results
(1)。 Set lxcfs container and set lxcfs to compare memory comparison
(2)。 Container is not set up
(1)。 Set lxcfs container and set lxcfs comparison uptime comparison
5.Kubernetes improves the visibility of container resources
Some students have asked how to use lxcfs in a Kubernetes cluster environment, and we will give you an example method for reference.
First, we will install and start lxcfs on the cluster node, and we will run the lxcfs FUSE file system using Kubernetes, container and DaemonSet.
Obtained through Github
Git clone https://github.com/denverdino/lxcfs-initializercd lxcfs-initializer
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.