error/hashpoolproblem migration

error/hashpoolproblem migration

by Omar Al Sayyed -
Number of replies: 21

Hi All

I copied my moodleData from another server and I import the database too , and I gives the right permission,but I can not access any file and picture from the new server


Old server fedora 20 and the new fedora 23 and same sql version on both servers.

Any help for migration 


Average of ratings: -
In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Albert Ramsbottom -

What about the moodle application folder? in particular the moodle config file??

Albert

In reply to Albert Ramsbottom

Re: error/hashpoolproblem migration

by Omar Al Sayyed -


all the date setting well,, the database name and password, and the wwwroot


$CFG->dbtype    = 'mysqli';

$CFG->dblibrary = 'native';

$CFG->dbhost    = 'localhost';

$CFG->dbname    = 'XXXXXX';

$CFG->dbuser    = 'root';

$CFG->dbpass    = 'Password';

$CFG->prefix    = 'mdl_';

$CFG->dboptions = array (

  'dbpersist' => 0,

  'dbsocket' => 0,

);

$CFG->wwwroot   = 'http://'.$_SERVER['SERVER_NAME']."/XXXX";

$CFG->dataroot  = '/var/XXXXdata';

$CFG->admin     = 'admin';

$CFG->directorypermissions = 0777;


In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Ken Task -
Picture of Particularly helpful Moodlers

So server(s) are on a local network (private?).

Are both using DHCP?   Don't have either servers in DNS?

See you are attempting to use $_SERVER['SERVER_NAME']

On new server, create a small php file at the document root of apache
where the moodle code now resides that contains:

<?php 
echo $_SERVER['SERVER_NAME']; 
?>

Save it as test.php and make sure it's owned by apache user/group.
It doesn't need to be executable.

If the old server is still on network, do the same on that one.

Then use browser from a workstation ... ie, not browser on server (either).

What was response on the old server for that variable?
What was response on the new server for that variable?
Are they the same?

See: http://www.w3resource.com/php/super-variables/$_SERVER.php

Moodle is unique in that it uses that variable for every internal link to that moodle instance - which includes images - and records them all in tables of the DB.   That's why search/replace is needed when moving a moodle to another server IF new server has a different FQDN, etc..


'spirit of sharing', Ken


In reply to Ken Task

Re: error/hashpoolproblem migration

by Omar Al Sayyed -

hi Ken

I made as you mentioned about test php for server name and the results point to right names

the old server name is xxx.xxx.xxx.xx and is online and the second one on my local network

I copied the online server into local one ,when i run the test.php on local it to point the local IP address

