zoukankan      html  css  js  c++  java
  • 设置自己的开机启动服务

    CentOS系统下,主要有两种方法设置自己安装的程序开机启动。
    1、把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd。

    1 #!/bin/sh
    2 #
    3 # This script will be executed *after* all the other init scripts.
    4 # You can put your own initialization stuff in here if you don't
    5 # want to do the full Sys V style init stuff.
    6  
    7 touch /var/lock/subsys/local --创建文件夹
    8 /usr/local/apache/bin/apachectl start

    2、把写好的启动脚本添加到目录/etc/rc.d/init.d/,然后使用命令chkconfig设置开机启动。

    chkconfig 功能说明:检查,设置系统的各种服务。

    语法:chkconfig [--add][--del][--list][系统服务] 或 chkconfig [--level <等级代号>][系统服务][on/off/reset]

    --add 添加服务

    --del 删除服务

    --list 查看各服务启动状态

    比如我们设置自启动mysql:

     1 #将mysql启动脚本放入所有脚本运行目录/etc/rc.d/init.d中
     2 cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld
     3 
     4 #改变权限
     5 chown root.root /etc/rc.d/init.d/mysqld
     6 
     7 #所有用户都可以执行,单只有root可以修改
     8 chmod 755 /etc/rc.d/init.d/mysqld
     9 
    10 #将mysqld 放入linux启动管理体系中
    11 chkconfig --add mysqld
    12 
    13 #查看全部服务在各运行级状态
    14 chkconfig --list mysqld
    15 
    16 #只要运行级别3启动,其他都关闭
    17 chkconfig --levels 245 mysqld off

    例如:我们把httpd的脚本写好后放进/etc/rc.d/init.d/目录,使用

    1 chkconfig --add httpd
    2 chkconfig httpd on

    命令即设置好了开机启动。

    3、把启动程序的命令添加到/etc/rc.d/rc.sysinit 文件中

    脚本/etc/rc.d/rc.sysinit,完成系统服务程序启动,如系统环境变量设置、设置系统时钟、加载字体、检查加载文件系统、生成系统启动信息日志文件等

    比如我们设置自启动apache:

    1 echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit

    4、创建一个修改RPS和RFS的脚本

     1 #!/bin/bash  
     2 # Enable RPS (Receive Packet Steering)  
     3       
     4 rfc=32768  
     5 cc=$(grep -c processor /proc/cpuinfo)  
     6 rsfe=32768
     7  
     8 #临时修改net.core.rps_sock_flow_entries的值
     9 #sysctl -w net.core.rps_sock_flow_entries=$rsfe
    10 #设置rps_sock_flow_entries的值
    11 
    12 echo '32768' >/proc/sys/net/core/rps_sock_flow_entries
    13 
    14 #查看有几个网卡放到fileRps里:/sys/class/net/eth0/queues/rx-0/rps_cpus
    15 
    16 for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus);do
    17  if [ $cc = "2" ]; then
    18     echo 3 > $fileRps  
    19  elif [ $cc = "4" ]; then
    20     echo f > $fileRps
    21  elif [ $cc = "6" ]; then
    22     echo 3f > $fileRps 
    23  elif [ $cc = "8" ]; then
    24     echo ff > $fileRps 
    25  elif [ $cc = "10" ]; then
    26     echo 3ff > $fileRps
    27  elif [ $cc = "12" ]; then
    28     echo fff > $fileRps
    29  elif [ $cc = "14" ]; then
    30     echo 3fff > $fileRps
    31  elif [ $cc = "16" ]; then
    32     echo ffff > $fileRps    
    33  else "Unknown"
    34  fi 
    35 done
    36       
    37 for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt)  
    38 do
    39     echo $rfc > $fileRfc  
    40 done
    41       
    42 tail /sys/class/net/eth*/queues/rx-*/{rps_cpus,rps_flow_cnt}
  • 相关阅读:
    Redux 学习总结
    ECMAScript 6 学习总结
    Bootstrap 前端UI框架
    React.js 学习总结
    html 之 <meta> 标签之http-equiv
    Leetcode Excel Sheet Column Number (C++) && Excel Sheet Column Title ( Python)
    490
    414
    494
    458
  • 原文地址:https://www.cnblogs.com/tian880820/p/5526789.html
Copyright © 2011-2022 走看看