GithubHelp home page GithubHelp logo

HAProxy PXC down about appside HOT 9 CLOSED

cloudsidedev avatar cloudsidedev commented on July 29, 2024
HAProxy PXC down

from appside.

Comments (9)

ivomarino avatar ivomarino commented on July 29, 2024

Here are some config infos: http://stackoverflow.com/a/22102219

from appside.

ivomarino avatar ivomarino commented on July 29, 2024

MySQL port is 3307 on the VIP:

netstat -tulpen | grep haproxy
tcp        0      0 0.0.0.0:3307            0.0.0.0:*               LISTEN      0          1628382     5113/haproxy
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      0          1628380     5113/haproxy
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      0          1628379     5113/haproxy

mysql --host=VIP --port=3307

from appside.

ivomarino avatar ivomarino commented on July 29, 2024

we need to override DB_HOST (mysql.local will point to VIP in /etc/hosts):

    ...   
    config_env: true
    env_opt: |
      DB_HOST=mysql.local:3307
      CFG_URL_DEVELOPMENT='http://site.dev.foo.com'
    ...

so we basically override DB_HOST in .env:

...
DB_HOST=mysql.local
DB_HOST=mysql.local:3307
...

@ocean90 is it possible to print the actual MySQL connection info which WP is using?

from appside.

ocean90 avatar ocean90 commented on July 29, 2024

Something like mysqli_get_host_info()?

$ wp shell
wp> mysqli_get_host_info( $GLOBALS['wpdb']->dbh );
=> string(22) "mysql.local via TCP/IP"

from appside.

ivomarino avatar ivomarino commented on July 29, 2024

works fine, thanks:

 % wp shell
wp> mysqli_get_host_info( $GLOBALS['wpdb']->dbh );
=> string(22) "mysql.local via TCP/IP"

but I need to print the port also or better the whole DB_HOST which contains the port also.

from appside.

ocean90 avatar ocean90 commented on July 29, 2024

To print the value of a constant you can use var_dump() like so:

$ wp eval "var_dump( DB_HOST );"
string(11) "mysql.local"

from appside.

ivomarino avatar ivomarino commented on July 29, 2024

ok, this gives:

 % wp eval "var_dump( DB_HOST );"
string(11) "mysql.local"

but we would like to have:

 % wp eval "var_dump( DB_HOST );"
string(11) "mysql.local:3307"

this means that

...
DB_HOST=mysql.local
DB_HOST=mysql.local:3307
...

does not overwrite as expected, WP get's always the first entry. This means we need to edit https://github.com/ttssdev/appflow/blob/master/playbooks/roles/web/templates/wp_bedrock/env.j2#L8 but keeping in mind that this is only for e.g. staging and production, not dev for sure or situations where we only have one MySQL node.

we can also think to make DB_HOST and DB_PORT vars of a vhost definition, like:

...
DB_NAME={{ item.value.db_name }}
DB_USER={{ item.value.db_user }}
DB_PASSWORD={{ item.value.db_password }}
DB_HOST={{ item.value.db_host }}
DB_PORT={{ item.value.db_port }}
DB_PREFIX={{ item.value.db_prefix }}
...

this means also setting a default value for DB_HOST and DB_PORT if not otherwise specified in the vhost definition in order to not break existing configurations.

to make a sure test we need to take down MySQL on the node which currently has the VIP address.

from appside.

ivomarino avatar ivomarino commented on July 29, 2024

For default vars we should http://stackoverflow.com/a/42109037.

from appside.

ivomarino avatar ivomarino commented on July 29, 2024

with commit 8656fba we've introduced db_connection_host var for vhost definitions:

    ...
    serveradmin: [email protected]
    db_name: foo_wp
    db_user: foo_wp
    db_password: RANDOM
    db_connection_host: mysql.local:3307 <- IF NOT GIVEN FALLBACK to mysql.local
    db_host: '%'
    db_prefix: foo_
    glusterfs_uploads: foo
    ...

this means all vhost definitions, where multiple nodes via PXC are involved, need to have this definition, this is not the case for hosts with a single MySQL instance like atlantis but for correctness we should define db_connection_host: mysql.local there.

from appside.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.