Friday, June 28, 2013

Restore HP-UX from ignite tape (with screen dump)

 Objective

To restore HP-UX (11i, 11.23 should work) from a backup (make_tape_recovery)
  1. Login MP console and recycle it
  2. "CO" to console
  3. Within that "10 seconds", press any key and see the menu
    ---- Main Menu ---------------------------------------------------------------
    
         Command                           Description
         -------                           -----------
         BOot [PRI|ALT|]             Boot from specified path
         PAth [PRI|ALT] []           Display or modify a path
         SEArch [DIsplay|IPL] []     Search for boot devices
    
         COnfiguration menu                Displays or sets boot values
         INformation menu                  Displays hardware information
         SERvice menu                      Displays service commands
    
         DIsplay                           Redisplay the current menu
         HElp [|]           Display help for menu or command
         RESET                             Restart the system
    ----
    Main Menu: Enter command or menu > sea
  4. Insert the tape and run "SEA" to search devices
    Main Menu: Enter command or menu > SEA
    
    Searching for potential boot device(s)
    This may take several minutes.
    
    To discontinue search, press any key (termination may not be immediate).
    
    
                                                                               IODC
       Path#  Device Path (dec)  Device Path (mnem)  Device Type               Rev
       -----  -----------------  ------------------  -----------               ----
       P0     0/0/2/0.0          ide.0               Random access media       1    
       P1     0/1/1/0.0          intscsia.0          Random access media       1    
       P2     0/1/1/1.4          intscsib.4          Sequential access media   1    
    
    
    Main Menu: Enter command or menu >
  5. "P2 0/1/1/1.4 intscsib.4 Sequential access media 1" -> which is the tape drive
  6. Start Restore
    Main Menu: Enter command or menu > BOot P2
    
    Interact with IPL (Y, N, or Cancel)?> N
    
    
    Booting... 
    Boot IO Dependent Code (IODC) revision 1
    
    
    HARD Booted.
    
    ISL Revision A.00.43  Apr 12, 2000 
    
    ISL booting  hpux (;0):INSTALL
    
    Boot
    : tape(0/1/1/1.4.0.0.0.0.0;0):WINSTALL
    
    11751424 + 1962072 + 2627800 start 0x2026e8
    
    
    
    
    
    alloc_pdc_pages: Relocating PDC from 0xfffffff0f0c00000 to 0x3f900000.
    
    gate64: sysvec_vaddr = 0xc0002000 for 2 pages
    NOTICE: nfs3_link(): File system was registered at index 4.
    NOTICE: autofs_link(): File system was registered at index 6.
    NOTICE: cachefs_link(): File system was registered at index 7.
    igelan0: INITIALIZING HP PCI 1000Base-T Core at hardware path 0/1/2/0
    
        System Console is on the Built-In Serial Interface
        Swap device table:  (start & size given in 512-byte blocks)
            entry 0 - auto-configured on root device; ignored - no room
    
    WARNING: no swap device configured, so dump cannot be defaulted to primary swap.
    
    WARNING: No dump devices are configured.  Dump is disabled.
    
    Starting the STREAMS daemons-phase 1
    
    Create STCP device files
    
              $Revision: vmunix:    vw: -proj    selectors: CUPI80_BL2000_1108 -c 'Vw for CUPI80_BL2000_1108 build' -- cupi80_bl2000_1108 'CUPI80_BL2000_1108'  Wed Nov  8 19:24:56 PST 2000 $
    
    Memory Information:
    
        physical page size = 4096 bytes, logical page size = 4096 bytes
    
        Physical: 2095104 Kbytes, lockable: 1549872 Kbytes, available: 1795200 Kbytes
    
    
    
    =======  06/17/13 20:46:28 EDT  HP-UX Installation Initialization. (Mon Jun 17 
             20:46:28 EDT 2013)
             @(#) Ignite-UX Revision B.5.1.33
             @(#) install/init (opt) $Revision: 10.279 $
           * Scanning system for IO devices...
           * Querying disk device: 0/1/1/0.0.0 ...
    Recovery tape created from system: rp3410 on Mon Jun  3 15:12:27 2013
    
    
    WARNING: The configuration information calls for a non-interactive
             installation.
    
             Press  within 10 seconds to cancel batch-mode installation:
           * Using client directory: /var/opt/ignite/clients/0x00306E4B16B6
           * Checking configuration for consistency...
           * Attempting a non-interactive installation.
           * Loading configuration utility...
           * Beginning installation from source: /dev/rmt/0m
    =======  06/17/13 20:47:21 EDT  Starting system configuration...
           * Configure_Disks:  Begin
           * Will install B.11.11 onto this system.
           * Creating LVM physical volume "/dev/rdsk/c2t0d0" (0/1/1/0.0.0).
           * Creating volume group "vg00".
           * Creating logical volume "vg00/lvol1" (/stand).
           * Creating logical volume "vg00/lvol2" (swap_dump).
           * Creating logical volume "vg00/lvol3" (/).
           * Creating logical volume "vg00/lvol4" (/tmp).
           * Creating logical volume "vg00/lvol5" (/home).
           * Creating logical volume "vg00/lvol6" (/opt).
           * Creating logical volume "vg00/lvol7" (/usr).
           * Creating logical volume "vg00/lvol8" (/var).
           * Extending logical volume "vg00/lvol1" (/stand).
           * Extending logical volume "vg00/lvol2" (swap_dump).
           * Extending logical volume "vg00/lvol3" (/).
           * Extending logical volume "vg00/lvol4" (/tmp).
           * Extending logical volume "vg00/lvol5" (/home).
           * Extending logical volume "vg00/lvol6" (/opt).
           * Extending logical volume "vg00/lvol7" (/usr).
           * Extending logical volume "vg00/lvol8" (/var).
           * Making HFS filesystem for "/stand", (/dev/vg00/rlvol1).
           * Making VxFS filesystem for "/", (/dev/vg00/rlvol3).
           * Making VxFS filesystem for "/tmp", (/dev/vg00/rlvol4).
           * Making VxFS filesystem for "/home", (/dev/vg00/rlvol5).
           * Making VxFS filesystem for "/opt", (/dev/vg00/rlvol6).
           * Making VxFS filesystem for "/usr", (/dev/vg00/rlvol7).
           * Making VxFS filesystem for "/var", (/dev/vg00/rlvol8).
           * Setting rotational delay to 0 for "/stand".
           * Configure_Disks:  Complete
           * Download_mini-system:  Begin
    x ./sbin/fs/hfs/mkfs, 290816 bytes, 568 tape blocks
    x ./sbin/fs/hfs/newfs, 212992 bytes, 416 tape blocks
    x ./sbin/fs/vxfs/mkfs, 393216 bytes, 768 tape blocks
    x ./sbin/fs/vxfs/newfs, 327680 bytes, 640 tape blocks
    x ./sbin/mkfs symbolic link to /sbin/fs_wrapper
    x ./sbin/newfs symbolic link to /sbin/fs_wrapper
    x ./sbin/lib/mfsconfig.d/hfs, 978 bytes, 2 tape blocks
    x ./sbin/lib/mfsconfig.d/vxfs, 966 bytes, 2 tape blocks
    x ./sbin/fs_wrapper, 233472 bytes, 456 tape blocks
    x ./sbin/sh, 401408 bytes, 784 tape blocks
    x ./usr/bin/mediainit, 32768 bytes, 64 tape blocks
    x ./usr/sbin/tunefs, 20480 bytes, 40 tape blocks
    x ./sbin/extendfs symbolic link to /sbin/fs_wrapper
    x ./sbin/fs/vxfs/extendfs, 319488 bytes, 624 tape blocks
    x ./sbin/fs/hfs/extendfs, 245760 bytes, 480 tape blocks
    x ./sbin/lvchange, 815104 bytes, 1592 tape blocks
    ./sbin/lvcreate linked to ./sbin/lvchange
    ./sbin/lvdisplay linked to ./sbin/lvchange
    ./sbin/lvextend linked to ./sbin/lvchange
    ./sbin/lvlnboot linked to ./sbin/lvchange
    ./sbin/lvreduce linked to ./sbin/lvchange
    ./sbin/lvremove linked to ./sbin/lvchange
    ./sbin/lvrmboot linked to ./sbin/lvchange
    ./sbin/pvchange linked to ./sbin/lvchange
    ./sbin/pvcreate linked to ./sbin/lvchange
    ./sbin/pvdisplay linked to ./sbin/lvchange
    ./sbin/pvmove linked to ./sbin/lvchange
    ./sbin/sdstolvm linked to ./sbin/lvchange
    ./sbin/vgcfgbackup linked to ./sbin/lvchange
    ./sbin/vgcfgrestore linked to ./sbin/lvchange
    ./sbin/vgchange linked to ./sbin/lvchange
    ./sbin/vgcreate linked to ./sbin/lvchange
    ./sbin/vgdisplay linked to ./sbin/lvchange
    ./sbin/vgexport linked to ./sbin/lvchange
    ./sbin/vgextend linked to ./sbin/lvchange
    ./sbin/vgimport linked to ./sbin/lvchange
    ...
    x ./monitor_bpr, 20480 bytes, 40 tape blocks
           * Download_mini-system:  Complete
           * Loading_software:  Begin
           * Installing boot area on disk.
           * Enabling swap areas.
           * Backing up LVM configuration for "vg00".
           * Processing the archive source (Recovery Archive).
           * Mon Jun 17 20:51:06 EDT 2013: Starting archive load of the source 
             (Recovery Archive).
           * Positioning the tape (/dev/rmt/0mn).
           * Archive extraction from tape is beginning. Please wait.
    pax_iux: Ready for volume 2
    
    pax_iux: Type "go" when ready to proceed (or "quit" to abort):
     

OpenVPN server setup on Raspberry Pi

Note: it is for bridge mode only


I found that Raspberry Pi is a good choice for setup OpenVPN server. I can always power on it as the power consumption is low. After setting it up, I can connect VPN to home in office or cafe outside. 

You may think port forwarding by router or via SSH is good enough. However, there are limitations when:
  1. there are lots of services you want to connect from outsider, then your port forwarding rules will be massive
  2. as the OpenVPN client can reconnect automatically, I can have a relative stable connection. Sometimes you would like to have a reserve connect from server to client. My own experience is that in my previous company, I setup OpenVPN client in office and connect to my home, leave the connection alive. Then when I go home I can reconnect to my office PC by remote desktop :)

Objective

  • Internal network: 192.168.28.0/24
  • Setup a OpenVPN server such that client connection will connect to the server and assign a 192.168.28.0/24 IP as if it is within the internal network
  • necessary install
    apt-get install  bridge-utils openvpn 

Tuesday, June 18, 2013

Cisco MDS port zoning 101

Objective

  • There are two FC ports (fd0, fd1) on a hp-ux rp3410 (hostname: rp3410 :) )
  • The storage is EMC VNX5100, we will use SPA P1/P2 and SPB P1/P2.

Physical connection

  • rp3410 fd0 will connect to SW1 port 1/7
  • rp3410 fd1 will connect to SW2 port 1/7
  • VNX5100 SPA P1 on SW1 port 1/1
  • VNX5100 SPB P1 on SW1 port 1/2
  • VNX5100 SPA P2 on SW2 port 1/1
  • VNX5100 SPB P2 on SW2 port 1/2

Switch configuration:

We will create 4 zones, 2 on each switch: The zoneset is "full-zoneset"

SW1 wwn is 20:00:xx:xx:xx:xx:xx:xx
SW2 wwn is 20:00:yy:yy:yy:yy:yy:yy

The VSAN of SW1 is 201, SW2 is 202

(it is port zoning, for soft zoning by wwn, it will be ready later)

SW1:
config t

vsan database
vsan 201 interface 1/7
 
interface 1/7
no shutdown
switchport mode F
switchport description "rp3410_fd0"

zone name rp3410_fd0_VNX5100_VNX_SPA1 vsan 201
member interface fc 1/1 swwn 20:00:xx:xx:xx:xx:xx:xx
member interface fc 1/7 swwn 20:00:xx:xx:xx:xx:xx:xx

zone name rp3410_fd0_VNX5100_VNX_SPB1 vsan 201
member interface fc 1/2 swwn 20:00:xx:xx:xx:xx:xx:xx
member interface fc 1/7 swwn 20:00:xx:xx:xx:xx:xx:xx

