Upgrade to Moodle 3.9.2 specifying data server ports.

Upgrade to Moodle 3.9.2 specifying data server ports.

by Richard Jones -
Number of replies: 4
Picture of Plugin developers Picture of Testers

Hello

I'm currently running Moodle 3.6.2+ (Build: 20190118) on CentOS with a Mariadb 5.5.52 server on localhost and PHP 7.4. 

However, Moodle now wants a higher version of MariaDB so I have installed an additional server (Mariadb 10.3) via ISP Manager which runs on 127.0.0.1:3310 and exported the database from the old and re-imported it to the new adding the required user etc.

I can't work out how to specify the database correctly in config.php.

Any help or advice would be appreciated.

Thanks

Richard

Average of ratings: -
In reply to Richard Jones

Re: Upgrade to Moodle 3.9.2 specifying data server ports.

by Ken Task -
Picture of Particularly helpful Moodlers
Typically, the setting for DB server on same machine is 'localhost' ... that in DNS is 127.0.0.1 ... and thus 'sockets' are involved.

Can your ISP manager set that newer DB server to use a higher port than what is typically the mysql/mariadb port 3306 .... something like 33306 and listening on the IP address of the server. Also check grants of new instance to assure localhost user has complete access to all databases on new DB server instance.

This might help: https://www.tecmint.com/change-default-mysql-mariadb-port-in-linux/
'SoS', Ken
In reply to Ken Task

Re: Upgrade to Moodle 3.9.2 specifying data server ports.

by Richard Jones -
Picture of Plugin developers Picture of Testers
Hi Ken

Thanks for the quick response. I can set the port myself in the ISP Manager. It seems that the additional server instance is in a docker container and that the mariadb 10.3 server within it is using TCP/IP to communicate (whereas the old server just uses a unix socket).

Are you saying that if I put the IP address directly into config.php (127.0.0.1:33306 for example) and leave the extra config of the DB (persist, port, socket) empty that should work?

Sorry your last sentence means little to me (but I'm also following up with my support desk as well so it will be useful). Confused bunny here! Still managed to get to 3.8.5 so I know the general process works and it's not something else I've forgotten.

Thanks again, the link looks very useful, I can give it a try and let you know.
Richard
In reply to Richard Jones

Re: Upgrade to Moodle 3.9.2 specifying data server ports.

by Ken Task -
Picture of Particularly helpful Moodlers

It was my understanding that if MariaDB/MySQL sees localhost in config, it means 127.0.0.1 (loopback iip address) and really uses a socket to connect - default port 3306.  Default for MariaDB/MySQL is to do a DNS check upon every client request.  So moodle code is really a client ... coming from localhost.

My suggestion was to install the second instance of DB server where it listens on the true IP address or server on a higher port not within well-known or other ports typically used by AMP stack ... 3306,80,443,22,23,25 etc. - the 33306.

In looking at a 3.8 config-dist.php file:

$CFG->dbhost    = 'localhost';  // eg 'localhost' or 'db.isp.com' or IP

which you would change localhost to the IP of your server.

In

$CFG->dboptions = array(

    'dbsocket'  => false,       // should connection via UNIX socket be used?
                                //  if you set it to 'true' or custom path
                                //  here set dbhost to 'localhost',
                                //  (please note mysql is always using socket
                                //  if dbhost is 'localhost' - if you need
                                //  local port connection use '127.0.0.1')
    'dbport'    => '',          // the TCP port number to use when connecting
                                //  to the server. keep empty string for the
                                //  default port

change those to match server config - false and if you used my suggestion dbport would be 33306.

Am sure there is a good reason, but have to ask ... why not just upgrade the DB server rather than try to run 2????

'SoS', Ken


In reply to Ken Task

Re: Upgrade to Moodle 3.9.2 specifying data server ports.

by Richard Jones -
Picture of Plugin developers Picture of Testers

Hi Ken

OK, that seems to have got it.  Also I think I needed to set the host of the Moodle database user correctly.

Thanks again.

Richard