Skip to content

Installing MOVES2014a on Linux

Catherine Seppanen edited this page May 7, 2020 · 3 revisions

Table of Contents

Prerequisites

Your Linux machine must have Java installed (version 7 or 8) and MySQL version 5.5 to 5.7. You'll need to know the MySQL root password and you'll need system root privileges.

The EPA provides a Windows installer for MOVES2014a. You'll need access to a Windows machine to run the installer, then transfer the necessary files to your Linux machine.

Installation

From EPA's MOVES site, download the MOVES2014a installer (currently the December 2015 update). In order to run the installer, you'll also need to install Java and MySQL on Windows. The installer will check for these dependencies and won't proceed unless the programs are installed.

While the MOVES2014a installer is running, make a copy of the file C:\Users\Public\EPA\MOVES\MOVES2014a\movesdb20151028.sql. Note that this file is automatically deleted once the installer is finished, so it has to be copied while the installer is running. You can hit the Cancel button after the file has been extracted to pause the installer. You can also grab it while the installer is installing the default database. If you miss it, just run the installer again.

After the installation finishes, copy the MOVES2014a directory (installed in C:\Users\Public\EPA\MOVES\MOVES2014a\ by default) to the Linux machine (/opt/MOVES2014a/). Also transfer the movesdb20151028.sql file. That's all for the Windows machine, everything else is done on the Linux machine.

MySQL Configuration

Running MySQL as root

For MOVES to read and write data between the database and disk, it uses the SQL constructs LOAD DATA INFILE and SELECT ... INTO OUTFILE 'file_name'. When using SELECT ... INTO OUTFILE, the system user that the mysqld process is running as (e.g. mysql) must have permissions to write the specified file. Additionally, every directory in the path to the file must be readable and accessible to that user. MOVES creates new temporary directories when running analyses like /opt/MOVES2014a/MOVESTemporary/ExtDataCache/. These directories are created as the user running the MOVES process.

It may be possible to use umasks and directory sticky bits to allow the mysql user access to the various locations needed by MOVES. However, the simplest option is to run mysqld as root. Note that this is expressly not recommended in the MySQL user's guide, and is a big security risk if MySQL is being used by other applications.

Changing the mysqld user will depend on your system. For example, on an Amazon Linux system, edit the file /etc/init.d/mysqld. Look in the start() section and find the chunk:

$exec   --datadir="$datadir" --socket="$socketfile" \
	--pid-file="$mypidfile" \
	--basedir=/usr --user=mysql >/dev/null 2>&1 &

Change --user=mysql to --user=root and save the file. Restart the MySQL server (the exact command will depend on your system):

sudo /etc/init.d/mysqld restart

You can check the mysqld user using the ps command:

ps aux | grep mysqld

You should see output like below, and the first column should be root.

root      2506  0.0  0.0 115344  3204 ?        S    19:29   0:00 /bin/sh /usr/libexec/mysql55/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=root
root      2715  0.7  0.3 550208 55144 ?        Sl   19:29   0:51 /usr/libexec/mysql55/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=root --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

If you upgrade MySQL, be sure to edit the system launch script (i.e. /etc/init.d/mysqld) each time.

Case sensitivity

In MySQL, database and table names are case sensitive depending on the operating system MySQL is running on. On Windows, the names are NOT case sensitive and the MOVES code is not always consistent about the capitalization of the names. On Linux, database and table names are case sensitive by default, and so MOVES will fail when it tries to run queries using a differently capitalized name.

To deal with the case sensitivity issue, set the MySQL system variable lower_case_table_names=1 in the main MySQL configuration file. Depending on your system, this configuration file might be /etc/my.cnf or /etc/mysql/my.cnf. Look for the [mysqld] section of the file, and add the line:

[mysqld]
...
lower_case_table_names=1
...

Restart the MySQL server (the exact command will depend on your system):

sudo /etc/init.d/mysqld restart

Create the MOVES user

Connect to MySQL (mysql -u root -p) and create the MOVES user. (The following is copied from the CreateMOVESUser.sql script run by the Windows installer.)

FLUSH TABLES;
DROP USER 'moves'@'localhost';
DROP USER 'moves'@'127.0.0.1';
CREATE USER 'moves'@'localhost' IDENTIFIED BY 'moves';
CREATE USER 'moves'@'127.0.0.1' IDENTIFIED BY 'moves';
GRANT ALL PRIVILEGES ON *.* TO 'moves'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'moves'@'127.0.0.1';
FLUSH PRIVILEGES;
FLUSH TABLES;

The above commands grant the MOVES user all privileges on all databases and tables. This allows MOVES to create new databases as needed, but can be a security risk if your MySQL installation is used for other purposes than MOVES (i.e. houses databases for other applications or projects).

If you want to restrict the privileges of the MOVES user, be aware that the LOAD DATA INFILE and SELECT ... INTO OUTFILE commands that MOVES uses require the MySQL user to have the FILE privilege. This privilege must be granted globally (i.e. GRANT FILE ON . TO user@host).

Load the default database

Load the movesdb20151028 database by feeding the file movesdb20151028.sql into MySQL.

mysql -u moves -pmoves <  movesdb20151028.sql

Once the database has been loaded, you can delete the movesdb20151028.sql file.

Go Compilation

MOVES2014a includes an emissions calculator written in the programming language Go. The Windows installation package includes 32- and 64-bit executables for this program (externalcalculatorgo32.exe, externalcalculatorgo64.exe) and the Go source code. To compile the executable on Linux, first install the golang package using the package manager (yum, apt-get, etc.).

sudo yum install golang

Next, compile the executable:

cd /opt/MOVES2014a/calc/go
export GOPATH=`pwd`
go build src/externalcalculatorgo.go

This creates the calculator executable /opt/MOVES2014a/calc/go/externalcalculatorgo.

MOVES2014a Configuration

In the /opt/MOVES2014a/ directory, edit the MOVES configuration files to update the paths for Linux:

File Parameters
MOVESConfiguration.txt sharedDistributedFolderPath = /opt/MOVES2014a/SharedWork
computerIDPath = /opt/MOVES2014a/MOVESComputerID.txt
masterFolderPath = /opt/MOVES2014a
WorkerConfiguration.txt workFolderPath = /opt/MOVES2014a/WorkerFolder
sharedDistributedFolderPath = /opt/MOVES2014a/SharedWork
calculatorApplicationPath = /opt/MOVES2014a/calc/go/externalcalculatorgo

Create the file /opt/MOVES2014a/setenv.csh based on setenv.bat:

#!/bin/csh

setenv MOVES_HOME /opt/MOVES2014a

setenv CLASSPATH $MOVES_HOME
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/jlfgr-1_0.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/junit-4.5.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/mysql-connector-java-5.1.17-bin.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/jaxp-api.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/xercesImpl.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/xml-apis.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/sax.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/jakarta-regexp-1.3.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/jai_core.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/jai_codec.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/commons-lang-2.2.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-api-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-coverage-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-main-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-render-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-wfs-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-wms-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt2-mappane-2.3.0.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-referencing-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/jsr-275-1.0-beta-2.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-shapefile-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-shapefile-renderer-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/jts-1.9.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/geoapi-2.2-M1.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/geotools/gt-metadata-2.5.4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/abbot/abbot.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/abbot/bsh-2.0b4.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/abbot/costello.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/abbot/gnu-regexp-1.1.0.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/abbot/jdom-1.0.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/commons-codec-1.5.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/commons-logging-1.1.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/dom4j-1.6.1.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/log4j-1.2.13.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/poi-3.9-20121203.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/poi-ooxml-3.9-20121203.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/poi-ooxml-schemas-3.9-20121203.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/stax-api-1.0.1.jar"
setenv CLASSPATH $CLASSPATH":$MOVES_HOME/libs/poi/xmlbeans-2.3.0.jar"

If you want to run the MOVES2014a GUI, create a MOVESMaster.sh launch script:

#!/bin/bash

rm -rf SharedWork/*
rm -rf WorkerFolder/*
rm moveslog_old.txt
mv moveslog.txt moveslog_old.txt

export MOVES_HOME=/opt/MOVES2014a

export CLASSPATH=$MOVES_HOME
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/jlfgr-1_0.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/junit-4.5.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/mysql-connector-java-5.1.17-bin.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/jaxp-api.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/xercesImpl.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/xml-apis.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/sax.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/jakarta-regexp-1.3.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/jai_core.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/jai_codec.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/commons-lang-2.2.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-api-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-coverage-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-main-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-render-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-wfs-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-wms-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt2-mappane-2.3.0.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-referencing-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/jsr-275-1.0-beta-2.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-shapefile-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-shapefile-renderer-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/jts-1.9.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/geoapi-2.2-M1.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/geotools/gt-metadata-2.5.4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/abbot/abbot.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/abbot/bsh-2.0b4.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/abbot/costello.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/abbot/gnu-regexp-1.1.0.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/abbot/jdom-1.0.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/commons-codec-1.5.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/commons-logging-1.1.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/dom4j-1.6.1.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/log4j-1.2.13.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/poi-3.9-20121203.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/poi-ooxml-3.9-20121203.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/poi-ooxml-schemas-3.9-20121203.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/stax-api-1.0.1.jar
CLASSPATH=$CLASSPATH:$MOVES_HOME/libs/poi/xmlbeans-2.3.0.jar

java -Xmx512M -classpath $CLASSPATH gov.epa.otaq.moves.master.gui.MOVESGUI
Clone this wiki locally