SAPDB (Debian) Linux Quickstart Howto
Introduction: This Howto is meant to get you up to speed quickly with SAPDB on Linux. It is not a replacement for other more detailed howtos or the reference documentation. I tested this with the tgz package of SAPDB version 220.127.116.11 on Debian Linux (Potato and Woody), but most of this should apply to other distributions as well.
Preliminaries: On the Woody release of Debian you need to install the old version of the C++ libraries with apt-get install libstdc++2.9-glibc2.1.
Download sapdb-server-linux-32bit-i386-*.tgz and sapdb-webtools-linux-32bit-i386-*.tgz from http://www.sapdb.org.
tar xfzv sapdb-server-*
Answer all question with yes, unless you have different preferences.
What the script basically does is to create a group called sapdb and a user called sapdb. Most files are installed unter /usr/sapdb, some configuration files are in /usr/spool/sql. The file /etc/services has new entries for the SAPDB ports (sql6 7210/tcp and sql30 7200/tcp). If you want to know more about all the folders and files, see this howto. You can also install everything under /usr/local/sapdb: It's a little bit more typing during the install and you have to adjust the paths in the script below.
Command line: The most important command line tools for SAPDB are dbmcli and repmcli. You should always run them as the user sapdb. To have easy access, add /usr/sapdb/indep_prog/bin:/usr/sapdb/depend/bin to your PATH. Call them with -h to view the main options.
sapdbadmin.sh: To simplify many common actions and demonstrate the capabilities of the command line tools I wrote a script called sapdbadmin.sh which is based on the create_demo_db.sh script usually included in SAPDB. Raimund Jacob contributed some enhancements. If you have more improvements I would be glad if you send me a patch so others can profit from it.
The top section of the script contains many options that you can edit for your preferences, the most importants options are the database name, the database size, the directories for the database files and the database user names and passwords. All size parameters can be specified in pages (p), KB (k), MB (m) and GB (g). You can also place these options in the file ~/.sapdbadminrc if you don't want to edit the original script. You can then call the script with these options:
--create Create a database with the settings stored in the script.
--drop Drop the database described in the script.
--delete Actually delete the database files after dropping the database.
--all Rebuild the database by doing do all in a row: drop, delete, create.
--execute FILE Execute a FILE with SQL commands. The file is loaded with repmcli, which means you need an empty line between each SQL command. this is not for queries but for creating and dropping tables or loading data.
--password USER NEW Change the password of USER to NEW, works with dba, dbm and SQL users.
--load TABLE FILE Load TABLE data from FILE. The file should be saved with the save option or have an appropriate comma seperated text file.
--save TABLE FILE Save TABLE data to FILE to comma seperated text file.
The load/save options use DATALOAD and DATAEXTRACT commands of repmcli. This is definitely worth looking up in the docs because repmcli can do far more powerful things.
--dump PREFIX Save database schema and data into files with PREFIX. This is a binary dump, several files are created. If the PREFIX does not include an absolute path, the files will be saved in /usr/sapdb/depend.
--rebuild PREFIX Rebuild database with schema and data from files with PREFIX.
Here the TABLELOAD, TABLEEXTRACT, CATALOGLOAD and CATALOGEXTRACT commands are used.
--backup Create a migration backup with the defined media and rotate the file by adding time and date.
--recover Recover last backup.
These two options are mostly for showing how it is done. In real life you should definitely read the documentation and find out what kind of backup is best for you. If anybody has some ideas how to make this more flexible, especially with incremental backups, please mail me.
The script writes a very detailed logfile in the current directory that you should consult first if something goes wrong.
Startup: Once you have created a database to play around with you may want to start it up automatically. Here's an init script. On Debian you have to
. Copy it to /etc/init.d
. Edit it to enter the names of the database instances you want to start
. Call update-rc.d sapdb defaults
It can also start up the webtools described next:
Webtools: The SAPDB webtools are very nice webinterfaces for database administration. Installation:
tar xfzv sapdb-webtools-*
Answer all question with yes, unless you have different preferences.
the webtools are installed into /usr/sapdb/web. In the configuration file /usr/spool/sql/ini/WebAgent73.ini you can change the port, the number of threads and the names of the log files. To get them working I also had to add /usr/sapdb/web/lib to /etc/ld.so.conf and call ldconfig. You can now start the webtools with wahttp in /usr/sapdb/web/pgm. Point your browser at localhost:9999/webdbm and log in as the dbm user or at localhost:9999/websql as the database user. The browser needs to accept cookies.
DbVisualizer: Another nice way to access the database is the Java program DbVisualizer. You need a Java 2 VM, I had to edit the file dbvis.lax after installation to tell it where it is, because it was using the 1.1.x version. If you have it running you need to tell it where the JDBC driver is. Add /usr/sapdb/depend/misc/sapdbc.jar and click on Find JDBC driver. Finally you need to add a database connection. For the driver URL you can choose the MySQL template and replace the mysql with sapdb.
Troubleshooting: In case of problems you should take a look into the directory /usr/sapdb/indep_data/wrk especially the files repserver.log and vserver.log. In the subdirectories for the database instances you should look at knldiag.* and knltrace. What you may find will be helpful when asking questions to the mailinglist. Sometimes I was stuck because I couldn't delete a database but couldn't create it either because the software said it existed. In this case it helps to delete everything starting with the database name in /usr/sapdb/indep_data/config/ and /usr/local/sapdb/indep_data/wrk/ and delete the entry for the database in /usr/spool/sql/ini/SAP_DBTech.ini in the section [Databases].
Programming: To get started with programming, take a look at the first steps documentation usually included with SAPDB. It has examples for Java, Perl and PHP. You can also use Python, C, C++. More good Perl examples are here(http://sapdb.icf.net/).
More information: If you want to get deeper into SAPDB, the documentation at http://sapdb.org is a good companion. Also very helpful might be the glossary(http://www.sapdb.org/sap_db_glossary.htm). The HTML documentation can also be downloaded as a tar archive from the FTP server. For the purpose of having a printout there are many PDFs available. And finally there's the mailinglist(http://www.sapdb.org/framesets/sap_db_contact.htm), a place to ask for help and share solutions. As always you should search(http://sapdb.icf.net/) it first.
Contributions: Please mail(mailto:email@example.com) me if you find this useful or have any questions or additions. Especially useful would be short descriptions on how to set things up for the various programming languages, how to set up ODBC and differences on rpm based systems.