ResourcesSoftwareApplicationsChemistryMaterials Science Mathematics Visualization Climate (restricted) |
MySQL at NERSCMySQL software is installed at NERSC in the mysql module. Client and server software is supplied. NERSC does not host an open MySQL server for its users. Using the MySQL clientLoad the mysql module to put the MySQL binaries in your shell search path. MySQL client utilities can connect outbound to a properly configured remote MySQL server from both interactive and compute nodes. % module load mysql % mysql -h remote_mysql_server_hostname -u mysql_username Using the MySQL APIYour code can connect to a MySQL database server by embedding MySQL API calls in your code. After you load the mysql module, these environment variables are defined: MYSQL_INCDIR path to MySQL header files MYSQL_LIBDIR path to MySQL libraries Using a local MySQL serverYou may start a MySQL server as part of your job at NERSC. This server can be accessed while your job is running. This is recommended only for those users who have significant experience using and administering MySQL databases. The procedure described below assumes familiarity with MySQL. Please do not start a server without adequate security. Doing so will jeopardize the integrity of your data. You do not want to allow other NERSC user to connect to your running server. Any attempt to connect to the server from outside NERSC will fail because the incoming network ports are blocked. How to set up and use a local MySQL serverThe following procedure will set up a MySQL database and allow it to be accessed during a run. Set up the database
Start the server
Start a client and configure the database
Stop the server
Using a local server in batch jobsYou can start a server in a batch script and then communicate to it from tasks running on different compute nodes. Start the server in your script; serial commands are executed by the lead task. Save the hostname in a file. Make sure you have granted server access to users on the 10.x.x.x and 128.55.x.x networks. The following example batch (PBS) script starts the server and then runs another script in parallel so that all tasks talk to the server. (An equivalent IBM LoadLeveler script has LoadLeveler directives instead of PBS directives and uses "poe" instead of "mpirun".) . # Sample MySQL batch script - test_mysql.pbs # LoadLeveler scripts are similar #PBS -V #PBS -S /bin/tcsh #PBS -l nodes=2:ppn=2,walltime=00:05:00 #PBS -N test #PBS -o mysql_test.out #PBS -e mysql_test.err #PBS -q debug module load mysql hostname >$HOME/mysql/mysql.server mysqld_safe --defaults-file=$HOME/mysql/my.cnf & sleep 10 cd $PBS_O_WORKDIR mpirun -np 4 ./checkcx.csh echo "Killing MySQL server..." kill `cat /tmp/mysqld.myusername.pid` #!/bin/csh # checkcx.csh - simple script to test mysql module load mysql set server=`cat $HOME/mysql/mysql.server` mysql --defaults-file=$HOME/mysql/my.cnf -h $server -u myusername <<_EOS status; show databases; quit _EOS Running on Jacquard with qsub test_mysql.pbs produces output that begins: PBS Leader node is jaccn260 Job setup time: Mon Jan 30 16:20:12 PST 2006 Setting up security Job startup at Mon Jan 30 16:20:17 PST 2006 ---------------------------------------------------------------- Warning: no access to tty (Bad file descriptor). Thus no job control in this shell. Directory: /usr/common/homes/m/myusername [1] 5285 Starting mysqld daemon with databases from /scratch/scratchdirs/myusername/mysql -------------- mysql Ver 14.7 Distrib 4.1.16, for unknown-linux-gnu (x86_64) using EditLine wrapper Connection id: 1 Current database: Current user: myusername@jaccn261-m.nersc.gov SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 4.1.16 Protocol version: 10 Connection: jaccn260 via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: latin1 Conn. characterset: latin1 TCP port: 6406 Uptime: 10 sec Threads: 2 Questions: 3 Slow queries: 0 Opens: 11 Flush tables: 1 Open tables: 5 Queries per second avg: 0.300 -------------- Database mysql test -------------- [...] |
![]() |
Page last modified: Thu, 26 Jan 2006 22:53:39 GMT Page URL: http://www.nersc.gov/nusers/resources/software/apps/mysql/ Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |