Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 48 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
48
Dung lượng
849,59 KB
Nội dung
Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 338 Installed files > /etc/openldap > /etc/openldap/ldap.conf > /etc/openldap/ldap.conf.default > /etc/openldap/ldapfilter.conf > /etc/openldap/ldapfilter.conf.default > /etc/openldap/ldaptemplates.conf > /etc/openldap/ldaptemplates.conf.default > /etc/openldap/ldapsearchprefs.conf > /etc/openldap/ldapsearchprefs.conf.default > /etc/openldap/slapd.conf > /etc/openldap/slapd.conf.default > /etc/openldap/slapd.at.conf > /etc/openldap/slapd.at.conf.default > /etc/openldap/slapd.oc.conf > /etc/openldap/slapd.oc.conf.default > /etc/openldap/ldapserver > /etc/rc.d/init.d/ldap > /etc/rc.d/rc0.d/K40ldap > /etc/rc.d/rc1.d/K40ldap > /etc/rc.d/rc2.d/K40ldap > /etc/rc.d/rc3.d/S70ldap > /etc/rc.d/rc4.d/S70ldap > /etc/rc.d/rc5.d/S70ldap > /etc/rc.d/rc6.d/K40ldap > /usr/bin/ud > /usr/bin/ldapsearch > /usr/bin/ldapmodify > /usr/bin/ldapdelete > /usr/bin/ldapmodrdn > /usr/bin/ldappasswd > /usr/bin/ldapadd > /usr/include/ldap.h > /usr/include/lber.h > /usr/include/ldap_cdefs.h > /usr/include/disptmpl.h > /usr/include/srchpref.h > /usr/lib/liblber.so.1.0.0 > /usr/lib/liblber.so.1 > /usr/lib/liblber.so > /usr/lib/liblber.la > /usr/lib/liblber.a > /usr/lib/libldap.so.1.0.0 > /usr/lib/libldap.so.1 > /usr/lib/libldap.so > /usr/lib/libldap.la > /usr/lib/libldap.a > /usr/man/man1/ud.1 > /usr/man/man1/ldapdelete.1 > /usr/man/man1/ldapmodify.1 > /usr/man/man1/ldapadd.1 > /usr/man/man1/ldapmodrdn.1 > /usr/man/man1/ldappasswd.1 > /usr/man/man1/ldapsearch.1 > /usr/man/man3/cldap_close.3 > /usr/man/man3/cldap_open.3 > /usr/man/man3/cldap_search_s.3 > /usr/man/man3/cldap_setretryinfo.3 > /usr/man/man3/lber-decode.3 > /usr/man/man3/lber-encode.3 > /usr/man/man3/ldap_open.3 > /usr/man/man3/ldap_errlist.3 > /usr/man/man3/ldap_err2string.3 > /usr/man/man3/ldap_first_attribute.3 > /usr/man/man3/ldap_next_attribute.3 > /usr/man/man3/ldap_first_entry.3 > /usr/man/man3/ldap_next_entry.3 > /usr/man/man3/ldap_count_entries.3 > /usr/man/man3/ldap_friendly.3 > /usr/man/man3/ldap_friendly_name.3 > /usr/man/man3/ldap_free_friendlymap.3 > /usr/man/man3/ldap_get_dn.3 > /usr/man/man3/ldap_explode_dn.3 > /usr/man/man3/ldap_explode_dns.3 > /usr/man/man3/ldap_dn2ufn.3 > /usr/man/man3/ldap_is_dns_dn.3 > /usr/man/man3/ldap_get_values.3 > /usr/man/man3/ldap_get_values_len.3 > /usr/man/man3/ldap_value_free.3 > /usr/man/man3/ldap_value_free_len.3 > /usr/man/man3/ldap_count_values.3 > /usr/man/man3/ldap_count_values_len.3 > /usr/man/man3/ldap_getfilter.3 > /usr/man/man3/ldap_init_getfilter.3 > /usr/man/man3/ldap_init_getfilter_buf.3 > /usr/man/man3/ldap_getfilter_free.3 > /usr/man/man3/ldap_getfirstfilter.3 > /usr/man/man3/ldap_getnextfilter.3 > /usr/man/man3/ldap_setfilteraffixes.3 > /usr/man/man3/ldap_build_filter.3 > /usr/man/man3/ldap_modify.3 > /usr/man/man3/ldap_modify_s.3 > /usr/man/man3/ldap_mods_free.3 > /usr/man/man3/ldap_modrdn.3 > /usr/man/man3/ldap_modrdn_s.3 > /usr/man/man3/ldap_modrdn2.3 > /usr/man/man3/ldap_modrdn2_s.3 > /usr/man/man3/ldap_init.3 > /usr/man/man3/ldap_result.3 > /usr/man/man3/ldap_msgfree.3 > /usr/man/man3/ldap_search.3 > /usr/man/man3/ldap_search_s.3 > /usr/man/man3/ldap_search_st.3 > /usr/man/man3/ldap_searchprefs.3 > /usr/man/man3/ldap_init_searchprefs.3 > /usr/man/man3/ldap_init_searchprefs_buf.3 > /usr/man/man3/ldap_free_searchprefs.3 > /usr/man/man3/ldap_first_searchobj.3 > /usr/man/man3/ldap_next_searchobj.3 > /usr/man/man3/ldap_sort.3 > /usr/man/man3/ldap_sort_entries.3 > /usr/man/man3/ldap_sort_values.3 > /usr/man/man3/ldap_sort_strcasecmp.3 > /usr/man/man3/ldap_ufn.3 > /usr/man/man3/ldap_ufn_search_s.3 > /usr/man/man3/ldap_ufn_search_c.3 > /usr/man/man3/ldap_ufn_search_ct.3 > /usr/man/man3/ldap_ufn_setprefix.3 > /usr/man/man3/ldap_ufn_setfilter.3 Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 339 > /usr/man/man3/ldap.3 > /usr/man/man3/cldap.3 > /usr/man/man3/ldap_abandon.3 > /usr/man/man3/ldap_add.3 > /usr/man/man3/ldap_add_s.3 > /usr/man/man3/ldap_bind.3 > /usr/man/man3/ldap_bind_s.3 > /usr/man/man3/ldap_simple_bind.3 > /usr/man/man3/ldap_simple_bind_s.3 > /usr/man/man3/ldap_kerberos_bind_s.3 > /usr/man/man3/ldap_kerberos_bind1.3 > /usr/man/man3/ldap_kerberos_bind1_s.3 > /usr/man/man3/ldap_kerberos_bind2.3 > /usr/man/man3/ldap_kerberos_bind2_s.3 > /usr/man/man3/ldap_unbind.3 > /usr/man/man3/ldap_unbind_s.3 > /usr/man/man3/ldap_set_rebind_proc.3 > /usr/man/man3/ldap_cache.3 > /usr/man/man3/ldap_enable_cache.3 > /usr/man/man3/ldap_disable_cache.3 > /usr/man/man3/ldap_destroy_cache.3 > /usr/man/man3/ldap_flush_cache.3 > /usr/man/man3/ldap_uncache_entry.3 > /usr/man/man3/ldap_uncache_request.3 > /usr/man/man3/ldap_set_cache_options.3 > /usr/man/man3/ldap_charset.3 > /usr/man/man3/ldap_set_string_translators.3 > /usr/man/man3/ldap_enable_translation.3 > /usr/man/man3/ldap_translate_from_t61.3 > /usr/man/man3/ldap_translate_to_t61.3 > /usr/man/man3/ldap_t61_to_8859.3 > /usr/man/man3/ldap_8859_to_t61.3 > /usr/man/man3/ldap_compare.3 > /usr/man/man3/ldap_compare_s.3 > /usr/man/man3/ldap_delete.3 > /usr/man/man3/ldap_delete_s.3 > /usr/man/man3/ldap_disptmpl.3 > /usr/man/man3/ldap_init_templates.3 > /usr/man/man3/ldap_init_templates_buf.3 > /usr/man/man3/ldap_free_templates.3 > /usr/man/man3/ldap_first_disptmpl.3 > /usr/man/man3/ldap_next_disptmpl.3 > /usr/man/man3/ldap_oc2template.3 > /usr/man/man3/ldap_tmplattrs.3 > /usr/man/man3/ldap_first_tmplrow.3 > /usr/man/man3/ldap_next_tmplrow.3 > /usr/man/man3/ldap_first_tmplcol.3 > /usr/man/man3/ldap_next_tmplcol.3 > /usr/man/man3/ldap_entry2text.3 > /usr/man/man3/ldap_entry2text_search.3 > /usr/man/man3/ldap_vals2text.3 > /usr/man/man3/ldap_entry2html.3 > /usr/man/man3/ldap_entry2html_search.3 > /usr/man/man3/ldap_vals2html.3 > /usr/man/man3/ldap_error.3 > /usr/man/man3/ldap_perror.3 > /usr/man/man3/ld_errno.3 > /usr/man/man3/ldap_result2error.3 > /usr/man/man3/ldap_ufn_timeout.3 > /usr/man/man3/ldap_url.3 > /usr/man/man3/ldap_is_ldap_url.3 > /usr/man/man3/ldap_url_parse.3 > /usr/man/man3/ldap_free_urldesc.3 > /usr/man/man3/ldap_url_search.3 > /usr/man/man3/ldap_url_search_s.3 > /usr/man/man3/ldap_url_search_st.3 > /usr/man/man5/ldap.conf.5 > /usr/man/man5/ldapfilter.conf.5 > /usr/man/man5/ldapfriendly.5 > /usr/man/man5/ldapsearchprefs.conf.5 > /usr/man/man5/ldaptemplates.conf.5 > /usr/man/man5/ldif.5 > /usr/man/man5/slapd.conf.5 > /usr/man/man5/slapd.replog.5 > /usr/man/man5/ud.conf.5 > /usr/man/man8/centipede.8 > /usr/man/man8/chlog2replog.8 > /usr/man/man8/edb2ldif.8 > /usr/man/man8/go500.8 > /usr/man/man8/go500gw.8 > /usr/man/man8/in.xfingerd.8 > /usr/man/man8/ldapd.8 > /usr/man/man8/ldbmcat.8 > /usr/man/man8/ldif.8 > /usr/man/man8/ldif2ldbm.8 > /usr/man/man8/ldif2index.8 > /usr/man/man8/ldif2id2entry.8 > /usr/man/man8/ldif2id2children.8 > /usr/man/man8/mail500.8 > /usr/man/man8/fax500.8 > /usr/man/man8/rcpt500.8 > /usr/man/man8/slapd.8 > /usr/man/man8/slurpd.8 > /usr/sbin/ldif > /usr/sbin/in.xfingerd > /usr/sbin/go500 > /usr/sbin/go500gw > /usr/sbin/mail500 > /usr/sbin/rp500 > /usr/sbin/fax500 > /usr/sbin/xrpcomp > /usr/sbin/rcpt500 > /usr/sbin/slapd > /usr/sbin/ldif2ldbm > /usr/sbin/ldif2index > /usr/sbin/ldif2id2entry > /usr/sbin/ldif2id2children > /usr/sbin/ldbmcat > /usr/sbin/centipede > /usr/sbin/ldbmtest > /usr/sbin/slurpd > /usr/share/openldap > /usr/share/openldap/ldapfriendly > /usr/share/openldap/go500gw.help > /usr/share/openldap/rcpt500.help > /var/ldap Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 340 Linux PostgreSQL Database Server Overview Once you begin to serve, and supply services to your customers, you’ll inevitably find that you need to keep information about them in an archive to be accessible and modifiable at any time, should you want it. These tasks can be accomplished with the use of a database. Many databases are available on Linux; Choosing one can be complicated, as it must be able to support a number of programming languages, standards and features. PostgreSQL, developed originally in the UC Berkeley Computer Science Department, pioneered many of the object- relational concepts now becoming available in commercial databases. It provides SQL92/SQL3 language support, transaction integrity, and type extensibility. As explained on the PostgreSQL web site: PostgreSQL is a sophisticated Object-Relational DBMS, supporting almost all SQL constructs, including subselects, transactions, and user-defined types and functions. It is the most advanced open-source database available anywhere. These installation instructions assume Commands are Unix-compatible. The source path is “/var/tmp” (other paths are possible). Installations were tested on Red Hat Linux 6.1 and 6.2. All steps in the installation will happen in super-user account “root”. PostgreSQL version number is 6.5.3 Packages PostgreSQL Homepage: http://www.postgresql.org/ PostgreSQL FTP Site: 216.126.84.28 You must be sure to download: postgresql-6.5.3.tar.gz Prerequisites Before compiling the PostgreSQL program, you must verify that egcs-c++-version.i386.rpm package is installed on your system. The egcs-c++-version.i386.rpm package is located in you Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 341 Red Hat Linux CD-ROM under “RedHat/RPMS” subdirectory. After compilation and installation of PostgreSQL you can remove the egcs-c++-version.i386.rpm package from your system. • To verify that egcs-c++-version.i386.rpm is already installed, use the following command: [root@deep /]# rpm -q egcs-c++ • To install egcs-c++-version.i386.rpm, use the following command: [root@deep /]# mount /dev/cdrom /mnt/cdrom [root@deep /]# cd /mnt/cdrom/RedHat/RPMS [root@deep RPMS]# rpm -Uvh egcs-c++-version.i386.rpm egcs-c++ ################################################## Tarballs It is a good idea to make a list of files on the system before you install it, and one afterwards, and then compare them using ‘diff’ to find out what file it placed where. Simply run ‘find /* > PostgreSQL1’ before and ‘find /* > PostgreSQL2’ after you install the tarball, and use ‘diff PostgreSQL1 PostgreSQL2 > PostgreSQL-Installed’ to get a list of what changed. Compilation Decompress the tarball (tar.gz). [root@deep /]# cp postgresql-version.tar.gz /var/tmp [root@deep /]# cd /var/tmp [root@deep tmp]# tar xzpf postgresql-version.tar.gz Compile and Optimize Step 1 First of all, to avoid security risks, we’ll create an unprivileged user account named “postgres” to be the owner of the Postgres files. • To create the Postgres account, use the following command: [root@deep /]# useradd -M -o -r -d /var/lib/pgsql -s /bin/bash -c "PostgreSQL Server" -u 40 postgres >/dev/null 2>&1 || : Step 2 Move into the new PosgreSQL directory we have untarred previously, and then move to its subdirectory named “src”. Type the following commands on your terminal: [root@deep /]# cd /var/tmp/postgresql-6.5.3 [root@deep postgresql-6.5.3]# cd src CC="egcs" \ ./configure \ prefix=/usr \ enable-locale This tells PostgreSQL to set itself up for this particular hardware setup with: - Enable locale support. Edit the Makefile.global file (vi +210 Makefile.global) and change the line: Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 342 CFLAGS= -I$(SRCDIR)/include -I$(SRCDIR)/backend To read: CFLAGS= -I$(SRCDIR)/include -I$(SRCDIR)/backend -O9 -funroll-loops -ffast-math -malign-double - mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions These are our optimization flags for the PostgreSQL Server. Of course, you must tailor them to fit your system and CPU architecture. Step 3 Now, we must compile and install PosgreSQL on to the server: [root@deep src]# make all [root@deep src]# cd [root@deep postgresql-6.5.3]# make -C src install [root@deep postgresql-6.5.3]# make -C src/man install [root@deep postgresql-6.5.3]# mkdir -p /usr/include/pgsql [root@deep postgresql-6.5.3]# mv /usr/include/access /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/commands /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/executor /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/lib /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/libpq /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/libpq++ /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/port /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/utils /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/fmgr.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/os.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/config.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/c.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/postgres.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/postgres_ext.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/libpq-fe.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/libpq-int.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/ecpgerrno.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/ecpglib.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/ecpgtype.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/sqlca.h /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/include/libpq++.H /usr/include/pgsql/ [root@deep postgresql-6.5.3]# mkdir -p /usr/lib/pgsql [root@deep postgresql-6.5.3]# mv /usr/lib/*source /usr/lib/pgsql/ [root@deep postgresql-6.5.3]# mv /usr/lib/*sample /usr/lib/pgsql/ [root@deep postgresql-6.5.3]# mkdir -p /var/lib/pgsql [root@deep postgresql-6.5.3]# chown -R postgres.postgres /var/lib/pgsql/ [root@deep postgresql-6.5.3]# chmod 755 /usr/lib/libpq.so.2.0 [root@deep postgresql-6.5.3]# chmod 755 /usr/lib/libecpg.so.3.0.0 [root@deep postgresql-6.5.3]# chmod 755 /usr/lib/libpq++.so.3.0 [root@deep postgresql-6.5.3]# strip /usr/bin/postgres [root@deep postgresql-6.5.3]# strip /usr/bin/postmaster [root@deep postgresql-6.5.3]# strip /usr/bin/ecpg [root@deep postgresql-6.5.3]# strip /usr/bin/pg_id [root@deep postgresql-6.5.3]# strip /usr/bin/pg_version [root@deep postgresql-6.5.3]# strip /usr/bin/pg_dump [root@deep postgresql-6.5.3]# strip /usr/bin/pg_passwd [root@deep postgresql-6.5.3]# strip /usr/bin/psql [root@deep postgresql-6.5.3]# rm -f /usr/lib/global1.description [root@deep postgresql-6.5.3]# rm -f /usr/lib/local1_template1.description The “make” command compiles all source files into executable binaries, and the “make install” command installs the binaries and any supporting files into the appropriate locations. The “mkdir” will create a new directory named “pgsql” under the “/usr/include” and “/usr/lib” directories, and Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 343 then we move all subdirectories and files related to PostgreSQL under “/usr/include” and “/usr/lib” directories to the “/usr/include/pgsql” and “/usr/lib/pgsql” directories respectively with the command “mv”. The "chown" command will set the correct owner and group permission for the “/var/lib/pgsql” directory. The “strip” command will discard all symbols from the object files. This means that our binary file will be smaller in size. This will improve the performance hit to the program since there will be fewer lines to read by the system when it executes the binary. The “rm” command will remove the “global1.description” and ”local1_template1.description” files that are not needed by our PosgreSQL program. Create the database installation from your Postgres superuser account Once PostgreSQL is installed on your Linux server, it’s important to create the database installation before starting your PostgreSQL server. • To create the database installation, use the following command: [root@deep /]# su postgres [postgres@deep /]$ initdb pglib=/usr/lib/pgsql pgdata=/var/lib/pgsql We are initializing the database system with username postgres (uid=40). This user will own all the files and must also own the server process. Creating Postgres database system directory /var/lib/pgsql/base Creating template database in /var/lib/pgsql/base/template1 Creating global classes in /var/lib/pgsql/base Adding template1 database to pg_database Vacuuming template1 Creating public pg_user view Creating view pg_rules Creating view pg_views Creating view pg_tables Creating view pg_indexes Loading pg_description [postgres@deep /]$ chmod 640 /var/lib/pgsql/pg_pwd [postgres@deep /]$ exit exit [root@deep /]# The “ pglib” command will specify where the library directory of PostgreSQL resides in the system, and the “ pgdata” command will specify where the database files must reside for this installation on Linux. NOTE: Do not create the database installation as “root”! This would be a major security hole. Cleanup after work [root@deep /]# cd /var/tmp [root@deep tmp]# rm -rf postgresql-version/ postgresql-version.tar.gz Remove the egcs-c++-version.i386.rpm package to save space. [root@deep /]# rpm -e egcs-c++ Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 344 The “rm” command will remove all the source files we have used to compile and install PostgreSQL. It will also remove the PostgreSQL compressed archive from the “/var/tmp” directory. The “rpm -e” command will remove the egcs-c++ package we installed to compile the PosgreSQL Server. Note that the egcs-c++ package is required only for compiling programs like PostgreSQL and can be uninstalled safely after successful compilation of PostgreSQL. Configurations All software we describe in this book has a specific directory and subdirectory in a tar compressed archive named “floppy.tgz” containing file configurations for specific programs. If you get this archive file, you won’t be obliged to reproduce the different configuration files below, manually, or cut and paste them to create your configuration files. Whether you decide to manually copy them, or get the files made for your convenience from the archive, it will be your responsibility to modify, adjust for your needs and place the files related to the PostgreSQL software in the appropriate places on your server, as shown below. The server configuration files archive to download is located at the following Internet address: http://www.openna.com/books/floppy.tgz • To run PostgreSQL Database server, the following file is required and must be created or copied to the appropriate directory on your server. Copy the postgresql script file to the “/etc/rc.d/init.d/” directory. You can obtain the configuration files listed below on our floppy.tgz archive. Copy the following files from the decompressed floppy.tgz archive to the appropriate places, or copy and paste them directly from this book to the concerned file. Configuration of the “/etc/rc.d/init.d/postgresql” script file Configure your “/etc/rc.d/init.d/postgresql” script file to start and stop PostgreSQL Server. Create the postgresql script file (touch /etc/rc.d/init.d/postgresql) and add: #! /bin/sh # postgresql This is the init script for starting up the PostgreSQL # server # chkconfig: 345 85 15 # description: Starts and stops the PostgreSQL backend daemon that handles \ # all database requests. # processname: postmaster # pidfile: /var/run/postmaster.pid # # Source function library. . /etc/rc.d/init.d/functions # Get config. . /etc/sysconfig/network # Check that networking is up. # Pretty much need it for postmaster. [ ${NETWORKING} = "no" ] && exit 0 [ -f /usr/bin/postmaster ] || exit 0 Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 345 # This script is slightly unusual in that the name of the daemon (postmaster) # is not the same as the name of the subsystem (postgresql) # See how we were called. case "$1" in start) echo -n "Checking postgresql installation: " # Check for the PGDATA structure if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d /var/lib/pgsql/base/template1 ] then # Check version of existing PGDATA if [ `cat /var/lib/pgsql/PG_VERSION` != '6.5' ] then echo "old version. Need to Upgrade." echo "See /usr/doc/postgresql-6.5.2/README.rpm for more information." exit 1 else echo "looks good!" fi # No existing PGDATA! Initdb it. else echo "no database files found." if [ ! -d /var/lib/pgsql ] then mkdir -p /var/lib/pgsql chown postgres.postgres /var/lib/pgsql fi su -l postgres -c '/usr/bin/initdb pglib=/usr/lib/pgsql pgdata=/var/lib/pgsql' fi # Check for postmaster already running pid=`pidof postmaster` if [ $pid ] then echo "Postmaster already running." else #all systems go remove any stale lock files rm -f /tmp/.s.PGSQL.* > /dev/null echo -n "Starting postgresql service: " su -l postgres -c '/usr/bin/postmaster -i -S -D/var/lib/pgsql' sleep 1 pid=`pidof postmaster` if [ $pid ] then echo -n "postmaster [$pid]" touch /var/lock/subsys/postgresql echo $pid > /var/run/postmaster.pid echo else echo "failed." fi fi ;; stop) echo -n "Stopping postgresql service: " killproc postmaster sleep 2 rm -f /var/run/postmaster.pid rm -f /var/lock/subsys/postgresql Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 346 echo ;; status) status postmaster ;; restart) $0 stop $0 start ;; *) echo "Usage: postgresql {start|stop|status|restart}" exit 1 esac exit 0 Now, make this script executable and change its default permissions: [root@deep /]# chmod 700 /etc/rc.d/init.d/postgresql Create the symbolic rc.d links for PostgreSQL with the command: [root@deep /]# chkconfig add postgresql Start your new PostgreSQL server manually with the following command: [root@deep /]# /etc/rc.d/init.d/postgresql start Checking postgresql installation: looks good! Starting postgresql service: postmaster [22401] Commands The commands listed below are some that we use often, but many more exist. Check the man page for more details and information. • To define a new user in your database, run the createuser utility program: [root@deep /]# su postgres [postgres@deep /]$ createuser Enter name of user to add > admin Enter user's postgres ID or RETURN to use unix user ID: 500 -> Is user "admin" allowed to create databases (y/n) y Is user "admin" a superuser? (y/n) y createuser: admin was successfully added • To remove a user in your database, run the destroyuser utility program: [root@deep /]# su postgres [postgres@deep /]$ destroyuser Enter name of user to delete > admin destroyuser: delete of user admin was successful. • To create a new database, run the createdb utility program: [root@deep /]# su postgres [postgres@deep /]$ createdb dbname (dbname is the name of the database). or with the Postgres terminal monitor program (psql) [root@deep /]# su admin [admin@deep /]$ psql template1 Welcome to the POSTGRESQL interactive sql monitor: Please read the file COPYRIGHT for copyright terms of POSTGRESQL [PostgreSQL 6.5.3 on i686-pc-linux-gnu, compiled by egcs ] Server Software (Database Network Services) 1 CHAPTER 7 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 347 type \? for help on slash commands type \q to quit type \g or terminate with semicolon to execute query You are currently connected to the database: template1 template1 create database foo; CREATEDB NOTE: Client connections can be restricted by IP address and/or user name via the “pg_hba.conf” file in PG_DATA. Other useful Postgres terminal monitor program commands (psql) are: • To connect to the new database, use the command: template1 \c foo connecting to new database: foo foo • To create a table, use the command: foo create table bar (i int4, c char(16)); CREATE foo • To inspect the new table, use the command: foo \d bar Table = bar + + + + | Field | Type | Length | + + + + | I | int4 | 4 | | c | char() | 16 | + + + + foo • To drop a table, index, view, use the command: foo drop table table_name; foo drop index index_name; foo drop view view_name; • To insert into: (once a table is created, it can be filled using the command…) foo insert into table_name (name_of_attr1, name_of_attr2, name_of_attr3) foo values (value1, value2, value3); Installed files > /etc/rc.d/init.d/postgresql > /etc/rc.d/rc0.d/K15postgresql > /etc/rc.d/rc1.d/K15postgresql > /etc/rc.d/rc2.d/K15postgresql > /etc/rc.d/rc3.d/S85postgresql > /etc/rc.d/rc4.d/S85postgresql > /etc/rc.d/rc5.d/S85postgresql > /etc/rc.d/rc6.d/K15postgresql > /usr/bin/postgres > /usr/bin/postmaster > /usr/bin/ecpg > /usr/bin/pg_id > /usr/bin/pg_version > /usr/bin/psql > /usr/man/manl/begin.l > /usr/man/manl/close.l > /usr/man/manl/cluster.l > /usr/man/manl/commit.l > /usr/man/manl/copy.l > /usr/man/manl/create_aggregate.l > /usr/man/manl/create_database.l > /usr/man/manl/create_function.l > /usr/man/manl/create_index.l > /usr/man/manl/create_language.l > /usr/man/manl/create_operator.l > /usr/man/manl/create_rule.l > /usr/man/manl/create_sequence.l > /usr/man/manl/create_table.l [...]... - HTTP: Security: FTP: Gopher: WAIS: 2 08. 164. 186 .1 2 08. 164. 186 .1 2 08. 164. 186 .1 2 08. 164. 186 .1 2 08. 164. 186 .1 Port: 80 80 Port: 80 80 Port: 80 80 Port: 80 80 Port: 80 80 Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 366 Server Software (Proxy Network Services) 1 CHAPTER 8 Installed files > /etc/squid > /etc/squid/mib.txt > /etc/squid/squid.conf.default > /etc/squid/squid.conf... 2 08. 164. 186 .3 (www.openna.com) and on port (80 ) “www.openna.com” is another host name on our network, and since the Squid Proxy Server doesn’t reside on the same host of Apache HTTP Web Server, we can use port (80 ) for our Squid Proxy Server, and port (80 ) for our Apache Web Server, and the illusion is perfect log_icp_queries off Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and. .. 6 7 8 Open Netscape Communicator Go to Edit menu Click on Preferences … Double click Advanced category on the left side Click on Proxies subcategory option Select on the right side Manual proxy configuration radio button Click on the View… button Fill the boxes with your proxy server information For example: - HTTP: Security: FTP: Gopher: WAIS: 2 08. 164. 186 .1 2 08. 164. 186 .1 2 08. 164. 186 .1 2 08. 164. 186 .1... squid and cache_effective_group squid The options “cache_effective_user” and “cache_effective_group” specify the UID/GID that the cache will run on Don’t forget to never run Squid as “root” In our configuration we use the UID “squid” and the GID “squid” httpd_accel_host 2 08. 164. 186 .3 and httpd_accel_port 80 The options “httpd_accel_host” and “httpd_accel_port” specify to Squid the IP address and port... http://www.hpl.hp.com/techreports/1999/HPL-1999-69.html and http://fog.hpl.external.hp.com/techreports/ 98/ HPL- 98- 173.html for more information acl all src 0.0.0.0/0.0.0.0 and http_access allow all The options “acl” and “http_access” specify and define an access control list to be applied on the proxy server Squid Our “acl” and “http_access” options are not restricted, and allow every one to connect on the proxy... control, and apply special policies on what can be viewed, accessed, and downloaded You can also control bandwidth usage, connection time, and so on A proxy cache server can be configured to run as stand-alone server for your corporation, or to use and share caches hierarchically with other proxy servers around the Internet With the first example below we show you how to configure Squid as a stand-alone... Architecture ® and OpenDocs Publishing 3 68 Chapter 19 Server Software (Web Network Services) In this Chapter Linux MM – Shared Memory Library Linux Apache Web Server Configurations PHP4 server-side scripting language Perl module Devel::Symdump CGI.pm Perl library Securing Apache Running Apache in a chroot jail Optimizing Apache Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs... squid, and the “chmod” command will make the mode of “squid” and “cache” directories (0750/drwxr-x -) for security reasons Take note that we remove the small scripts named “RunCache” and “RunAccel” which start Squid in either caching mode or accelerator mode, since we use a better script named “squid” located under the “/etc/rc.d/init.d/” directory that takes advantage of Linux system V The “strip” command... Gerhard Mourani, Open Network Architecture ® and OpenDocs Publishing 354 Server Software (Proxy Network Services) 1 CHAPTER 8 [root@deep tmp]# rm -rf malloc/ malloc.tar.gz (if you used the GNU malloc external library) The “rm” command will remove all the source files we have used to compile and install Squid and GNU malloc It will also remove the Squid and GNU malloc compressed archive from the “/var/tmp”... run on port 81 With the Apache web server, you can do it by assign the line (Port 80 ) to (Port 81 ) in its “httpd.conf” file If the Web Server runs on other servers in your network like we do, you can keep the same port number (80 ) for Apache, since Squid will bind on a different IP number where port (80 ) is not already in use Copyright 1999 - 2000 Gerhard Mourani, Open Network Architecture ® and OpenDocs . /usr/man/man8/centipede .8 > /usr/man/man8/chlog2replog .8 > /usr/man/man8/edb2ldif .8 > /usr/man/man8/go500 .8 > /usr/man/man8/go500gw .8 > /usr/man/man8/in.xfingerd .8 > /usr/man/man8/ldapd .8. /usr/man/man8/ldapd .8 > /usr/man/man8/ldbmcat .8 > /usr/man/man8/ldif .8 > /usr/man/man8/ldif2ldbm .8 > /usr/man/man8/ldif2index .8 > /usr/man/man8/ldif2id2entry .8 > /usr/man/man8/ldif2id2children .8. /usr/man/man8/ldif2id2children .8 > /usr/man/man8/mail500 .8 > /usr/man/man8/fax500 .8 > /usr/man/man8/rcpt500 .8 > /usr/man/man8/slapd .8 > /usr/man/man8/slurpd .8 > /usr/sbin/ldif