Quickstart Linux

From MidasWiki
Revision as of 19:51, 21 December 2015 by Suz (talk | contribs) (Created page with "{{Pagelinks}} ==Installation== Decide on a username to run the experiment, and log in as this username on the host machine. This machine will host the MIDAS experiment, i.e....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Installation

Decide on a username to run the experiment, and log in as this username on the host machine. This machine will host the MIDAS experiment, i.e. where the ODB and other shared memory buffers will reside. This will also be where the MIDAS and other packages will be installed, and will be called the MIDAS host (localhost). Decide on a name for the experiment (i.e. MIDAS experiment name).

In these instructions, the username is "johnfoo" and the MIDAS and other packages will be installed under $HOME/packages/ . The MIDAS experiment directory will be $HOME/online and the MIDAS experiment name will be "e777". The MIDAS host name will be "mhostpc" The user will substitute appropriate host name, username, MIDAS experiment name and directories for his/her own setup.

Experimental setup

These instructions describe setting up an experiment that will run ONLY on the MIDAS host computer (i.e. localhost only). In this case, the MIDAS host has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer.

Modifications to run an experiment with additional frontend(s) running remotely (i.e. on remote cpu(s)) will be described below. In that case, the remote cpu(s) typically have access to some or all the hardware. They might be cpus running in VME crates for example, connected to the MIDAS Host via Ethernet. They read data from the hardware and send it back to the MIDAS Host to be analyzed and/or logged.

In both cases, the main MIDAS applications (e.g. mlogger, mhttpd) run on the MIDAS host.

Environment Variables

The following Environment variables should to be added to the $HOME/.cshrc (or .bash) file depending on your shell so that they will then be defined at login. Substitute appropriate values for your own setup.

csh bash comment
setenv LANG C export LANG=C
setenv GIT_EDITOR "emacs -nw" export GIT_EDITOR="emacs -nw"
setenv MIDASSYS $HOME/packages/midas export MIDASSYS=$HOME/packages/midas Base directory of the MIDAS package
setenv ROOTSYS $HOME/packages/root export ROOTSYS=$HOME/packages/root setup ROOTSYS only if using ROOT
setenv MIDAS_EXPTAB $HOME/online/exptab export MIDAS_EXPTAB=$HOME/online/exptab MIDAS experiment table
setenv MIDAS_EXPT_NAME e777 export MIDAS_EXPT_NAME=e777 MIDAS experiment name
setenv PATH .:$MIDASSYS/linux/bin:$PATH export PATH=$PATH:$MIDASSYS/linux/bin path
setenv PATH .:$HOME/online/bin:$ROOTSYS/bin:$PATH export PATH=$PATH:$HOME/online/bin:$ROOTSYS/bin if using ROOT

Logout and login again, or source .cshrc (source .bashrc) for the changes to take effect.

ROOT Package Installation

For full MIDAS operation, ROOT is needed for the data logging and analysis packages. However, ROOT is not essential to run MIDAS. If ROOT is NOT installed, the environment variable ROOTSYS should be undefined.

If ROOT is needed, see Install ROOT.

MIDAS Package Installation

Installed the MIDAS and other package(s) from the MIDAS git repository as follows:

   mkdir $HOME/packages
   cd $HOME/packages
   git clone https://bitbucket.org/tmidas/midas
   git clone https://bitbucket.org/tmidas/mxml

Install the MSCB package only if you will be using the MSCB (seeMSCB Page) system for slow-controls:

   git clone https://bitbucket.org/tmidas/mscb    ## MSCB package
   cd mscb
   make        ## Build the MSCB package
   cd ../

The MIDAS Makefile will auto-detect whether MSCB, ROOT, MYSQL, SQLITE, ODBC etc. are available (or have been installed). If you need these features, make sure they are available before building the MIDAS package.

   cd midas
   make          ## Build the MIDAS package
   ls -l linux/bin/odbedit      ### check that odbedit has been created (do not run it yet)
 

In case of problems see bitbucket down or SSL certificate errors.


ROOTANA Package Installation

If ROOTANA is needed,

   cd $HOME/packages
   git clone https://bitbucket.org/tmidas/rootana
   cd rootana
   make

ROODY Package Installation

If ROODY is needed,

   cd $HOME/packages
   git clone https://bitbucket.org/tmidas/roody
   cd roody
   make
   

Create exptab

In this example, the experimental directory is $HOME/online.

mkdir $HOME/online
cd $HOME/online

Create the exptab file "$HOME/online/exptab" containing the three parameters

  1. the experiment name
  2. location of MIDAS shared memory buffers
  3. username

as follows:

   cat > exptab
   e777 /home/johnfoo/online johnfoo

Create shared memory files

At this point you should be able to run odbedit on localhost. The first time odbedit is run, it will create the required .*.SHM files in the MIDAS experiment directory $HOME/online.

The default directory $HOME/online will contain the MIDAS messages file (midas.log) and any data files you may create. If you want an alternative location for the data files see #Customizing your experiment.

Now run odbedit, and type the command "ls" to list the default directories.

odbedit>
[local:e777:S]/>ls
Experiment
System
Programs
Logger
Runinfo
Alarms 

Run the MIDAS logger mlogger

Start the MIDAS logger $ mlogger This should start without error at this point. It is usually run as a daemon, however in this case it is run in a terminal to check for errors.

Run the MIDAS Web Server mhttpd

If you are running behind a firewall or plan to set up an HTTPS/SSL proxy, follow the instructions mhttpd using an HTTPS/SSL proxy.

Otherwise, the default HTTPS/SSL web server (Mongoose) will be used. Now try to start mhttpd like this:

$ mhttpd

You will get the following messages:

[mhttpd,INFO] ODB subtree /Runinfo corrected successfully
Mongoose web server will listen on ports "8080r,8443s"
Mongoose web server will use SSL certificate file "/home/johnfoo/packages/midas/ssl_cert.pem"
[mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file "/home/johnfoo/online/htpasswd.txt"
[mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas
could not start the mongoose web server, see messages and midas.log, bye!

For testing, use the SSL certificate file provided in the MIDAS package (unless your site provides one, or you wish to create one of your own, see Create an SSL certificate).

However, you do need to create a password file by following the above instructions. You will be asked to type in a password

$ htdigest -c /home/johnfoo/online/htpasswd.txt Default midas Adding password for midas in realm Default. New password: Re-type new password:

Now restart mhttpd $ mhttpd Mongoose web server will listen on ports "8080r,8443s" Mongoose web server will use SSL certificate file "/home/suz/packages/midas/ssl_cert.pem" Mongoose web server will use authentication realm "Default", password file "./htpasswd.txt"

Now point a web browser running on the same host computer (localhost) to https://localhost:8443/ (If the web browser is running on a different computer, go to URL https://mhostpc.triumf.ca:8443 where you substitute your host machine name for "mhostpc.triumf.ca").

If you are using the default SSL certificate you will probably get a "This Connection is Untrusted" message. Click "I understand the risks" and add an exception. This is because the test certificate is self-signed. Then confirm an exception.

You should then see an authentication box asking you for the user name and password. The user name is "midas". Enter the password you just created. Then you should see the MIDAS Status Page for your experiment.

Note that the default ports of 8080 and 8443 are used by mhttpd. If these ports are in use on your machine, start mhttpd with alternative ports, e.g.

$ mhttpd --https 8448 --http 8089

or see Mhttpd#Usage to change the default ports.


Create a start_daq script

Create $HOME/online/bin/start_daq.sh as follows, (supply the mhttpd ports if default is not used).

#!/bin/sh
# start_daq.sh
cd $HOME/online
odbedit -c clean
#   start mhttpd on default port. (Mongoose https version)
mhttpd  -D  # optionally restrict access to localhost and/or other specified hosts - see mhttpd
xterm -e ./frontend &
xterm -e ./analyzer &
mlogger -D
#end file

Before running this script, you will need to shutdown mhttpd and mlogger if they are running. This script will start them as daemons. You will also need to #Create a frontend and analyzer if desired.

Create a frontend and analyzer

There are several examples available under $MIDASSYS/examples/. Choose a suitable example from this directory that you can modify later for your own particular setup (e.g. for a slow control, choose the slowcont/ example). The example chosen here is $MIDASSYS/examples/experiment/ .

On the MIDAS host (localhost), copy the example to the experiment directory and build it.

     cd $HOME/online
     cp $MIDASSYS/examples/experiment/* .
     make

The analyzer will build properly if ROOT has been previously installed.

   At this point the frontend and the analyzer should be ready if no errors were generated during the build. You can try the frontend and analyzer by starting them by hand, or run the script start_daq.sh (see #Create a start_daq script).

By running the script start_daq.sh, several midas applications will be started in sequence.

       Cleanup previous midas application (if any).
       Start the midas web server [mhttpd]
       Start the frontend application in its own xterm (for debugging purpose).
       Start the analyzer application in its own xterm (for debugging purpose).
       Start the Midas Data logger [mlogger]
  $ sh ./start_daq

Starting a frontend will automatically create the /Equipment ODB tree and one or more equipments. Starting the midas logger mlogger will automatically create more keys in the /Logger ODB tree.

View the MIDAS main status web page by pointing your browser to https://localhost:8443/ (or appropriate port if not using the default). The Midas run status page should appear with multiple buttons for run control as well as equipment listing and application listings. Please refer to mhttpd (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the ODB Page to access the database (ODB). You will want to customize the ODB for your experiment.

While a run is in progress, the midas application mdump will provide you an event dump of the collected data from the running frontend. For further data processing/analysis, either the midas analyzer or the rootana can used for data display as well.


Running with one or more REMOTE frontend(s)

These instructions assume you have already setup an experiment running on localhost, i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the mhttpd password etc.

Follow these instructions to make the modifications needed to run an experiment with remote frontends.

These instructions also assume that there is one remote cpu, which is a 32-bit machine which mounts the /home disk of the localhost machine, so that it has access to the MIDAS packages, the $HOME/online directory and shares the .cshrc (or .bash) script. The REMOTE Host will be called "rlxhost" in these instructions.

If the MIDAS host computer (localhost) is 64-bit, and the frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.

   cd /home/packages/midas
   make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine
   ls -l linux-m32/bin/odbedit ### check that the 32-bit odbedit has been created (do not run it)

Modify .cshrc (.bash)

Add the following to the .cshrc (modified appropriately for .bash). When running with a REMOTE Host, the application mserver will be started (using a particular port) on the MIDAS host machine only. Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but not on the MIDAS host.

  1. setenv MIDAS_HOST mhostpc # substitute your midas host name
  2. setenv REMOTE_HOST rlxhost # substitute your remote host name (add more if > 1)
  3. setup the MIDAS mserver host

switch (`hostname`) case $MIDAS_HOST*:

  unsetenv MIDAS_SERVER_HOST     ## MIDAS_SERVER_HOST not defined
  breaksw

default: setenv MIDAS_SERVER_HOST $MIDAS_HOST.triumf.ca:1175 ## for remote host, define as hostname + domain name + default mserver port

                                                ## port must match that of mserver used in start_daq.sh 

endsw

  1. select 64-bit or 32-bit MIDAS and ROOT

switch (`uname -i`) case i386:

  setenv ROOTSYS /triumfcs/trshare/olchansk/root/root_v5.28.00_SL55_32
  setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH
  breaksw

default:

  setenv ROOTSYS $HOME/packages/root
  setenv PATH .:$MIDASSYS/linux/bin:$PATH

endsw

setenv PATH .:$HOME/online/bin:$HOME/packages/roody/bin:$ROOTSYS/bin:$PATH

After executing .cshrc (or .bash) or logging out, on the MIDAS host (mhostpc) make sure MIDAS_SERVER_HOST is NOT defined

echo $MIDAS_SERVER_HOST
MIDAS_SERVER_HOST: Undefined variable.

and on the REMOTE Host, make sure MIDAS_SERVER_HOST IS defined:

 echo $MIDAS_SERVER_HOST
 MIDAS_SERVER_HOST

Also on the REMOTE Host, make sure that the correct (32-bit) odbedit will be used (do not run it yet!) [johnfoo@rlxhost e777]$ which odbedit /home/johnfoo/packages/midas/linux-m32/bin/odbedit

Grant REMOTE host access permission

Give permission for the remote host(s) to access the experiment. Follow the instructions |Allow MIDAS programs on remote machines. If the MIDAS web server is running, use ODB Page to edit the ODB keys listed, otherwise use odbedit on the MIDAS host machine.

Modify experiment startup script

Modify the experiment startup script start_daq.sh. The application mserver is not required when running on localhost only, but it IS required for access from a REMOTE frontend.

  1. !/bin/sh
  2. start_daq.sh

cd $HOME/online

switch (`hostname`)

case $MIDAS_HOST*:
   echo "Good, we are on $MIDAS_HOST"
   breaksw
case $REMOTE_HOST*:
   echo "start_daq script should be executed on $MIDAS_HOST"

endsw

odbedit -c clean

  1. start mhttpd on default port (Mongoose https version)

mhttpd -D # optionally restrict access to localhost and/or other specified hosts - see mhttpd

  1. start mserver on default port (use argument -p to use a different port)

mserver -D # start mserver on default port (1175) or a different port using -p option - see mserver

           # the port must match that of MIDAS_SERVER_HOST in .cshrc (.bash) - see above
           # access must be specifically allowed - see above

xterm -e ./analyzer &

    1. start frontend on remote host
  1. ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O >& $HOME/online/bin/start_frontend.log &

mlogger -D

  1. end file

Note that command to start the frontend on the remote host is commented out. It can be uncommented once the start_frontend script is written and tested.

Shut down any clients that are running already by running odbedit on the MIDAS HOST

 odbedit>
[local:e777:S]/>sh all

Execute the new startup script start_daq.sh and check that odbedit now works on the REMOTE host

[johnfoo@rlxhost e777]$ odbedit
[mhostpc.triumf.ca:1177:e777:Stopped]/>ls

If it does not, check that

  • MIDAS_SERVER_HOST is setup correctly
  • mserver is running with the correct port
  • remote access permission to REMOTE host has been granted

See above for details.

Build the frontend

The frontend must be built on the REMOTE Host (a 32-bit machine in this example). To avoid confusion, create a different subdirectory for the frontend running on the remote host, e.g.

  mkdir $HOME/online/fe32

Create or modify an example frontend in this directory, and modify a Makefile to compile and build it with the 32-bit MIDAS libraries. Once built, start the frontend by hand (while logged on to the REMOTE host). Check that it connects successfully to the experiment (e.g. with mhttpd Status Page).

Create start_frontend script

Create start_frontend script (e.g. file $HOME/online/bin/start_frontend)

  1. !/bin/tcsh
  2. Script to start frontend running on $REMOTE_HOST
  3. This script runs on the REMOTE HOST

echo "starting frontend for experiment $MIDAS_EXPT_NAME " xterm -geometry 150x50+800+0 -fg white -bg blue -title "Frontend" -e "$HOME/$ONLINE/fe32/frontend" & echo "Frontend task has been started" exit

Check it works by running it on the REMOTE host. Then uncomment line in start_daq.sh, and check start_daq.sh can start all the clients from the MIDAS host.


Customize the experiment

data directory

To change where data files are stored and the message file midas.log is located away from the default, create a data directory, e.g.

mkdir /data1/e777/; mkdir /data1/e777/data

[local:e777:S]/>ls /logger ## list the contents of the /logger tree

Data dir                        /home/johnfoo/online/          
Message file                    midas.log

If desired, set the location for the midas.log and any data files, e.g.

[local:e777:S]/>set "/logger/data dir" /data1/e777/data/
[local:Default:S]/>exit