Moodle 3 (stable) Migration from Debian to CentOS 7

Moodle 3 (stable) Migration from Debian to CentOS 7

by Malik Koné -
Number of replies: 11

Hello,

I've been playing with moodle for several years and managed to install, upgrade it without problem on Debian and Ubuntu.

But lately I need to migrate my website on Centos7 where I have a cpanel installed.  I followed the usual step,

  • mysql db dump,
  • mysql db restore (with user have right credential)
  • transfering moodledata, 
  • getting moodle core code for git
  • updating the config file
  • and trying to update or install

Doing so I run in the following database compatibility issue.  I guess it has to do with my CentOS 7 php configuration but I don't know how to correct it.

Debug info: Error code: dbdriverproblem Stack trace: line 419 of /lib/dml/mysqli_native_moodle_database.php: dml_exception thrown line 344 of /lib/dmllib.php: call to mysqli_native_moodle_database->connect() line 615 of /lib/setup.php: call to setup_DB() line 829 of /config.php: call to require_once() line 87 of /admin/index.php: call to require()


Please help me

Thank you

Average of ratings: -
In reply to Malik Koné

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Do you have the correct setting in config.php for your database type (especially if you have swapped from mysql to mariadb or the reverse) and is the correct PHP module installed for your database. If it's cPanel then one would think that PHP should be set up properly for the supplied database but you never know!

In reply to Malik Koné

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Ken Task -
Picture of Particularly helpful Moodlers

Since you've used git to acquire code, that means you have command line and can use it. smile   Soooo ... a little more info is needed.     Is your CentOS 7 server a VPS or on a shared host (multpile customers).  If remotely hosted what provider? (the only reason for asking this is simple ... not all hosting providers do things the same way).

What is displayed for the following commands:

php -v

php -m |grep mysql

mysql -V

In the following, if you post back the info, do not include DB user or DB password.   From the code directory of Moodle or from any location:

fgrep 'db' /path/to/moodle/code/config.php

And the following might sound un-needed but it is:

yum repolist

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Malik Koné -

Thank you Ken for asking.

The website is hosted on a VPS from OVH. 

#php -v

PHP 5.5.32 (cli) (built: Mar  7 2016 23:28:56)

#php -m | grep mysql

mysql
mysqlnd
pdo_mysql

#mysql -V

mysql  Ver 15.1 Distrib 10.0.24-MariaDB, for Linux (x86_64) using readline 5.1

#grep 'db' config.php

