Get the most out of your Centmin Mod LEMP stack
Become a Member

Install rc.local missing on CentOS 7

Discussion in 'Install & Upgrades or Pre-Install Questions' started by noly, Jul 25, 2017.

  1. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    Let's take a look at this error popping up during the mysqltempdir installation:

    Code:
    ls: cannot access /etc/rc.d/rc.local: No such file or directory
    chmod: cannot access ‘/etc/rc.d/rc.local’: No such file or directory
    ls: cannot access /etc/rc.d/rc.local: No such file or directory
    no crontab for root
    11 */23 * * * /usr/local/src/centminmod/tools/autoprotect.sh 2>/dev/null
    11 */23 * * * /usr/local/src/centminmod/tools/autoprotect.sh 2>/dev/null
    0 */4 * * * /usr/bin/cminfo_updater 2>/dev/null
    ls: cannot access /etc/rc.d/rc.local: No such file or directory
    chmod: cannot access ‘/etc/rc.d/rc.local’: No such file or directory
    ls: cannot access /etc/rc.d/rc.local: No such file or directory
    In case you need the install.log....

    error in mysqltempdir installation - /etc/rc.d/rc.local · GitHub
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    2:20 AM
    Nginx 1.13.x
    MariaDB 5.5
    what's output for
    Code (Text):
    grep -rin 'chmod: cannot access' /root/centminlogs/

    and
    Code (Text):
    ls -lah /etc/rc.d/rc.local

    and
    Code (Text):
    rpm -ql systemd | grep rc.local

    and
    Code (Text):
    systemctl status rc-local.service


    normally should only be
    Code (Text):
    grep -rin 'chmod: cannot access' /root/centminlogs/                  
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_230717-000213_install.log:18568:chmod: cannot access ‘/var/log/lfd.log*’: No such file or directory
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_230717-000213_install.log:18578:chmod: cannot access ‘/etc/csf/*.cgi’: No such file or directory
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_230717-000213_install.log:18582:chmod: cannot access ‘/etc/csf/*.php’: No such file or directory
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_230717-000213_install.log:18584:chmod: cannot access ‘/etc/csf/*.py’: No such file or directory


    /etc/rc.d/rc.local is standard centos 6/7 file and should exist, if it doesn't then your centos 7 image provided by your web may not be 100% proper AFAIK but even if it's missing, rest of install should be fine from your install log. I updated 123.09beta01 to hide those errors for /etc/rc.d/rc.local
    Code (Text):
    ls -lah /etc/rc.d/rc.local
    -rwxr-xr-x 1 root root 548 Jul 22 23:57 /etc/rc.d/rc.local


    Code (Text):
    rpm -ql systemd | grep rc.local
    /etc/rc.d/rc.local
    /etc/rc.local
    /usr/lib/systemd/system-generators/systemd-rc-local-generator
    /usr/lib/systemd/system/rc-local.service
    
     
    Last edited: Jul 25, 2017
  3. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    Pronto...

    Code:
    [root@]# grep -rin 'chmod: cannot access' /root/centminlogs/
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_250717-115029_git_updatecur_branch.log:5: Do you want to update your local Centmin Mod Git code ? [y/n]: grep -rin 'chmod: cannot access' /root/centminlogs/
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_250717-110305_install.log:21188:chmod: cannot access ‘/var/log/lfd.log*’: No such file or directory
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_250717-110305_install.log:21198:chmod: cannot access ‘/etc/csf/*.cgi’: No such file or directory
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_250717-110305_install.log:21202:chmod: cannot access ‘/etc/csf/*.php’: No such file or directory
    /root/centminlogs/centminmod_1.2.3-eva2000.09.005_250717-110305_install.log:21204:chmod: cannot access ‘/etc/csf/*.py’: No such file or directory
    

    Code:
    [root@]# ls -lah /etc/rc.d/rc.local
    ls: Zugriff auf /etc/rc.d/rc.local nicht möglich: Datei oder Verzeichnis nicht gefunden
    ..it means "not found".

    Code:
    [root@]# rpm -ql systemd | grep rc.local
    /etc/rc.d/rc.local
    /etc/rc.local
    /usr/lib/systemd/system-generators/systemd-rc-local-generator
    /usr/lib/systemd/system/rc-local.service
    Code:
    [root@]# systemctl status rc-local -l
    
    ● rc-local.service - /etc/rc.local Compatibility
    
       Loaded: loaded (/etc/systemd/system/rc-local.service; disabled; vendor preset: disabled)
    
       Active: inactive (dead)
    
    Jul 25 09:23:05 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:24:13 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:24:13 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:24:41 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:24:41 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:24:42 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:24:42 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:34:45 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 09:56:57 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Jul 25 11:49:56 xxxsystemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    
    
    Regarding your guess...

    "/etc/rc.d/rc.local is standard centos 6/7 file and should exist, if it doesn't then your centos 7 image provided by your web may not be 100% proper"

    I researched that rc.local is now considered a service which is turned "off" by default. The default rc-local file says:

    Code:
    #!/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.
    
    So since it's actually obsolete and not needed by centmin mod i agree on simply hiding the error message.
     
    Last edited: Jul 26, 2017
    • Informative Informative x 1
  4. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    2:20 AM
    Nginx 1.13.x
    MariaDB 5.5
    rc.local in centos 7 is turned off by default, but centmin mod automatically turns it on as it is used by centmin mod. Hence, why you got the errors as centmin mod tried to turn on the usage of rc.local via chmod +x and ls listing of the file to check that the right permissions were set.

    every centos 7 server I have used as rc.local still, so your image must be a be a bit different in not even making it available

    Code (Text):
    cat /etc/rc.d/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.
    

    working
    Code (Text):
    systemctl status rc-local -l
    ● 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 Mon 2017-07-24 20:52:26 UTC; 23h ago
    
    Jul 24 20:52:26 host.domain.com systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
    Jul 24 20:52:26 host.domain.com systemd[1]: Started /etc/rc.d/rc.local Compatibility.
    

    your system will work with centmin mod install though you miss out on some potential optimisations I do via rc.local so will need to work out a way to do it via systemd services for centos 7 instead

    what happens if you run following commands
    Code (Text):
    systemctl start rc-local
    systemctl enable rc-local
    systemctl status rc-local -l
    

    and what is contents of /etc/systemd/system/rc-local.service ?
    Code (Text):
    cat /etc/systemd/system/rc-local.service
    

    as seems to not be a default file on any of my centos 7 systems
    Code (Text):
    cat /etc/systemd/system/rc-local.service
    cat: /etc/systemd/system/rc-local.service: No such file or directory
    

    Code (Text):
    yum provides /etc/systemd/system/rc-local.service --disableplugin=priorities
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.linode.com
     * epel: fedora-epel.mirrors.tds.net
     * extras: mirrors.linode.com
     * rpmforge: repoforge.mirror.constant.com
     * updates: mirrors.linode.com
    No matches found
    

    google search for /etc/systemd/system/rc-local.service shows it as instructions for Ubuntu systemd rc.local setup and not CentOS 7, so your web host who created the CentOS 7 image your using probably messed up How can I execute command on startup (rc.local alternative) on Ubuntu 16.10 or outdated web site guide instructions
     
    Last edited: Jul 26, 2017
  5. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    2:20 AM
    Nginx 1.13.x
    MariaDB 5.5
    i wrote a quick fix script which alters your rc.local setup as it isn't centos 7 default and changes it's rc.local configuration to standard centos 7 expected setup. You can run this command to run it and fix your system rc.local setup. Please post output from this command run too
    Code (Text):
    curl -sL https://gist.githubusercontent.com/centminmod/8b981931c4deb950e7a51b89e7679d5e/raw/rc.local.sh | bash
    


    who's your web host btw, so can take note for future instances. Though I will be updating 123.09beta01 code to detect for this rc.local misconfiguration in future too

    edit: 123.09beta01 has been updated with fix/detection as well Beta Branch - CentOS 7 non-standard rc.local detection & correction now so running centmin.sh menu option 23 submenu option 2 will update the centmin mod code. Then on first re-run of centmin.sh the auto workaround fix will be automatically applied to a CentOS 7 system which has detected missing /etc/rc.d/rc.local file and has the incorrect rc.local service file
     
    Last edited: Jul 26, 2017
    • Like Like x 1
  6. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    Thank you for the fix. I am no sure if it is web host related...my guess is that it is related to CentOS 7.3.xxxx.

    Here are the requested outputs:

    Code:
    [root@ ~]# systemctl start rc-local
    [root@ ~]# systemctl enable rc-local
    
    Created symlink from /etc/systemd/system/multi-user.target.wants/rc-local.service to /etc/systemd/system/rc-local.service.
    
    [root@ ~]# systemctl status rc-local -l
    ● rc-local.service - /etc/rc.local Compatibility
       Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: disabled)
       Active: active (exited) since Di 2017-07-25 22:44:53 UTC; 36s ago
    
    systemd[1]: Starting /etc/rc.local Compatibility...
    systemd[1]: Started /etc/rc.local Compatibility.
    systemd[1]: [/etc/systemd/system/rc-local.service:11] Support for option SysVStartPriority= has been removed and it is ignored
    Code:
    [root@ ~]# cat /etc/systemd/system/rc-local.service
    [Unit]
    Description=/etc/rc.local Compatibility
    ConditionPathExists=/etc/rc.local
    
    [Service]
    Type=forking
    ExecStart=/etc/rc.local start
    TimeoutSec=0
    StandardOutput=tty
    RemainAfterExit=yes
    SysVStartPriority=99
    
    [Install]
    WantedBy=multi-user.target
    Code:
    [root@ ~]# curl -sL https://gist.githubusercontent.com/centminmod/8b981931c4deb950e7a51b89e7679d5e/raw/rc.local.sh | bash
    cat /etc/systemd/system/rc-local.service
    [Unit]
    Description=/etc/rc.local Compatibility
    ConditionPathExists=/etc/rc.local
    
    [Service]
    Type=forking
    ExecStart=/etc/rc.local start
    TimeoutSec=0
    StandardOutput=tty
    RemainAfterExit=yes
    SysVStartPriority=99
    
    [Install]
    WantedBy=multi-user.target
    
    /etc ~
    ln: die symbolische Verknüpfung „/etc/rc.local“ konnte nicht angelegt werden: Die Datei existiert bereits
    ~
    ● rc-local.service - /etc/rc.d/rc.local Compatibility
       Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled; vendor preset: disabled)
       Active: active (exited) since Di 2017-07-25 22:59:00 UTC; 4ms ago
      Process: 17004 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
    
    systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
    systemd[1]: Started /etc/rc.d/rc.local Compatibility.
     
  7. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    Out of curiosity....

    Which optimizations are implemented?

    And don't they presuppose a reboot of the server?
     
  8. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    2:20 AM
    Nginx 1.13.x
    MariaDB 5.5
    thanks the script run output confirms it's now fixed on your server for proper rc.local usage

    the rc.local related tweaks are system environment dependent and only applied dynamically if certain criteria are satisified i.e. non-openvz vps vs openvz vps etc

    you can see references to rc.local in github repo for centmin mod here which include detecting if your system supports transparent huge pages without redis server detected and enabling php 7 zend opcache transparent huge pages support, open file descriptor limits, optimal nf_conntrack hashsize and transparent huge page count if support is detected via dynamically configured value is based on the detected cpu cache size (and accounts for numa awareness for multiple cpu sockets) and system memory availability etc

    rc.local changes are applied only at boot/reboot time or reinforced at boot/reboot as they are applied inline/online/dynamically to existing system but require rc.local to reapply them on reboots
     
    • Like Like x 1
  9. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    So your recommendation would be to reboot server after one has installed centmin?
     
  10. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    2:20 AM
    Nginx 1.13.x
    MariaDB 5.5
    run centmin.sh once, exit via menu option 24 to see if any other updates get applied to rc.local and then run these commands as you'd be missing this from initial install setup configuration
    Code (Text):
    echo "ulimit -n 262144" >> /etc/rc.local
    /usr/local/src/centminmod/tools/hptweaks.sh
    

    hptweaks.sh will reapply nf_conntrack dynamic hashsize configuration if it applies to your system
    then check contents of /etc/rc.d/rc.local
    Code (Text):
    cat /etc/rc.d/rc.local
    

    reboot system to test if rc.local runs as
    Code (Text):
    ulimit -aH
    

    as open file descriptor limit should report = 262144
    Code (Text):
    ulimit -aH
    core file size          (blocks, -c) unlimited
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 3941
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 262144
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) unlimited
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 8192
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    
     
    Last edited: Jul 26, 2017
  11. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    Indeed...

    Code:
    [root@ ~]# ulimit -aH
    core file size          (blocks, -c) unlimited
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 23151
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 262144
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) unlimited
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 8192
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    So...the next time i set up centmin on a fresh baked centos7 the values should be the same AFTER rebooting.

    It may make sense to add the recommendation of rebooting to the docs.
     
  12. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    2:20 AM
    Nginx 1.13.x
    MariaDB 5.5
    no need to reboot, the settings are applied dynamically to existing server session just they are lost on reboot without a working rc.local hence why centmin mod applies settings to rc.local as well to ensure they are intact on reboots
     
    • Like Like x 2
  13. noly

    noly Premium Member Premium Member

    69
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    6:20 PM
    1.13.x
    10.x
    5 stars for the logic! (y)
     
    • Like Like x 2