问题: 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) 重启后验证依然生效

最新文章

  1. Android6.0动态申请权限
  2. Java_Swing程序设计_尝试开发一个登陆窗体,包括用户名、密码以及提交按钮和重置按钮,当用户输入用户名my,密码love时,弹出登陆成功提示对话框。
  3. <Android>文件下载
  4. SDR 研究
  5. 利用脚本修改SQL SERVER排序规则
  6. 【Android 界面效果33】二级listview列表
  7. 《Introduction to Algorithm》-chaper33-计算几何学
  8. uva 10602 Editor Nottoobad(排序)
  9. kafka中partition和消费者对应关系
  10. ABP官方文档翻译 6.1.2 MVC视图
  11. [Tjoi 2013]松鼠聚会
  12. (二 -4) 天猫精灵接入Home Assistant-自动发现Mqtt设备--传感器系列
  13. 代码合并工具Beyond Compare的使用技巧
  14. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习4
  15. js 可拖动div 调整大小
  16. Sonya and Problem Wihtout a Legend CodeForces - 714E (dp)
  17. Spring任务调度器之Task的使用(转)
  18. POJ 1151 Atlantis 矩形面积求交/线段树扫描线
  19. 使用idea的的第一个坑-----javax.xml.ws.WebServiceRef
  20. 3、Spring Cloud - Eureka(高可用Eureka Server集群)

热门文章

  1. 【转】Hadoop vs Spark性能对比
  2. Google Guava--Guava新增集合
  3. Java代码实现单例模式
  4. google tensorflow bert代码分析
  5. Spring整合Hibernate的XML文件配置,以及web.xml文件配置
  6. BATJ面试必会之Java IO 篇
  7. [Codeforces 993E]Nikita and Order Statistics
  8. IDF实验室-简单的js解密
  9. [转]微信小程序之购物数量加减 —— 微信小程序实战商城系列(3)
  10. 针对Eclipse闪退的两种解决方案