Welcome to Centmin Mod Community
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 Premium Member Premium Member

    5,299
    1,326
    113
    May 25, 2014
    Ratings:
    +2,050
    Local Time:
    12:40 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 Premium Member Premium Member

    5,299
    1,326
    113
    May 25, 2014
    Ratings:
    +2,050
    Local Time:
    12:40 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:
    5:40 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 Premium Member Premium Member

    5,299
    1,326
    113
    May 25, 2014
    Ratings:
    +2,050
    Local Time:
    12:40 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:
    5:40 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 Premium Member Premium Member

    5,299
    1,326
    113
    May 25, 2014
    Ratings:
    +2,050
    Local Time:
    12:40 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:
    5:40 PM
    1.91
    10.0.19
    :stop:(y):D Great stuff
     
  8. eva2000

    eva2000 Administrator Staff Member

    48,977
    11,224
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,474
    Local Time:
    2:40 AM
    Nginx 1.21.x
    MariaDB 10.x
    yup private ip for listen and ensure CSF firewall on both servers has whitelisted each others ips :)