2005/06/22

PostgreSQL 8.0.3 インストール、SMF 管理

ポスト @ 3:34:40 | Solaris

この前の PostgreSQL のインストールと、SMF 管理用設定メモ。



<

ul>

  • ソースのダウンロード、インストール

    ソースを一ヶ所修正した以外は、ほぼ INSTALL ドキュメント通り。

    src/backend/port/sysv_shmem.c の、

    #ifdef SHM_SHARE_MMU                    /* use intimate shared memory on Solaris */
    #define PG_SHMAT_FLAGS                  0 /*SHM_SHARE_MMU*/
    #else
    #define PG_SHMAT_FLAGS                  0
    #endif
    

    SHM_SHARE_MMU で宣言されていたのを、0 に変更。そのままだと InternalIpcMemoryCreate 関数内、

            /* OK, should be able to attach to the segment */
            memAddress = shmat(shmid, NULL, PG_SHMAT_FLAGS);
            if (memAddress == (void *) -1)
                    elog(FATAL, "shmat(id=%d) failed: %m", shmid);
    

    shmat で失敗する。コメントから、Solaris の ISM(intimate shared memory) の関係なのだろう。x86 というか、CPU が VIA C3 なのが原因? と、まあとりあえず動いているみたいなので、それ以上はつっこんでいない。

    # wget ftp://ftp.sra.co.jp/pub/cmd/postgres/8.0.3/postgresql-8.0.3.tar.gz
    # gunzip -c postgresql-8.0.3.tar.gz | tar xvf -
    # cd postgresql-8.0.3
    # ./configure --prefix=/opt/local/pgsql
    # make
    # make install
    
    # su postgres
    # initdb -D /opt/local/pgsql/data
    

  • SMF 用設定
  • 一応、動いてはいるが、もう少し上手く書けるのではないかと思う。

    <?xml version="1.0"?>
    <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
    <service_bundle type='manifest' name='pgsql'>
    <service name='application/pgsql' type='service' version='1'>
    <instance name='postmaster' enabled='false'> <exec_method type='method' name='start' exec='su - postgres -c "/opt/local/pgsql/bin/pg_ctl start -D /opt/local/pgsql/data -\l /opt/local/pgsql/logfile"' timeout_seconds='60' />
    <exec_method type='method' name='stop' exec='su - postgres -c "/opt/local/pgsql/bin/pg_ctl stop -D /opt/local/pgsql/data"' timeout_seconds='60' />
    <exec_method type='method' name='refresh' exec='su - postgres -c "/opt/local/pgsql/bin/pg_ctl restart -D /opt/local/pgsql/data\"' timeout_seconds='60' /> </instance>
    <stability value='Unstable' /> </service>
    </service_bundle>
    # svccfg import /var/svc/manifest/application/pgsql.xml
    # svcs -a | grep pgsql
    disabled        2:38:52 svc:/application/pgsql:postmaster
    # ps -ef | grep postmaster
    # svcadm enable application/pgsql
    # svcs -a | grep pgsql
    online          2:39:24 svc:/application/pgsql:postmaster
    # ps -ef | grep postmaster
    postgres 13347 13346   0 02:39:25 ?           0:00 /opt/local/pgsql/bin/postmaster -D /opt/local/pgsql/data
    postgres 13346 13343   0 02:39:25 ?           0:00 /opt/local/pgsql/bin/postmaster -D /opt/local/pgsql/data
    postgres 13345 13343   0 02:39:25 ?           0:00 /opt/local/pgsql/bin/postmaster -D /opt/local/pgsql/data
    postgres 13343  5677   0 02:39:25 ?           0:00 /opt/local/pgsql/bin/postmaster -D /opt/local/pgsql/data