zoukankan      html  css  js  c++  java
  • RHEL7: How to configure a rc-local service

    问题: linux7 /etc/rc.local 不生效:

    [root@bogon mysql3306]# uname -a
    Linux bogon 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    在/etc/rc.local上添加如下部分,重启后没有生效:

    if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
     echo never > /sys/kernel/mm/transparent_hugepage/enabled
    fi
    if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
     echo never > /sys/kernel/mm/transparent_hugepage/defrag
    fi

    [root@bogon mysql3306]# cat /etc/rc.local
    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.

    解决方法:

    (1) chmod +x /etc/rc.d/rc.local

    (2) systemctl enable rc-local

    [root@bogon software]# systemctl status rc-local
    ● rc-local.service - /etc/rc.d/rc.local Compatibility
       Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
       Active: active (exited) since Sun 2018-11-18 17:27:56 CST; 1h 9min ago
      Process: 1039 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
        Tasks: 0
    Nov 18 17:27:56 bogon systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
    Nov 18 17:27:56 bogon systemd[1]: Started /etc/rc.d/rc.local Compatibility.
    [root@bogon software]#
     

    (3) systemctl start rc-local

    (4) 验证生效:

    [root@bogon ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
    always madvise [never]
    [root@bogon ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
    always madvise [never]
    [root@bogon ~]#

    (5) 重启后验证依然生效

  • 相关阅读:
    Prime Time使用
    cache与MMU与总线仲裁
    IUS tcl cmd
    CPU cache
    generated clock
    PL301 matrix内部模块
    014-数据结构-树形结构-基数树、Patricia树、默克尔树、梅克尔帕特里夏树( Merkle Patricia Tree, MPT)
    001-软件架构概览、maven补充【分包工程、合并包、web容器插件】、git补充
    013-数据结构-树形结构-决策树
    012-数据结构-树形结构-哈希树[hashtree]、字典树[trietree]、后缀树
  • 原文地址:https://www.cnblogs.com/DataArt/p/9978764.html
Copyright © 2011-2022 走看看