GVKun编程网logo

linux 设备事件管理服务 systemd-udevd.service 简介(linux系统设备管理)

3

如果您对linux设备事件管理服务systemd-udevd.service简介感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于linux设备事件管理服务systemd-ud

如果您对linux 设备事件管理服务 systemd-udevd.service 简介感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于linux 设备事件管理服务 systemd-udevd.service 简介的详细内容,我们还将为您解答linux系统设备管理的相关问题,并且为您提供关于angular j j angular j angular angular service service service j、Arch Linux/systemd – 防止任何类型的shutdown/rebboot、CENTOS/RHEL 7 系统中设置 SYSTEMD SERVICE 的 ULIMIT 资源限制、centos7 linux ailed to stop iptables.service: Unit iptables.service not loaded.的有价值信息。

本文目录一览:

linux 设备事件管理服务 systemd-udevd.service 简介(linux系统设备管理)

linux 设备事件管理服务 systemd-udevd.service 简介(linux系统设备管理)

名称

systemd-udevd.service,systemd-udevd-control.socket,systemd-udevd-kernel.socket,systemd-udevd — 设备事件管理服务

大纲

systemd-udevd.service

systemd-udevd-control.socket

systemd-udevd-kernel.socket

/usr/lib/systemd/systemd-udevd [--daemon] [--debug] [--children-max=] [--exec-delay=] [--event-timeout=] [--resolve-names=early|late|never] [--version] [--help]

描述

systemd-udevd 监听内核发出的设备事件, 并根据 udev 规则处理每个事件。

可以通过文件、 命令行选项、环境变量、 内核引导选项等,配置守护进程的行为。还可以通过 udevadm control 命令动态的控制守护进程的行为。

选项

-d--daemon

脱离控制台,并作为后台守护进程运行。

-D--debug

在标准错误上输出调试信息

-c=--children-max=

限制最多同时并行处理多少个设备事件

-e=--exec-delay=

在运行 RUN 前暂停的秒数。 可用于调试处理冷插事件时, 加载异常内核模块 导致的系统崩溃。

-t=--event-timeout=

设置处理设备事件的最大允许秒数, 若超时则强制终止此设备事件。默认值是180秒。

-N=--resolve-names=

指定 systemd-udevd 应该何时解析用户与组的名称: early(默认值) 表示在规则的解析阶段; late 表示在每个设备事件发生的时候; never 表示从不解析, 所有设备的属主与属组都是 root

-h--help

显示简短的帮助信息并退出。

--version

显示简短的版本信息并退出。

内核引导选项

注意,下面以"rd."开头的参数 仅用于 initrd 环境。

udev.log_priority=rd.udev.log_priority=

设置日志等级

udev.children_max=rd.udev.children_max=

限制最多同时并行处理多少个设备事件

udev.exec_delay=rd.udev.exec_delay=

在运行 RUN 前暂停的秒数。 可用于调试处理冷插事件时, 加载异常内核模块 导致的系统崩溃。

udev.event_timeout=rd.udev.event_timeout=

设置处理设备事件的最大允许秒数。 主要用于避免在系统启动过程中 驱动程序花费太长时间初始化进而影响启动过程。

net.ifnames=

设为"1"(默认值)表示将网络接口按照类似"enp0s3"这样固定的名称命名。 设为"0"则表示依然使用传统的"eth0"或"wlan0"这样动态的名称命名。

net.naming-scheme=

设置将网络接口重命名为固定名称的方案。 当 net.ifnames=0 时,此选项没有意义。 取值范围如下: "v238" 表示 systemd-238 版本的重命名方案; "v239" 表示 systemd-239 版本的重命名方案; "v240" 表示 systemd-240 版本的重命名方案; "v241" 表示 systemd-241 版本的重命名方案; "v243" 表示 systemd-243 版本的重命名方案; "latest"(默认值) 表示当前已知的最新版本的重命名方案。

注意,选择一个特定的重命名方案并不能完全固定网络接口的名称。 因为名称通常是从内核驱动程序公开的属性派生而来,而内核经常升级更新, 所以,有可能会出现先前没有的新属性, 进而影响命名方案的最终结果。

 

 

angular j j angular j angular angular service service service j

angular j j angular j angular angular service service service j

我试图写一个业务/茉莉花测试,我想要一些关于mocks如何在一个正在退回承诺的服务上的解释。我解释我的情况:

我有一个控制器,我在其中进行以下调用:

mapService.getMapByUuid(mapUUID,isEditor).then(function(datas){
    fillMapDatas(datas);
});

