Installing Sybase ASE Express For Linux

Introduction

Sybase released (quite a while back) an "Express" version of their Adaptive Server Enterprise for Linux, for free. Whilst the installation documentation provided with the distribution shows you enough (barely) to get the system installed and running, it leaves a lot to the imagination. Luckily I've worked with Sybase ASE extensively in the past, so I could fill in the gaps in the documentation. What follows are brief notes on the installation of Sybase ASE Express Edition on a SUSE 9.3 Professional system. This also covers how to initialise a database device and a log device ready to accomodate your databases.

Throughout this article, # illustrates the root users prompt, and % the sybase users prompt.

Preparation

First we need to add a sybase user account to the system. This will be used for the installation, operation and administration of Sybase ASE.

    
# mkdir /opt/sybase
# useradd -m -d /opt/sybase -s /bin/ksh -c "Sybase DBA" sybase
# chown -R sybase:sybase /opt/sybase
# passwd sybase
    
    

Like many other Linux distros, SUSE will create a sybase group by default, and make the sybase user have this group as it's primary group. This is fine.

Next, we need to configure the kernel shared memory limit. Normally, this is 32kb, but Sybase requires 64kb. We can do this two ways - on the fly (which will not persist past a reboot), or via an entry in the /etc/sysctl.conf file. We'll set it on the fly so that we don't have to reboot the system to continue with our installation, and add it to the configuration file so it'll take effect permanently.

    
# sysctl -w kernel.shmmax=67108864
kernel.shmmax = 67108864
# echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf
    
    

Installation

First, we'll unpack the installation tarball to a temporary directory.

    
# su - sybase
Password:
% mkdir /opt/sybase/tmp
% mv /tmp/ase1253esd1xe_linux.tar.gz /opt/sybase/tmp
% cd /opt/sybase/tmp
% zcat ./ase1253esd1xe_linux.tar.gz | tar xf -
    
    

There is a graphical installation utility, but I will run it in text mode. The installation itself is very straightforward, and the official installation documentation covers this well enough. I will install all four servers, ASE itself, the backup server, the XP server, plus the monitor server.

    
% pwd
/opt/sybase/tmp
% ./setup -console
<follow and answer prompts>
    
    

Once the installation is complete, the setup program will automatically launch the servers for you. However, it will not create any scripts in /etc/init.d, but it's fairly straightforward to write one yourself (see the end of this article for an example).

Whilst ASE comes with a graphical interface called Sybase Central (scjview) we won't bother with that. We'll use the command line utility isql to administer ASE. But we can't even do that yet. You need to source a script to configure the environment for you.

    
% cd $HOME
% pwd
/opt/sybase
% echo ". /opt/sybase/SYBASE.sh" >> ./.bash_profile # we're using bash here...
% echo "export LANG=C" >> ./.bash_profile           # this'll be fixed properly in our init.d script
% . /opt/sybase/SYBASE.sh
% export LANG=C
    
    

Configuration

OK, now we're ready to get going. Read a book on Sybase ASE (or the manuals) to find out how to administer Sybase. I'll cover the basics here on device and database creation, but there are thousands of pages of documentation devoted to this, and they cover it pretty well. If you've used Sybase before, you'll know that you can use isql (which is now in your PATH) to administer Sybase. However, the installation document neglects to inform you what the sa password is. Well... it's blank! We'll change that straight away.

    
isql -Usa -P -SFOO
1> sp password NULL,'newpass'
2> go
Password correctly set.
(return status = 0)
   
    

Okay, now we'll add a non-privileged user to the server...

    
1> sp_addlogin 'kevin','mypass'
2> go
Password correctly set.
Account unlocked.
New login created.
(return status = 0)
   
    

Next, create a directory for our database device files. It is far more effecient to use raw disk partitions for devices, (or quick IO files under Veritas Volume Manager), but we'll make do with "standard" files here - for our purposes this will suffice. We need at least one database device, and one log device.

    
1> !!mkdir /opt/sybase/devices
[sh:mkdir /opt/sybase/devices]
1> disk init name = 'datadev1', physname = '/opt/sybase/devices/datadev1', size = '100M'
2> go
1> disk init name = 'logdev1', physname = '/opt/sybase/devices/logdev1', size = '50M'
2> go
   
    

We can now create a database on our devices

    
1> create database test_db on datadev1 log on logdev1
2> go
CREATE DATABASE: allocating 1024 logical pages (2.0 megabytes) on disk
'datadev1'.
CREATE DATABASE: allocating 1024 logical pages (2.0 megabytes) on disk
'logdev1'.
   
    

You can now check that the database has been created correctly with sp_helpdb

    
1> sp_helpdb
2> go
>output removed for clarity>
   
    

Next, change the owner of this database to our newly created kevin login

    
1> select db_name()
2> go

 ------------------------------
 master

(1 row affected)
1> use test_db
2> go
1> select db_name()
2> go

 ------------------------------
 test_db

(1 row affected)
1> sp_changedbowner kevin
2> go
DBCC execution completed. If DBCC printed error messages, contact a user with
System Administrator (SA) role.
Database owner changed.
(return status = 0)
   
    

Almost there! We can now exit, log back in as the DB owner, and create a table in our database

    
1> quit
% isql -Ukevin -Pmypass -w200 -SFOO
1> use test_db
2> go
> create table test_table_one (
2>   id int NOT NULL,
3>   foo varchar(20),
4>   bar varchar(15)
5> )
6> go
1> insert into test_table_one values( 0, 'Hello', 'World' )
2> go
(1 row affected)
1> select * from test_table one where id = 0
2> go
 id          foo                  bar
 ----------- -------------------- ---------------
           0 Hello                World

(1 row affected)
1> exit
   
    

That'll do us nicely! Obviously this has just touched the surface of what Sybase ASE has to offer. Read the documentation if you want to learn more - you can download all the documentation in PDF format from the Sybase website.

Appendix A - Sybase init.d script

This is a very basic script that can be used as an init.d script to control Sybase.

    
#!/bin/sh

ASE="/opt/sybase/ASE-12_5/install"
OCS="/opt/sybase/OCS-12_5/bin"

case "$1" in
 start)
       echo -n "Starting Sybase ASE ... "
       cd $ASE
       for run_server in RUN_*; do
         echo "${run_server}" | grep '^.*MS$' >/dev/null 2>&1
         if [ $? -ne "0" ]; then
            su - sybase -c "unset LANG; unset LC_ALL; \
            $ASE/startserver -f $ASE/${run_server} >/dev/null 2>&1"
         else
            sleep 5
            su - sybase -c "$ASE/RUN_*_MS >/dev/null 2>&1 &"
         fi
         echo -n "${run_server} "
       done
       echo
       ;;

 stop)
       echo -n "Shutting down Sybase ASE configured servers:"
       su - sybase -c "$OCS/isql -Usa -Pnewpass -SFOO <<EoF
shutdown SYB_BACKUP with nowait
go
shutdown
go
exit
EoF"
       pkill monserver >/dev/null 2>&1
       echo
       ;;
 status)
       $ASE/showserver
       ;;

 restart)
       $0 stop
       $0 start
       ;;
 *)
       echo "*** Usage: sybase {start|stop|status|restart}"
       exit 1
esac

exit 0
   
    

Conclusion

Together with the official installation notes, manuals and documentation, this guide should have assisted you in setting up Sybase ASE Express Edition for Linux with relative ease.

Cheers
Kevin Waldron
kevin@zazzybob.com

Disclaimer! - This article is provided for guidance only, and does not replace the relevant official documentation and manuals. I will not be held liable for any hosed systems and/or data.

Valid CSS!

Valid HTML 4.01!