Learn about Centmin Mod LEMP Stack today
Register Now

Now I have 2 nodes mysql/memcached and nginx/php, How can I connect to memcached?

Discussion in 'Other Centmin Mod Installed software' started by rdan, Jun 16, 2015.

  1. rdan

    rdan Well-Known Member

    5,447
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    12:01 AM
    Mainline
    10.2
    How can I connect to memcached from nginx/php server?

    I tried using the private IP that I use for Mysql, but can't login into my forum.

     
  2. rdan

    rdan Well-Known Member

    5,447
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    12:01 AM
    Mainline
    10.2
    I mean here:
    Code:
    // Cache
    $config['cache'] = array(
        'enabled'                      => true,
        'cacheSessions'                => true,
        'frontend'                     => 'Core',
        'frontendOptions'              => array(
            'caching'                  => true,
            'cache_id_prefix'          => 'xf_',
            'automatic_serialization'  => true,
            'lifetime'                 => 0),
        'backend'                      => 'Libmemcached',
        'backendOptions'               => array(
            'servers'                  => array(
                array(
                    'host'             => 'localhost',
                    'port'             => 11211,
                    'weight'           => 1
                )
            )
        )
    );
    // End Cache
    Instead of localhost, I want to use memcached on other node.
     
  3. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:01 PM
    1.91
    10.0.19
    On the other node, is memcached listening on 127.0.0.1 or is it listening on the public IP

    Check
    Code:
    /etc/rc.d/init.d/memcached
    Code:
    SERVERIP='127.0.0.1'
    Think you may need to change it to 0.0.0.0, Sure thats what I did when I had a server just running memcached

    Then change your code 'host' => 'localhost', to the private IP
     
  4. rdan

    rdan Well-Known Member

    5,447
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    12:01 AM
    Mainline
    10.2
    Or use the current private IP?
     
  5. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:01 PM
    1.91
    10.0.19
    Yea use the current private IP of that server, will only bind to that address

    Then restart memcached
     
  6. rdan

    rdan Well-Known Member

    5,447
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    12:01 AM
    Mainline
    10.2
    Nice, it works great now :)
     
  7. Steve Tozer

    Steve Tozer Member

    70
    42
    18
    Jul 28, 2014
    South Wales, UK
    Ratings:
    +49
    Local Time:
    4:01 PM
    1.91
    10.0.19
    :stop:(y):D Great stuff
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,901
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:01 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yup private ip for listen and ensure CSF firewall on both servers has whitelisted each others ips :)