function fillMapDatas(datas){
    if($scope.elements === undefined){
        $scope.elements = [];
    }
 //Here while debugging my unit test,'datas' contain the promise javascript object instead //of my real reponse.
   debugger;
    var allOfThem = _.union($scope.elements,datas.elements);

    ...

以下是我的服务:

(function () {
'use strict';

var serviceId = 'mapService';

angular.module('onmap.map-module.services').factory(serviceId,[
    '$resource','appContext','restHello','restMap',serviceFunc]);

function serviceFunc($resource,appContext,restHello,restMap) {

    var Maps = $resource(appContext+restMap,{uuid: '@uuid',editor: '@editor'});

    return{          
        getMapByUuid: function (uuid,modeEditor) {
            var maps = Maps.get({'uuid' : uuid,'editor': modeEditor});
            return maps.$promise;
        }
    };
}

})();

最后,这是我的单位测试:

describe('Map controller',function() {
var $scope,$rootScope,$httpBackend,$timeout,createController,MapService,$resource;

beforeEach(module('onmapApp'));

beforeEach(inject(function($injector) {
    $httpBackend = $injector.get('$httpBackend');
    $rootScope = $injector.get('$rootScope');
    $scope = $rootScope.$new();

    var $controller = $injector.get('$controller');

    createController = function() {
        return $controller('maps.ctrl',{
            '$scope': $scope
        });
    };
}));

afterEach(function() {
    $httpBackend.verifyNoOutstandingExpectation();
    $httpBackend.verifyNoOutstandingRequest();
});

var response = {"elements":[1,2,3]};

it('should allow user to get a map',function() {

    var controller = createController();
    $httpBackend.expect('GET','/onmap/rest/map/MY-UUID?editor=true')
        .respond({
            "success": response
        });


// hope to call /onmap/rest/map/MY-UUID?editor=true url and hope to have response as the fillMapDatas parameter
    $scope.getMapByUUID('MY-UUID',true); 

    $httpBackend.flush();
});
});

我真正想要做的是将我的响应对象({“elements:…})作为fillMapDatas函数的datas参数,我不明白如何模拟所有的服务(服务,承诺,然后)

提前感谢您的帮助

所以你想测试,如果你的服务响应如预期的?然后,这是你想要的服务测试。基于单元测试的方法可能如下所示:
var mapService,$q,$rootScope;

beforeEach(inject(function (_mapService_,_$httpBackend_,_$q_,_$rootScope_) {
  mapService = mapService;
  $httpBackend = _$httpBackend_;
  $q = _$q_;
  $rootScope = _$rootScope_;

  // expect the actual request
  $httpBackend.expect('GET','/onmap/rest/map/uuid?editor=true');

  // react on that request
  $httpBackend.whenGET('/onmap/rest/map/uuid?editor=true').respond({
    success: {
      elements: [1,3]
    }
  });
}));

您可以看到,您不需要使用$ inject,因为您可以直接注入所需的服务。如果您想在整个测试中使用正确的服务名称,您可以使用前缀和后缀“_”注入它们,注入()足够聪明地识别出您的意思。我们还为每个it()规范设置$ httpBackend mock。并且我们设置$ q和$ rootScope进行后续处理。

以下是您如何测试您的服务方法返回承诺:

it('should return a promise',function () {
  expect(mapService.getMapUuid('uuid',true).then).tobedefined();
});

由于承诺总是有一个.then()方法,我们可以检查这个属性,看看它是否是一个承诺(当然,其他对象也可以使用这个方法)。

接下来,您可以用适当的价值测试您得到的解决方案的承诺。您可以设置您明确解析的延迟。

it('should resolve with [something]',function () {
  var data;

  // set up a deferred
  var deferred = $q.defer();
  // get promise reference
  var promise = deferred.promise;

  // set up promise resolve callback
  promise.then(function (response) {
    data = response.success;
  });

  mapService.getMapUuid('uuid',true).then(function(response) {
    // resolve our deferred with the response when it returns
    deferred.resolve(response);
  });

  // force `$digest` to resolve/reject deferreds
  $rootScope.$digest();

  // make your actual test
  expect(data).toEqual([something]);
});

希望这可以帮助!

Arch Linux/systemd – 防止任何类型的shutdown/rebboot

Arch Linux/systemd – 防止任何类型的shutdown/rebboot

我正在运行基于Arch的manjaro Linux并为自己编写了一个小程序,每7个小时启动一次,并在后台完全运行.此更新程序由systemd启动.

我想知道的是:无论用户是想关闭它还是任何程序想要这样做,我怎样才能防止在程序运行期间任何系统关闭/重启.

最好的是,如果任何关闭/重启动作不会被取消而是延迟,那么当更新程序完成运行时,关机/重启将继续.

我的系统部分是:

uupgrades.timer

[Unit]
Description=UU Upgrades Timer

[Timer]
OnBootSec=23min
OnUnitactiveSec=7h
Unit=uupgrades.target

[Install]
WantedBy=basic.target

uupgrades.target

[Unit]
Description=UU Upgrades Timer Target
StopWhenUnneeded=yes

并在文件夹uupgrades.target.wants中

uupgrades.service

[Unit]
Description=UU Update Program

[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/bin/uupgrades

我怎样才能做到这一点?

最佳答案
如果具有足够权限重新启动服务器或操作进程的用户想要停止或重新启动计算机,则无法阻止它们.这就是linux的工作方式.您应该设置权限和帐户,以便其他用户没有足够的root权限或权限来操作进程正在运行的进程或用户.

CENTOS/RHEL 7 系统中设置 SYSTEMD SERVICE 的 ULIMIT 资源限制

CENTOS/RHEL 7 系统中设置 SYSTEMD SERVICE 的 ULIMIT 资源限制

遇到的问题: golang 程序一直出现 too many open files 的报错, 尽管对 /etc/security/limits.conf 做了设置, 对最大文件打开数,最大进程数做了调优。 

解决方法: centos 7 跟 centos 6 在最大文件数的设置方面存在差别的, 需更改不同的配置文件来进行修改。 

 

在 bash 中,有个 ulimit 命令,提供了对 shell 及该 shell 启动的进程的可用资源控制。主要包括打开文件描述符数量、用户的最大进程数量、coredump 文件的大小等。

在 centos 5/6 等版本中,资源限制的配置可以在 /etc/security/limits.conf 设置,针对 root/user 等各个用户或者 * 代表所有用户来设置。 当然,/etc/security/limits.d/ 中可以配置,系统是先加载 limits.conf 然后按照英文字母顺序加载 limits.d 目录下的配置文件,后加载配置覆盖之前的配置。 一个配置示例如下:

 
1
2
3
4
5
6
*     soft   nofile    100000
*     hard   nofile    100000
*     soft   nproc     100000
*     hard   nproc     100000
*     soft   core      100000
*     hard   core      100000

 

不过,在 CentOS 7 / RHEL 7 的系统中,使用 Systemd 替代了之前的 SysV,因此 /etc/security/limits.conf 文件的配置作用域缩小了一些。limits.conf 这里的配置,只适用于通过 PAM 认证登录用户的资源限制,它对 systemd 的 service 的资源限制不生效。登录用户的限制,与上面讲的一样,通过 /etc/security/limits.conf 和 limits.d 来配置即可。
对于 systemd service 的资源限制,如何配置呢?

全局的配置,放在文件 /etc/systemd/system.conf 和 /etc/systemd/user.conf。 同时,也会加载两个对应的目录中的所有.conf 文件 /etc/systemd/system.conf.d/*.conf 和 /etc/systemd/user.conf.d/*.conf
其中,system.conf 是系统实例使用的,user.conf 用户实例使用的。一般的 sevice,使用 system.conf 中的配置即可。systemd.conf.d/*.conf 中配置会覆盖 system.conf。

 
1
2
3
DefaultLimitCORE=infinity
DefaultLimitNOFILE=100000
DefaultLimitNPROC=100000

注意:修改了 system.conf 后,需要重启系统才会生效。

针对单个 Service,也可以设置,以 nginx 为例。
编辑 /usr/lib/systemd/system/nginx.service 文件,或者 /usr/lib/systemd/system/nginx.service.d/my-limit.conf 文件,做如下配置:

 
1
2
3
4
[Service]
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=100000

然后运行如下命令,才能生效。

 
1
2
sudo systemctl daemon-reload
sudo systemctl restart nginx.service

 

查看一个进程的 limit 设置:cat /proc/YOUR-PID/limits
例如我的一个 nginx service 的配置效果:

nginx 进程的资源限制
 
 
 
 
 
Shell
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$cat /proc/$(cat /var/run/nginx.pid)/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             100000               100000               processes
Max open files            100000               100000               files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       1030606              1030606              signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

 

顺便提一下,我还被 CentOS7 自带的 /etc/security/limits.d/20-nproc.conf 文件坑过,里面默认设置了非 root 用户的最大进程数为 4096,难怪我上次在 limits.conf 中设置了没啥效果,原来被 limit.d 目录中的配置覆盖了。

centos7 linux ailed to stop iptables.service: Unit iptables.service not loaded.

centos7 linux ailed to stop iptables.service: Unit iptables.service not loaded.

因为使用win 下的 虚拟机 安装Linux 。

但是 在win 下是可以ping 通 Linux 的。

可是在 win 下使用 浏览器方法 Linux 的服务的时候,访问不了。

怀疑是 防火墙问题。 关闭防火墙

root@bogon bin]# chkconfig iptables off
error reading information on service iptables: No such file or directory
[root@bogon bin]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.

不可以,报错了, 百度说是命令不对,

[root@bogon bin]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@bogon bin]# systemctl disable firewalld
[root@bogon bin]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.

 

通过 systemctl disable firewalld 虽然有反应了。 可是以测试,还是不行。

 

参考 systemctl stop firewalld.service && systemctl disable firewalld.service 

https://www.cnblogs.com/blueskyli/p/7218570.html

[root@bogon bin]# systemctl stop firewalld.service && systemctl disable firewalld.service

搞定

 

 

关于linux 设备事件管理服务 systemd-udevd.service 简介linux系统设备管理的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于angular j j angular j angular angular service service service j、Arch Linux/systemd – 防止任何类型的shutdown/rebboot、CENTOS/RHEL 7 系统中设置 SYSTEMD SERVICE 的 ULIMIT 资源限制、centos7 linux ailed to stop iptables.service: Unit iptables.service not loaded.的相关信息,请在本站寻找。

本文标签: