Páginas

segunda-feira, 11 de julho de 2011

Maintain wtmp on AIX

In /var/adm/wtmp on AIX maintains a list of past user sessions and information about the restart/shutdown of that particular system. While this file is normally very small in terms of file size, on an active box, this can grow if not properly maintained. You can use the “last” command to read wtmp, or export it to a text file for further processing with “fwtmp”. While you can simply redirect nothing into wtmp to empty it out “>/var/adm/wtmp”, it’s always a good idea to keep this file (or at least a backup) for security/auditing reasons.

Below is a simple script which will rotate the last 1000 entries in wtmp and discard the rest.
#!/bin/ksh 
#
# Maintain the last 1000 lines in /var/adm/wtmp
# and discard the rest.
#
if [ -s /var/adm/wtmp ]; then 
   /usr/sbin/acct/fwtmp < /var/adm/wtmp > /tmp/wtmp.tmp 
   /usr/bin/tail -1000 /tmp/wtmp.tmp | /usr/sbin/acct/fwtmp -ic > /var/adm/wtmp 
   /usr/bin/rm /tmp/wtmp.tmp
else 
   continue 
fi
Linux on Power Systems Servers overview
 
IBM® Power Systems™ Servers allow you to run Linux® applications, while taking advantage of POWER® hardware performance, availability, and reliability features.
You can use the IBM Installation Toolkit to install Linux on your Power Systems server. Then, virtualize your system and configure open source workloads using the IBM Installation Toolkit for Linux Simplified Setup Tool (Simplified Setup Tool).
Continue with the following topics for information about supported features, supported distributions, and additional resources for installing Linux on Power Systems Servers.
 
This page shows the steps used to compile and build apache2 on linux. The example uses Apache 2.0.46 on Redhat 8 using a bash shell, you will need gcc installed. You can find Apache's install instructions here
Downlaod the latest tar.gz file for apache2

You can download it from httpd.apache.org.
Login as root

You can type su to switch to root. Then run source /etc/profile to ensure that your path environment variable is setup properly.
Extract the source code

In this example we extract the source code to a directory under /usr/local/src/
cp httpd-2.0.46.tar.gz /usr/local/src

 cd /usr/local/src

 gunzip httpd-2.0.46.tar.gz

 tar -xvf httpd-2.0.46.tar

 rm -f httpd-2.0.46.tar

 cd httpd-2.0.46

Now you should be in the directory that contains the source code. Set compiler options (optional)

If you want you can set some compiler options, this is typically done to create optimized code. One very common thing to do is to set CFLAGS=-O2 or CFLAGS=-O3 (that's an Oh, not a Zero) that tells the compiler how much code optimization to do, setting it to a higher value does more optimization, but also takes longer to compile and may potentially cause unexpected things (not common). O2 is a fairly safe level to use. To do this type the following:
export CFLAGS=-O2

You can also tell the compiler what kind of CPU you have to perform more optimizations, I'm not going to get into that here, but if your interested check out the GCC manual. Run autoconf (configure)

Now you need to set the configuration options, and check that all libraries needed to compile are present. This is done with a script called configure, to find out what options you can set type the following:
./configure --help

You will see quite a few options there, we will set the prefix (the directory to install apache, we picked /usr/local/apache2) and also tell it which modules to compile and install. We will tell configure to compile and install all modules as shared DSO libraries, that way we can easily enable and disable them in the httpd.conf file. Here's how we ran configure:
configure --prefix=/usr/local/apache2 --enable-mods-shared=all

Compile Apache

Now to compile apache we run make this compiles the source code into executable binaries.
make

Installing Apache

The next step copies the binaries into the install directory, and sets up the modules.
make install

Starting/Stopping/Restarting Apache

Now to start/stop apache use apachectl in the bin directory of your install dir.
cd /usr/local/apache2/bin
 
 ./apachectl start
 
 ./apachectl stop
 
 ./apachectl restart

A script for init.d (optional)

Here's a script you can save to /etc/init.d/httpd it is a modified version of the one that came in the rpm for Apache 2.0.40
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#              HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
pid=$httpd/logs/httpd.pid
prog=httpd
RETVAL=0


# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
        echo -n $"Starting $prog: "
        daemon $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $httpd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $httpd -HUP
        RETVAL=$?
        echo
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $httpd
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f $pid ] ; then
                stop
                start
        fi
        ;;
  reload)
        reload
        ;;
  graceful|help|configtest|fullstatus)
        $apachectl $@
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status"
  echo $"|fullstatus|graceful|help|configtest}"
        exit 1
esac

exit $RETVAL

Next run chkconfig to setup runlevels for which httpd will run:
 chkconfig --add httpd
 
 chkconfig --level 2345 httpd on
 
 chkconfig --list
 
Uninstall old rpm packages (Optional)

If you have old rpm apache packages installed, you can check by running:
rpm -q httpd
 
In my case it lists the following:
redhat-config-httpd-1.0.1-13
httpd-2.0.40-11.3
httpd-manual-2.0.40-11.3
To uninstall one of the rpm's type rpm -e packagename
rpm -e httpd-2.0.40-11.3
 
It may tell you that you have other packages that depend on httpd, you will have to uninstall them first before you can remove the old httpd server.

terça-feira, 5 de julho de 2011

How Do I Install AIX 64-bit?

The simple answer is you don’t. You install AIX normally, which by default installs a 32-bit kernel (at least 32-bit is default for AIX 5.3). Then you change your kernel and reboot.
I have AIX running on top of (as a client partition of) Virtual I/O (VIO) Server, which is IBM’s virtualization version of VMware.  Does VIO server allow 64-bit client OS installs?  Yes.

Does My System Support AIX 64-bit?

Check whether your kernel is currently 32-bit:
AIX# bootinfo -K
32
Your AIX version must be 5.1 or above:
AIX# oslevel
5.3.0
Verify that your hardware supports 64 bits:
AIX# bootinfo -y
64

How to Change Your 32-bit AIX Kernel to 64-bit

1) Create/overwrite your links to the Unix kernel:
ln -sf /usr/lib/boot/unix_64 /unix
ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix
2) Verify:
ls -l /unix
ls -l /usr/lib/boot/unix
lsvg -l rootvg
3) Create your boot image and restart:
lslv -m hd5
bosboot -ad /dev/ipldevice
shutdown -Fr
Note: If you have LSOF installed, make sure you’re running the 64-bit version.  Check out the last part of my How to Install LSOF post.
4) After you reboot, verify your OS Kernel:
bootinfo -K

How to Revert Back from 64-bit to 32-bit:

From 64-bit to 32-bit:
ln -sf /usr/lib/boot/unix_mp /unix
ln -sf /usr/lib/boot/unix_mp /usr/lib/boot/unix
lslv -m hd5
bosboot -ad /dev/ipldevice
shutdown -Fr
Tags: , , , , , , , ,