# [SOLVED] Problem z uruchomieniem postgresa

## Lord_Raven

Witam

Mam problem z uruchomieniem postgresql-server na swoim lokalnym komputerze. Postępuje według wskazówek a wiec:

1. emerge postgresql-server

2. edycja /etc/conf.d/postgresql-9.0 (podmianka lokalów z en_US na pl_PL)

cat /etc/conf.d/postgresql-9.0

```
# PostgreSQL's Database Directory

PGDATA="/var/lib/postgresql/9.0/data"

# Options to pass to PostgreSQL's initdb.

PG_INITDB_OPTS="--locale=pl_PL.UTF-8"

# PostgreSQL User

PGUSER="postgres"

# Which port and socket to bind PostgreSQL

PGPORT="5432"

# Extra options to run postmaster with, e.g.:

# -N is the maximal number of client connections

# -B is the number of shared buffers and has to be at least 2x the value for -N

# Please read the man-page to postmaster for more options. Many of

# these options can be set directly in the configuration file.

#PGOPTS="-N 512 -B 1024"

# Allow *_TIMEOUT to run its course.

# Can be overriden by changing to '-W' (capital W)

WAIT_FOR_START="-w"

WAIT_FOR_STOP="-w"

# How long to wait for server to start in seconds

START_TIMEOUT=60

# Ignore new connections and wait for clients to disconnect from server before

# shutting down.

# Set NICE_QUIT to "NO" to disable. NICE_TIMEOUT in seconds.

NICE_QUIT="YES"

NICE_TIMEOUT=60

# Forecfully disconnect clients from server and shut down. This is performed

# after NICE_QUIT. Terminating a client results in a rollback of open

# transactions for that client.

# Set RUDE_QUIT to "NO" to disable. RUDE_TIMEOUT in seconds.

RUDE_QUIT="YES"

RUDE_TIMEOUT=30

# If the server still fails to shutdown, you can force it to quit by setting

# this to yes and a recover-run will execute on the next startup.

# Set FORCE_QUIT to "YES" to enable. FORCE_TIMEOUT in seconds.

FORCE_QUIT="NO"

FORCE_TIMEOUT=2

# Pass extra environment variables. If you have to export environment variables

# for the database process, this can be done here.

# Don't forget to escape quotes.

#PG_EXTRA_ENV="PGPASSFILE=\"/path/to/.pgpass\""
```

3. emerge --config =dev-db/postgresql-server-9.0.1

```
Configuring pkg...

 * You can pass options to initdb by setting the PG_INITDB_OPTS variable.

 * More information can be found here:

 *     http://www.postgresql.org/docs/9.0/static/creating-cluster.html

 *     http://www.postgresql.org/docs/9.0/static/app-initdb.html

 * Simply add the options you would have added to initdb to the PG_INITDB_OPTS

 * variable.

 * 

 * You can change the directory where the database cluster is being created by

 * setting the PGDATA variable.

 * 

 * PG_INITDB_OPTS is currently set to:

 *     "--locale=pl_PL.UTF-8"

 * and the database cluster will be created in:

 *     "/var/lib/postgresql/9.0/data"

 * Are you ready to continue? (Y/n)

Y

 * Checking system parameters...

 * Checking whether your system supports at least 128 connections...

 * Passed.

 * Creating the data directory ...

 * Initializing the database ...

The files belonging to this database system will be owned by user "postgres".

This user must also own the server process.

The database cluster will be initialized with locale pl_PL.UTF-8.

The default database encoding has accordingly been set to UTF8.

initdb: could not find suitable text search configuration for locale pl_PL.UTF-8

The default text search configuration will be set to "simple".

fixing permissions on existing directory /var/lib/postgresql/9.0/data ... ok

creating subdirectories ... ok

selecting default max_connections ... 100

selecting default shared_buffers ... 24MB

creating configuration files ... ok

creating template1 database in /var/lib/postgresql/9.0/data/base/1 ... ok

initializing pg_authid ... ok

initializing dependencies ... ok

creating system views ... ok

loading system objects' descriptions ... ok

creating conversions ... ok

creating dictionaries ... ok

setting privileges on built-in objects ... ok

creating information schema ... ok

loading PL/pgSQL server-side language ... ok

vacuuming database template1 ... ok

copying template1 to template0 ... ok

copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections

You can change this by editing pg_hba.conf or using the -A option the

next time you run initdb.

Success. You can now start the database server using:

    /usr/lib64/postgresql-9.0/bin/postgres -D /var/lib/postgresql/9.0/data

or

    /usr/lib64/postgresql-9.0/bin/pg_ctl -D /var/lib/postgresql/9.0/data -l logfile start

 * 

 * You can use the '//etc/init.d/postgresql-9.0' script to run PostgreSQL

 * instead of 'pg_ctl'.

 * 
```

