*** THIRD AND LAST UPDATE ***
Excuse me very much, the error was highly stupid: I modified start.conf and changed it to manual. I thought that it was related to the start of the service at init, not to the start of the cluster at the service start...
*** SECOND UPDATE ***
I gave up and reset completely postgres, as suggested in this thread. Even after this reset I was not able to use the "main" cluster, I had to remove and reinstall it. Now it works, but I don't understand what happened.
I think that @Pjack was on the right track, the problem was probably be that postgres thought the clusters were already running, or the ports were already used. If the problem comes up again I'll investigate more deeply.
*** UPDATE ***
I tried also to remove and reinstall postgres and postgis but it doesn't work. This is what I've done
sudo apt-get remove postgis libarmadillo3 libdap11 libdapclient3 libepsilon0 libfreexl1 libgdal1 libgeos-3.3.8 libgeos-c1 libgfortran3 libhdf4-0-alt libhdf5-7 liblapack3 libnetcdfc7 libodbc1 libpq5 libproj0 libspatialite5 libxerces-c28 odbcinst odbcinst1debian2 postgresql-9.1 postgresql-9.1-postgis postgresql-client-9.1 postgresql-client-common postgresql-common proj-bin proj-data
A strange message was showed up during uninstall:
Removing postgresql-common ... * No PostgreSQL clusters exist; see "man pg_createcluster"
Of course I have created a cluster when I installed postgres. I tried to install a new cluster 'test' and it works, but I obviously I can't access any database of the other clusters.
I can't connect anymore to my Postgres databases. Trying to access it gives me the usual error:
psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?
Starting the postgres service gives me no error, and there's no error in var/log/postgresql/ , but checking the status gives me:
9.1/main (port 5432): down 9.1/postgres (port 5433): down
while usually I have port 5433 up, and
netstat -l | grep postg gives me no result.
From the last time it worked and now, I tried to dump OpenStreetMap data inside a postgis db. The only "dangerous" things that I could have done was changing these postgres settings:
shared_buffers = 944MB checkpoint_segments = 20 maintenance_work_mem = 256MB effective_cache_size = 1889MB checkpoint_completion_target = 0.9
and adding in /etc/sysctl.conf
as suggested on postgres documentation for tuning-up the db performance. Anyway I reverted all the changes, using the default values or commenting added lines.
The second thing I've done was that I executed osm2pgsql to dump the data, using:
sudo stop lightdm osm2pgsql -r pbf -C 3200 --slim -G --tablespace-main-data main-data --tablespace-main-index main-index --tablespace-slim-data slim-data --tablespace-slim-index slim-index toscana.pbf
I don't know if osm2pgsql did something dangerous, but I don't think so... What could have happened?
I'm using Postgres 9.1 + Postgis 2 on Lubuntu 13.04 32 bit on local, using a peer authentication and a Unix socket.