Coder Social home page Coder Social logo

Comments (12)

szazs89 avatar szazs89 commented on August 15, 2024 1

I have also tried to migrate from sagemathinc/cocalc to sagemathinc/cocalc-v2 and the suggested method was not very clear to me...
So, what I did at the old server:

docker exec -it old-cocalc-container bash
kill -9 `head -1 /projects/postgres/data/postmaster.pid` # check with ps axf...

PG10=/projects/postgres10
PG14=/projects/postgres
cp -a /projects/postgres $PG10
rm -rf /projects/postgres/data/*  # does not need chown / chmod :-)
apt-get update && apt-get install postgresql-14

PG10_BIN=/usr/lib/postgresql/10/bin
PG14_BIN=/usr/lib/postgresql/14/bin
sudo -u sage $PG14_BIN/pg_ctl init -D $PG14/data
sudo -u sage $PG14_BIN/pg_upgrade -d $PG10/data -D $PG14/data -b $PG10_BIN -B $PG14_BIN
cp -a $PG10/data/{socket,pg_hba.conf} $PG14/data/
tail -3 $PG10/data/postgresql.conf >> $PG14/data/postgresql.conf
exit
docker stop old-cocalc-container

Run the new container using cocalc-v2 image.
Ta-da...

from cocalc-docker.

crockeea avatar crockeea commented on August 15, 2024 1

The following worked for me:

docker exec -it cocalc-server bash

PG10=/projects/postgres10
PG14=/projects/postgres
PG10_BIN=/usr/lib/postgresql/10/bin
PG14_BIN=/usr/lib/postgresql/14/bin

sudo -u sage $PG10_BIN/pg_ctl stop -D $PG14/data

cp -a /projects/postgres $PG10
rm -rf /projects/postgres/data/*  # does not need chown / chmod :-)
apt-get update && apt-get install postgresql-14

cd /tmp
sudo -u sage $PG14_BIN/pg_ctl init -D $PG14/data
sudo -u sage $PG14_BIN/pg_upgrade -d $PG10/data -D $PG14/data -b $PG10_BIN -B $PG14_BIN
cp -a $PG10/data/{socket,pg_hba.conf} $PG14/data/
tail -3 $PG10/data/postgresql.conf >> $PG14/data/postgresql.conf
exit
docker stop old-cocalc-container

I was getting errors about "The source was not shut down cleanly" and/or "could not open log file "pg_upgrade_internal.log": Permission denied" when using kill -9. Using pg_ctl stop seems to fix those issues. I also needed to change to /tmp instead of running the conversion command from /.

from cocalc-docker.

haraldschilly avatar haraldschilly commented on August 15, 2024

Thank you @szazs89 … this looks like a first step towards automating this. I've added a link to your instructions from the README.md file.

from cocalc-docker.

crockeea avatar crockeea commented on August 15, 2024

When running

sudo -u sage $PG14_BIN/pg_upgrade -d $PG10/data -D $PG14/data -b $PG10_BIN -B $PG14_BIN

could not open log file "pg_upgrade_internal.log": Permission denied
Failure, exiting

Suggestions?

from cocalc-docker.

williamstein avatar williamstein commented on August 15, 2024

from cocalc-docker.

szazs89 avatar szazs89 commented on August 15, 2024

@crockeea check the ownership of the directory structure (the new one and the one which the db to be migrated from...)

from cocalc-docker.

crockeea avatar crockeea commented on August 15, 2024

@williamstein That command is copied from szazs89's suggestion.

from cocalc-docker.

williamstein avatar williamstein commented on August 15, 2024

Please check the ownership of the relevant directories to see. Maybe use the user "postgres" or whatever the owner of the relevant files is.

from cocalc-docker.

crockeea avatar crockeea commented on August 15, 2024
> ls -l /projects
...
drwx------  3 sage      sage        18 Aug 26  2019 postgres
drwx------  3 sage      sage        18 Aug 26  2019 postgres10

I tried changing the owner of both directories to postgres and running the command with sudo -u postgres, but got the same error. I think the real problem was that I was running the command from /; I got farther after cd /tmp.

Now I'm getting

root@0bb1704ab603:/tmp# sudo -u sage $PG14_BIN/pg_upgrade -d $PG10/data -D $PG14/data -b $PG10_BIN -B $PG14_BIN

There seems to be a postmaster servicing the old cluster.
Please shutdown that postmaster and try again.
Failure, exiting

root@0bb1704ab603:/tmp# ps afx
  PID TTY      STAT   TIME COMMAND
   94 pts/0    Ss     0:00 bash
 3796 pts/0    R+     0:00  \_ ps afx
    1 ?        Ss     0:00 python3 /root/run.py
   20 ?        Ss     0:00 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups
   29 ?        S      0:00 /bin/bash -c mkdir -p /var/log/hub && cd /cocalc/src/packages/hub && npm run hub-docker-prod > /v
   32 ?        Sl     0:00  \_ npm run hub-docker-prod
   60 ?        Sl     0:00      \_ npm exec cocalc-hub-server --mode=multi-user --all --hostname=0.0.0.0 --https-key=/projec
   71 ?        Sl     0:14          \_ node /cocalc/src/packages/hub/node_modules/.bin/cocalc-hub-server --mode=multi-user -

from cocalc-docker.

williamstein avatar williamstein commented on August 15, 2024

"There seems to be a postmaster servicing the old cluster. Please shutdown that postmaster and try again."

I think this message is based on a pid file existing, not some actual process running. You have to find that file and delete it. It's called postmaster.pid. https://dba.stackexchange.com/questions/30949/cannot-shutdown-old-postmaster-when-upgrading-to-postgres-9-2

from cocalc-docker.

williamstein avatar williamstein commented on August 15, 2024

Thanks!!

from cocalc-docker.

crockeea avatar crockeea commented on August 15, 2024

One further note: if, in the process of doing this upgrade, you're moving /projects to another location/drive, use cp -p to preserve permissions. Otherwise, when you start the new server, your projects and files will appear but you will get an Error: EACCES, permission denied error when you try to open a file.

from cocalc-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.