| このマニュアルでは、Adaptive Server Anywhere (SQL Anywhere) データベースを Linux で実行するためのサービスの作成方法について説明します。
 データベースを起動する
 
 データベース・サーバを起動する場合の最も簡単な方法は、スクリプトを使用することです。以下の手順では、データベースを起動する
            SQLAnywhereService.init ファイルの作成方法を説明します。
 
 スクリプトを作成しデータベースを起動する
 
 1. テキスト・エディタを使用し、SQL Anywhere Studio インストール・ディレクトリ
            (デフォルトでは /opt/sybase/SYBSsa9)内の SQL Anywhere インストール・ディレクトリに、以下のような内容の
            SQLAnywhereService.init というファイルを作成します。(以下のテキストには
            asademo サンプル・データベースを起動するコマンドが含まれていることに注意してください)。
 
 
            #!/bin/sh.2. 必要に応じて、データベースを起動するコマンドをカスタマイズします。コマンドライン・オプションについては、『Adaptive Server
            Anywhere データベース管理ガイド』の「データベース・サーバの実行」を参照してください。#
 # The service runs as root, and the default tmp directory for
 # root is likely /root/tmp. You can then set your users to have
 # the same value for ASTMP and shared memory connections will
 # work.
 # Uncomment the following command if you want shared memory
 # connections for connections on the same machine.
 #
 # export ASTMP=/tmp
 #
 # The -gd all option specifies that any user can start or stop
 # the database, while the -o option option specifies that all
 # server window messages are output to the specified file.
 . /opt/sybase/SYBSsa9/bin/asa_config.sh > /dev/null
 # The following command must be entered all on one line.
 dbsrv9 -n ASA -gd all -ud -o /var/log/asademo_service.log /opt/sybase/SYBSsa9/asademo.db
 
 
 
 データベースを停止する
 
 データベースを停止するには、独立したスクリプトが必要です。以下の手順では、データベースを停止するSQLAnywhereService.fini
            ファイルの作成方法について説明します。
 
 1. テキスト・エディタを使用し、以下のような内容の SQLAnywhereService.fini
            というファイルを /opt/sybase/SYBSsa9/に作成します。
 
            #!/bin/sh.#
 # The service runs as root, and the default tmp directory for
 # root is likely /root/tmp. You can then set your users to the
 # have same value for ASTMP and share memory connections will
 # work.
 # Uncomment the following command may if you want shared memory
 # connections.
 #
 # export ASTMP=/tmp
 #
 . /opt/sybase/SYBSsa9/bin/asa_config.sh > /dev/null
 dbstop -c "uid=DBA;pwd=SQL;eng=ASA;CommLinks=tcpip" > /dev/null
 
 2. 上記例の dbstop コマンドは、SQLAnywhereService.init ファイルで起動される
            ASA データベースを参照します。必要に応じて、データベースを停止するコマンドをカスタマイズします。コマンドライン・オプションについては、『Adaptive
            Server Anywhere データベース管理ガイド』の「データベース・サーバの停止」を参照してください。
 
 サービススクリプトのパーミッションを設定する
 
 ルート・ユーザに対して SQLAnywhereService.fini と SQLAnywhereService.init
            を実行可能にするには、以下のコマンドを使用します (ルート・ユーザとしてログインした場合)
 
 
            chmod u+x SQLAnywhereService.initchmod u+x SQLAnywhereService.fini
 
 サービスのコンテンツを作成する
 
 
 1. ルート・アカウントを使用して、以下のような内容の SQLAnywhereService
            というファイルを /etc/init.d ディレクトリに作成します。
 
            #!/bin/sh2. 以下のコマンドを実行して、このファイルをルート・ユーザに対して実行可能にします
            (ルート・ユーザとしてログインした場合)#
 # Startup script for Adaptive Server Anywhere Service
 #
 # chkconfig: 2345 20 80
 # description: SQL Anywhere's Adaptive Server Anywhere (dbsrv9)
 # is a SQL database server.
 # processname: dbsrv9
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 # The following are brief examples of how to have SQL Anywhere
 # Start and stop from the system.
 
 start() {
 gprintf "Attempting to start Adaptive Server Anywhere"
 echo $*
 /opt/sybase/SYBSsa9/SQLAnywhereService.init
 }
 stop() {
 gprintf "Attempting to stop Adaptive Server Anywhere"
 /opt/sybase/SYBSsa9/SQLAnywhereService.fini
 }
 restart() {
 gprintf "Attempting to restart Adaptive Server Anywhere"
 /opt/sybase/SYBSsa9/SQLAnywhereService.fini
 /opt/sybase/SYBSsa9/ SQLAnywhereService.init
 }
 
 case "$1" in
 
 start)
 start
 ;;
 stop)
 stop
 ;;
 restart|reload)
 restart
 ;;
 *)
 gprintf "Usage: %s {start|stop|restart}\n" "$0"
 exit 1
 esac
 exit 0
 
 
 
            chmod u+x SQLAnywhereService3. 以下のコマンドを使用してサービスを追加します。
 
 
            chkconfig -add SQLAnywhereService
 サービスをテストする
 
 Interactive SQL で (接続パラメータ "uid=DBA;pwd=SQL;links=tcpip;eng=ASA"
            だけを使用して) 再起動してサーバに接続することにより、サービスをテストできます。
 
 また、ASTMP を共通の場所で設定した場合は、接続文字列を "uid=DBA;pwd=SQL"
            にすることができます。マシンのスタートアップ時には、"Attempting to
            start SQL Anywhere (SQL Anywhere を起動しようとしています)" に関する非常に短いメッセージが表示されます。
 
 ASTMP 環境変数を使用して共有メモリ接続を考慮する代わりに、su コマンドを使用して、SQLAnywhereService.init
            スクリプト内から別のユーザ・アカウントのもとでデータベース・サーバを実行することができます。このオプションは、システム上の
            1 人のユーザだけがデータベースにアクセスする必要がある場合に役立ちます。
 
 
            su -c "dbeng9 -n ASA /home/myuser1/mydb.db" myuser1コマンド・ラインからのサービスの開始と停止
 
 以下のコマンドを発行した場合は、ルートとしてコマンド・ラインからサービスを開始または停止できます。
 
 
            service SQLAnywhereService startservice SQLAnywhereService stop
 
 
 |