OGSA Prerequisite Software Installation and Configuration on Linux RedHat 9.0 HOWTO by Hong Ong $Id: gt3_preinstall.txt,v 1.1 2004/03/30 12:47:00 hong Exp hong $ This document explains how to install, configure and test some of the pre-requisite software for Grid Service Development. Although the explanation is meant for RH 9.0 Linux, other Unix or Unix-like distributions could potentially follow this guide. Copyright and License --------------------- This document, OGSA Prerequisite Software Installation and Configuration on Linux RedHat 9.0 HOWTO, is copyrighted (c) 2003, 2004 by the Distributed Systems Group, Portsmouth, UK. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html. Linux is a registered trademark of Linus Torvalds. Redhat is a registered trademark of Redhat Inc. Disclaimer ---------- No liability for the contents of this document can be accepted. Use the concepts, examples and information at your own risk. There may be errors and inaccuracies that could be damaging to your system. Proceed with caution, and although this is highly unlikely, the author(s) do not take any responsibility. All copyrights are held by their respective owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements. 0. Prologues ============ This document could be used with the following documents: * GT3 Installation Guide on Redhat 9.0 Linux. * OGSA-DAI Installation Guide on Redhat 9.0 Linux. * Grid service development on Redhat 9.0 Linux. The software described here is required, in general, for Grid-based services development. However, you might find it useful for your non Grid-based projects. This document is considered as work in progress. Additional materials, where appropriate, will be added in future. Please send your comments to the author(s). 1. GT3 Pre-requisite Software Installation ========================================= This document presents the steps necessary to install and configure some software required by GT3, OGSA-DAI and GridSphere on machines running Redhat Linux. 2. System Environment ===================== The target system is a Redhat 9.0 Linux 2.4 distribution. Whenever possible, we will use binary and/or rpm distributions. This will make life easier. Off course, if you enjoy the "challenge", you could also compile packages using source distribution; a brief guide will soon be given in the appendix of this document. Some software installation, e.g., databases software, required you to have root permissions. Unless stated otherwise, in this document, we assume the user root will install all pre-requisite software. Ensure that you have downloaded all of the files before you start the installation; it will go smoother, trust me. A set of shell scripts (alpha release) has been created to help installation. They (the shell scripts) can be obtained from http://dsg.port.ac.uk/ogsa-testbed/. 3 Essential tools ================= 3.1 Software Download ===================== Packages are assume to be downloaded to $DOWNLOAD_DIR directory, e.g., DOWNLOAD_DIR=/tmp/download. * Java(TM) 2 Software Development Kit, Standard Edition Package: j2sdk Version: 1.4.2_03 Homepage: http://java.sun.com/linux Description: JVM, core class libraries and tools for Java programming. * Apache Ant Package: apache-ant Version: 1.6.1+ Homepage: http://ant.apache.org/ Description: Apache build tool * Junit Package: junit Version: 3.8.1+ Homepage: http://www.junit.org Description: Unit testing * Jakarta Tomcat Servlet Container Tomcat Package: jakarta-tomcat Version: 4.1+ Homepage: http://jakarta.apache.org/tomcat/index.html Description: Web service container Comment: If you intend to use with GridSphere, do not download the Light Edition (LE); also, do not download Tomcat 5 since it uses the Servlet 2.4 API and has not yet been tested with GridSphere 1.1; * Network Time Protocol Package: ntp Version: 4.1.2 Homepage: http://www.ntp.org Description: Network time protocol * Relational Databases Required only if you want to install Reliable File Transfer (RFT) and Replica Location Service (RLS), and OGSA-DAI. You only need to select one of the following: * Postgresql Package: postgresql Version: 7.4.0+ Homepage: http://www.postgresql.org Description: relational database * MySQL Package: mysql Version: 4.0.18+ Homepage: http://www.mysql.com Description: relational database * Relational Database Driver Depending on the databases you have chosen above, you may need to install the appropriate JDBC driver. JDBC is a Java API for executing SQL statements. It consists of a set of classes and interfaces written in Java. More information about JDBC can be found at http://java.sun.com/products/jdbc. You only need to select one of the following: * Postgresql JDBC Driver Package: postgresql-jdbc Version: 7.4.0+ Homepage: http://www.postgresql.org Description: Postgresql JDBC driver * MySQL JDBC Driver Package: mysql-connector-java Version: 4.0.18 Homepage: http://www.mysql.com/downloads Description: mysql jdbc driver 3.2 Annotation ============== DOWNLOAD_DIR - software download directory (/tmp/download). INSTALL_DIR - software install directory (/opt). ANT_HOME - ant installation directory ($INSTALL_DIR/apache-ant/ant). JAVA_HOME - java installation directory (/usr/java/java). JUNIT_HOME - junit installation directory ($INSTALL_DIR/junit/junit). CATALINA_HOME - tomcat installation directory ($INSTALL_DIR/tomcat4/tomcat). OGSA_HOME - Globus GT3 installation directory ($INSTALL_DIR/globus/gt3); OGSADAI_HOME - ogsa-dai installation directory ($INSTALL_DIR/globus/ogsa-dai); 3.3 Software Installation ========================= Go to your $DOWNLOAD_DIR and start with the following procedures. They will walk you through extracting the source files of the applications, compiling, installing, configuring, and then testing them. Tip: For some packages, you could install the rpm packages using RH9 Add/Remove Application program. Go to your main menu panel, select System Settings -> Add/Remove Applications and select the required software packages. 3.3.1 Java SDK Installation =========================== * Refer to java_install_rpm.sh (for rpm package) or java_install.sh (for self-extract binary) Installation ------------- * Goto your $DOWNLOAD_DIR directory and become root, {hong@l59 < ~ >}[%1] cd /tmp/download {hong@l59 < /tmp/download >}[%2] su Password: * Extract the j2sdk rpm [root@l59 ] sh j2sdk-1_4_1_05-linux-i586-rpm.bin * You will see Java license statement - Sun Microsystems, Inc. Binary Code License Agreement for the JAVATM 2 SOFTWARE DEVELOPMENT KIT (J2SDK), STANDARD EDITION, VERSION 1.4.2_X ... For inquiries please contact: Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. (LFI#135003/Form ID#011801) Do you agree to the above license terms? [yes or no] yes Unpacking... Checksumming... 0 0 Extracting... UnZipSFX 5.40 of 28 November 1998, by Info-ZIP (Zip-Bugs@lists.wku.edu). * Install j2sdk rpm. JDK will be installed into /usr/java/j2sdk1.4.2_03 [root@l59 download]# rpm -ivh j2sdk-1_4_2_03-linux-i586.rpm Preparing... ########################################### [100%] 1:j2sdk ########################################### [100%] Configuration -------------- * Create a symbolic link [root@l59 ]# ln -s /usr/java/j2sdk1.4.2_03 /usr/java/java * Set up JAVA_HOME and PATH environment [root@l59 download]# export JAVA_HOME=/usr/java/java [root@l59 download]# export PATH=$PATH:$JAVA_HOME/bin Testing ------- * Create a HelloWorld.java program with you favorite editor: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } * Compile and run the HelloWorld.java program javac HelloWorld.java java HelloWorld * You should see the following output: Hello, World! * Congratulations, you have installed, set up an environment for, and tested the Sun J2SE for Linux. 3.3.2 Apache-Ant Build Tool =========================== * Refer to ant_install_bin.sh Installation ------------ * Goto $DOWNLOAD and become root. {hong@l59 < ~ >}[%1] cd /tmp/download {hong@l59 < /tmp/download >}[%2] su Password: * Unzip apache-ant [root@l59 ]# tar zvxf apache-ant-1.6.1-bin.tar.gz * Make an installation directory $INSTALL_DIR/apache-ant for apache-ant [root@l59 ]# mkdir /opt/apache-ant * Move $DOWNLOAD_DIR/apache-ant-1.6.1 to $INSTALL_DIR/apache-ant [root@l59 ]# mv apache-ant-1.6.1 /opt/apache-ant/ Configuration ------------- * Create a symbolic link to ant [root@l59 ]# ln -s /opt/apache-ant/apache-ant-1.6.1 /opt/apache-ant/ant * Set the ANT_HOME environment to point to this location. [root@l59 ]# export ANT_HOME=/opt/apache-ant/ant * Add ANT to your PATH environment [root@l59 ]# export PATH=$ANT_HOME/bin:$PATH * For system-wide configuration, you may want to put the above two commands to "/etc/profile.d/ant.sh" and "/etc/profile.d/ant.csh" Testing ------- * To test ant-installation, create a build.xml file [root@l59 ]# vi build.xml public class HelloWorld { public static void main(String[] args) { System.out.println("HelloWorld"); } } * Run ant, make sure ANT_HOME and your PATH are set appropriately. [root@l59 ]# ant run * You should see the following output: Buildfile: build.xml init: HelloWorld: [echo] Wrote HelloWorld.java compile: [javac] Compiling 1 source file to /home/hong/grid/testbed/scripts/test run: [java] HelloWorld [echo] Ant has been successfully installed BUILD SUCCESSFUL Total time: 7 seconds * Congratulation, you have successfully installed apache-ant. 3.3.3 Junit =========== * Refer to junit_install_bin.sh Installation ------------ * Goto $DOWNLOAD_DIR directory and become root, {hong@l59 < ~ >}[%1] cd /tmp/download {hong@l59 < /tmp/download >}[%2] su Password: * Unzip the junit.zip distribution file [root@l59 ]# unzip junit3.8.1.zip * Make an installation directory, $INSTALL_DIR/junit, for junit [root@l59 ]# mkdir /opt/junit * Move $DOWNLOAD_DIR/junit3.8.1 to $INSTALL_DIR/junit [root@l59 ]# mv junit3.8.1 /opt/junit/ Configuration -------------- * Create a symbolic link to ant [root@l59 ]# ln -s /opt/junit/junit3.8.1 /opt/junit/junit * Add JUnit to the classpath: [root@l59 ]# export JUNIT_HOME=/opt/junit/junit [root@l59 ]# export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit.jar * For system wide configuration, create a shell script (/etc/profile.d/junit.sh) and insert the above two lines. Testing ------- * Test Junit installation [root@l59 ]# java -classpath $CLASSPATH:/opt/junit/junit/junit.jar:/opt/junit/junit junit.textui.TestRunner junit.samples.AllTests * You should see the following output: ......................................... ......................................... ..................................... Time: 1.734 OK (119 tests) * Congratulations, you have successfully install junit 3.3.4 Jakarta Tomcat Servlet Container ====================================== * Refer to tomcat4_install_bin.sh Installation ------------ * Goto $DOWNLOAD_DIR directory and become root, {hong@l59 < ~ >}[%1] cd /tmp/download {hong@l59 < /tmp/download >}[%2] su Password: * Unzip jakarta-tomcat-4.1.30.tar.gz [root@l59 ]# tar zvxf jakarta-tomcat-4.1.30.tar.gz * Make an installation directory for tomcat container [root@l59 ]# mkdir /opt/tomcat4 * Create a tomcat user [root@l59 ]# groupadd tomcat [root@l59 ]# useradd -g tomcat -c "Tomcat User" -d /opt/tomcat tomcat [root@l59 ]# passwd tomcat * Move $DOWNLOAD_DIR/tomcat-4.1.30 to $INSTALL_DIR/tomocat [root@l59 ]# mv jakarta-tomcat-4.1.30 /opt/tomcat/ * Change ownship of $INSTALL_DIR/tomocat [root@l59 ]# chown -R tomcat.tomcat /opt/tomcat Configuration ------------- * Create a symbolic link to ant [root@l59 ]# ln -s /opt/tomcat4/jakarta-tomcat-4.1.30 /opt/tomcat4/tomcat * Set the CATLINA_HOME environment to point to this location. [root@l59 download]# export CATALINA_HOME=/opt/tomcat4/tomcat * Add Tomcat4 to your PATH environment [root@l59 download]# export PATH=$CATALINA_HOME/bin:$PATH * You could also configure tomcat to start up at boot time. You may need to adjust the $TOMCAT_HOME and $JAVA_HOME variables inside the scripts * Create a startup script "/etc/init.d/tomcatd". #!/bin/bash # # Startup script for Tomcat # # chkconfig: 345 84 16 # description: Tomcat jakarta JSP server TOMCAT_HOME=/opt/tomcat4/tomcat TOMCAT_START=$TOMCAT_HOME/bin/startup.sh TOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh #Necessary environment variables export JAVA_HOME="/usr/java/java" export CATALINA_HOME=$TOMCAT_HOME #export LD_KERNEL_ASSUME="2.2.5" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 #Check for tomcat script if [ ! -f $TOMCAT_HOME/bin/catalina.sh ] then echo "Tomcat not available..." exit fi start() { echo -n "Starting Tomcat: " su - tomcat -c $TOMCAT_START echo touch /var/lock/subsys/tomcatd # We may need to sleep here so it will be up for apache sleep 3 #Instead should check to see if apache is up by looking for httpd.pid } stop() { echo -n $"Shutting down Tomcat: " su - tomcat -c $TOMCAT_STOP rm -f /var/lock/subsys/tomcatd echo } status() { ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt read line < /tmp/tomcat_process_count.txt if [ $line -gt 0 ]; then echo -n "tomcatd ( pid " ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' echo -n ") is running..." echo else echo "Tomcat is stopped" fi } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 3 start ;; status) status ;; *) echo "Usage: tomcatd {start|stop|restart|status}" exit 1 esac * Execute the following command after editing "tomcatd" [root@l59 ]# chkconfig tomcatd on * To start tomcat, [root@l59 ]# service tomcatd start * Refer to Apache server for more configuration options. Testing ------- * Test the installation. As root, type [root@l59 ]# $CATALINA_HOME/bin/startup.sh Using CATALINA_BASE: /opt/tomcat4/tomcat Using CATALINA_HOME: /opt/tomcat4/tomcat Using CATALINA_TMPDIR: /opt/tomcat4/tomcat/temp Using JAVA_HOME: /usr/java/java * Check that everything is okay by accessing http://localhost:8080/ with your favorite browser - you should see a Tomcat page. If you do not, please refer to Tomcat's installation documentation. * Congratulations, you have successfully installed Tomcat. 3.3.5 Network Time Protocol (NTP) ================================= The clocks on the system, throughout the Grid, need to be synchronized. This is to ensure the proxy certificates are valid for specific times. So, if you do not synchronize the system clocks, the proxy certificate may appear to be expired on or not yet valid. If your system is configured with NTP, then you can skip this section. Installation ------------ * To check if NTP is installed, [root@l59 ]# rpm -qa | grep ntp ntp-4.1.2-0.rc1.2 * If you did not see the above output, you need to install NTP; you could get this package from http://www.redhat.com/download/mirror.html. As root, issue the following command: [root@l59 ]# rpm -ivh ntp-4.1.2-0.rc1.2.i386.rpm * For source compilation, see http://www.ntp.org documentation page. Configuration ------------- * Modify the /etc/ntp.conf. * Start the NTP service, [root@l59 download]# service ntpd start * To start at boot time, [root@l59 download]# chkconfig ntpd on * Congratulation, you have successfully installed NTP. 3.3.6 Relational Database and JDBC Driver Installation ====================================================== 3.3.6.1 Postgresql and JDBC Driver for Postgresql ================================================= Installation ------------ * Check for previous postgresql installation. If you are using RH9, most probably, postgresql is installed. To check, do [root@l59 ]# rpm -qa | grep postgresql postgresql-devel-7.3.4-3.rhl9 postgresql-server-7.3.4-3.rhl9 postgresql-test-7.3.4-3.rhl9 postgresql-libs-7.3.4-3.rhl9 postgresql-jdbc-7.3.4-3.rhl9 postgresql-7.3.4-3.rhl9 postgresql-docs-7.3.4-3.rhl9 * If you see the above output, postgresql is installed. You can skip this section unless you want to upgrade your postgresql to a newer version. * If postgresql is not installed or you want to install a newer version, you can download from www.postgresql.com. There's currently no redhat-9 rpm for 7.4.1. So, here, we are using 7.4.0. * Downlaod postgresql from http://www.postgresql.org * As root, [root@l59 ]# rpm -Fvh postgresql-*PGDG.i386.rpm Preparing... ########################################### [100%] 1:postgresql-libs ########################################### [ 14%] 2:postgresql ########################################### [ 29%] 3:postgresql-server ########################################### [ 43%] 4:postgresql-devel ########################################### [ 57%] 5:postgresql-docs ########################################### [ 71%] 6:postgresql-jdbc ########################################### [ 86%] 7:postgresql-test ########################################### [100%] Configuration ------------- * Edit /etc/init.d/postgresql. Look for this line: su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster -o '-p ${PGPORT}' start > /dev/null 2>&1" < /dev/null ** And, replace it by the following line: su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster -o '-i -p ${PGPORT}' start > /dev/null 2>&1" < /dev/null ** The addition is in the -o '-i'. That allows postgresql to accept TCP/IP connections. * After saving the file, start the database [root@l59 ]# service postgresql start ** or, you could type, [root@l59 ]# /etc/init.d/postgresql start. [root@l59 ]# service postgresql start Initializing database: [ OK ] Starting postgresql service: [ OK ] * In the first instance, this will create /var/lib/pgsql/data. * Shutdown postgresql [root@l59 ]# service postgresql stop Stopping postgresql service: [ OK ] * Now, edit /var/lib/pgsql/data/postgresql.conf to enable TCP/IP sockets to JDBC to connect to our databases; Look for the "tcpip_socket" line; set it to true # - Connection Settings - tcpip_socket = true ** Depending on how many connection you anticipate, you might also want to adjust the max_connections parameters. max_connections = 100 * Next, edit /var/lib/pgsql/data/pg_hba.conf and add a line host all all 127.0.0.1 255.255.255.0 trust ** The above means anyone on this machine can access any database. ** If you want to accept internet connections from machines other than your own, you will need to add extra line(s) that look similar to above in /var/lib/pgsql/data/pg_hba.conf. Please refer to Postgresql docs for how to configure hosts and users access, and securing your database. * If you want to automatically start postgresql at boot time, do [root@l59 ]# chkconfig postgresql on [root@l59 ]# chkconfig --list | grep postgresql postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off * Start the postgresql to reload the configuration [root@l59 download]# service postgresql start Starting postgresql service: [ OK ] * Create a test database: [root@l59 download]# su - postgres -bash-2.05b$ createdb test CREATE DATABASE ** You should not see any error messages. If you do, you need to check with the postgresql documentation. Testing ------- * Create a test table with one test row. First, log in to the interactive PostgreSQL tool and connect to the test database you just created by typing (as the postgres user): -bash-2.05b$ psql test Welcome to psql 7.4, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit test=# * Create the test table by typing (within psql): test=# create table testdb (col1 varchar(255)); CREATE TABLE * Insert on row by typing (within psql): test=# insert into testdb (col1) values ('Hello World, from PostgreSQL.'); INSERT 17145 1 * Finally, confirm that the row is there by typing (within psql): test=# select col1 from testdb; col1 ------------------------------- Hello World, from PostgreSQL. (1 row) * Quit postgresql, type (within psql): test=# \q * JDBC testing - create a java program PSQL_JDBC_Test.java /* * A Simple Postgresql/JDBC Testing Program */ import java.sql.*; class PSQL_JDBC_Test { public static void main (String[] args) { try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { System.out.println("Unable to load PostgreSQL JDBC driver"); return; } try { String url = "jdbc:postgresql:test"; Connection connect = DriverManager.getConnection(url, "postgres", ""); if (connect.isClosed()) { return; } System.out.println("Successfully connected to PostgreSQL server"); Statement query = connect.createStatement(); // query.setQueryTimeout(10); ResultSet states = query.executeQuery("select col1 from testdb"); while (states.next()) { System.out.println(states.getString(1)); } states.close(); query.close(); connect.close(); } catch (SQLException e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(System.out); } } } * Compile the PSQL_JDBC_Test.java [root@l59 ]# javac PSQL_JDBC_Test.java * Run the PSQL_JDBC_Test.java [root@l59 ]# java -classpath $CLASSPATH:/usr/share/pgsql/pg73jdbc3.jar PSQL_JDBC_Test * You should see the following output: Hello World, from PostgreSQL. * Congratulations, you have installed, set up an environment for, and tested a JDBC interface to PostgreSQL. 3.3.6.2 MySQL and JDBC Driver for MySQL ======================================= Installation ------------- * Check for previous mysql installation. If you are using RH9, most probably, mysql is installed. To check, do [root@l59 ]# rpm -qa | grep mysql mysql-server-3.23.58-1.9 mysql-3.23.58-1.9 mysql-devel-3.23.58-1.9 * If you see the above output, mysql is installed. You can skip this section unless you want to upgrade your mysql to a newer version. * If mysql is not installed or you want to install a newer version, you can download from http://www.mysql.com. * As root, [root@l59 ]# rpm -ivh MySQL-client-4.0.18-0.i386.rpm MySQL-server-4.0.18-0.i386.rpm MySQL-devel-4.0.18-0.i386.rpm warning: MySQL-client-4.0.18-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5 Preparing... ########################################### [100%] 1:MySQL-devel ########################################### [ 33%] 2:MySQL-client ########################################### [ 67%] 3:MySQL-server ########################################### [100%] Preparing db table Preparing host table Preparing user table Preparing func table Preparing tables_priv table Preparing columns_priv table Installing all prepared tables 040229 20:36:42 /usr/sbin/mysqld: Shutdown Complete PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h l59 password 'new-password' See the manual for more instructions. Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at https://order.mysql.com * Install JDBC driver for MySQL [root@l59 ]# tar zxf mysql-connector-java-3.0.11-stable.tar.gz [root@l59 ]# cp mysql-connector-java-3.0.11-stable/mysql-connector-java-3.0.11-stable-bin.jar /usr/java/java/jre/lib/ext/ Configuration ------------- * Setup the mysql root password: [root@l59 ]# mysqladmin -u root password 'whatever' * Note that the mysql root password does not have to be the same as your system's root password. For security reason, it's recommended that you don't use the same password as your root password. * Check the root password is set up properly: [root@l59 ]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 to server version: 4.0.18-standard Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> * To see the initial databases created during the installation process: mysql> SHOW DATABASES; +----------+ | Database | +----------+ | mysql | | test | +----------+ 2 rows in set (0.03 sec) ** Note that mysql commands in Linux are case-sensitives. * Change to mysql database: mysql> Use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker start-up with -A Database changed * Remove no user/password access: mysql> SELECT host, user, password FROM user; +-----------+------+------------------+ | host | user | password | +-----------+------+------------------+ | localhost | root | 782108625ac0c25f | | l59 | root | 782108625ac0c25f | | localhost | | | | l59 | | | +-----------+------+------------------+ 4 rows in set (0.04 sec) ** The last two rows are what I meant by no user/password access. * To remove this account, type at mysql prompt: mysql> DELETE FROM user WHERE user = ''; Query OK, 2 rows affected (0.00 sec) * To check, mysql> SELECT host, user, password FROM user; +-----------+------+------------------+ | host | user | password | +-----------+------+------------------+ | localhost | root | 782108625ac0c25f | | l59 | root | 782108625ac0c25f | +-----------+------+------------------+ 2 rows in set (0.00 sec) * Fixing the localhost problem for JDBC/MySQL. If you look in /etc/hosts, you most probably will see this line: 127.0.0.1 localhost.localdomain localhost ** This means that the localhost's fully qualified name is localhost.localdomain. The problem with the above line is that the MySQL driver's localhost request is translated to the fully qualified name localhost.localdomain, which does NOT match 'localhost' entry in the mysql user table. We need to modify this entry in the mysql user table so that it also matches localhost.localdomain. ** To do this we want to replace the 'localhost' value by 'localhost%'. The wildcard % matches any string. To do this, type (within mysql): mysql> UPDATE user SET Host='localhost%' WHERE Host='localhost' && User='root'; Query OK, 1 row affected (0.05 sec) Rows matched: 1 Changed: 1 Warnings: 0 * To confirm the changes make above: mysql> SELECT host, user FROM user; +------------+------+ | host | user | +------------+------+ | l59 | root | | localhost% | root | +------------+------+ 2 rows in set (0.00 sec) * Quit mysql and reload mysql> quit Bye * Reload the entire changes made above, type (within mysql): [root@l59 ]# mysqladmin -p -u root reload Testing ------- * Create a java program MySQL_JDBC_Test.java /* * A Simple MySQL/JDBC Testing Program */ import java.sql.*; class MySQL_JDBC_Test { public static void main (String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { System.out.println("Unable to load MySQL JDBC driver"); return; } try { String url = "jdbc:mysql://localhost/mysql?user=root&password=whatever"; Connection connect = DriverManager.getConnection(url); if (connect.isClosed()) { return; } System.out.println("Successfully connected to MySQL server"); Statement query = connect.createStatement(); // query.setQueryTimeout(10); ResultSet states = query.executeQuery("SELECT * FROM user"); while (states.next()) { System.out.println(states.getString(1)); } states.close(); query.close(); connect.close(); } catch (SQLException e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(System.out); } } } * Compile the MySQL_JDBC_Test.java [root@l59 ] javac MySQL_JDBC_Test.java * Run the MySQL_JDBC_Test.java [root@l59 ] java -classpath $CLASSPATH:/usr/java/java/jre/lib/ext/mysql-connector-java-3.0.11-stable-bin.jar MySQL_JDBC_Test * You should see the following output: Successfully connected to MySQL server localhost% l59 ** Actually, you do not need to define '-classpath' since /usr/java/java/jre/lib/ext/ is in JVM search path. * Congratulations, you have installed, set up an environment for, and tested a JDBC interface to MySQL. 4. Concluding Remarks ===================== You are now ready to install other Grid Software. Acknowledgement ============== This project is funded in parts by the UK e-Science programme. This document is based on many installation guides found on the Internet. The author(s) of this document wish to thanks all the authors who wrote the guides.