Want to subscribe to topics you're interested in?
Become a Member

Install mmap(MAP_ANON|MAP_SHARED) failed, can't allocated memory

Discussion in 'Install & Upgrades or Pre-Install Questions' started by hendry, Oct 27, 2016.

  1. hendry

    hendry Member

    59
    14
    8
    Sep 19, 2016
    Ratings:
    +18
    Local Time:
    12:52 PM
    nginx/1.11.4
    MariaDB 10
    I just install centminmod on my new vps and the trouble is nginx won't start. when I restart this error message appear:
    Code (Text):
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: [alert] mmap(MAP_ANON|MAP_SHARED, 16777216) failed (12: Cannot allocate memory)
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
    


    server free memory and info
    Code (Text):
    # free -m
                 total       used       free     shared    buffers     cached
    Mem:          1536        234       1301        242          0        222
    -/+ buffers/cache:         12       1523
    Swap:          512          0        512
    
    # cat /proc/meminfo
    MemTotal:        1572864 kB
    MemFree:         1285284 kB
    Cached:           274808 kB
    Buffers:               0 kB
    Active:           135100 kB
    Inactive:         139700 kB
    Active(anon):      80264 kB
    Inactive(anon):    20464 kB
    Active(file):      54836 kB
    Inactive(file):   119236 kB
    Unevictable:           0 kB
    Mlocked:               0 kB
    SwapTotal:        524288 kB
    SwapFree:         524288 kB
    Dirty:                16 kB
    Writeback:             0 kB
    AnonPages:        100728 kB
    Shmem:            248392 kB
    Slab:              12772 kB
    SReclaimable:       6168 kB
    SUnreclaim:         6604 kB
    
    


    I try to resize memory setting from 32Mb to 256Mb
    Code (Text):
    # echo $((`cat /proc/sys/kernel/shmmax` / 1024 / 1024))Mb
    256Mb
    


    I also try to recompile nginx but nginx still can not start. Could someone be so nice and explain me how to solve this problem?

     
  2. eva2000

    eva2000 Administrator Staff Member

    55,237
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    3:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You probably ran into same issue as @johnnyc at Install - 123.08stable installer out of memory on OpenVZ VPS - broke php | Centmin Mod Community - particularly look at /proc/user_beancounters reported shmpages limits and whether any counts in failcnt column = hitting web hosts restricted limits

    i.e.

    Code (Text):
    cat /proc/user_beancounters
    Version: 2.5
           uid  resource                     held              maxheld              barrier                limit              failcnt
          251:  kmemsize                137604923            284540928            536870912            536870912                    0
                lockedpages                     0                    8               131072               131072                    0
                privvmpages                242739               474925  9223372036854775807  9223372036854775807                    0
                shmpages                    58155                95464  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                numproc                        73                  138  9223372036854775807  9223372036854775807                    0
                physpages                  198500               262194                    0               262144                    0
                vmguarpages                     0                    0  9223372036854775807  9223372036854775807                    0
                oomguarpages                53404               175918  9223372036854775807  9223372036854775807                    0
                numtcpsock                     19                  152  9223372036854775807  9223372036854775807                    0
                numflock                      104                  332  9223372036854775807  9223372036854775807                    0
                numpty                          1                    3  9223372036854775807  9223372036854775807                    0
                numsiginfo                      0                   33  9223372036854775807  9223372036854775807                    0
                tcpsndbuf                  331360              2823232  9223372036854775807  9223372036854775807                    0
                tcprcvbuf                  311296             22857328  9223372036854775807  9223372036854775807                    0
                othersockbuf               210392               870904  9223372036854775807  9223372036854775807                    0
                dgramrcvbuf                     0                27048  9223372036854775807  9223372036854775807                    0
                numothersock                  151                  175  9223372036854775807  9223372036854775807                    0
                dcachesize              125052432            268435456            268435456            268435456                    0
                numfile                      1328                 1985  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                numiptent                    1045                 1045  9223372036854775807  9223372036854775807      


    If you're using OpenVZ based VPSes, you might have ran into limits set by your web hosts OpenVZ /proc/user_beancounters limits Install - 123.08stable installer out of memory on OpenVZ VPS - broke php | Centmin Mod Community

    To troubleshoot, you'll need to post on the forums with the following info
    • Server or VPS details ? XEN, KVM, OpenVZ, VMWare or dedicated server ? OS ? CentOS 6.7 or 7.2 ? 32bit or 64bit ?
    • What version of Centmin Mod ? .07 stable or 08 stable or .09 beta01 or another branch version ?
    • Was it fresh install or upgrade ?
    • Method of install ? Via centmin.sh menu option 1, Git install or curl one liner install as outlined at centminmod.com/download.html ?
    • How long ago did you install Centmin Mod ?
    • There's numerous code changes, bug fixes over time, so ensure you have latest Centmin Mod code installed by upgrading your Centmin Mod code as instructed below.

    Troubleshooting Initial Install



    To troubleshoot initial installation, you need to check the initial install log at /root/centminlogs and instructions under Sharing logs and errors heading for using Pastebin.com or Gists to share a sanitised version of the contents of the initial install log. You can see full details at How to troubleshoot Centmin Mod initial install issues

    Example list /root/centminlogs files in date ascending order and grep for install.log
    Code (Text):
    ls -lahrt /root/centminlogs | grep install.log
    

    example output returns install log at /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_install.log
    Code (Text):
    ls -lahrt /root/centminlogs | grep install.log
    -rw-r--r--  1 root root 2.2M Oct 11 01:40 centminmod_1.2.3-eva2000.09.001_111016-112321_install.log
    

    in SSH use cat to ouput contents of /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_install.log. Clear your SSH client window/buffer so only output is the contents of the file
    Code (Text):
    cat /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-112321_install.log
    

    Then copy and paste into Pastebin.com or Gists entry. If your SSH window scroll buffer isn't that large to get the whole contents of the install log, you can download file manually and copy and paste contents. But makes sure it's sanitised version of the contents of the initial install log as outlined at How to troubleshoot Centmin Mod initial install issues
     
    Last edited: Oct 27, 2016
  3. eva2000

    eva2000 Administrator Staff Member

    55,237
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    3:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    whipped up a quick memory map mmap test script to confirm if it's openvz related at GitHub - centminmod/mmap_test

    just run this command in ssh and share output via CODE BBCODE tag
    Code (Text):
    curl -sL https://raw.githubusercontent.com/centminmod/mmap_test/master/mmap_test.sh | bash
    

    this is example working ok output for centmin mod install on OpenVZ based Centos 6 32bit vps which has only 128MB memory installed
    Code (Text):
    checking system shared memory limits for mmap
    
    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) 255841
    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) 4096
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    
    65536 bytes mmaped
    131072 bytes mmaped
    262144 bytes mmaped
    524288 bytes mmaped
    1048576 bytes mmaped
    2097152 bytes mmaped
    4194304 bytes mmaped
    8388608 bytes mmaped
    16777216 bytes mmaped
    33554432 bytes mmaped
    67108864 bytes mmaped
    134217728 bytes mmaped
    268435456 bytes mmaped
    536870912 bytes mmaped
    

    Code (Text):
    OpenVZ system detected...
    Checking /proc/user_beancounters limits for shmpages
    
    shmpages used & percentage used: 29 MB (0%)
    
     
  4. hendry

    hendry Member

    59
    14
    8
    Sep 19, 2016
    Ratings:
    +18
    Local Time:
    12:52 PM
    nginx/1.11.4
    MariaDB 10
    maybe, here is the cat /proc/user_beancounters
    Code (Text):
    # cat /proc/user_beancounters
    Version: 2.5
           uid  resource                     held              maxheld              barrier                limit              failcnt
        21616:  kmemsize                 12940530             16109568             20971520             52428800                    0
                lockedpages                     0                    0                 2059                 2059                    0
                privvmpages                137748               177195               393216               406016                    0
                shmpages                    62098                62434                65536                65536                    1
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                numproc                        53                   69                  200                  200                    0
                physpages                   72589                90438                    0               393216                    0
                vmguarpages                     0                    0               393216               406016                    0
                oomguarpages                25163                30355               131072           2147483647                    0
                numtcpsock                      9                   12                  600                  700                    0
                numflock                       11                   16                 1000                 1000                    0
                numpty                          1                    1                  128                  128                    0
                numsiginfo                      0                   18                 1024                 1024                    0
                tcpsndbuf                  163632               209280              6584420              6594420                    0
                tcprcvbuf                  147456               196608              6584420              6594420                    0
                othersockbuf                20808                47464              4923119              4933119                    0
                dgramrcvbuf                     0                 2576              4923119              4933119                    0
                numothersock                   31                   37                  600                  700                    0
                dcachesize                6316841              6340598              6155930              6340608                    0
                numfile                       571                  690                 4096                 4096                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                numiptent                     340                  340           2147483647           2147483647                    0
    


    - OpenVZ Centos 6.8 64bit
    - using 09beta01
    - fresh install
    - curl one liner install = yum -y update; curl -O https://centminmod.com/betainstaller-latest.sh && chmod 0700 betainstaller-latest.sh && bash betainstaller-latest.sh
    - few hours ago.

    Gist =
    install log1 · GitHub
     
  5. hendry

    hendry Member

    59
    14
    8
    Sep 19, 2016
    Ratings:
    +18
    Local Time:
    12:52 PM
    nginx/1.11.4
    MariaDB 10
    Code (Text):
    # curl -sL https://raw.githubusercontent.com/centminmod/mmap_test/master/mmap_test.sh | bash                                           
    checking system shared memory limits for mmap
    
    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) 63097
    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
    
    65536 bytes mmaped
    131072 bytes mmaped
    262144 bytes mmaped
    524288 bytes mmaped
    1048576 bytes mmaped
    2097152 bytes mmaped
    4194304 bytes mmaped
    8388608 bytes mmaped
    mmap(MAP_ANON|MAP_SHARED, 16777216) failed, errno = 12
    
    OpenVZ system detected...
    Checking /proc/user_beancounters limits for shmpages
    
    shmpages used & percentage used: 247 MB (96%)
    
                 total       used       free     shared    buffers     cached
    Mem:          1536        306       1229        247          0        293
    -/+ buffers/cache:         13       1522
    Swap:          512          0        512
    
    Version: 2.5
           uid  resource                     held              maxheld              barrier                limit              failcnt
        21616:  kmemsize                 14170648             17100800             20971520             52428800                    0
                lockedpages                     0                    0                 2059                 2059                    0
                privvmpages                140464               200086               393216               406016                    0
                shmpages                    63378                65426                65536                65536                    2
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                numproc                        58                   72                  200                  200                    0
                physpages                   78526                90438                    0               393216                    0
                vmguarpages                     0                    0               393216               406016                    0
                oomguarpages                26482                32538               131072           2147483647                    0
                numtcpsock                     11                   13                  600                  700                    0
                numflock                       11                   16                 1000                 1000                    0
                numpty                          1                    1                  128                  128                    0
                numsiginfo                      1                   18                 1024                 1024                    0
                tcpsndbuf                  817896               957416              6584420              6594420                    0
                tcprcvbuf                  180224               212992              6584420              6594420                    0
                othersockbuf                20808                47464              4923119              4933119                    0
                dgramrcvbuf                     0                 3600              4923119              4933119                    0
                numothersock                   31                   37                  600                  700                    0
                dcachesize                6314717              6340598              6155930              6340608                    0
                numfile                       741                  805                 4096                 4096                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                dummy                           0                    0  9223372036854775807  9223372036854775807                    0
                numiptent                     344                  344           2147483647           2147483647                    0
    
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,237
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    3:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yup your web host has restricted shmpages to ~256MB or 65536 pages (65536/256 = 256MB)
    Code (Text):
    OpenVZ system detected...
    Checking /proc/user_beancounters limits for shmpages
    
    shmpages used & percentage used: 247 MB (96%)
    
                 total       used       free     shared    buffers     cached
    Mem:          1536        306       1229        247          0        293
    -/+ buffers/cache:         13       1522
    Swap:          512          0        512
    
    Version: 2.5
           uid  resource                     held              maxheld              barrier                limit              failcnt
                shmpages                    63378                65426                65536                65536                    2


    your failcnt counter incremented to 2 and the mmap_test aborted so you need to ask web host to raise their shmpages limit or upgrade or move web hosts if they are restrictive on all their OpenVZ plans.

    Or switch to KVM based VPS which doesn't have OpenVZ like user_beancounters limits

    edit: might integrate mmap_test.sh GitHub - centminmod/mmap_test into centmin mod install routines so folks don't need to go through this issue :)
     
    Last edited: Oct 27, 2016
  7. hendry

    hendry Member

    59
    14
    8
    Sep 19, 2016
    Ratings:
    +18
    Local Time:
    12:52 PM
    nginx/1.11.4
    MariaDB 10
    Ok thanks eva for your time to help me.
     
  8. eva2000

    eva2000 Administrator Staff Member

    55,237
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    3:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    btw, who is your web host and what plan are you on for vps ?

    i have dozens of openvz vps servers from 128MB to 512MB memory and none limit shmpages to such a small size
     
  9. hendry

    hendry Member

    59
    14
    8
    Sep 19, 2016
    Ratings:
    +18
    Local Time:
    12:52 PM
    nginx/1.11.4
    MariaDB 10
    Euserv. i don't know what plan, i got it from a recommended link on a forum. its cost 3$/year, maybe because its cheap they limit shmpages :dead:
     
  10. eva2000

    eva2000 Administrator Staff Member

    55,237
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,833
    Local Time:
    3:52 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  11. hendry

    hendry Member

    59
    14
    8
    Sep 19, 2016
    Ratings:
    +18
    Local Time:
    12:52 PM
    nginx/1.11.4
    MariaDB 10