Yosemite で Server.app (v3.2.2) の postgres を起動する
Yosemite にアップグレードしてふと Application フォルダを見てみると・・・
Server.app が使えなくなっていた。もともと,Server.app は dolphin server を mac で起動するのに postgres が必要だったために購入したものなので,とりあえず Server.app 内の postgres だけ動かすことにした。まず,postgres がどうなったか調べてみると
$ sudo serveradmin status postgres postgres:state = "STOPPED" $ sudo serveradmin start postgres postgres:error = "CANNOT_START_SERVICE_TIMEOUT_ERR"
当然,postgres は起動しない。そこで,直接 Server.app 内の postgres を起動してみる。
$ sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/postgres -D /Library/Server/PostgreSQL/Data -k /var/pgsql_socket/ FATAL: database files are incompatible with server DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.4.
postgres のバージョンがいつの間にか 9.2 から 9.3.4 に上がってしまっていた。仕方がないので,一旦データベースを消去して作り直すことにする。
$ sudo rm -rf /Library/Server/PostgreSQL/Data
$ sudo mkdir /Library/Server/PostgreSQL/Data
$ sudo chown -R _postgres:_postgres /Library/Server/PostgreSQL
$ sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/initdb -D /Library/Server/PostgreSQL/Data
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 "ja_JP.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "ja_JP.UTF-8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
fixing permissions on existing directory /Library/Server/PostgreSQL/Data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /Library/Server/PostgreSQL/Data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... 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
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
postgres -D /Library/Server/PostgreSQL/Data/ -k /Library/Server/PostgreSQL/Data/
or
pg_ctl -D /Library/Server/PostgreSQL/Data/ -l logfile -o "-k /Library/Server/PostgreSQL/Data/" start
これで postgres が起動するようになる。
$ sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/postgres -D /Library/Server/PostgreSQL/Data -k /var/pgsql_socket/ LOG: database system was shut down at 2014-12-22 11:09:41 JST LOG: database system is ready to accept connections LOG: autovacuum launcher started
dolphin データベースをバックアップから復旧する
$ sudo -u _postgres createuser dolphin
$ sudo -u _postgres createdb -O dolphin dolphin
$ sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/pg_restore -Fc -d dolphin dolphin_db.dump
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1409594; 0 0 ACL public postgres
pg_restore: [archiver (db)] could not execute query: ERROR: role "postgres" does not exist
Command was: REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
...
WARNING: errors ignored on restore: 1
psql で確認してみる
$ sudo -u _postgres psql -U dolphin dolphin psql (9.3.4) Type "help" for help. dolphin=> \d public | d_admin | table | dolphin public | d_admin_comment | table | dolphin :
無事 postgres だけ起動できるようになった。
« orca api の仕様変更(4) | トップページ | Yosemite で Server.app (v4.0) の postgres を使う »
「いろいろ」カテゴリの記事
- オン資PCインストール忘備録(2025.01.31)
- 15年目の運用まとめ(2023.02.06)
- 13年目の運用まとめ(2021.02.04)
- 添書作成スクリプト(2020.05.22)
- 12年目の運用まとめ(2020.02.11)


