cancel
Showing results for 
Search instead for 
Did you mean: 

Moving data directory - postgresql could not be started

chrisokelly
Champ on-the-rise
Champ on-the-rise
A background of the situation - We have alfresco 4.0.d set up on ubuntu/tomcat/postgres. Originally, during testing, the contentstore was at /opt/alfresco/alf_data. I copied the directory as a whole to /mnt/alf_data and modified the alfresco-global.properties->dir.root property to match.
This appeared to work - restarted the server, could see the files in the repository and the test spaces which had been setup. It was only later in the day I noticed a red "Could not Retrieve tags" warning. This was accompanied by -
org.alfresco.repo.search.impl.lucene.LuceneQueryParserException: 03110615 Request failed 404 /solr/alfresco/alfresco?q=PATH%3A%22%2Fcm%3Ataggable%22&wt=json&fl=*%2Cscore&rows=2147483647&df=TEXT&start=0&locale=en_US&fq=%7B%21afts%7DAUTHORITY_FILTER_FROM_JSON
when trying to add a tag.
I changed /opt/alfresco/alf_data to /opt/alfresco/alf_data-old to see if it was related to the old or the new directory and restarted the server again - big problems. Postgres was unable to start, referring to a missing .conf file. I have found a few possible causes of this issue so far (obviously they weren't the whole problem as it persists) -

1 Permissions - as I used sudo cp to move the files they were all owned by root. In the original location this was actually par for the course, excepting the postgresql directory all the files and folders in alf_data were owned by root. I used "sudo chown -R postgresSmiley Tongueostgres postgresql/" inside the new directory and made sure that it was set up for 0700 permissions.
2 postgres configuration - in /opt/alfresco/postgresql/scripts there was a script called ctl.sh which seems to be hardcoded to the original alf_data location. I didn't do the initial install of our setup so unfortunately I can't say for sure where this came from but I'd hazard a guess that it was generated by the web quick start installation. Towards the very top of this file 2 variables are defined -
POSTGRESQL_PIDFILE=/opt/alfresco/alf_data/postgresql/postmaster.pid

POSTGRESQL_START="/opt/alfresco/postgresql/bin/postgres -D /opt/alfresco/alf_data/postgresql -p 5432"

so I changed this to
POSTGRESQL_PIDFILE=/mnt/alf_data/postgresql/postmaster.pid

POSTGRESQL_START="/opt/alfresco/postgresql/bin/postgres -D /mnt/alf_data/postgresql -p 5432"

then saved and restarted the server.

It still gives me, in the logs -
/opt/alfresco/postgresql/scripts/ctl.sh : postgresql  could not be started
I have looked through /postgresql/scripts/ctl.sh and found the command to start postgres -
 su postgres -c "$POSTGRESQL_START &"
and tested it
sudo su postgres -c "/opt/alfresco/postgresql/bin/postgres -D /mnt/alf_data/postgresql -p 5432"
which works fine (or at least, does not return an error).

It seems to me that somewhere, in some script, the path to alf_data has been hard coded, rather than referenced from dir.root, however I'm stumped as to where and why it is that postgres cannot start. Any thoughts or pointers appreciated

Edit:

We never fully figured out the problems with pointing the data.dir at another folder. I wouldn't suggest it unless you have a good set of backups at your disposal. What we did to get around this, in case it helps anyone else, was to reinstall alfresco (we used the linux quick installer, if you do too you'll need to select no when it asks at the very end whether you would like to start the alfresco service). After installing, our process was as follows -
-mount the network location to be used as data directory in a temporary location. For us,
sudo mount ip.address.of.nas:/alf_data /opt/alfresco-4.0.d/alf_data_mount
-copy the files from the installation alf_data to the new data directory. Again, the command for us was -
sudo cp -p -r alf_data/* alf_data_mount/
-Make sure the Owner/Group/Permissions match between the two folders (especially /postgres)
-unmount the new data dir. ours -
sudo umount ip.address.of.nas:/alf_data
-remount it at the original data directory location -
sudo mount ip.address.of.nas:/alf_data /opt/alfresco-4.0.d/alf_data
-If you are using SOLR, set it up now, following the Wiki. Delete the existing Index stores as it will need to rebuild them on first startup.
-Start Alfresco -
sudo ./alfresco.sh start

It seems, at least with the quick installer, that a few items are hardcoded to the original alf_data directory. This turned out to be the easiest way (for us) to have a mounted resource as a data directory. I'm sure we could have eventually sorted out the various scripts pointing to this location but I figure this way, from the Alfresco Server's perspective, the data dir will always be the same one it was installed to use.
1 REPLY 1

mathias_lin
Star Contributor
Star Contributor