$CFG->dbtype    = 'mariadb'; // I tryed with mysqli too
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'mydbname'; // database name, eg moodle
$CFG->dbuser = 'mymdldbuser'; // your database username
$CFG->dbpass = 'mymdldbuserpwd'; // your database password
$CFG->dboptions = array(
'dbpersist' => false, // should persistent database connections be
'dbsocket' => false, // I tryed with true also.
'dbport' => '', // the TCP port number to use when connecting

#yum repolist

Loading mirror speeds from cached hostfile
* base: mirror0.babylon.network
* extras: mirror0.babylon.network
* updates: mirror0.babylon.network
id du dépôt nom du dépôt statut
!MariaDB100 MariaDB100 14
!base/7/x86_64 CentOS-7 - Base 8 964+43
!extras/7/x86_64 CentOS-7 - Extras 226
!updates/7/x86_64 CentOS-7 - Updates 846+2
!vz-base vz-base 1
!vz-updates vz-updates 0
repolist: 10 051


I'm new to CentOs but it seems from the last commande that MariaDB repositories are not upto date.

Finaly,  I think it's a php.ini issue.  But I don't know how to find it and correct it.  I've check the php.ini and I do have an extension loaded pdo_mysql.so.  But is it the correct one?

Thank you
In reply to Malik Koné

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Ken Task -
Picture of Particularly helpful Moodlers

Let's IF the mariadb daemon (server) is running:

ps aux |grep mysqld

Yes, mysqld ... mariadb is a dropin replacement for MySQL and the commands
used for MariaDB are the same as for MySQL.   Even the daemon (server) is
or appears to user as a MySQL server.

If you get no response from the ps command above ... ie, displays
nothing, then you'll need to use one of your control panels to start the
MariaDB service.   That will then require setting up a superuser for
the DBs and might even setup a DB user for Moodle as well.

Starting that on localhost, then, your config.php file for Moodle
would change:
dbtype would still be mariadb
dblibrary would still be native
dbhost = localhost
Then ... of course, the settings for dbuser, dbname, dbpassword also.

You might have SELinux running also which will mess with
apache's ability to read moodledata.
What does sestatus show?

If it says 'enforcing' I'd set SELinux to run 'permissive'.   That will require reboot of box.

Not sure what the ! are in front of repos ... could be something new on CentOS 7 with yum.

They could indicate those repos are currently NOT enabled - which is fine.   The last thing you need is conflicts with software packages from two or more repos.

So try this repo command:

yum --enablerepo=* list mariadb*

Looks like you need to read up/study OVH's docs for customers.

'spirit of sharing', Ken



In reply to Ken Task

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Malik Koné -

mysqld is up and running.

I agree it looks more like a host or cpanel issue than a moodle one.

Thank you

In reply to Malik Koné

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Ken Task -
Picture of Particularly helpful Moodlers

Well, if mysqld (mariadb) is running you should be able to connect to it via command line as a test.

mysql -u root -p[password]

User might be different than above.  If you can't do that then MariaDB isn't quite setup.  Might be running with no users/host setup.

'spirit of sharing', Ken

In reply to Malik Koné

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Olumuyiwa Taiwo -
Picture of Plugin developers

The error message points to a missing 'mysqli' driver. That is confirmed by the output of the 'php -m | grep mysql' command. 

How you install/enable it will depend on your operating system/control panel - a Google search should help.

If you can't be bothered installing/enabling 'mysqli' driver, you can use the 'mysql' (or 'mysqlnd') driver since that is enabled. Simply set 

$CFG->dbtype = 'mysql';

in your config.php

In reply to Olumuyiwa Taiwo

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Ken Task -
Picture of Particularly helpful Moodlers

My 2 cents, of course ...

Think it best to set it up right rather than do any work-around.  Isn't pointing to 'mysql' really pointing to the mysql client app?

In the past, I've always chosen to use the mysqli vs what RH and CentOS wanted to do ... mysqlsnd

Maybe we need to get a peek at config file for MariaDB:

cat /etc/my.cnf

You don't need to copy and paste all of my.cnf in here ... just check it out ... see if there are comments at the top of the config file specific to MariaDB.   File should also provide links for more information.

One thing you should see:

# The MariaDB server
[mysqld]
port        = 3306
socket        = /var/lib/mysql/mysql.sock

From what I've read about MySQL/MariaDB, if DB server is set to localhost, it actually uses socket connection and not the port.   Which would make sense to me ... no sense sending queries to the port to have to loop back inside to the server.   The port is there in case the sys OP wanted to allow a client app connection to the DB server.   Have always found it more secure to use ssh to login to the server and then use the client app on the server rather than have to contend with more pokes and probs from all of internet.

'spirit of sharing', Ken


In reply to Ken Task

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Olumuyiwa Taiwo -
Picture of Plugin developers

My last suggestion won't work. I just checked the Moodle code, and only 'pgsql', 'mysqli', 'mssql' or 'oci' database drivers are supported - it seems this has been the case since 2.0. I must have dozed off at some point smile

Therefore if you're using MySQL, you'll have to enable the 'mysqli' driver. 

It should already be installed in Centos 7 (the rpm package is named php-mysqlnd or similar), and you probably only need to enable it. Look in /etc/php.ini or /etc/php.d/nn-mysqli.ini for a line that like

extension=mysqli.so
Alternatively, considering that you have CPanel installed, you may have to recompile EasyApache in WHM, selecting the option MySQLi in "exhaustive options list" in order to get it to work.
In reply to Olumuyiwa Taiwo

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Ken Task -
Picture of Particularly helpful Moodlers

This from a CentOS 6 server that host four instances of Moodle by a different hostname but same domain name.  1 DB server ... that of MariaDB

ps aux |grep mysqld

In the process output it shows what appears to be mysql but, in fact, is really MariaDB ... a drop-in replacement for MySQL. The only thing changed below is the site (host name):

root     26607  0.0  0.0 106192  1168 ?        S    Feb25   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/site.pid
mysql    26751  3.0 46.2 24018524 22853512 ?   Sl   Feb25 591:07 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/site.err --pid-file=/var/lib/mysql/site.pid --socket=/var/lib/mysql/mysql.sock --port=3306

It looks like MySQL but it's not:

mysql -V shows:
mysql  Ver 15.1 Distrib 10.0.24-MariaDB, for Linux (x86_64) using readline 5.1

config.php files for the 4 instances running on this site show:

fgrep '$CFG->dbtype' ./*/config.php
./site1/config.php:$CFG->dbtype    = 'mariadb';
./site2/config.php:$CFG->dbtype    = 'mariadb';
./site3/config.php:$CFG->dbtype    = 'mariadb';
./site4/config.php:$CFG->dbtype    = 'mariadb';

Even the .so files are not named for MariaDB, but, rather, mysql, mysqli, mysqlnd.

Using the client to connect to server shows:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1404490
Server version: 10.0.24-MariaDB MariaDB Server

All 4 sites are running just fine.   No issues with DB.

We've not heard back from Malik and his communications with the hosting provider and their setup of his server.  Sounds like whatever control panel is being used is confusing OP or the configuration ... dunno as this is VPS on OVH.

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle 3 (stable) Migration from Debian to CentOS 7

by Malik Koné -

Thank you and sorry for the delay in my response.  You guessed it. I had resolved my issue.

It had to do with php.  I was missing a mysql module.  I installed it with cpanel and every thing worked fine.


Thank you.