Join the community 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 Premium Member Premium Member

    4,367
    1,053
    113
    May 25, 2014
    Ratings:
    +1,524
    Local Time:
    11:44 AM
    Mainline
    10.2
  2. eva2000

    eva2000 Administrator Staff Member

    36,871
    8,070
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,429
    Local Time:
    1:44 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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. rdan

    rdan Premium Member Premium Member

    4,367
    1,053
    113
    May 25, 2014
    Ratings:
    +1,524
    Local Time:
    11:44 AM
    Mainline
    10.2
  4. eva2000

    eva2000 Administrator Staff Member

    36,871
    8,070
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,429
    Local Time:
    1:44 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Yup :D
     
  5. rdan

    rdan Premium Member Premium Member

    4,367
    1,053
    113
    May 25, 2014
    Ratings:
    +1,524
    Local Time:
    11:44 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

    36,871
    8,070
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,429
    Local Time:
    1:44 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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 Premium Member Premium Member

    4,367
    1,053
    113
    May 25, 2014
    Ratings:
    +1,524
    Local Time:
    11:44 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 Premium Member Premium Member

    4,367
    1,053
    113
    May 25, 2014
    Ratings:
    +1,524
    Local Time:
    11:44 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

    36,871
    8,070
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,429
    Local Time:
    1:44 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    /etc/init.d/ symlinked

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

    rdan Premium Member Premium Member

    4,367
    1,053
    113
    May 25, 2014
    Ratings:
    +1,524
    Local Time:
    11:44 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

    36,871
    8,070
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,429
    Local Time:
    1:44 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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
..