zoneset name full-zoneset vsan 201
memeber rp3410_fd0_VNX5100_VNX_SPA1
memeber rp3410_fd0_VNX5100_VNX_SPB1
zoneset activate name full-zoneset
 
SW2
config t

vsan database
vsan 202 interface 1/7

interface 1/7
no shutdown
switchport mode F
switchport description "rp3410_fd1"

zone name rp3410_fd1_VNX5100_VNX_SPA2 vsan 202
member interface fc 1/1 swwn 20:00:yy:yy:yy:yy:yy:yy
member interface fc 1/7 swwn 20:00:yy:yy:yy:yy:yy:yy

zone name rp3410_fd1_VNX5100_VNX_SPB2 vsan 202
member interface fc 1/2 swwn 20:00:yy:yy:yy:yy:yy:yy
member interface fc 1/7 swwn 20:00:yy:yy:yy:yy:yy:yy

zoneset name full-zoneset vsan 202
memeber rp3410_fd1_VNX5100_VNX_SPA2 vsan 202
memeber rp3410_fd1_VNX5100_VNX_SPB2 vsan 202
zoneset activate name full-zoneset

Wednesday, May 08, 2013

Update MoinMoin from 1.9.5 to 1.9.7

This is the general steps for updating moinmoin from 1.9.5 to 1.9.7

  1. Stop web server or standalone process
  2. backup wiki instance (eg. mywiki or instance1)
  3. backup moinmoin installation path
  4. if there is customized logo, backup it as well (eg. moinmoin.png)
  5. delete *.pyc or *.pyo
    find  -name *.pyc -exec rm {} \; 
  6. download moinoin1.9.7 and install to existing path
    python setup.py install --prefix 
  7. replace moinmoin.png if necessary
  8. if using web server, remember to change the static path from "/moin_static195" to "/moin_static197"
  9. start web server or standalone process
  10. double check the version by http:///SystemInfo

