1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiple Memcache Servers Config File Setting

Discussion in 'Server Configuration and Hosting' started by BamaStangGuy, May 29, 2012.

  1. BamaStangGuy

    BamaStangGuy Well-Known Member

    How should I configure my config.php file to point to more than one memcached server?

    Currently have one setup but want to create another so that the forums can fall back to it in case one fails.
     
  2. Slavik

    Slavik XenForo Moderator Staff Member

    I believe it would be as follows.

    Code:
    $config['cache']['backend'] = 'Memcached';
    $config['cache']['backendOptions'] = array(
        'compression' => false,
        'servers' => array(
            array(
                // your memcached server IP /address
                'host' => 'localhost',
               
                // memcached port
                'port' => 11211,
            )
        )
        'servers' => array(
            array(
                // your memcached server IP /address
                'host' => 'localhost',
               
                // memcached port
                'port' => 11211,
            )
        )
    );
    If that doesn't work

    Code:
    $config['cache']['backend'] = 'Memcached';
    $config['cache']['backendOptions'] = array(
        'compression' => false,
        'servers' => array(
            array(
                // your memcached server IP /address
                'host' => 'localhost',
               
                // memcached port
                'port' => 11211,
            )
           array(
                // your memcached server IP /address
                'host' => 'localhost',
               
                // memcached port
                'port' => 11211,
            )
        )
    );
     
  3. BamaStangGuy

    BamaStangGuy Well-Known Member

    Thanks I will give those a try. Should I miss with the weight option between the servers?
     
  4. Slavik

    Slavik XenForo Moderator Staff Member

    I don't thinkso, this way the data *should* be identically copied and served to and from each server, and should one fail the other will carry on without issue...

    thats the theory at least...
     
  5. BamaStangGuy

    BamaStangGuy Well-Known Member

    Okay. Thanks!
     
  6. MattW

    MattW Well-Known Member

    I've tried both of these to get my primary server to use the second install of memcache on my second server, and neither work

    I get this error
    Code:
    Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /home/z22se/public_html/forum/library/config.php on line 31
    Example:
    Code:
    $config['cache']['backendOptions']=array(
            'compression'=>false,
            'servers' => array(
                    array(
                            'host'=>'localhost',
                            'port'=>11211,
                    )     
                    array(        #This is line 31
                            'host'=>'IP ADDRESS',
                            'port'=>11211,
                    )
                   
            )
    );

    Code:
    Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /home/z22se/public_html/forum/library/config.php on line 32
    Code:
    $config['cache']['backendOptions']=array(
            'compression'=>false,
            'servers' => array(
                    array(
                            'host'=>'localhost',
                            'port'=>11211,
                    )     
            )     
            'servers' => array( # This is line 32
                    array(
                    'host'=>'IP ADDRESS',
                    'port'=>11211,
                    )
            )
    );
     
  7. MattW

    MattW Well-Known Member

    Think I've fixed it.

    It was missing a comma between the two arrays

    Code:
    $config['cache']['backendOptions']=array(
            'compression'=>false,
            'servers' => array(
                    array(
                            'host'=>'localhost',
                            'port'=>'11211'
                    ),
                    array(
                            'host'=>'IP ADDRESS',
                            'port'=>'11211'
                    )
            )
    );
    
     
    dono, bioanarchism and Slavik like this.

Share This Page