PostgreSQLをサーバ起動時にstartさせたいと思っています。
/etc/rc.d/rc.localに下記を追記しましたが、起動してくれません。ログファイルも作成されていませんでした。
echo -n "Starting PostgreSQL: "
su -l pgsql -s /bin/sh -c "/usr/local/pgsql/bin/pg_ctl -l /var/log/postgresql.log start > /dev/null 2>&1" < /dev/null
echo "done."
何が悪いのでしょうか?PostgreSQLは手動でstartすることはできます。
また、PostgreSQLの起動スクリプトを作成し、webminで制御したいと思うのですが、PostgreSQLの起動スクリプトの書き方について参考になるHPがあれば紹介していただきたいと思っています。
よろしくお願いいたします。
No.2ベストアンサー
- 回答日時:
起動スクリプトの書き方は、参考URLがいかがでしょう。
僕自身が使っているスクリプトを参考に書いておきます。
アカウント名や、パスの環境変数を書き換えてください。
(RedHat7.3, postgresql7.2.1で使っています。)
chkconfig対応なので、
パーミッションを755か700にして、
chkconfig --add postgres
とすると、起動時に起動してくれます。
chkconfig --list
として確認できます。
#!/bin/sh
#
#
# chkconfig: 35 85 15
# description: Starts and stops the PostgreSQL backend daemon\
# that handles all database requests.
# processname: postmaster
#
# Config Variables
#
PGACCOUNT="postgres"
#
# The non-root user account which will be used to run the
# PostgreSQL executeable. For this script to work, the
# shell for this account must be SH/BASH.
#
export PGDATA="/usr/local/pgsql/data"
export POSTMASTER="/usr/local/pgsql/bin/postmaster -S -i"
export PG_CTL="/usr/local/pgsql/bin/pg_ctl"
#
# The executable program which is to be run, in this case
# it is the listener, which waits for requests on the port
# specified during configuration.
#
# Source function library.
. /etc/rc.d/init.d/functions
#
# See how we were called.
#
case "$1" in
start)
echo -n "Starting postgres: "
su - $PGACCOUNT -c "$POSTMASTER"
echo
touch /var/lock/subsys/postgres
;;
stop)
echo -n "Stopping postgres: "
$PG_CTL -m f stop
echo
rm -f /var/lock/subsys/postgres
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
参考URL:http://www.zdnet.co.jp/help/howto/linux/0007mast …
No.3
- 回答日時:
PostgreSQLをソースからビルドした場合、contrib/start-scriptsにFreeBSDとLinux用の起動スクリプトがありますが、それを利用するのではいけないのでしょうか?
Linuxであれば、
# cp contrib/start-scripts/linux /etc/init.d/postgresql
# chmod +x /etc/init.d/postgresql
# chkconfig --add postgresql
とすればシステムサービスに登録されます。
PGDATAのパスが/usr/local/pgsql/dataでない場合は、スクリプトを集成してやる必要があります。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- その他(プログラミング・Web制作) mariadbでのエラー 1 2022/11/15 12:31
- PostgreSQL PostgreSQLで"pg_dumpall -f data.sql"を使ってバックアップしたデータ 2 2022/09/19 08:14
- UNIX・Linux postfix smtpサーバーリレーがTLSハンドシェーク失敗 1 2022/08/15 15:45
- UNIX・Linux cronの@rebootでのdateコマンドの実行につきまして 2 2023/06/11 16:23
- PostgreSQL PostgreSQLドライバの登録。 MavenプロジェクトからPostgreSQLへ接続をするため 1 2022/09/26 12:30
- PostgreSQL DBFluteについて質問です。 環境:PostgreSQL java8 前提:webアプリケーショ 1 2022/07/07 00:49
- オープンソース Coinmarketcap api 1 2022/05/30 15:47
- PostgreSQL 【PostgreSQL】行の値の並びを変えるには 1 2023/03/21 16:46
- UNIX・Linux デフォルト値のパラメータ展開 1 2022/08/12 17:34
- PostgreSQL SQLでUPSERTを一度に複数行やる方法 3 2022/03/25 15:17
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
Windows Media Playerを開くと...
-
windows11でクイックスキャン等...
-
ディスククリーンアップが終わ...
-
エクスプローラのアクティブウ...
-
Windowsファイルエクスプローラ...
-
MS-DOS 6.22のダウンロード
-
windows11 きれいなロック画面...
-
windows11におけるファイルの並...
-
ゼロからのOS自作入門について
-
Windows11のデスクトップのアプ...
-
Windowsで大量の画像サイズを半...
-
MS-DOSでなければ動かないPCゲ...
-
ウィンドウズ11です。 ケース1...
-
Windowsアップデートしたらタス...
-
OPPOのRENOシリーズのOSのアプ...
-
パソコンを離れていたら 画面に...
-
アイコンに、四角い枠が出来て...
-
Windows11の画面の色が薄いので...
-
Acer AXC605-H54D にOSをインス...
-
Windows11のシステム通知音が小...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
windows11でクイックスキャン等...
-
エクスプローラのアクティブウ...
-
クロムOSについて教えてください
-
Windows Media Playerを開くと...
-
windows11 きれいなロック画面...
-
Windows11の右クリックメニュー...
-
Windows11のデスクトップのアプ...
-
windows11におけるファイルの並...
-
「Wi-Fiアダプターへのアクセス...
-
Windows11 システム通知音がも...
-
Windowsの古いゲーム(32bit OS...
-
windows10DVDからインストール...
-
アイコンに、四角い枠が出来て...
-
有料Microsoft365は、PCを変え...
-
Mac用の外付けHDはWindowsPCで...
-
コマンドプロンプト tree
-
Win + G でCPU使用率が表示され...
-
Windows11 ゴミ箱 ファイルの取...
-
Windowsアップデートしたらタス...
-
MS-DOS 6.22のダウンロード
おすすめ情報