Installing Sybase on Your Linux Server

By: Alexander Prohorenko
Thursday, July 18, 2002 03:20:19 PM EST
URL: http://www.linuxplanet.com/linuxplanet/tutorials/4323/1/

Why Look at Sybase?

As licensing concerns become an increasingly prevalent factor in IT, it's nice to know that there are alternatives out there. One of the alternatives is, of course, migration to Linux and freeware software for Linux. The power and flexibility of Linux and its current software options allows you to accomplish many things, including the creation of an internal database server.

There are a lot of open-source and freeware software of different SQL packages, each of them with its own minuses and pluses. Before you will choose any of them, you need to analyze in detail these pros and cons, and decide which option meets your goals.

For many business database goals, Sybase may hold many of the answers. Sybase is a commercial (but free for Linux) SQL server that is highly reliable, very fast, compatible with MS SQL, and supports different international codepages.

The commerical aspects of Sybase may be more attractive to project managers and supervisors who think poorly of open source as a concept, even if open source purists will not be too excited about this aspect.

There are some quirks to the product. If you are running a shop with Windows clients, there really isn't any free client software for Windows (except OpenClient from Sybase, but it doesn't work with ODBC). For Delphi and C++ Builder there are a lot of free components working through OpenClient. On the Linux side of the realm, however, we can easily find a lot of free software.

If you decide to give Sybase a try for your SQL server needs, let's walk though the installation.

Installing Sybase: A Primer

The first thing to do is visit http://www.sybase.com, register there, and download neccessary installation software packages for Linux:

  • sybase-ase-11.9.2 - server itself
  • sybase-common-11.9.2 - common libraries
  • sybase-doc-11.9.2 - documentation, in English, very usefulfor administrators or developers
  • sybase-openclient - client for Linux (libraries) for server access
  • README.txt - file with description of procedure of server installation

It is here that you may get a slightly unpleasant surprise, because Sybase for Linux comes only in RPM files. It's a big minus for Debian and Slackware users.

Now comes package installation. Here we need to have superuser rights, from xterm or some other X Window program--not the console (why this is so is something I will describe you a bit later).

Sybase is rather "heavy" software and it needs at least 260MB of free space on your hard disk to be installed properly. So, you should make sure, that you have the space:

df -k /opt
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda1              7234264   6086180    780600  89% /opt

Also, make sure you add the directory /sbin to the PATH variable if it's not there already:

export PATH=$PATH:/sbin
Now we can install packages:
rpm -hiv sybase-common-11.9.2-3.i386.rpm
rpm -hiv sybase-ase-11.9.2-.i386.rpm
rpm -hiv sybase-doc-11.9.2-1.i386.rpm
rpm -hiv sybase-openclient-11.1.1-3.i386.rpm

After complete package installation we need to edit /etc/profile next and add these two strings:


SYBASE=/opt/sybase-11.9.2
export SYBASE

These will define the system variable SYBASE, which will point to whichever directory Sybase is installed. If you skip this step, the server will not work. We also need to execute these commands from the terminal:


SYBASE=/opt/sybase-11.9.2
export SYBASE

Last, but not least, we will execute a shell script that will allow us to setup system configuration for server startup:


cd $SYBASE
$SYBASE/install/sybinstall.sh

This script will create the user and group called sybase.

Now we will configure the server.


su sybase
$ id
uid=507(sybase) gid=510(sybase) group=510(sybase)
$ . .profile
.......
Do you want to start 'srvbuild' now? [y/n]: y

