Skip to content
mdavidsaver edited this page May 24, 2019 · 6 revisions

Setup Archiver Appliance on a RHEL7 or CentOS7 Host

Based on https://slacmshankar.github.io/epicsarchiver_docs/installguide.html

This page describes configuring a single host archiver suitable for evaluation, and for small to medium sized installations. Cluster setup is not described.

Admin notes after install

start/stop with systemd 'archappl.service'.

Uses RPMs for tomcat (must remain 7) and mysql connector

Custom configuration in:

  • /etc/archappl
  • /etc/tomcat/tomcat.conf
  • /var/lib/tomcats/{mgmt,etl,engine,retrieval}

Archive data stored via /arch/{sts,mts,lts} which may be symlinks.

Tested with Java 8.

Installation process

Install Dependencies

Install RPMs for runtime dependencies, and starting the RDB.

yum install tomcat mysql-connector-java mariadb mariadb-server
systemctl start mariadb.service

# choose root PW (or none)
# limit root to localhost recommended
mysql_secure_installation

# Recommended to change final 'archappl' to a different password
# must also change below in '<Resource name="jdbc/archappl"'
mysql --user=root --password=***** <<EOF
CREATE DATABASE archappl;
GRANT ALL ON archappl.* TO 'archappl' identified by 'archappl';
EOF

Prepare storage

A very basic configuration which stores to local disk. Sufficient for testing and small scale use. For production use it is highly recommended that /arch/mts and /arch/lts be symlinks to separate dedicated storage.

install -d -o tomcat -g tomcat /arch
ln -s /dev/shm /arch/sts
install -d -o tomcat -g tomcat /arch/mts/ArchiverStore
install -d -o tomcat -g tomcat /arch/lts/ArchiverStore

Download AA

Download and unpack Archive Appliance release tar.

Further instructions assume the contents of this tar, including mgmt.war, are present in the current working directory.

Initialize the database schema.

unzip -j mgmt.war install/archappl_mysql.sql
mysql --database=archappl --user=archappl --password=archappl < archappl_mysql.sql

Prepare configuration

We will place some archiver wide configuration under /etc/archappl. Defaults are populated.

install -d /etc/archappl
unzip -j mgmt.war WEB-INF/classes/policies.py
unzip -j mgmt.war WEB-INF/classes/archappl.properties
cp policies.py archappl.properties /etc/archappl/

The appliances.xml is holds configuration needed to allow the four archiver processes to communication.

cat > /etc/archappl/appliances.xml <<EOF
 <appliances>
   <appliance>
     <identity>appliance0</identity>
     <cluster_inetport>localhost:16670</cluster_inetport>
     <mgmt_url>http://localhost:17665/mgmt/bpl</mgmt_url>
     <engine_url>http://localhost:17666/engine/bpl</engine_url>
     <etl_url>http://localhost:17667/etl/bpl</etl_url>
     <retrieval_url>http://localhost:17668/retrieval/bpl</retrieval_url>
     <data_retrieval_url>http://localhost:17668/retrieval</data_retrieval_url>
   </appliance>
 </appliances>
EOF

Note: using different port numbers here requires changes in server.xml files. See below.

The contents of appliances.xml are also returned to clients, so it will be necessary to replace localhost with the actual system host name before clients on other hosts can retrieve data.

eg.

sed -i -e 's|localhost|myhost.lab.gov|g' /etc/archappl/appliances.xml

RDB Client configuration

The contents of tomcat.conf are used by systemd to populate environment variables in all four archiver processes.

cat >> /etc/tomcat/tomcat.conf <<EOF
ARCHAPPL_APPLIANCES="/etc/archappl/appliances.xml"
ARCHAPPL_POLICIES="/etc/archappl/policies.py"
ARCHAPPL_PROPERTIES_FILENAME="/etc/archappl/archappl.properties"
ARCHAPPL_MYIDENTITY="appliance0"
ARCHAPPL_SHORT_TERM_FOLDER="/arch/sts/ArchiverStore"
ARCHAPPL_MEDIUM_TERM_FOLDER="/arch/mts/ArchiverStore"
ARCHAPPL_LONG_TERM_FOLDER="/arch/lts/ArchiverStore"
EOF