4. /etc/init.d/postgres

```
 * Caching service dependencies ...                                                                                                                                                     [ ok ]

 * Starting PostgreSQL ...

pg_ctl: could not start server

Examine the log output.                                                                                                                                                                 [ !! ]

 * ERROR: postgresql-9.0 failed to start
```

cat /var/lib/postgresql/9.0/data/postmaster.log

```
LOG:  database system was shut down at 2010-10-18 23:32:45 CEST

PANIC:  could not open file "pg_xlog/000000010000000000000000" (log file 0, segment 0): Z?y argument

LOG:  startup process (PID 16586) was terminated by signal 6: Aborted

LOG:  aborting startup due to startup process failure
```

ls -l /var/lib/postgresql/9.0/data/

```
drwx------ 5 postgres postgres  4096 10-18 23:32 base

drwx------ 2 postgres postgres  4096 10-18 23:34 global

drwx------ 2 postgres postgres  4096 10-18 23:32 pg_clog

-rw------- 1 postgres postgres  3939 10-18 23:32 pg_hba.conf

-rw------- 1 postgres postgres  1636 10-18 23:32 pg_ident.conf

drwx------ 4 postgres postgres  4096 10-18 23:32 pg_multixact

drwx------ 2 postgres postgres  4096 10-18 23:34 pg_notify

drwx------ 2 postgres postgres  4096 10-18 23:32 pg_stat_tmp

drwx------ 2 postgres postgres  4096 10-18 23:32 pg_subtrans

drwx------ 2 postgres postgres  4096 10-18 23:32 pg_tblspc

drwx------ 2 postgres postgres  4096 10-18 23:32 pg_twophase

-rw------- 1 postgres postgres     4 10-18 23:32 PG_VERSION

drwx------ 3 postgres postgres  4096 10-18 23:32 pg_xlog

-rw------- 1 postgres postgres 17955 10-18 23:32 postgresql.conf

-rw------- 1 postgres postgres   289 10-18 23:34 postmaster.log

-rw------- 1 postgres postgres    60 10-18 23:34 postmaster.opts
```

O czymś zapomniałem? Coś robie nie tak? Dla ścisłości dodam jeszcze:

eselect postgresql show-all

```
Utilities:  9.0

Service:    9.0
```

Last edited by Lord_Raven on Wed Oct 20, 2010 8:16 am; edited 1 time in total

----------

## matidz

1. zakladam ze masz uzytkownika postgres (tak jak w configu)

ktory ma odpowiednie uprawnienia dla 

/var/lib/postgresql/

2. Sprobuj tak:

su postgres

/usr/lib/postgresql-9.0/bin/postgres -D /var/lib/postgresql/9.0/data

#mozesz jeszcze z -d 5 uruchomic -powinno wiecej info wyswietlic

----------

## lsdudi

```
PANIC:  could not open file "pg_xlog/000000010000000000000000" (log file 0, segment 0): Z?y argument
```

usun plik pg_xlog/000000010000000000000000

a najlepiej  zrób od nowa initdb

----------

## Lord_Raven

su postgres

/usr/lib/postgresql-9.0/bin/postgres -D /var/lib/postgresql/9.0/data

```
LOG:  database system was shut down at 2010-10-19 10:40:26 CEST

PANIC:  could not open file "pg_xlog/000000010000000000000000" (log file 0, segment 0): Zły argument

LOG:  startup process (PID 9289) was terminated by signal 6: Aborted

LOG:  aborting startup due to startup process failure
```

/usr/lib/postgresql-9.0/bin/postgres -D /var/lib/postgresql/9.0/data -d 5

