|
Running SQL Relay
The sqlr-start program is provided to simplify the startup process.
The sqlr-start program starts up one instance of sqlr-listener, one instance of sqlr-scaler and the number of sqlr-connection daemons specified in the config file for the given id. The sqlr-start program also checks to see if a sqlr-cachemanager is running. If one is then it leaves it running. If not then it starts one. See the section about sqlr-cachemanager below for an important note about it. Debugging and Tracing:The instance tag of the CONFIGFILE contains an optional debug attribute. When it is set, the sqlr-start program starts up debugging versions of the sqlr-listener and/or sqlr-connection daemons. These daemons output debugging information to files in /usr/local/firstworks/var/sqlrelay/debug. See Configuring SQL Relay for more information on the debug attribute. The sqlr-start program also takes an optional -strace parameter. When run as root, if the -strace parameter is used, sqlr-start starts the sqlr-connection daemons using strace -ff -o sqlr-connection-strace causing sqlr-connection-strace.pid files to be written to the root directory. See the strace man page for more information. Starting Daemons Individually:If for some reason you don't want to use sqlr-start, you can start the daemons individually. Setting Up a Listener:The first step in is setting up a listener. The job of the listener is to connect to a TCP port and wait for queries. When it gets one, it waits for an available connection daemon and hands off the client to it. Run the sqlr-listener daemon to establish a listener.
CONFIGFILE is the filename of the configuration file to use. The default configuration file is /usr/local/firstworks/etc/sqlrelay.conf ID is an identifier that associates a listener with a pool of connections. Only one listener needs to be established for a given ID. Setting Up a Connection:Connecting to a database is the next step. To estabish a connection, run one or more of the sqlr-connection daemons.
Where "dbase" is one of oracle7, oracle8, mysql, msql, postgresql, sqlite, lago, odbc, db2, interbase, sybase or freetds. CONFIGFILE is the configuration file to use when starting the daemon. The default configuration file is /usr/local/firstworks/etc/sqlrelay.conf ID is just an identifier. Starting multiple connections with the same ID make them available as a pool of connections. The more connections you start, the more queries can be executed in parallel. In addition, the ID argument specifies which config file entry to use. CONNECTIONID is another identifier. When using replicated or clustered databases, within a pool of connections, some connections will connected to 1 machine and some will connect to another. This argument tells the connection daemon which machine to connect to. When not using clustered or replicated databases, this id will be the same for every connection in the pool. Setting Up the Scaler:The third step is running the scaler. You can start as many sqlr-connection daemons as you like. If you start fewer than the maximum number defined for the ID, the sqlr-scaler daemon will fire up new connections on demand. The new connections will time out after a period of inactivity and shut down on their own. Run the sqlr-scaler daemon to establish a scaler.
CONFIGFILE is the filename of the configuration file to use. The default configuration file is /usr/local/firstworks/etc/sqlrelay.conf ID is the same as the ID argument in the sqlr-connection daemon and associates a scaler with a pool of connections. Only one scaler needs to be established for a given ID. Setting Up the Cache Manager:The fourth step is running the cache manager. Clients can cache result sets with a time-to-live on them. The cache manager goes through the cached result sets periodically and removes the ones that have expired. Run the sqlr-cachemanager daemon to establish the cache manager.
The optional INTERVAL argument specifies in seconds how often the cache manager scans the result sets. Each scan is scheduled from the end of the previous scan. If the argument is left off, the cache manager scans at a default interval of 30 seconds. Only one cache manager needs to be started per machine. Important Note: Since cache managers clean up after SQL Relay clients, not servers, they need to be run on machines which run clients that could cache result sets. These may not be the same machines that run the sqlr-listener and sqlr-connection daemons. If there is no SQL Relay installation on those machines, you should create the cache directory (/usr/local/firstworks/var/sqlrelay/cache unless changed at compile time), install the sqlr-cachemanager program by itself and set it up to run at boot time. Extending, Killing and Restarting:Once the daemons are up and running, clients can use them. In the event that more connections are required, additional sqlr-connection-"dbase" daemons may be started from the command line using the same ID and CONFIGFILE and will be immediately available to clients. Connection daemons should not be killed once they have been started without restarting everything with that ID. The sqlr-stop command is provided to kill running daemons. It accepts a single argument, the id of the instance to kill. Running it kills anything with "sqlr-" and that id in it's name. It uses grep, so it's not perfect. If you have id's like "web" and "webster" and run "sqlr-stop web" then it will kill both of them. Running it with no arguments will kill all SQL Relay processes. Using the Command Line Interfaces:Four command line utilities are provided for use with SQL Relay: query, fields, backupschema and sqlrsh. The syntax for each is:
The HOST, PORT, SOCKET, USER and PASSWORD arguments specify which listener to connect to and what authentication to use.
The query command executes the query specified in the QUERY parameter and returns the result set as a quote/comma/return seperated value list to standard output. The fields command returns a comma seperated list of the fields in the table specified by the TABLE argument to standard output. The backupschema command only works against oracle databases and uses the "select table_name from user_tables" query in combination with the query and fields commands to generate Oracle SQL Loader control files for all tables owned by the user a particular connection is logged in as. The command is useful for backing up an entire schema of data to a readily re-importable format. sqlrsh is an interactive query tool similar to (though not as powerful as) SQL Plus, mysql, psql, isql and the like. Run it and type help; at the prompt for detailed usage instructions. When sqlrsh starts up, it reads and executes two rc files, the system rc file (most likely /usr/local/firstworks/etc/sqlrshrc) and a personal rc file .sqlrshrc in your home directory. These files should contain sqlrsh commands, ending in semicolons, seperated by carraige returns. Any commands may be used in the rc files, even queries. Common Problems:
|