Welcome to Centmin Mod Community
Become a Member

Memcached How to Run memcached from a socket?

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

Tags:
  1. RoldanLT

    RoldanLT Well-Known Member

    3,975
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    8:03 PM
    1.11
    10.2
  2. eva2000

    eva2000 Administrator Staff Member

    30,897
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,403
    Local Time:
    10:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    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
     
    • Like Like x 1
  3. RoldanLT

    RoldanLT Well-Known Member

    3,975
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    8:03 PM
    1.11
    10.2
  4. eva2000

    eva2000 Administrator Staff Member

    30,897
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,403
    Local Time:
    10:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    Yup :D
     
  5. RoldanLT

    RoldanLT Well-Known Member

    3,975
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    8:03 PM
    1.11
    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

    30,897
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,403
    Local Time:
    10:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    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. RoldanLT

    RoldanLT Well-Known Member

    3,975
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    8:03 PM
    1.11
    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. RoldanLT

    RoldanLT Well-Known Member

    3,975
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    8:03 PM
    1.11
    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

    30,897
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,403
    Local Time:
    10:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    /etc/init.d/ symlinked

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

    RoldanLT Well-Known Member

    3,975
    965
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,329
    Local Time:
    8:03 PM
    1.11
    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

    30,897
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,403
    Local Time:
    10:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    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
    )
    )
    );
     
    • Like Like x 1