I make the replace.php and work fine. when I want to download any file a message (error/storedfilecannotread

I check database Mdl_files the files is there and the contenthash is right and point to files locations

any help

In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Ken Task -
Picture of Particularly helpful Moodlers

confirm that the 'contenthash' you see when checking tables in DB is actually in moodledata/filedir/

The contenthash value: 1st two characters should be a directory in moodledata/filedir/

Example contenthash value begins with 04by

In moodledata/filedir/ there should be a '04' directory and inside that there should be another directory 'by'

Then, inside /moodledata/filedir/04/by/ there should be a file that begins with the same characters ... 04by... and then a string of characters/numbers.

When a link in Moodle goes to a file of somesort, the link you see is generated from the DB ... actually tries to access a file such as described above, but you see the filename as it has recorded in the row of mdl_files of that contenthash value.

Also check the ownerships/permissions on moodledata and all it contains.   The moodledata directory and all it's contents should be readable, writable by the web server user.   On a Linux CentOS or RH family boxen that user is normally apache:apache ... on typical Ubuntu/Debian www-data ... on Winders?

If the above checks out .. turn on debugging and attempt to access a link to a file.   If debugging reports something/anything, copy that text to the clipboard of your workstation, paste it into a text docment (NOT word) so you can obscure what needs to be obscured.    Then come back here with a response and paste the errors from the text file.  (if I were you, I'd save the text file as something like errors[date].txt in case you have to do more things like this ... you have a running record then (so to speak).

Ken


In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Did the url change?  Have you run replace.php?  Is your config file pointing to the correct location for your moodledata folder?

In reply to Emma Richardson

Re: error/hashpoolproblem migration

by Omar Al Sayyed -

hi Emma

I copied the website to a newer server(it is locally on my network)

I did not know how to user replace.php ...the config file is right pointing to location of moodledata


Please emman help me ,,,you helped me before in LDAP setting


many thanx too all

In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

1.  Check that config.php is also pointing to new url of site.

2.  Go to yoursite.com/admin/tool/replace/index.php and put the old url and new url in where indicated.  This will then search your database (BACKUP YOUR DATABASE BEFORE DOING THIS) and make the changes.

3.  Clear caches again and then see if it is working correctly.  You might need to clear your browser caches too.

In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Albert Ramsbottom -

Does apache work on your new server?

Did you see the "It works" page


You need to explain what is happening? what error in the browser? What is in your Apache log files?

Apache needs to be configured as well for a moved site

Does your new server even have a web server on it?


Cheers

Albert

In reply to Albert Ramsbottom

Re: error/hashpoolproblem migration

by Omar Al Sayyed -


Thnak you Ken

I cleared the caches,and no results,I gave the folders in filedir owner for apache with 0777 and for files inside the folders for apache with 0755 and also no results and with 0777 no results. can you advise me step by step to give the permission .also I made same as old moodle site permissions and no results

note : old moodle on fedora 20 and the new one is on fodora 23 with same http version

The contenthash value is pointing to right folder and subfolder and to the file,,

I don know how to set the permissions right ,,any help


there is a folder named 6c and e0 and inside it the file

Attachment DB File.PNG
In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Ken Task -
Picture of Particularly helpful Moodlers

First, learn your own poison ... Fedora 23.
I can't seem to find docs for that version but here are docs for Fedora 22
https://docs.fedoraproject.org/en-US/Fedora/22/html/System_Administrators_Guide/ch-Web_Servers.html#s1-The_Apache_HTTP_Server

IF 23 is same as 22:

fgrep 'User' /etc/httpd/conf/httpd.conf
You'll get several lines finding the term 'User' (case sensitive).
What you are looking for is a line that should be:

#  . On SCO (ODT 3) use "User nouser" and "Group nogroup".
User apache  <- this one

Do that same for 'Group'.

On Fedora, the user:group for the user that runs apache web service (called httpd) should
be apache:apache

If you don't see that then stop ... do not do the rest of this.

cd /path_to_moodledata/ (where you can see 'moodledata' directory - ***might/should be in /var/www/ on a stock Fedora box.***   Your config file clip shows /var/XXXXdata.   Apache should already have access to /var/www/.    The html directory is where the moodle code resides.   Suggest 'moodledata' should be in /var/www/ to assure the apache user and the apache group can have access.

Then issue the following command:

chown apache:apache moodledata -R

That sets User:Group to 'apache' for the moodledata directory and does so recursively ... i.e., all
directories/files in moodledata.

Then:

chmod ugo+rw moodledata -R

This makes sure that user (apache), group (apache), others can both 'read' and 'write' to everything in
moodledata.

The clip of the phpMyAdmin reference to the contenthash/file shows 'draft'.
Suggest editing the link to that file in Moodle to see if the icon for the file shows while editing.
No need to change anything really IF the file (Presentation1DB.ppt from your clip) appears to be there.
Just save the link.
Then see if one can access it ...

One more item ... is seLinux running?   That would cause problems as well - especially considering you've moodledata in /var/

To find out:

/usr/sbin/sestatus

as root user

'spirit of sharing', Ken

In reply to Ken Task

Re: error/hashpoolproblem migration

by Omar Al Sayyed -

Hi Ken

just one file can be access and download and other files same problem,

I tried to edit files there is a problem (error/hashpoolproblem) and also when to add  any file (resource )

the error appears

I wondering why just one file can access not all files

I did all things you told me

many thanx again Ken

 

In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Ken Task -
Picture of Particularly helpful Moodlers

Am not sure you've done all things suggested ... here's why ...

In a previous response you showed clips of screen shots from PHPMyAdmin.   That shows what's in the database ... reference to contenthash.   BUT did you then confirm that file actually did exist from the command line ... did you find a moodledata/xx/xx/contenthash file?

Have asked about seLinux ... on or off?

Am beginning to think that you might need to start over in creating a sandbox/clone of your production server onto a private clone of the production site for testing/tinkering purposes.

A migration consist of the code directory, the data directory, and an sql dump of the DB.

Since it's on the same family of server this shouldn't be that difficult.

Does the production server work?

'spirit of sharing', Ken


In reply to Ken Task

Re: error/hashpoolproblem migration

by Omar Al Sayyed -

Hi Ken

thanx for ur reply

Yes the files is there (all the files are in /var/mooldedata) all the files are 3 and one jpg file

when I changed as you advise the  permissions just one file can be read. the selinux is active.

i will tell you what finally I want, I need to make a backup server for all I have in this server

( lms.uop.edu.jo ) ( lms.uop.edu.jo/gp ) ( lms.uop.edu.jo/itsaf ) and many site on this

Please take a look on it, When my main server is down I can use the backup server.

I copied the code and data directory in binary and export the sql

 

In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Ken Task -
Picture of Particularly helpful Moodlers

Please clarify ... each moodle site (lms, gp, itsaf - maybe others you've not mentioned) has a *separate* moodledata directory.  

In the config.php file for lms, as an example, has $CFG->dataroot variable pointed to a unique data directory for the lms site.

Is that correct?

OR ... do all sites have their $CFG->dataroot variable pointed to the *same* /var/moodledata/ directory?

If the case is the latter (the OR above), that's the problem and error report you are seeing.

Each Moodle site must have it's own (unique, not shared) moodledata directory.

The contenthash calculation that each Moodle instance uses is unique to the site and won't match the contenthash calculation that another instance of Moodle would calculate, even if on same host.

What you are seeking is what sounds to be 'fail-over'.    That's a totally different situation.   If the entire server fails, for some reason, you'd have to have another IP addressed server that has rsynced the entire web root + data directories + databases for each site.   Only  change to DNS and firewalls would be needed to 'cutover' to the 'backup' server.   It would not be instant.  DNS changes take time to propagate (ie, get out to other DNS servers).

IF, however, it's just one Moodle instance that fails, that changes the picture and how one goes about 'fail-over'.   IF this is what is desired, each site could rsync code directory, data directory, and database by a slightly different name, to other directories on the server.   Apache config would then need to have changes made so that access to say the failed gp site points to it's rsync'd directory.   The one file that shouldn't be rsync'd every time rsync runs is config.php cause it would have paths, db, etc. pointing to the 'cloned' code, data directory, and database by a slightly different name.

The above is a basic idea.

'spirit of sharing', Ken


In reply to Ken Task

Re: error/hashpoolproblem migration

by Omar Al Sayyed -

He Ken

Yes, I have for each site it own directory var\gpdata , var\lmsdata .....

and each site has his own database 

in each site config.php pointintg to their data and data base.

NOW : I want to install Redhat or centos (which one you refer) and sync all my sites code and data and database .

can you put me in first step and continue with you

Many thanx

In reply to Omar Al Sayyed

Re: error/hashpoolproblem migration

by Ken Task -
Picture of Particularly helpful Moodlers

Do you still have the errors?   Must fix those before thinking about moving otherwise the move brings along the errors.   RedHat or CentOS or whatever, won't automagically fix it/them.

Fedora is Linux and could do rsync as well.

Can offer 2 cent opinion on RHEL or CentOS ... up to you ... RH is commercial - entitlement required to get updates to the OS and, other than having a company to contact for technical issues, really isn't any better than CentOS ... which is based upon RHEL but no RH eye candy and no licensing/entitlement cost/issues.    But, with free there comes ... slightly behind latest/greatest and slightly behind on updates/upgrades to PHP, etc..   With CentOS one has to use 3rd party repos for things like PHP 7 which RHEL doesn't normally provide with their boxen.  Managed boxen ... ie, they (whomever 'they' is) do the OS updates/fixes/patches/firewall, etc. cost.  Un-managed means you do.

But ... CentOS is 'long term support' ... version 6 of their OS supported for fixes until November 30, 2020.   and 7 until June 30, 2024

https://wiki.centos.org/FAQ/General

The above is your first step.

Remember, however, these forums shouldn't be used for CentOS server admin 101/installing the OS from scratch, etc..    For that, one could find many blogs out there ... just Google for them ... tons!

'spirit of sharing', Ken

In reply to Ken Task

Re: error/hashpoolproblem migration

by Elliott Benzle -

Hi, I found this post as I was having the same problem after transferring to a new server. My solution was to move the moodledata directory to /var/www/html/ previously it was in /var/moodledata

Hope that helps.


In reply to Elliott Benzle

Re: error/hashpoolproblem migration

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Please reconsider!

You have moved your moodledata into your web root and as such have made it entirely open to public access.

In reply to Richard Oelmann

Re: error/hashpoolproblem migration

by Elliott Benzle -

Hi Richard,

Actually my server is setup so the web root is /var/www/html/lms/ so the /html/ directory is not visible to the public.

Thanks for noting that though, I understand that for most users this would be publicly available and they should probably put it in/var/www/ or one directory under their root Moodle installation.

Average of ratings: Useful (1)
In reply to Elliott Benzle

Re: error/hashpoolproblem migration

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Phew! - but that might have been useful to note in a post that offers a 'solution' to the problem noted previously, for the benefit of future readers, even if you understand the process yourself smile

Note for those future readers: One directory under root Moodle may still be available to public on the web - just because Moodle is installed in a sub-directory does not prevent the rest of /var/www/html being accessible. That would be controlled by something such as .htaccess or some other set of web-server rules (which Elliott has done by setting the server webroot up to the /lms subfolder rather than the more usual default /html). For future readers, please ensure that your moodledata is outside a web-reachable location, depending on your system (it can even go in the main moodle code folder - and is set up that way by some hosting 'one-click' solutions - provided that location is then protected from public access through the .htaccess file or similar restrictions - but its definitely NOT recommended!)


Richard