Edit /etc/tomcat/context.xml and place the following just before the </Context> tag at the end of the file. Note that this is only a shortcut to avoid editing all /var/lib/tomcats/*/conf/context.xml after the later copy step.

<Resource name="jdbc/archappl"
      auth="Container"
      type="javax.sql.DataSource"
      factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
      username="archappl"
      password="archappl" 
      testWhileIdle="true"
      testOnBorrow="true"
      testOnReturn="false"
      validationQuery="SELECT 1"
      validationInterval="30000"
      timeBetweenEvictionRunsMillis="30000"
      maxActive="10" 
      minIdle="2" 
      maxWait="10000" 
      initialSize="2"
      removeAbandonedTimeout="60"
      removeAbandoned="true"
      logAbandoned="true"
      minEvictableIdleTimeMillis="30000" 
      jmxEnabled="true"
      driverClassName="com.mysql.jdbc.Driver"
      url="jdbc:mysql://localhost:3306/archappl"
 />

Tomcat instance setup

Run the following to create and copy the default tomcat configuration for each of the four archiver processes.

This only makes modifications under /var/lib/tomcats/ which should be empty by default.

for name in engine etl mgmt retrieval
do
  # Wipe result of previous run.
  # No data or configuration present, except maybe site customization of HTML ui elements.
  rm -rf /var/lib/tomcats/${name}

  for dname in webapps logs temp work lib
  do
    install -d -d /var/lib/tomcats/${name}/${dname}
  done
  cp -r /etc/tomcat /var/lib/tomcats/${name}/conf

  cp ${name}.war /var/lib/tomcats/${name}/webapps

  chown -R tomcat:tomcat /var/lib/tomcats/${name}

  # cf. default for common.loader=
  # in conf/catalina.properties
  ln -s /usr/share/java/mysql-connector-java.jar /var/lib/tomcats/${name}/lib/
done

It is necessary for these four copies to use different TCP ports. The Server and AJP ports may be arbitrarily selected. The Connector port numbers must match those listed in appliances.xml.

sed -i -e 's|Server port="8005"|Server port="8010"|' /var/lib/tomcats/mgmt/conf/server.xml
sed -i -e 's|Server port="8005"|Server port="8011"|' /var/lib/tomcats/engine/conf/server.xml
sed -i -e 's|Server port="8005"|Server port="8012"|' /var/lib/tomcats/etl/conf/server.xml
sed -i -e 's|Server port="8005"|Server port="8013"|' /var/lib/tomcats/retrieval/conf/server.xml

# AJP connector may also removed entirely
sed -i -e 's|port="8009"|port="8020"|' /var/lib/tomcats/mgmt/conf/server.xml
sed -i -e 's|port="8009"|port="8021"|' /var/lib/tomcats/engine/conf/server.xml
sed -i -e 's|port="8009"|port="8022"|' /var/lib/tomcats/etl/conf/server.xml
sed -i -e 's|port="8009"|port="8023"|' /var/lib/tomcats/retrieval/conf/server.xml

sed -i -e 's|Connector port="8080"|Connector port="17665"|' /var/lib/tomcats/mgmt/conf/server.xml
sed -i -e 's|Connector port="8080"|Connector port="17666"|' /var/lib/tomcats/engine/conf/server.xml
sed -i -e 's|Connector port="8080"|Connector port="17667"|' /var/lib/tomcats/etl/conf/server.xml
sed -i -e 's|Connector port="8080"|Connector port="17668"|' /var/lib/tomcats/retrieval/conf/server.xml

Configure systemd

The tomcat RPM provides /usr/lib/systemd/system/tomcat@.service handles the mechanics of starting and stopping JVMs. We only need to provide archiver specific information on dependencies and order.

The archappl.service unit will act as the entry point for starting and stopping all four processes.

cat > /etc/systemd/system/archappl.service <<EOF
[Unit]
Description=EPICS Archiver Appliance
Requires=network.target
After=network.target
Requires=tomcat@mgmt.service tomcat@engine.service tomcat@etl.service
Wants=tomcat@retrieval.service
[Service]
Type=oneshot
ExecStart=/bin/true
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

For the individual processes, we inject some extra configuration. After a daemon-reload, the effects of this can be observed with systemctl cat ....

install -d /etc/systemd/system/tomcat@mgmt.service.d
cat > /etc/systemd/system/tomcat@mgmt.service.d/extra.conf <<EOF
[Unit]
After=mariadb.service
Requires=mariadb.service
PartOf=archappl.service
EOF

install -d /etc/systemd/system/tomcat@etl.service.d
cat > /etc/systemd/system/tomcat@etl.service.d/extra.conf <<EOF
[Unit]
After=network.target tomcat@mgmt.service
Requires=network.target tomcat@mgmt.service
PartOf=archappl.service
EOF

install -d /etc/systemd/system/tomcat@engine.service.d
cat > /etc/systemd/system/tomcat@engine.service.d/extra.conf <<EOF
[Unit]
After=network.target tomcat@mgmt.service tomcat@etl.service
Requires=network.target tomcat@mgmt.service tomcat@etl.service
PartOf=archappl.service
EOF

install -d /etc/systemd/system/tomcat@retrieval.service.d
cat > /etc/systemd/system/tomcat@retrieval.service.d/extra.conf <<EOF
[Unit]
After=network.target tomcat@mgmt.service tomcat@engine.service tomcat@etl.service
Requires=network.target tomcat@mgmt.service
Wants=tomcat@engine.service tomcat@etl.service
PartOf=archappl.service
EOF

systemctl daemon-reload

Starting up...

Before starting the archiver it will be necessary either to disable SELinux, or to change the policy for Java and/or Tomcat to allow using the the CA ports. Doing so is far beyond the scope of this guide. To disable:

setenforce 0

Actually start the archiver with:

systemctl start archappl.service

Now point a browser to http://localhost:17665/mgmt

To automatically start on boot

systemctl enable archappl.service