Now we come to the surprise I mentioned a few paragraphs ago. srvbuild is an auto-executed graphic installation program. This is why you needed to start this process in X Window. (Strictly speaking, we don't need X Window server exactly on database server, we can just correctly set the system variable DISPLAY and work remotely.) We'll detail how this works in the next section.

Building with srvbuild

In the srvbuild program (shown in Figure 1), we can choose what to install: Adaptive server or Backup server. The Backup server (necessary for creationg of backup/reserve copy) can be installed to a completely different computer. In this example, we can skip this option and not install it.

Fill all the other fields with server names (based on your own taste) and click OK. The next window displays Server Attribute Editor (see Figure 2).

We need to pay attention here so that this server will work.

  • Master device path - path where service base master will be located. Sybase bases can be located in files and also in raw devices. To optimize speed of working of our Sybase server I recommend using raw devices. It's a pity, but max size of device (but not of base!) in Sybase can not be more than 2 Gb, and we need to count on that when we are doing server configuration.
  • Master device size - size for device where master base will be located.
  • Master database size - startup size of master base. In the future this base can be increased, but the limiting size is "master device size".
  • Sybsystemprocs device path - path where service base of system functions will be located. Usually file can be used--these subroutines will not be used very often.
  • Sybsystemprocs device size - size for device where sybsystemprocs will be located. Use default value.
  • Sybsystemprocs database size - choose it like we did with sybsystemprocs device size.

Please make sure you configure the user sybase to have write rights to the directory or device where will the database will be kept. (Also, remember the TCP port number where the server will be working. We may need this in future.)

After all fields are appropriately filled, click on OK. The Server Attribute Editor will display the Backup server attributes (see Figure 3).

Here, we need to configure Backup server. We have two fields here that are important to note:

  • Language - russian (for example).
  • Codepage - cp1251 or koi8r, it depends on which codepage we will be using for keeping our data.

Click the Build Servers button and a special script will be executed that will start the servers and create the necessary service databases.

This can take some time, just be patient. Once everything is finished, a dialog box will appear asking to localize your server. I recommend skipping this step. If you need to do this later, it can be easily done manually--a process we will describe in the next section.

To proceed, click on No to close this dialog, then on OK in the next window. This brings us back to the original srvbuild dialog box. To close it, click on the Exit button.

To configure Sybase to be auto-started after each computer reboot we need to configure the system a bit more:

chkconfig -add sybase
chkconfig sybase on
chkconfig --list sybase
sybase      0:off  1:off  2:off  3:on   4:on   5:on   6:off

Sybase is now installed. The only thing we have ahead is to localize it. In this case we will make Sybase able to work with the Russian language.

Localizing Sybase

All of the necessary files and advice about Russian language localization can be found at http://www.sybase.newmail.ru/ase/119rus.html. To find your own language localization guides, use any search engine you like and you should be able to find your language packs without much difficulty.

Before we begin this process, make sure you pay attention to upper/lower case in file names. Linux, as with all Unix systems, understands upper and lowers case as different characters, and this can create some problems if you're not careful.

I was also able to find an absolutely prepared Russian localization package for Linux following this link: ftp://ftp.svzserv.kemerovo.su/pub/databases/sybase-ase/Synchsets.tgz. I recommend everybody who needs Russian localization. If you also download http://www.sybase.newmail.ru/files/convtbls.zip you can find a good description of installation inside that package.,

In the meantime, to illustrate how localization works in whatever language you use, I will describe whole process step by step.

First, unpack and copy the appropriate files.

tar -xzf Synchsets.tgz
cp -r charsets/group5/* $SYBASE/charsets
cp -r convtbls/group5/* $SYBASE/charsets
cp -r locales/group5/* $SYBASE/locales

Remember, don't copy the locales.dat file from the archive! It's very old.

Fix files common.loc and server.loc in all subdirectories $SYBASE/locales/russian/--if you have an earlier version, you will need to change the version of these files to that of your server.

Unpack the convtbls.zip archive and copy all tables of conversions utf8->russian:

unzip convtbl.zip
cp CONVTBLS/UNICODE/UTF8/CP866.CTB $SYBASE/charsets/utf8/cp866.ctb
cp CONVTBLS/UNICODE/UTF8/KOI8.CTB $SYBASE/charsets/utf8/koi8.ctb
cp CONVTBLS/UNICODE/UTF8/CP1251.CTB $SYBASE/charsets/utf8/cp1251.ctb

Update the configuration file $SYBASE/charsets/utf8/utf8.cfg by adding these lines:

convertto = koi8, table, MATCH, 3F
convertto = cp1251, table, MATCH, 3F
convertto = cp866, table, MATCH, 3F

And update the file with locales descriptions $SYBASE/locales/locales.dat by adding into the [linux] section these lines:

locale = ru_RU, russian, koi8
locale = ru_UA, russian, koi8

This will allow out Linux clients to operate more smoothly with the new language. Now, into the [natlang] section in the file $SYBASE/config/objectid.dat add:

; russian
1.3.6.1.4.1.897.4.9.2.182119 = russian

Now, don't forget to do little cleanup:


ln -s $SYBASE/locales/message/us_english $SYBASE/locales/messages/russian
ln -s $SYBASE/locales/us_english/cp850 $SYBASE/locales/us_english/cp866
ln -s $SYBASE/locales/us_english/cp850 $SYBASE/locales/us_english/cp1251
ln -s $SYBASE/locales/us_english/cp850 $SYBASE/locales/us_english/koi8 

The next major step to to load a new list of chars and their sort order. The easiest way is to use graphic utility that came with Sybase:


su sybase
$ cd ~
$ bin/sqlloc

In the first window (shown in Figure 4), you have to choose your server.

We do not have password for sa by default. So, just click on OK to open the Default Language dialog box (see Figure 5).

And now let's configure the necessary localization. For example, to support the Windows codepage, with sorting, without dependence of lower/upper case we will choose these options in each respecitive field in the dialog: Russian, cp1251, Russian case-insensitive dictionary ordering.

After clicking on OK, the Add and Remove Languages dialog will appear to will warn us that the codepage will be changed and it will suggest installing a new language (Russian). Again, click on OK. The Localization Summary dialog will appear (see Figure 6).

The utility will start installing support for the Russian language, shown in the Status Output window. Eventually the Status Report window will close and you will be returned to the User Name and Password dialog. Choose Exit.

When configuring the client (OpenClient) for Windows we need to remember to update $SYBASE/ini/objectid.dat. In the section [natlang] add:

; russian
1.3.6.1.4.1.897.4.9.2.182119 = russian 

Also, add identifers of Russian codepages (if you don't have such) in section [charset]:

1.3.6.1.4.1.897.4.9.1.50 = iso88595
1.3.6.1.4.1.897.4.9.1.51 = cp855
1.3.6.1.4.1.897.4.9.1.52 = cp866
1.3.6.1.4.1.897.4.9.1.53 = cp1251
1.3.6.1.4.1.897.4.9.1.55 = koi8
1.3.6.1.4.1.897.4.9.1.56 = mac_cyr

Copyright Jupitermedia Corp. All Rights Reserved.