```
/usr/lib/postgresql-9.0/bin/postgres -D /var/lib/postgresql/9.0/data -d 5 > /var/tmp/t.txt

DEBUG:  postgres: PostmasterMain: initial environ dump:

DEBUG:  -----------------------------------------

DEBUG:     MANPATH=/etc/java-config-2/current-system-vm/man:/usr/local/share/man:/usr/share/man:

/usr/share/binutils-data/x86_64-pc-linux-gnu/2.20.1/man:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.4/man

:/etc/java-config/system-vm/man/:/usr/lib64/php5/man/:/usr/share/postgresql-9.0/man

DEBUG:     SSH_AGENT_PID=1875

DEBUG:     GLADE_PIXMAP_PATH=:

DEBUG:     TERM=xterm

DEBUG:     SHELL=/bin/bash

DEBUG:     VBOX_APP_HOME=/opt/VirtualBox

DEBUG:     WINDOWID=46249496

DEBUG:     ANT_HOME=/usr/share/ant

DEBUG:     USER=postgres

DEBUG:     LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01

:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32

:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31

:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31

:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31

:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35

:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35

:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35

:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35

:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35

:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32

:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36

:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36

:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:

DEBUG:     PRELINK_PATH_MASK=/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so

DEBUG:     GDK_USE_XFT=1

DEBUG:     GLADE_MODULE_PATH=:

DEBUG:     SSH_AUTH_SOCK=/tmp/ssh-nkBCFw1874/agent.1874

DEBUG:     SESSION_MANAGER=local/tux:@/tmp/.ICE-unix/1883,unix/tux:/tmp/.ICE-unix/1883

DEBUG:     PAGER=/usr/bin/less

DEBUG:     CONFIG_PROTECT_MASK=/etc/gentoo-release /etc/sandbox.d /etc/env.d/java/ /etc/php/cli-php5/ext-active/

 /etc/php/cgi-php5/ext-active/ /etc/php/apache2-php5/ext-active/ /etc/fonts/fonts.conf /etc/gconf /etc/terminfo

 /etc/eselect/postgresql /etc/ca-certificates.conf /etc/texmf/web2c /etc/texmf/language.dat.d

 /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/revdep-rebuild

DEBUG:     XDG_CONFIG_DIRS=/etc/xdg

DEBUG:     MAIL=/var/mail/raven

DEBUG:     PATH=/bin:/usr/bin

DEBUG:     PWD=/home/raven

DEBUG:     JAVA_HOME=/etc/java-config-2/current-system-vm

DEBUG:     EDITOR=/bin/nano

DEBUG:     JAVAC=/etc/java-config-2/current-system-vm/bin/javac

DEBUG:     LANG=pl_PL.UTF-8

DEBUG:     HOME=/var/lib

DEBUG:     JDK_HOME=/etc/java-config-2/current-system-vm

DEBUG:     SHLVL=5

DEBUG:     GTK_PATH=:/usr/lib64/gtk-2.0

DEBUG:     LOGNAME=postgres

DEBUG:     LESS=-R -M --shift 5

DEBUG:     CVS_RSH=ssh

DEBUG:     GCC_SPECS=

DEBUG:     XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share

DEBUG:     DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2hY7yobUCB,guid=e1b05886c357f90192ce76e100000028

DEBUG:     LESSOPEN=|lesspipe.sh %s

DEBUG:     INFOPATH=/usr/share/info:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.20.1/info:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.4/info

DEBUG:     DISPLAY=:0.0

DEBUG:     LIBGLADE_MODULE_PATH=:/usr/lib64/libglade/2.0

DEBUG:     OPENGL_PROFILE=xorg-x11

DEBUG:     GLADE_CATALOG_PATH=:

DEBUG:     XSESSION=Xfce4

DEBUG:     CONFIG_PROTECT=/usr/share/X11/xkb /usr/share/config

DEBUG:     COLORTERM=Terminal

DEBUG:     XAUTHORITY=/root/.xauthT7kMAh

DEBUG:     _=/usr/lib/postgresql-9.0/bin/postgres

DEBUG:     PGLOCALEDIR=/usr/lib64/postgresql-9.0/share/locale

DEBUG:     PGSYSCONFDIR=/etc/postgresql-9.0

DEBUG:     LC_COLLATE=pl_PL.UTF-8

DEBUG:     LC_CTYPE=pl_PL.UTF-8

DEBUG:     LC_MESSAGES=pl_PL.UTF-8

DEBUG:     LC_MONETARY=C

DEBUG:     LC_NUMERIC=C

DEBUG:     LC_TIME=C

DEBUG:  -----------------------------------------

DEBUG:  TZ "Factory" scores 0: at 1263427200 2010-01-14 00:00:00 std versus 2010-01-14 01:00:00 std

DEBUG:  TZ "EST5EDT" scores 0: at 1263427200 2010-01-13 19:00:00 std versus 2010-01-14 01:00:00 std

(.....)

DEBUG:  TZ "Poland" gets max score 5200

(.....)

DEBUG:  invoking IpcMemoryCreate(size=29376512)

DEBUG:  removing file "pg_notify/0000"

DEBUG:  max_safe_fds = 985, usable_fds = 1000, already_open = 5

LOG:  database system was shut down at 2010-10-19 10:40:26 CEST

DEBUG:  checkpoint record is at 0/5F7588

DEBUG:  redo record is at 0/5F7588; shutdown TRUE

DEBUG:  next transaction ID: 0/662; next OID: 11875

DEBUG:  next MultiXactId: 1; next MultiXactOffset: 0

DEBUG:  oldest unfrozen transaction ID: 654, in database 1

DEBUG:  transaction ID wrap limit is 2147484301, limited by database with OID 1

PANIC:  could not open file "pg_xlog/000000010000000000000000" (log file 0, segment 0): Zły argument

DEBUG:  reaping dead processes

LOG:  startup process (PID 9316) was terminated by signal 6: Aborted

LOG:  aborting startup due to startup process failure

DEBUG:  shmem_exit(1): 3 callbacks to make

DEBUG:  proc_exit(1): 3 callbacks to make

DEBUG:  exit(1)

DEBUG:  shmem_exit(-1): 0 callbacks to make

DEBUG:  proc_exit(-1): 0 callbacks to make
```

