Changes between Initial Version and Version 1 of epics/Archiver Appliance インストールメモ(EL6版)


Ignore:
Timestamp:
09/06/24 12:09:11 (7 months ago)
Author:
Shuei Yamada
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • epics/Archiver Appliance インストールメモ(EL6版)

    v1 v1  
     1[[PageOutline]]
     2
     3= はじめに =
     4このドキュメントはJ-PARC加速器向けに[https://slacmshankar.github.io/epicsarchiver_docs/ Archiver Appliance (AA)]をインストールして立ち上げた際の作業メモなので、適宜読み替えて頂きたい。
     5* AAの[https://slacmshankar.github.io/epicsarchiver_docs/installguide.html インストールガイド]を良く読んでおくこと。
     6* AAの[https://slacmshankar.github.io/epicsarchiver_docs/installguide.html インストールガイド]を良く読んでおくこと。
     7 * [https://slacmshankar.github.io/epicsarchiver_docs/quickstart.html Quickstart]はあくまでもAAを試食するためのセットアップ方法。よく読むと「Quickstartの方法では設定が保存されない。AAを再起動したら、アーカイブしたいPVを再度AAに設定しなければならない」旨が書いてある。
     8* jkjarchiver-ap.mr.jkcontにインストールする
     9 * OS : SL 6.8 / x86_64
     10 * epicsアカウントで作業する
     11 * 作業ディレクトリ: /home/epics/archappl
     12 * AAのインストール先: /opt/archappl
     13 * AAのデータ保存先: /localdata/archappl
     14 * 各種設定ファイル・起動スクリプトは(できるだけ)mercurialでバージョン管理している
     15* Raspberry Pi 2BにもAAを入れてみたのでメモしておく
     16 * OS : Raspbian stretch
     17* インストールの際に、X Window System上での作業が必要
     18* AAインストール後の運用については[[wiki:Archiver Appliance 運用メモ|Archiver Appliance 運用メモ]]を参照のこと
     19
     20= ダウンロード =
     21AAに必要なソフトウェアをあらかじめダウンロードしておく。ここでは/home/epics/archappl/downloadにダウンロードする。
     22
     23== Archiver Appliance ==
     24インストールするのはバイナリの配布物だが、ソースコードに管理用のスクリプトの例が含まれているので一緒にダウンロードしておく。
     25* バイナリ
     26{{{
     27% wget https://github.com/slacmshankar/epicsarchiverap/releases/download/v0.0.1_SNAPSHOT_27-Nov-2017/archappl_v0.0.1_SNAPSHOT_27-November-2017T16-32-40.tar.gz
     28}}}
     29* ソースコード
     30{{{
     31% git clone https://github.com/slacmshankar/epicsarchiverap epicsarchiverap.git
     32}}}
     33
     34== Apache Tomcat ==
     35AAを走らせるにはApache Tomcat 7.0.61以降が必要。[http://tomcat.apache.org/download-80.cgi Apache Tomcat配布元]から8.5.28をダウンロードした。
     36
     37== MySQL ==
     38AAがアーカイブするレコードの情報を記録するのに、MySQL 5.1以降が必要。
     39SL6の配布物からMySQL 5.1.73をrpmでインストールした。
     40{{{
     41# yum install mysql mysql-server mysql-devel
     42}}}
     43
     44今回は
     45* AAを実行するマシンでMySQLサーバも走らせる
     46* MySQLのテーブルはNFSサーバ上に置く
     47という構成にしたが、MySQLサーバはAAとは独立したマシンにした方がよかったかもしれない。
     48
     49Raspbian stretchでは、mariadb 10.1.23を用いた
     50{{{
     51# apt install mariadb-server mariadb-client
     52}}}
     53
     54== MySQL クライアント jar ==
     55mysql-connector-javaを[http://dev.mysql.com/downloads/connector/j/ MySQL本家]からダウンロードする。
     56SL6標準のrpmパッケージは依存するライブラリを多数インストールするのでやめておく。AAのインストール後に、インストール先ディレクトリのapache-tomcat-8.5.xx/libに置いてあるjarを差し替えることで、javaクライアントを入れ替えることができる。
     57
     58SL6では以下のクライアントで動いた:
     59* mysql-connector-java-5.1.45-bin.jar
     60* mysql-connector-java-5.1.47.jar
     61※ SL6のMySQLは5.1なので、 mysql-connector-java-8.0.12.jarでは次のエラーを出してAAが起動しない:
     62{{{
     63SEVERE: Unable to create initial connections of pool.
     64java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required
     65}}}
     66
     67Raspbian stretchでは以下のクライアントで動いた:
     68* mysql-connector-java-8.0.12.jar
     69
     70以下のクライアントではAAがエラーを吐いて動作しなかった:
     71* mariadb-java-client-2.3.0.jar
     72{{{
     73重大: Unable to create initial connections of pool.
     74java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:java.net.URLClassLoader@18025c;ClassLoader:ParallelWebappClassLoader
     75}}}
     76* ${TOMCAT_HOME}/conf/context.xml (後述) を次のように書き換えても動作しない。どこかでhard codingされている可能性がある
     77{{{
     78driverClassName="org.mariadb.jdbc.Driver"
     79}}}
     80
     81== JDK 8/9 ==
     82制御計算機ではOracleのjdk-8u181-linux-x64を用いた。
     83
     84Raspbian stretchでは以下の3つのJDKで動作確認した:
     85* oracle-java8-jdk (JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt)
     86* openjdk-8-jdk (JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf)
     87* openjdk-9-jdk (JAVA_HOME=/usr/lib/jvm/java-1.9.0-openjdk-armhf)
     88Raspbianでは、AAのインストールの過程でjsvcのビルドに失敗する。apache tomcatのcommons-daemon-native.tar.gzの中のconfigureにパッチを当てるのは大変なので、JDKに手をいれて対処する:
     89{{{
     90cd $JAVA_HOME/include
     91ln -fs linux arm
     92}}}
     93
     94== zenity ==
     95制御計算機にはSL標準のrpmパッケージがインストールしてあるので省略。
     96
     97== tar ballの展開 ==
     98{{{
     99% mkdir -p ~/archappl/workspace
     100% cd ~/archappl/workspace
     101% tar xf ../download/archappl_v0.0.1_SNAPSHOT_20-September-2016T13-50-17.tar.gz
     102% tar xf ../download/mysql-connector-java-5.1.40.tar.gz
     103}}}
     104
     105= MySQLのセットアップ =
     106== uid, gid ==
     107mysql:mysqlが27:27になっている(mysqlをインストールする際に作られる?)のを、既存のマシンにあわせて38099:38099にする。
     108mysqlが使うディレクトリのownerも変えておく:
     109{{{
     110# chown 38099:38099 /var/lib/mysql
     111# chown 38099:38099 /var/run/mysql
     112}}}
     113
     114== dbを置くディレクトリ ==
     115dbは/svrdbに置く。NFSサーバがexportしているディレクトリを/svrdbにマウントする。
     116{{{
     117jkjds01.ccr.jkcont:/svrdb    /svrdb    nfs  bg,intr,soft,timeo=10,retrans=15,nfsvers=3 0 0
     118}}}
     119/svrdbを掘ってマウントし、パーミッションを設定する。mysqlの起動スクリプトがroot権限でこのディレクトリに書き込もうとするので、NFSサーバも設定しておく。
     120{{{
     121# mkdir /svrdb
     122# mount /svrdb
     123# mkdir /svrdb/mysql5.1/jkjarchiver-ap
     124# chown 38099:38099 /svrdb/mysql5.1/jkjarchiver-ap
     125}}}
     126
     127== /etc/my.cnf ==
     128* SL6の場合
     129 MySQLの設定ファイルをリポジトリからコピーして使う。
     130{{{
     131[mysqld]
     132#datadir=/var/lib/mysql
     133#socket=/var/lib/mysql/mysql.sock
     134#user=mysql
     135# Disabling symbolic-links is recommended to prevent assorted security risks
     136#symbolic-links=0
     137
     138#datadir=/localdata/mysql
     139#socket=/localdata/mysql/mysql.sock
     140datadir=/svrdb/mysql5.1/jkjarchiver-ap/
     141socket=/var/lib/mysql/mysql.sock
     142user=mysql
     143symbolic-links=0
     144character-set-server = utf8
     145innodb_flush_log_at_trx_commit = 1
     146
     147[mysqld_safe]
     148log-error=/var/log/mysqld.log
     149pid-file=/var/run/mysqld/mysqld.pid
     150}}}
     151
     152* Rasibianのmariadbの場
     153 /etc/mysql/mariadb.conf.d/50-server.cnfでdatadirを適宜書き換える。
     154 debian由来のmariadbでは、デフォルトの文字コードがutf8mb(4-bytes unicode)になっているために767バイト制限に引っかかってテーブルを作れない。次のファイルを書き換えてutf8 (3-bytes unicode)を使うようにする。
     155 * /etc/mysql/mariadb.conf.d/50-server.cnf
     156{{{
     157...
     158[mysqld]
     159...
     160character-set-server  = utf8
     161collation-server      = utf8_general_ci
     162...
     163}}}
     164 * /etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
     165{{{
     166...
     167[mysql]
     168...
     169default-character-set = utf8
     170...
     171}}}
     172 * /etc/mysql/mariadb.conf.d/50-clients.cnf
     173  * AAはmysqlクライアントなので、mariadbクライアント向けの設定は変えなくてもよい
     174
     175== logrotate ==
     176/etc/logrotate.d/mysqld に手順が書いてある。後回し。
     177
     178== mysqlサーバ自動起動の設定 ==
     179* SL6の場合
     180MySQLをインストールしても自動起動しない。自動起動するように設定する
     181{{{
     182# cd /etc/rd.c/ini.d
     183# /sbin/chkconfig  --level 3 mysqld on
     184# /sbin/chkconfig  --level 4 mysqld on
     185# /sbin/chkconfig  --level 5 mysqld on
     186}}}
     187
     188== MySQLサーバの起動 ==
     189* SL6のrpmパッケージでMySQLをインストールした場合
     190MySQLサーバの初回起動時に(dbが存在しなければ)dbを作ってくれる。
     191{{{
     192# /etc/rc.d/init.d/mysqld start
     193MySQL データベースを初期化中:  Installing MySQL system tables...
     194
     195Filling help tables...
     196OK
     197
     198To start mysqld at boot time you have to copy
     199support-files/mysql.server to the right place for your system
     200
     201PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
     202To do so, start the server, then issue the following commands:
     203
     204/usr/bin/mysqladmin -u root password 'new-password'
     205/usr/bin/mysqladmin -u root -h jkjarchiver-ap.mr.jkcont password 'new-password'
     206
     207Alternatively you can run:
     208/usr/bin/mysql_secure_installation
     209
     210which will also give you the option of removing the test
     211databases and anonymous user created by default.  This is
     212strongly recommended for production servers.
     213
     214See the manual for more instructions.
     215
     216You can start the MySQL daemon with:
     217cd /usr ; /usr/bin/mysqld_safe &
     218
     219You can test the MySQL daemon with mysql-test-run.pl
     220cd /usr/mysql-test ; perl mysql-test-run.pl
     221
     222Please report any problems with the /usr/bin/mysqlbug script!
     223
     224                                                           [  OK  ]
     225mysqld を起動中:                                           [  OK  ]
     226}}}
     227
     228* Raspbianのmariadbの場合
     229datadirを標準のものから変えた場合は明示的にdbを作る必要がある。
     230{{{
     231systemctl stop mariadb
     232mysql_install_db --user=mysql --datadir=/localdata/mysql
     233systemctl start mariadb
     234}}}
     235
     236== /usr/bin/mysql_secure_installation ==
     237MySQLの初期設定を行う。質問をよく読む。Yes/Noの質問には全てYで答える。
     238
     239{{{
     240# /usr/bin/mysql_secure_installation
     241
     242
     243
     244
     245NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
     246      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
     247
     248
     249In order to log into MySQL to secure it, we'll need the current
     250password for the root user.  If you've just installed MySQL, and
     251you haven't set the root password yet, the password will be blank,
     252so you should just press enter here.
     253
     254Enter current password for root (enter for none):
     255OK, successfully used password, moving on...
     256
     257Setting the root password ensures that nobody can log into the MySQL
     258root user without the proper authorisation.
     259
     260Set root password? [Y/n] Y
     261New password:
     262Re-enter new password:
     263Password updated successfully!
     264Reloading privilege tables..
     265 ... Success!
     266
     267
     268By default, a MySQL installation has an anonymous user, allowing anyone
     269to log into MySQL without having to have a user account created for
     270them.  This is intended only for testing, and to make the installation
     271go a bit smoother.  You should remove them before moving into a
     272production environment.
     273
     274Remove anonymous users? [Y/n] y
     275 ... Success!
     276
     277Normally, root should only be allowed to connect from 'localhost'.  This
     278ensures that someone cannot guess at the root password from the network.
     279
     280Disallow root login remotely? [Y/n] y
     281 ... Success!
     282
     283By default, MySQL comes with a database named 'test' that anyone can
     284access.  This is also intended only for testing, and should be removed
     285before moving into a production environment.
     286
     287Remove test database and access to it? [Y/n] y
     288 - Dropping test database...
     289 ... Success!
     290 - Removing privileges on test database...
     291 ... Success!
     292
     293Reloading the privilege tables will ensure that all changes made so far
     294will take effect immediately.
     295
     296Reload privilege tables now? [Y/n] y
     297 ... Success!
     298
     299Cleaning up...
     300
     301
     302
     303All done!  If you've completed all of the above steps, your MySQL
     304installation should now be secure.
     305
     306Thanks for using MySQL!
     307}}}
     308
     309== schemaの作成 ==
     310DB(archappl), ユーザー(archappl)とパスワード(archappl)を作る。
     311
     312{{{
     313% mysql -u root -p
     314Enter password:
     315Welcome to the MySQL monitor.  Commands end with ; or \g.
     316Your MySQL connection id is 14
     317Server version: 5.1.73 Source distribution
     318
     319Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     320
     321Oracle is a registered trademark of Oracle Corporation and/or its
     322affiliates. Other names may be trademarks of their respective
     323owners.
     324
     325Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
     326
     327mysql> CREATE DATABASE IF NOT EXISTS archappl;
     328Query OK, 1 row affected (0.00 sec)
     329
     330mysql> GRANT ALL PRIVILEGES ON archappl.* TO 'archappl'@'localhost' IDENTIFIED BY 'archappl';
     331Query OK, 0 rows affected (0.00 sec)
     332}}}
     333
     334== テーブルの作成 ==
     335AA用のテーブルはAAのインストールスクリプト(後述)が作ってくれる。
     336
     337= Archiver Applianceのインストール =
     338
     339インストールスクリプトを走せると、
     3401. MySQLのテーブル
     3411. Tomcatのデプロイ
     3421. アプライアンスの設定ファイルの作成
     3431. 起動スクリプトの作成
     344をやってくれる
     345
     346== インストール先のディレクトリ ==
     347AAをインストールするディレクトリ(/opt/archappl)をあらかじめ掘っておく
     348{{{
     349# mkdir -p /opt/archappl
     350}}}
     351
     352== ポリシーファイル ==
     353ポリシーファイルは AAにレコードを登録する際に用いられるファイルで、
     354* LTS/MTS/STSの設定
     355* レコードをサンプルする方法(monitor/scan)とサンプリング時間
     356* 値と一緒に保存するHIGH/HIGH/LOW/LOLO等のフィールド
     357等をPythonのdictionaryとして記述する。
     358
     359インストールスクリプトを走らせる前に、ポリシーファイルを用意しておく。雛形が
     360{{{
     361epicsarchiverap.git/src/sitespecific/tests/classpathfiles/policies.py
     362}}}
     363に用意されている。
     364* インストールスクリプトがポリシーファイルの所在を尋ねてくる。存在しないファイルを指定すると、スクリプトの実行に失敗する
     365* 中身は後で書き換えるので、ここでは気にしない
     366* AAのクラスタを組む場合は、各ノードに同じファイルのコピーを置くか、共有ディレクトリに置いておく
     367制御計算機用のポリシーファイルは
     368{{{
     369/jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/policies.py
     370}}}
     371に置いてある
     372
     373=== LTS/MTS/STS ===
     374* STS ... PARTITION_HOUR
     375* MTS ... PARTITION_DAY&hold=5&gather=1
     376* LTS ... PARTITION_MONTH
     377
     378=== sampling method/sampling period ===
     379* 基本的にはMONITORにする
     380* 25Hzで更新されるLIのPVはSCAN 1.0secにする
     381
     382=== metaFields ===
     383HIHI等のメタフィールドは保存しない。pvPolicyDict\["archiveFields"\]は空のarrayにしておく。
     384
     385== インストールスクリプト ==
     386予めインストール先のディレクトリを作っておく。epicsアカウントで書き込めるようにownerを変更しておく:
     387{{{
     388# mkdir -p /opt/archappl
     389# chown epics.epics /opt/archappl
     390}}}
     391
     392AAを展開したディレクトリでインストールスクリプトを走らせる。AAを実行するアカウント(ここではepics)で走らせること。
     393sample_site_specific_contentをディレクトリごとsite_specific_contentにコピーして内容を編集しておくと、管理用ページのhtmlページの文言やヘッダに表示する図を差し替えることができる。
     394
     395スクリプトを走らせると、ダイアログが開いて
     396* DEPLOY_DIR (tomcatを展開するディレクトリ) → /opt/archappl
     397* apache-tomcat-x.y.z.tar.gz の所在
     398* mysql-connector-java-x.y.z-bin.jar の所在
     399* mysqlサーバに接続するためのmysqlコマンドに渡す引き数 → ここでは--user=archappl --password=archappl --database=archappl
     400* ポリシーファイル(policies.py)の所在
     401を尋ねてくる。
     402{{{
     403% cd ~archappl/workspace
     404% install_scripts/single_machine_install.sh
     405This script runs thru a typical install scenario for a single machine
     406You can use this to create a standard multi-instance (one Tomcat for ear WAR) tomcat deployment in a multi machine cluster by setting the ARCHAPPL_APPLIANCES and the ARCHAPPL_MYIDENTITY
     407For installations in a cluster, please do create a valid appliances.xml and export ARCHAPPL_APPLIANCES and ARCHAPPL_MYIDENTITY
     408...
     409...
     410Setting TOMCAT_HOME to the mgmt webapp in /opt/archappl/mgmt
     411Setting TOMCAT_HOME to /opt/archappl/apache-tomcat-8.5.16
     412Calling deploy release with /opt/archappl/deployRelease.sh /home/epics/archappl/workspace
     413Deploying a new release from /home/epics/archappl/workspace onto /opt/archappl
     414/opt/archappl/mgmt/webapps ~/archappl/workspace
     415~/archappl/workspace
     416/opt/archappl/engine/webapps ~/archappl/workspace
     417~/archappl/workspace
     418/opt/archappl/etl/webapps ~/archappl/workspace
     419~/archappl/workspace
     420/opt/archappl/retrieval/webapps ~/archappl/workspace
     421~/archappl/workspace
     422Done deploying a new release from /home/epics/archappl/workspace onto /opt/archappl
     423Do you have a site specific policies.py file?
     424Where's your site specific policies.py file?
     425Setting ARCHAPPL_POLICIES to /home/epics/archappl/policies.py
     426Done with the installation. Please use /opt/archappl/sampleStartup.sh to start and stop the appliance and /opt/archappl/deployRelease.sh to deploy a new release.
     427}}}
     428
     429== アプライアンスの設定 ==
     430appliances.xmlでノードのidentityと各webappが使うURLを設定する
     431* デフォルトでは/opt/archappl/appliances.xmlが使われる
     432 * 起動スクリプトの環境変数でファイル名を指定する
     433* AAのクラスタを組む場合は、各ノードに同じファイルのコピーを置くか、共有ディレクトリに置いておく
     434
     435{{{
     436<appliances>
     437   <appliance>
     438     <identity>appliance0</identity>
     439     <cluster_inetport>jkjarchiver-ap.mr.jkcont:16670</cluster_inetport>
     440     <mgmt_url>http://jkjarchiver-ap.mr.jkcont:17665/mgmt/bpl</mgmt_url>
     441     <engine_url>http://jkjarchiver-ap.mr.jkcont:17666/engine/bpl</engine_url>
     442     <etl_url>http://jkjarchiver-ap.mr.jkcont:17667/etl/bpl</etl_url>
     443     <retrieval_url>http://localhost:17668/retrieval/bpl</retrieval_url>
     444     <data_retrieval_url>http://jkjarchiver-ap.mr.jkcont:17668/retrieval</data_retrieval_url>
     445   </appliance>
     446 </appliances>
     447}}}
     448
     449
     450== プロパティファイル ==
     451archappl.propertiesでAAの動作を設定する。
     452* デフォルトでは各web appのWEB-INF/classes/archappl.propertiesが使われる
     453 * 例えば: /opt/archappl/engine/webapps/engine/WEB-INF/classes/archappl.properties
     454 * 起動スクリプトの環境変数ARCHAPPL_PROPERTIES_FILENAMEでファイル名を指定する
     455
     456アーカイブエンジンのバッファがあふれるので、プロパティファイルでマージンを大きめにとることにする:
     457{{{
     458...
     459# Increase buffer capacity adjustment in order to avoid buffer overflow in J-PARC MR.
     460org.epics.archiverappliance.config.PVTypeInfo.sampleBufferCapacityAdjustment = 5.0
     461...
     462}}}
     463
     464サンプリング間隔の補正は無効にしておく:
     465{{{
     466...
     467# J-PARC MR
     468org.epics.archiverappliance.engine.epics.scanJitterFactor=1.00
     469...
     470}}}
     471
     472デフォルトでは、AAに追加したPVが24時間経過しても見つからなかったら、諦めてそのPVのアーカイブは取りやめてしまう。無効にする:
     473{{{
     474# For the moment, don't abort never connected PVs for J-PARC MR
     475org.epics.archiverappliance.mgmt.MgmtRuntimeState.abortArchiveRequestInMins = -1
     476}}}
     477
     478pbファイルのディレクトリの区切りに使う文字を指定する。とりあえずデフォルトのままにしたが、アンダースコア("_")も含めておいた方がよかったかもしれない。
     479{{{
     480org.epics.archiverappliance.config.ConvertPVNameToKey.siteNameSpaceSeparators = [\\:\\-]
     481}}}
     482
     483== TOMCATの設定 ==
     484=== ${TOMCAT_HOME}/conf/server.xml ===
     485* mgmt webappが使うポートを、8080(tomcatのデフォルト)からappliances.xmlで指定したポート番号に合わせて17665にする。
     486{{{
     487...
     488    <!-- A "Connector" represents an endpoint by which requests are received
     489         and responses are returned. Documentation at :
     490         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     491         Java AJP  Connector: /docs/config/ajp.html
     492         APR (HTTP/AJP) Connector: /docs/apr.html
     493         Define a non-SSL HTTP/1.1 Connector on port 8080
     494    -->
     495    <Connector port="17665" protocol="HTTP/1.1"
     496               connectionTimeout="20000"
     497               redirectPort="8443" />
     498
     499...
     500}}}
     501* apache httpdとAJPを使った連携をしない場合は、AJP Connectorの設定をコメントアウトしておく:
     502{{{
     503...
     504    <!--<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />-->
     505...
     506}}}
     507* SHUTDOWNコマンドの使うポートは8005のままにしておく。
     508
     509=== ${TOMCAT_HOME}/lib/log4j.properties ===
     510* logローテーションを仕掛けたい。が、とりあえずそのままにしておく
     511{{{
     512# Set root logger level and its only appender to A1.
     513log4j.rootLogger=ERROR, A1
     514log4j.logger.config.org.epics.archiverappliance=INFO
     515log4j.logger.org.apache.http=ERROR
     516
     517
     518# A1 is set to be a DailyRollingFileAppender
     519log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
     520log4j.appender.A1.File=arch.log
     521log4j.appender.A1.DatePattern='.'yyyy-MM-dd
     522
     523
     524# A1 uses PatternLayout.
     525log4j.appender.A1.layout=org.apache.log4j.PatternLayout
     526log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
     527}}}
     528
     529=== ${TOMCAT_HOME}/conf/context.xml にMySQLの設定を追加する ===
     530* 'jdbc/archappl'の設定を追加する:
     531{{{
     532...
     533<Context>
     534
     535    <!-- Default set of monitored resources -->
     536    <WatchedResource>WEB-INF/web.xml</WatchedResource>
     537
     538    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
     539    <!--
     540    <Manager pathname="" />
     541    -->
     542
     543    <!-- Uncomment this to enable Comet connection tacking (provides events
     544         on session expiration as well as webapp lifecycle) -->
     545    <!--
     546    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
     547    -->
     548
     549    <Resource   name="jdbc/archappl"
     550                auth="Container"
     551                type="javax.sql.DataSource"
     552                factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
     553                username="archappl"
     554                password="archappl"
     555                testWhileIdle="true"
     556                testOnBorrow="true"
     557                testOnReturn="false"
     558                validationQuery="SELECT 1"
     559                validationInterval="30000"
     560                timeBetweenEvictionRunsMillis="30000"
     561                maxActive="10"
     562                minIdle="2"
     563                maxWait="10000"
     564                initialSize="2"
     565                removeAbandonedTimeout="60"
     566                removeAbandoned="true"
     567                logAbandoned="true"
     568                minEvictableIdleTimeMillis="30000"
     569                jmxEnabled="true"
     570                driverClassName="com.mysql.jdbc.Driver"
     571                url="jdbc:mysql://localhost:3306/archappl"
     572                />
     573</Context>
     574}}}
     575
     576== 起動スクリプトの修正 ==
     577インストールスクリプトがAAの起動スクリプトsampleStartup.shを生成するので、環境に合わせて書き換える。
     578* Rasibianでoracle jdk8/openjdk8を使う場合、jvmにサーバーモードが存在しない。jsvcに渡す引数から-serverを削除しておくこと。
     579
     580=== アプライアンスの設定 ===
     581{{{
     582export ARCHAPPL_APPLIANCES=/jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/appliances.xml
     583export ARCHAPPL_MYIDENTITY="appliance0"
     584}}}
     585
     586=== EPICSの設定 ===
     587EPICS用の環境変数を設定するshスクリプトをsourceする:
     588{{{
     589source /jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/setEPICSEnv.sh
     590}}}
     591
     592{{{
     593export EPICS_CA_ADDR_LIST=...
     594#export EPICS_CA_AUTO_ADDR_LIST=false
     595#export EPICS_CA_SERVER_PORT=5064
     596#export EPICS_CA_REPEATER_PORT=5065
     597
     598export EPICS_TS_MIN_WEST=-540
     599#export EPICS_CA_MAX_ARRAY_BYTES=6000000
     600export EPICS_CA_MAX_ARRAY_BYTES=65536
     601}}}
     602
     603=== ポリシーファイル ===
     604ポリシーファイルは環境変数で指定する。インストールスクリプトを実行した際に指定したファイルを指しているので、運転用のポリシーファイルを指すように書き換える:
     605{{{
     606export ARCHAPPL_POLICIES=/jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/policies.py
     607}}}
     608
     609=== プロパティファイル ===
     610インストールスクリプトが作るAAの起動スクリプトには何も書かれていないが、プロパティファイルも起動スクリプトから環境変数で指定する:
     611{{{
     612export ARCHAPPL_PROPERTIES_FILENAME=/jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/archappl.properties
     613}}}
     614
     615=== ストレージの設定 ===
     616{{{
     617export ARCHAPPL_SHORT_TERM_FOLDER=/localdata/archappl/sts/ArchiverStore
     618export ARCHAPPL_MEDIUM_TERM_FOLDER=/localdata/archappl/mts/ArchiverStore
     619export ARCHAPPL_LONG_TERM_FOLDER=/localdata/archappl/lts/ArchiverStore
     620}}}
     621
     622== データ保存先の作成 ==
     623起動スクリプトでの設定に合うように、データを保存するディレクトリを作る。epicsアカウントで書き込めるようにownerを変更しておく:
     624{{{
     625# mkdir -p /localdata/archappl/lts
     626# mkdir -p /localdata/archappl/mts
     627# mkdir -p /localdata/archappl/sts
     628# chown epics.epics /localdata/archappl
     629# chown epics.epics /localdata/archappl/lts
     630# chown epics.epics /localdata/archappl/mts
     631# chown epics.epics /localdata/archappl/sts
     632}}}
     633
     634= Apache httpdとの連携 =
     635AAの各web appにポート80番でアクセスできるようにするため、jkjarchiver-apにリバースプロキシを立ち上げる。ここではAJPを使わずに、naiiveなhttpプロキシにする:
     636{{{
     637# yum install httpd24-httpd-tools httpd24-httpd
     638}}}
     639
     640* /opt/rh/httpd24/root/etc/httpd/conf/httpd.confには触らないようにする
     641* ドキュメントのディレクトリにあるファイルをconf.dにコピーして適宜書き換える
     642{{{
     643# cd /opt/rh/httpd24/root/etc/httpd/conf.d
     644# cp /opt/rh/httpd24/root/usr/share/doc/httpd24-httpd-2.4.18/httpd-default.conf 00-default.conf
     645# cp /opt/rh/httpd24/root/usr/share/doc/httpd24-httpd-2.4.18/httpd-mpm.conf 00-mpm.conf
     646}}}
     647
     648== 基本的な設定 ==
     649* conf.d/00-default.cont
     650{{{
     651Timeout 600
     652}}}
     653
     654* conf.d/00-mpm.conf
     655{{{
     656<IfModule mpm_prefork_module>
     657...
     658   MaxConnecitonPerChild 2000
     659</ifModule>
     660}}}
     661
     662== リバースプロキシの設定 ==
     663* conf.d/proxy.conf
     664{{{
     665ProxyRequests Off
     666
     667ProxyPass        /mgmt http://localhost:17665/mgmt
     668ProxyPassReverse /mgmt http://localhost:17665/mgmt
     669
     670ProxyPass        /retrieval http://localhost:17668/retrieval
     671ProxyPassReverse /retrieval http://localhost:17668/retrieval
     672
     673<Proxy *>
     674   Order deny,allow
     675   Allow from all
     676</Proxy>
     677}}}
     678
     679== httpd24の自動起動の設定 ==
     680{{{
     681# chkconfig --add httpd24-httpd
     682# chkconfig --level 3 httpd24-httpd on
     683# chkconfig --level 4 httpd24-httpd on
     684# chkconfig --level 5 httpd24-httpd on
     685}}}
     686
     687= AAの起動と確認 =
     688== 自動起動/自動停止させる ==
     689/etc/rc.d/init.dに起動スクリプトを用意し、マシンの起動時/停止時にepicsアカウントでAAが自動的に起動/停止するようにする。
     690
     691インストールスクリプトが作った起動スクリプトをrcスクリプトに書き換えたものが
     692{{{
     693/jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/sampleStartup.sh
     694}}}
     695に置いてある。/etc/rc.d/init.dにコピーし、chkconfigを使って適切にsymlinkを張る:
     696{{{
     697# cp /jk/dev/operation_app/jkControl/ArchiverAppliance/deploy/sampleStartup.sh /etc/rc.d/init.d/archappl
     698# /sbin/chkconfig --add archappl
     699# chkconfig --level 3 archappl on
     700# chkconfig --level 4 archappl on
     701# chkconfig --level 5 archappl on
     702}}}
     703
     704== 手動で起動する ==
     705{{{
     706# /etc/rc.d/init.d/archappl start
     707}}}
     708
     709== webブラウザで管理用web appにアクセスする ==
     710次のURLにアクセスする:
     711{{{
     712http://jkjarchiver-ap.mr.jkcont:17665/mgmt
     713}}}
     714* http://jkjarchiver-ap.mr.jkcont:17665/mgmt/ui/index.html にforwardされる
     715* 各web appが起動する前にアクセスすると503が返ってきて"数分待て"と表示されるが、数分では起動しない。気長に待て
     716* 各web appが起動する前にアクセスすると503が返ってきて"数分待て"と表示されるが、数分では起動しない。気長に待て
     717* [[wiki:Archiver Appliance 運用メモ|Archiver Appliance 運用メモ]]に続く
     718
     719= 参考 =
     720* [https://slacmshankar.github.io/epicsarchiver_docs/installguide.html Archiver Appliance Install Guide]
     721* [https://slacmshankar.github.io/epicsarchiver_docs/admin.html Archiver Appliance Administration Guide]
     722* [https://slacmshankar.github.io/epicsarchiver_docs/api/mgmt_scriptables.html Business Process Logics for scripting]
     723* [https://github.com/jeonghanlee/epicsarchiverap-sites Site-specific (ESS) EPICS Archiver Appliance Deployment (for CentOS7)]