Does the thought of tackling a program as huge and complex as Sybase Adaptive Server Enterprise (ASE) sound somewhat terrifying? If so, take heart—and dive right into this Daily Drill Down. You’re going to tame one of the biggest database beasts of all. By the end of this Daily Drill Down, you’ll have this industrial-strength database server running on your system. What’s more, you’ll open a sample database and try out some SQL queries. For a review of Linux database fundamentals, see part 1 of this series. You can download RPM packages for version 220.127.116.11 from the Sybase Web site.
Caution: Sybase’s Web page and the license built into the installation utility both state that version 18.104.22.168 is free for production as well as development use. However, the 22.214.171.124 download page is linked to a license that denies the right to production use. If you decide to use Sybase ASE 126.96.36.199 for production purposes, your legal department should seek clarification from Sybase on just what uses are permissible.
You should install the Sybase master database file in its own partition. In the steps that follow, you install Sybase ASE for testing and learning purposes, so you install the Sybase master database within your Linux filesystem. You’ll see warnings about this, but you can ignore them; Sybase ASE will work just fine for testing and learning purposes when installed this way.
Getting ready to install Sybase ASE
To run Sybase ASE on your system, you’ll need the following:
- Linux Kernel—Version 2.1.122 or higher.
- RAM—32 MB is required; I recommend 64 or 128 MB.
- Free disk space—At least 200 MB in the device that contains the /opt directory, or 200 MB in the device that contains the root directory (/) if /opt does not exist.
- Free TCP port—Before you install Sybase ASE, open a terminal window, type netstat -t -a -n, and press [Enter]; you’ll see a list of the TCP ports currently in use on your system. Make sure you do not assign Sybase ASE to a port other than those listed in this command’s output.
- Working TCP/IP Configuration—Although you do not need to connect to the Internet to run Sybase ASE, your Linux system must be fully configured to run TCP/IP internally.
Making room for Sybase ASE
Chances are good that you won’t have enough space in /opt or the root directory to install Sybase ASE. Here’s why. Many people install Linux using more than one disk partition. On such systems, the root directory generally contains the /opt directory, and it may lack sufficient disk space. When you attempt to install the Sybase ASE RPM package, you’ll get the message that additional disk space is needed in the root directory.
To fix this problem, you’ll need to create an /opt/sybase directory and link it to a directory positioned within a partition that does contain sufficient space. Here’s how:
- Log in as root user, or switch to superuser (type su and provide the root password).
- Create a sybase directory in a partition that contains at least 200 MB of disk space, such as /home/sybase or /usr/local/sybase.
- Symbolically link the new sybase directory (such as /usr/local/sybase) to /opt/sybase. To do so, type ln -s /usr/local/sybase /opt/sybase-and press [Enter]. This command creates a symbolic link (/opt/sybase) that looks like a directory; in actuality, it’s a symbolic link, and it points to the new sybase directory (such as /usr/local/sybase) that is located within a partition with sufficient disk space.
- Important:Make the /opt directory and /opt/sybase file readable and executable for all users. To do so, type chmod a+rx /opt and press [Enter]. Then type chmod a+rx /opt/sybase and press [Enter].
Obtaining and installing Sybase ASE
Once you’ve downloaded Sybase ASE, it’s a cinch to install the packages. Just switch to superuser (type suand supply the root user password), type rpm -ivh sybase*rpm, and press [Enter]. If you see a message about insufficient disk space, see the previous section.
Once you’ve installed the RPM packages, you’re ready to run the installation script. To do so, switch to superuser, if necessary, and type /opt/sybase/install/sybinstall.sh. You’ll be asked to confirm the license terms. Type yes and press [Enter]. Next, you’ll be asked whether you want to create the sybase user. Type y and press [Enter]. You’ll be asked to supply a password for this user; be sure to write it down!
Important: If you needed to create /opt/sybase as a symbolic link due to insufficient disk space on your root directory, switch to superuser, if necessary, and switch to the physical directory that contains the Sybase ASE files (such as /home/sybase or /user/local/sybase). Type the following: chown -R sybase.sybase * and press [Enter].
Configuring Sybase ASE
To configure Sybase ASE, you can use the sybinit script. Follow these instructions to configure Sybase ASE for use on your system:
- Log in as the sybase user. Do not run the configuration script as the root user or superuser!
- Now start the sybinit script: type /opt/sybase/install/sybinitand press [Enter]. You’ll see the script’s menu on your screen.
- To configure the Sybase SQL Server, type 3 and press [Enter]. You’ll see the Configure Server Products menu. From this menu, you can configure the SQL Server or the Backup Server. For now, configure the SQL Server.
- Type 1 and press [Enter] to configure the SQL Server. You’ll see the New or Existing SQL Server menu.
- Type 1 and press [Enter] to create the new server. You’ll see the Add New SQL Server menu.
- Type 1 and press [Enter] to create the server name. Press [Enter] to create the default server name SYBASE. You’ll see the Add New SQL Server menu again.
- Press [Ctrl][A] to accept the server name. Next, you’ll see the SQL Server Configuration menu. Note that this menu lists nine items, and all of them are marked incomplete. To install the server, you must go through all nine of the options, although you’ll accept the defaults in all but one of them.
- Type 1 to configure the server interface. You’ll see the Server Interface window. Leave the first two options with their default settings.
- Type 3 to set up the TCP connection. You’ll see the Edit TCP Service menu. If TCP/IP is properly installed on your system, you should see your system’s hostname in the first option. You need to specify the TCP port.
- Type 2 to configure the TCP port. Type an unused port number (try 7100, if it’s free), and press [Enter].
- Confirm the TCP setting by pressing [Ctrl][A], typing y, pressing Ctrl][A] again, and typing y again. You’ll see the Server Configuration menu again. The first item should now be marked complete.
- From here, your job is simple: Access each option, and accept the defaults by pressing [Ctrl][A]. Do this for options 2 through 9 until all of them are marked complete.
- To accept the completed configuration, press [Ctrl][A]. Type y to confirm, and press [Enter] to ignore the warning about master.dat. Press [Enter] and type y as necessary to complete the configuration.
When you’ve completed these steps, Sybase ASE is up and running on your system! In the following sections, you’ll prove it to yourself by running a SQL query utility. In addition, you’ll install a demonstration database and try searching it.
Running isql and installing the Pubs2 database
To work with your Sybase ASE server, you can use isql, a text-based utility that’s installed on your system. It’s nothing to write home about, admittedly; what’s more, there are a variety of GUI-based programs you can use to interact with your database server. For now, though, try running isql, which is already installed on your system. You’ll use isql to install the pubs2 sample database.
To start isql and install the pubs2 database, log in as the sybase user, then switch to the sybase directory. Start isql with the following command:
isql -Usa -P -i ./scripts/installpubs2
then press [Enter]. (Note: You must enter the switches with the exact capitalization pattern shown here.) At the end of the messages, press [Enter] to return to the shell prompt.
Querying the Pubs2 database
Now that you’ve installed the Pubs2 database, you can use isql to search it. Start isql again by typing isql -Usa -P and pressing [Enter]. You’ll see the isql prompt (>1).
To use the Pubs2 database, type the following at the isql prompt:
This isn’t the place to teach the essentials of the SQL query language; suffice it to say that it’s fairly simple to use, once you’ve learned the basics. In essence, SQL enables you to specify what information you want and how it should be presented. Try the following SQL query:
>1select * from titles
>2order by price
This query says, in effect, Get all of the data from the titles database, and sort them by price. The output is pretty ugly; you can improve it by specifying which columns to list:
>1select price, title from titles
>2order by price
Looks better, doesn’t it? Now try the where statement, which enables you to select data that matches your specification:
>1select price, title from titles
>3order by price
In the following example, you perform a join, one of the most basic and important functions of a relational database system. In a join, you draw data from two or more tables. Try this example:
>1select * from authors, publishers
You’ll see a list that combines the information from both tables, which are linked by means of a common field.
Shutting down and starting the server
If you’re planning to run Sybase ASE for day-to-day database services, you’ll want to add a startup command line to your shell profile so that the server starts automatically. For now, though, you’re just experimenting with Sybase ASE, so you’ll probably want to shut it down when you’re not using it (and start it only when you’re ready for more experimentation). You can use isql for both purposes. To shut down the server, type shutdown at the isql prompt, press [Enter], type go, and press [Enter]. To start the server, log in as the sybase user, switch to the sybase/install directory, and type the following:
./startserver -f ./RUN_SYBASE
At the end of the messages, just press [Enter] to return to the shell prompt.
There’s much more to learn about Sybase ASE and SQL, of course, but you’ve accomplished quite a lot in this Daily Drill Down. You’ve installed one of the industry’s most heavy-hitting database servers, configured it so that it’s running smoothly, and tried out a few SQL queries.
In the next installment of this series, I’ll show you how to create your own Sybase ASE database.
Bryan Pfaffenberger, a UNIX user since 1985, is a University of Virginia professor, an author, and a passionate advocate of Linux and open source software. A Linux Journal columnist, his recent Linux-related books include Linux Clearly Explained (Morgan-Kaufmann) and Mastering Gnome (Sybex; in press). His hobbies include messing around with his home LAN and sailing the southern Chesapeake Bay. He lives in Charlottesville, VA. If you’d like to contact Bryan, send him an e-mail.
The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.