Monday, February 18, 2013

Setup Trac on Raspberry Pi as a Wiki and Issue Tracking Tool

Trac with GIT

Trac is a wiki and issue tracking tool. There are other choices such as redmind and mantisbt. However, Trac is the most suitable one for running on Raspberry Pi because:
  1. it is run by python, which is installed by default for raspbian. (php and ruby are not required)
  2. it is relatively light weight. It can use sqlite as the database, rather than MySQL or PostgresSQL.
  3. it can be run in standalone mode, without using apache or lighttpd. (although I will still use lighttpd to 'proxy' Trac)
  4. It supports modern version control tool such as Subversion and GIT. (redmine also supports, but again, it's not that light weight)
  5. with making use of virtual environment (virutalenv), you can setup Trac without using a privilege account.
  6. it is a mature product and many organizations are using it (http://trac.edgewall.org/wiki/TracUsers)

Install and setup Trac

First, make sure virtualenv is already installed. (apt-get install virtualenv)

Remove a file completely in GIT

GIT is a great version control tool. I was a CVS and SVN users but I think GIT is even more powerful. Perhaps I can write something about GIT but now I want to share an experience: How to remove a file completely from GIT.

There is an internal db in GIT. Once your add and commit codes into the repository, the info will be store and the great thing is that you can check out the file at any version. However, I did an stupid thing - I hard coded some personal information (eg password) in a file and commit it to the repository. It won't be a problem if you are the only developer of the project.  But if you need to share the code by cloning the repository to the others, your information can be retrieved, even you delete it in filesystem.

So I did some quick search and find a solution: just runt the following command to remove the history and file:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch " HEAD

Make sure you make a copy to some places out of the GIT repository. Then you can copy the file back and add it as a "fresh new" file.

PS. As a better practice, don't hard coded any thing that cannot be shared in a repository !!

Tuesday, January 29, 2013

Getting Serial Number of HP-UX (works on RP5470 - HP11i PA-RISC)

HP-UX 11i is now pretty old but it is surprised that there are still a lot of companies using it. Though it is stable but hardware failure is something unpreventable. Once you found hardware fault, you probably need to call vendors (HP or others) to diagnostics.

A typical question will be "what is your server model? OS? Serial number?" Here is the quick answer:

OS Version: uname -a
Model: model (yes, simple?)
Serial Number: no single command to get it. but the information can be retrieved in cstm:
echo "sel path system\ninfolog\nexit"|cstm|grep "System Serial Number"

eg.
# uname -a
HP-UX zzzzzzzzz B.11.11 U 9000/800 106424635 unlimited-user license
# model
9000/800/L3000-8x
# echo "sel path system\ninfolog\nexit"|cstm|grep "System Serial Number"
   System Serial Number...: xxxxxxxxxx
 

Thursday, November 29, 2012

Remote access to your Raspberry Pi with ssl/ssh multiplexer

One big advantage of Raspberry Pi is its low power consumption. I can power on it 7x24 and remote it at anytime (of course, assumed your router is also on). SSH from internet to your Pi is simple, by just forwarding port 22 or making the Pi is the default DMZ. However, some places only allows you to visit port 80 or 443, or you have to connect to the internal via a proxy server, which also blocks every ports but 80/443.

Since port 443 is an exception, why don't we set the SSH service to listen to it? Just modify /etc/ssh/sshd_config and add a line "Port 80" or "Port 443". It does work, but wait, what about if the Pi also serves as a Web Server with SSL enabled? If you choose 443 to serve SSH, then you can't have your web server to use SSL at 443. So how to solve this situation? Here is one of the possible approach.

Monday, November 26, 2012

Create a Soalris 8 zone (32bit) to a container

Last time I had successfully created a flar image from an old Solaris 8 server (ref). Now I have to setup a zone of Solaris 10 container and install the image into it. The overall idea is clear and easy. Normally just create the zone configuration, and install it from a "flar" image.

1. Create zone configuration

root@sol10 # zonecfg -z z_sol8
z_sol8: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:z_sol8> create -t SUNWsolaris8
zonecfg:z_sol8> set zonepath=/pool/zone/sol8
zonecfg:z_sol8> set autoboot=false
zonecfg:z_sol8> set ip-type=shared
zonecfg:z_sol8> add net
zonecfg:z_sol8:net> set address=192.168.123.123
zonecfg:z_sol8:net> set physical=nxge0
zonecfg:z_sol8:net> end
zonecfg:z_sol8> verify
zonecfg:z_sol8> commit
zonecfg:z_sol8> exit


Next install the zone from the flar image:       

Thursday, November 22, 2012

Create a Wiki (Moinmoin) on Raspberry

Moinmoin is a very good Wiki application without using a DB. It is very fast, with easy syntax and I recommend to use it as a quick knowledge base for home or SME usage.

 This guide is to install moinmoin on a Raspberry Pi and make it accessible via Lighttpd (using fastcgi). It is assumed a virtual host is available for this wiki (eg. http://wiki.example.com )
The moinmoin program will be installed at /usr/local/moinmoin_engine while the instance will be installed at another place (eg. /usr/local/moinmoin_instance1. )
  1. Download the latest source (1.9.5 as of this moment) at http://moinmo.in
  2. extract the tar ball to a temp place (eg. /tmp)
  3. under the source path, run
    python setup.py install --prefix=/usr/local/moinmoin_engine
  4. mkdir the instance path
    mkdir /usr/local/moinmoin_instance1
  5. copy the following directories from "engine" to "instance", and change the ownership to the lighttpd user:
    cp -r /usr/local/moinmoin_engine/share/moin/data /usr/local/moinmoin_instance1
    cp -r /usr/local/moinmoin_engine/share/moin/underlay /usr/local/moinmoin_instance1
    cp /usr/local/moinmoin_engine/share/moin/config/wikiconfig.py /usr/local/moinmoin_instance1
    cp /usr/local/moinmoin_engine/share/moin/server/moin.fcgi /usr/local/moinmoin_instance1
    chown -R www-data:www-data /usr/local/moinmoin_instance1
  6. modify the moin.fcgi, locate the following lines:
    # a1) Path of the directory where the MoinMoin code package is located.
    #     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
    #sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
    sys.path.insert(0, '/usr/local/moinmoin_engine/lib/python2.7/site-packages')
    
    # a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
    #     See wiki/config/... for some sample config files.
    #sys.path.insert(0, '/path/to/wikiconfigdir')
    sys.path.insert(0, '/usr/local/moinmoin_instance1')
    
    ...
    
    ## this works around a bug in flup's CGI autodetection (as of flup 1.0.1):
    #os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI
    os.environ['FCGI_FORCE_CGI'] = 'N'
    
    ...
    
    # Is fixing the script name needed?
    # Use None if your url looks like http://domain/wiki/moin.fcgi
    # Use '' if you use rewriting to run at http://domain/
    # Use '/mywiki' if you use rewriting to run at http://domain/mywiki/
    #fix_script_name = None  # <-- adapt="adapt" as="as" class="anchor" here="here" id="line-24" needed="needed" span="span">
fix_script_name = ''# <-- adapt="adapt" as="as" here="here" needed="needed" pre="pre">
  • Next prepare virtual host by appending the following block /etc/lighttpd/lighttpd.conf:
    $HTTP["host"] =~ "wiki\.example\.com" {
            
      fastcgi.server += ( "/" =>
          ((
            "socket" => "/tmp/moin.socket",
            "min-procs" => 1,
            "max-procs" => 2,
            "check-local" => "disable",
            "bin-path" => "/usr/local/moinmoin_instance1/moin.fcgi",
            "fix-root-scriptname" => "enable"
          ))
      )
    
      alias.url += ( "/moin_static195" => "/usr/local/moinmoin_engine/lib/python2.7/site-packages/MoinMoin/web/static/htdocs")
    
    }
  • Restart Lighttpd and the your own wiki is just born! 

  • For more information about user and administration guide, please refer the HelpContents.

    PS: So here is the wiki running on my Raspberry Pi: http://wiki.jessed121.us/ . You can walk around and feel it.