Discover Centmin Mod today
Register Now

Memcached How to Run memcached from a socket?

Discussion in 'Centmin Mod Insights' started by rdan, Jul 28, 2014.

Tags:
  1. rdan

    rdan Well-Known Member

    5,443
    1,402
    113
    May 25, 2014
    Ratings:
    +2,194
    Local Time:
    10:12 AM
    Mainline
    10.2
  2. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    12:12 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You can do it manually. Or you can try a revised /etc/init.d/memcached script I just made :D
    • To enable unix socket set SOCKET_ENABLE=y in /etc/init.d/memcached
    • To use default TCP set SOCKET_ENABLE=n in /etc/init.d/memcached
    • Afterwards restart memcached server = service memcached restart
    Code:
    wget -O /etc/init.d/memcached https://gist.githubusercontent.com/centminmod/94940d2f1cd75c5e18dd/raw/memcached.sh
    chmod +x /etc/init.d/memcached
    
    Also found a bug preventing stopping memcached in the existing memcached file, so will update that for .07 stable and .08 betas :D
     
  3. rdan

    rdan Well-Known Member

    5,443
    1,402
    113
    May 25, 2014
    Ratings:
    +2,194
    Local Time:
    10:12 AM
    Mainline
    10.2
  4. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    12:12 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yup :D
     
  5. rdan

    rdan Well-Known Member

    5,443
    1,402
    113
    May 25, 2014
    Ratings:
    +2,194
    Local Time:
    10:12 AM
    Mainline
    10.2
    So what if I use memcached also for ngx_pagespeed, What adjustment needs to be done on pagespeed.conf?
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    12:12 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    don't think ngx_pagespeed memcached feature supports unix sockets yet only TCP Google Groups

    you'd probably have to disable memcached server caching in ngx_pagespeed pagespeed.conf
     
  7. rdan

    rdan Well-Known Member

    5,443
    1,402
    113
    May 25, 2014
    Ratings:
    +2,194
    Local Time:
    10:12 AM
    Mainline
    10.2
    So I can't switch to unix socket on this case?
    Because once socket is activated tcp will not work anymore right?
     
  8. rdan

    rdan Well-Known Member

    5,443
    1,402
    113
    May 25, 2014
    Ratings:
    +2,194
    Local Time:
    10:12 AM
    Mainline
    10.2
    Wait, On CentOS 6. the correct directory is /etc/rc.d/init.d right?
    And file is memcached?
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    12:12 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    /etc/init.d/ symlinked

    just use to /etc/init.d/memcached :D
     
  10. rdan

    rdan Well-Known Member

    5,443
    1,402
    113
    May 25, 2014
    Ratings:
    +2,194
    Local Time:
    10:12 AM
    Mainline
    10.2
    So on my xenforo config.php:
    Code:
    'backendOptions' => array(
            'servers' => array(
                array( 'host' => '/var/run/memcached/memcached1.sock',  'port' => 0755 )
            ),
            'compression' => false
        ),
    Correct?

    Thanks!
     
  11. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    12:12 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    not sure as I think it's just a matter of changing your existing memcached settings by replacing host value 127.0.0.1 with /var/run/memcached/memcached1.sock and port value with 0 (755 is socket file permission not port)

    for me I have Libmemcached backend

    PHP:
    $config['cache']['backend'] = 'Libmemcached';

    $config['cache']['backendOptions'] = array(
    'servers' => array(
    array(
    'host' => '127.0.0.1',
    'port' => 11211,
    'persistent' => 'true',
    'weight' => 1
    )
    )
    );