Ponowne wywolanie inita bazy nie pomaga.

rm /var/lib/postgresql/9.0/data/pg_xlog/000000010000000000000000

```
LOG:  database system was shut down at 2010-10-19 10:40:26 CEST

LOG:  could not open file "pg_xlog/000000010000000000000000" (log file 0, segment 0): Nie ma takiego pliku ani katalogu

LOG:  invalid primary checkpoint record

LOG:  could not open file "pg_xlog/000000010000000000000000" (log file 0, segment 0): Nie ma takiego pliku ani katalogu

LOG:  invalid secondary checkpoint record

PANIC:  could not locate a valid checkpoint record

LOG:  startup process (PID 9323) was terminated by signal 6: Aborted

LOG:  aborting startup due to startup process failure
```

----------

## matidz

masz jakies dane w tej bazie? jesli nie to moze zainteresuj sie pg_restetxlog

----------

## unK

Masz / na reiser4? Ja ostatnio miałem ten sam problem, to przeniosłem katalog danych postgresql na partycję z reiserfs i wystartowało bez problemu.

----------

## Lord_Raven

Baza jest pusta, jest to pierwsze uruchomienie postgresa na tej maszynie.

Co do systemu plików to jest to ext3 i nie za bardzo mi po drodze ze zmiana systemu plików

----------

## lsdudi

usuń wszystkie pliki i zrób initdb 

ewntualnie baw się 

```
pg_resetxlog
```

----------

## Lord_Raven

Wyczytałem, gdzieś na sieci że może to mieść związek z dodatkowym journalingiem jaki kiedyś włączałem przy pomocy tune2fs, chodzi o:

```
tune2fs -o journal_data
```

Czy mogę bezpiecznie wyłączyć ten journaling bez obawy o utratę danych? Niestety nie mam dodatkowej partycji na testy.

----------

## Lord_Raven

Problem rozwiązany. Z liveCD zrobiłem tune2fs -o journal_data_ordered /dev/sdaX. Danych nie straciłem, wszystko działa. Dzięki za naprowadzanie na problem z systemem plików.

----------

