This is a major wtf for new users. Our install script doesn't support local mysql connexions: it always goes through the network through the magic name resolution thingy. While it's good for multi-server setups (but we don't even support that in the installer) it makes things utterly painful during the original install.

here's a typical install run:

aegir@angela:~$ sh install.sh aegir.angela.anarcat.ath.cx --client_email=anarcat@anarcat.ath.cx
==> Aegir 0.4-alpha14 automated install script
==> MySQL is listening on 127.0.0.2.
==> This script makes the following assumptions:
 * you have read INSTALL.txt and prepared the platform accordingly
 * you are executing this script as your "aegir" user
Do you want to proceed with the install? [Y/n]
==> Aegir will now generate a mysql super user password for you:
  Username : aegir_root
  Password : 5dd9154acd53f435ebbf9ca0fe32353e
  Hostname : angela (127.0.0.2)

You will be asked to enter your mysql root user password now :
Enter password:
/usr/bin/drush
==> Drush is in the path, good
[...]
==> Installing the frontend
Project drush_make (6.x-2.0-beta9) downloaded to /var/aegir/.drush/drush_make.                                                                                [success]
The external command could not be executed due to an application error.                                                                                       [error]
Provision configuration path /var/aegir/config/server_master does not exist.                                                                                  [warning]
Backup path /var/aegir/backups does not exist.                                                                                                                [warning]
Provision PHP configuration path /var/aegir/config/includes does not exist.                                                                                   [warning]
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'angela' (111)                                                                                        [error]
Drush command could not be completed.                                                                                                                         [error]
Output from failed command :                                                                                                                                  [error]

Fatal error: Call to a member function quote() on a non-object in /var/aegir/.drush/provision/db/db.drush.inc on line 315

An error occurred at function : drush_provision_hostmaster_install                                                                                            [error]

Disregarding the cryptic error message that yields, we notice that we can't actually connect to that mysql server, even though the mysql server is up and runnin, and that hostname resolves (it resolves to 127.0.0.2, a common configuration for debian and ubuntu).

The workaround, here, is to change /etc/hosts from this:

127.0.0.1 localhost
127.0.0.2 angela.anarcat.ath.cx angela aegir.angela.anarcat.ath.cx aegir

to this:

127.0.0.1 localhost angela.anarcat.ath.cx angela aegir.angela.anarcat.ath.cx aegir

I think we shouldn't require such a change.

Furthermore, people that have "skip-networking" in their mysql configuration (also a common security measure taken by sysadmins) will notice it's simply impossible to install aegir at all, even if we use "localhost" as a hostname.

My take on this is that we should try to have better heuristics to guess the location of the mysql server. "localhost" should not be resolved and use sockets. If a hostname resolves to something within 127.0.0.1/8, we should also try "localhost" for the mysql server.

We can prompt the user for more info, and we can also take --db_server as an argument, which would incidentally allow for remote db servers installs.

Let's keep in mind that *all* UNIX hosts are at least dual-hosted: they have a network card of some sort and a loopback interface. Sometimes also a dedicated interface for a private lan. It is *very* common to have private services (mysql, nfs, etc) hosted on that private interface (lo or eth1) and we should support such a scenario. This may mean reorganizing the ip_addresses listing, but it will also solve major problems that are sure to happen with conflicts between mysql (which require a private IP), apache_ssl and DNS (which require a public one).

Maybe we want to have two sets of IPs? Or one set per interface?

Comments

anarcat’s picture

thinking more about this, i believe a simple fix to workaround this would be to:

1. not resolve the hostname when connecting through mysql (mysql can do that itself)
2. add a --aegir_dbhost parameter to hostmaster-install to allow installs on localhost dbs or remote dbs

this will cover all use cases and would be the simpler scenario.

lavamind’s picture

+1 on this issue.

In my specific case, I need to have Aegir connect to MySQL through 127.0.0.1 exactly (not localhost). However the Aegir installation assumes that my database is listening on $hostname, which obviously points to my public IP...

anarcat’s picture

anarcat’s picture

Status: Active » Fixed

If you're using the latest head, you can use the --aegir_db_host=localhost parameter (regardless of the FQDN setting) to install to localhost, and this will use sockets.

Anonymous’s picture

That is unreal - finally it is Saturday and I will test the helll out of this stuff.

We should make sure that this usage is documented in the INSTALL.txt (even as a 'Use Case: localhost' example) as a lot of users will want to do it like this.

anarcat’s picture

I suspect in fact that --aegir_db_host=localhost should be the *default*... :P But maybe we can let things stand as they are right now, because that would mean we would have two servers by default, and that may not be desirable for some reason i don't quite get.

See #977024: make "localhost" the default db host for followup on this conversation.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.