5.29.2006

Curl notes and usage

cURL notes:

official web sites:

curl: http://curl.haxx.se

http://curl.siamu.ac.th/docs/httpscripting.html

openssl: http://www.openssl.org


Curl is an open source command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. Curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and a busload of other useful tricks. Openssl handles the encryption part of the transfer.


Curl usage:

TO use config file ( _culrc ) the next line must be set in the batch file or scripting environment.

set home=c:\directory_pathto_config_file


Since curl will only work with PEM formatted certificates, we need to convert the PKCS12 format certificate:


openssl pkcs12 -in [original certificate file] -clcerts -out [PEMfile]


I believe some web sites use cookies for the session timeout (I believe a 5-10 minute timeout period). For that reason when initially communicating with the server we MUST run 2 passes of curl, 1 to authenticate and 1 to do the transfer or whatever other command we want to issue.


Using config file:

list directory:

curl https://this.secretwebsite.com/* -- will list everything recursively; lists just file/path names

curl https://this.secretwebsite.com -- is like doing an ls -l


download:

curl -O https://this.secretwebsite.com/outbound/SFT_Win32_4.0.39_Guide.doc


upload:

curl -T mylocalfile.txt https://this.secretwebsite.com/


files we get back: mylocalfile.txt_201706.NO_ADD_REC

that's HHMMSS (maybe pacific timezone)


Deleting files:

curl -X DELETE https://this.secretwebsite.com/mylocalfile.txt_201706.NO_ADD_REC


from manual-

-X/--request <command>

(HTTP) Specifies a custom request to use when com­

municating with the HTTP server. The specified

request will be used instead of the standard GET.

Read the HTTP 1.1 specification for details and

explanations


_culrc (config file) contents:

#cookie send file (-b)

cookie C:\sys\temp\curl\cookie.jar


#cookie receive file (-c)

cookie-jar C:\sys\temp\curl\cookie.jar


#redirect to different location (-L)

location


#certificate file and pw for authenication (-E)

cert e:\curl\mysecrets.pem:the_password_goes_here


#display progress bar (-#) instead of default statistics

progress-bar


#Write output to a local file named like the remote file we get.

#(Only the file part of the remote file is used, the path is cut off.)

#remote-name


HP-UX btmp-utmp accounting

/home/maint/bin/acctcleanup.sh ;; runs only via cron on the first day of every month at midnight. It moves all entries in btmp and wtmp to /home/maint/logs/acct with a file name format of: wtmp-monthYEAR or btmp-monthYEAR


see utmp(4)


/var/adm/btmp Bad login database

/var/adm/wtmp Login database

/etc/utmp


utmp = record of all users logged onto the system.

btmp = bad login entries for each invalid logon attempt

wtmp = record of all logins and logouts.



acctcleanup.sh::::
#!/usr/bin/sh
# cleans up accounting files: /var/adm/wtmp and /var/adm/btmp  Should be run via
# cron at 0:00 the first of every month.
#wtmp contains a record of all logins and logouts
#btmp contains bad login entries for each invalid logon attempt

#if not running under cron then exit
if ! /home/maint/bin/rptree.sh $$ | grep cron >/dev/null; then
 banner executes "only under" cron
 exit
fi

w=/var/adm/wtmp
b=/var/adm/btmp
fwtmp=/usr/sbin/acct/fwtmp
wtmpfix=/usr/sbin/acct/wtmpfix
log=/home/maint/logs/acct

#Since we are in a new month, get last month's name
case `date +%B` in
January) month=December;;
February) month=January;;
March) month=February;;
April) month=March;;
May) month=April;;
June) month=May;;
July) month=June;;
August) month=July;;
September) month=August;;
October) month=September;;
November) month=October;;
December) month=November;;
esac

wdate=$log/wtmp-$month`date +%Y.log`
bdate=$log/btmp-$month`date +%Y.log`

$fwtmp < $w > $wdate
cat /dev/null > $w

$fwtmp < $b > $bdate
cat /dev/null > $b


fbackup/frecover tips

Diagnostics: HP Library and Tape Tools (L&TT or LTT)

in: /opt/ltt and the main program: /opt/ltt/hp_ltt


most of our maintenance scripts are contained in:

/home/maint/bin


Our main backup script and associated files are in:

/home/maint/bin/fbackup main script: /home/maint/bin/fbackup/bin/fullback.sh


An email reminder to swap the tape is sent when the backup job is complete. Tapes must be swapped every M-F.



Notes on using fbackup:


fbackup -v -f /dev/rmt/1m -f /dev/rmt/2m -I /indexfile.txt -g graphfile -i include_path -i include_another -c configFile


fbackup graph files do not support wildcards....


graph file contents:

i /include_me

e /exclude_me


If media is write protected you'll see something similar to the following:

fbackup(3032): could not open output file /dev/rmt/2m


default fbackup config used by sam: /etc/sam/br/fbackup_config

fbackup stores incremental backup information in /var/adm/fbackupfiles/dates

fbackup -u option updates the 'dates' files: /var/adm/fbackupfiles/dates


fbackup config file : current config file used in production: /home/maint/fbackup/cfg/best

current config file

description of each line

blocksperrecord 256

+ Number of 1024-byte blocks per record.

records 32

+ Number of records of shared memory to allocate.

checkpointfreq 1024

+ Number of records between checkpoints. Since the EOF marks between checkpoints are also used for fast searching on DLT tape drives, changing the checkpoint frequency may also affect selective recovery speed (see WARNINGS section).

readerprocesses 6

+ Number of file-reader processes.

maxretries 5

+ Maximum number of times fbackup is to retry an active file.

retrylimit 5000000

+ Maximum number of bytes of media to use while retrying the backup of an active file.

maxvoluses 2000

+ Maximum number of times a magnetic tape volume can be used.

filesperfsm 2000

+ The number of files between the fast search marks on DDS tapes. The cost of these marks are negligible in terms of space on the DDS tape. Not all DDS tape devices support fast search marks.

chgvol /home/maint/fbackup/bin/chgvol

+ Name of a file to be executed when a volume change occurs. This file must exist and be executable.

error /home/maint/fbackup/bin/error

+ Name of a file to be executed when a fatal error occurs. This file must exist and be executable.



Clearing fbackup header:

If you wish to clear the fbackup volume header from an fbackup tape because you want to blank out the number of times the tape has been used, use another backup utility on the tape. For example:

tar -cvf /dev/rmt/1m file_to_backup


frecover - recovering files from fbackup tape:

recovering files may take quite a long time, escpecially if they are small files. To restore a small home directory containing less than 18mb took over 10minutes, compared to restoring an 8.5GB file which took only 17 minutes.

Unlike fbackup, single files and wildcarded files(sometimes) may be specified and recovered using frecover. In either fbackup or frecover, the hyphen ( - ) can be used almost anywhere to write/read to/from stdout (standard output). This can be used to pipe commands together as well.


to export the contents (the index) of an fbackup tape:

frecover -f /dev/rmt/1m -I /path/index_file

to write contents to stdout: frecover -f /dev/rmt/1m -I -

to view the volume header ( contains fbackup specific info ):

frecover -f /dev/rmt/1m -V /path/volume_file


test recover (N option): preform the same options, but don't recover the files to disk:

frecover -xvN -f /dev/rmt/1m


recover everything (should only be done in the event of a total system failure):

frecover -v -r -f /dev/rmt/1m

or

frecover -v -x -f /path_to_fbackup_file


recover all files on tape to the current directory without creating directory structure

frecover -v -x -f /dev/rmt/1m -F


recover all the files in the -i included path to the current directory without creating directory structure

frecover -v -x -f /dev/rmt/1m -F -i /home/maint/fbackup/cfg


recover entire tape contents to current working directory:

frecover -v -x -f /dev/rmt/1m -X


recover graph contents to current working directory:

frecover -v -x -f /dev/rmt/1m -X -g mygraphfile


recover /home/maint/fbackup to current working directory:

frecover -v -x -f /dev/rmt/1m -X -i /home/maint/fbackup/


recover back to orginal file location. File on disk will not be over-written if it's newer than the file from the tape. Use the -o option CAUTIOUSLY to bypass this limitation.

frecover -vxf /dev/rmt/1m -i /home/maint/bin/showuser.sh


frecover option:

-m Print a message each time a file marker is encountered.

Using this option, frecover prints a message each time

either a DDS fast search mark, a filemark (EOF), or a

checkpoint record is read. Although useful primarily for

troubleshooting, these messages can also be used to

reassure the user that the backup is progressing during

long, and otherwise silent, periods during the recovery.



UNKNOWN TAPE FORMAT - extraction:

if tape is of unknown format you can extract the contents using pax:

cd to_path_where_extracted_files_should_be_placed

pax -rv -s'/^\///' </dev/rmt/0m




tar - tape archiver:

WARNING: Use -tV to list all the files on the tape before extracting, because tar will not prompt to overwrite and will restore to the fully qualified pathname that is stored in the archive. So when creating a tar archive, please remember to use relative path names and not absolute ones. If no file argument is given, the entire content of the archive is extracted. Note that if several files with the same name are on the archive, the last one overwrites all earlier ones. Wildcards don't work.

tar -cvf /dev/rmt/1m path_to_archive -create a new archive

tar -cvf /dev/rmt/1m -C /home/maint . -create new archive, first change to /home/maint and backup that directory using the relative path (.) Multiple -C options can be used

tar -tVf /dev/rmt/1m -list all files on tape

tar -xvf /dev/rmt/1m - extract all files from tape

tar -xvwf /dev/rmt/1m - extract all files from tape prompting the user to restore each file

tar -xvf /dev/rmt/1m ./index_file - extract the file named index_file into the current directory.


MAKE_TAPE_RECOVERY:

make_tape_recovery: makes a bootable recovery tape

copy_boot_tape: make a copy of a recovery tape


/makerecovery.sh is the custom make_tape_recovery script that creates a recovery tape.


Ejecting a tape:

mt -f /dev/rmt/1mnb offline


Obtaining tape drive status:

mt -f /dev/rmt/2mnb status --show if tape is write protected


st -f /dev/rmt/0mnb -s --limited to displaying if device is OK and ready



Changing foreground / background colors in WRQ Reflection from connected host programmatically

Changing foreground / background colors in WRQ Reflection from connected host programmatically.


Sample perl source: also see /usr/local/bin/*.pl

#!/usr/bin/perl -w

# /usr/local/bin/prodcolors.pl

# Changes colors of foreground/background to: black/white respectively


use warnings;

use strict;


my $code="\e&o2GSub Main

With Application

.SetColorMap rcPlainAttribute, rcBlack, rcWhite

End With

End Sub\e&oH";


print "$code";



<ESC>&o2G Sub Main

Dim c As Integer

c = Val(InputBox$("Enter the sales amount:"))

MsgBox "Your commission is: " & c

End Sub<ESC>&oH



Reflection Basic:

Syntax: object.SetColorMap Attribute, Foreground, Background


.SetColorMap rcInverseAttribute+rcBlinkAttribute, rcGrey, rcBlue

or

.SetColorMap rcPlainAttribute, rcGrey, rcBlue


Attributes:

rcPlainAttribute

rcBlinkAttribute

rcInverseAttribute

rcUnderlineAttribute

rcBoldAttribute (for UNIX and Digital hosts)

rcHalfbrightAttribute (for HP hosts)

rcFunctionKeys (for HP hosts)

rcHotspotAttribute

rcCursorAttribute


Colors:

rcWhite

rcGrey

rcRed

rcBlue

rcGreen

rcYellow

rcCyan

rcMagenta

rcBlack

rcDkGrey

rcDkRed

rcDkBlue

rcDkGreen

rcDkYellow

rcDkCyan

rcDkMagenta

To open/add Reflection Basic macros menu:

Under the Setup menu, click Menu. Then add the Script menu from the "Additional Items/Items from version 6.x" tree to the current menu.


Reflection tech references:

How to Send Reflection Commands from the Host

http://support.wrq.com/techdocs/1223.html


Index of Reflection Scripting Technical Notes

http://support.wrq.com/techdocs/9993.html


Other very good references are the manuals/help files in:

C:\Program Files\Reflection\Manuals and C:\Program Files\Reflection\Help\Enu

rbrwin.hlp - Reflection Basic (scripting) Help


HP-UX CIFS (samba server) implementation

CIFS implementation on HPUX box:


Custom made mount at startup files:

/sbin/init.d/mntcifs

/etc/rc.config.d/mntcifs

/sbin/rc2.d/S910mntcifs

/sbin/rc1.d/K105mntcifs



CIFS Client configuration file:

/etc/opt/cifsclient/cifsclient.cfg


log files:

/var/opt/cifsclient/debug


test kerberos ticket:

/opt/cifsclient/bin/cifsgettkt -s windowsbox1



To mount:

$ mount -F cifs buildsys:/source /home/devl/source

To unmount:

$ umount /home/devl/source



mount -F cifs "windowsbox1:/php share" /cifs_mounts/windowsshare

umount /cifs_mounts/windowsshare



cifslogin windowsbox1 myusername

cifslogout windowsbox1


cifslist -A lists servers with shares and mountpoints

cifslist -U lists users in database

cifslist -M lists mounts in database

cifslist -S lists connected servers

cifslist -s <server> lists shares open at server

cifslist -u <server> lists users logged in at server

cifslist -m <share> lists mountpoints for share


5.28.2006

clone and Oracle 9i DB

Clone an Oracle 9i database:

In source DB:

  • ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/b1/mytracefile.trc';

  • shutdown immediate


  • Copy data files and redo logs to clone location. aka:

    • for id in 01 02 03 04 05 06 07 08 09 10 11 12

    • do

    • mkdir -p /u${id}/mydb1 ; chown -R oracle:oinstall /u${id}/mydb1 ; cp -p -r /u${id}/prevea2/* /u${id}/mydb1

    • done

  • Copy source db's init{SID}.ora file to init{newSID}.ora ( usually in $ORACLE_HOME/dbs )


In trace file created earlier:

  • Remove second half of file (starts at the section: "Set #2. RESETLOGS case")

  • Remove all comment lines (they begin with #)

  • Remove blank space between -- STANDBY LOGFILE and DATAFILE

  • At top insert: connect / as sysdba

  • Change line: startup nomount to: startup nomount pfile={location of new cloned init file}

  • Change ALL file references from source db location to new clone location.


In the init{newSID}.ora:

  • Change ALL file references from source db location to new clone location.


  • export ORACLE_SID={newSID}

  • Create a new password file: orapwd file=$ORACLE_HOME/dbs/orapw{SID} password=sys entries=1

  • sqlplus /nolog

    • sql> @/b1/mytracefile.trc

    • You'll see 2 message, these are OK to ignore:

      • ORA-00283: recovery session canceled due to errors

      • ORA-00264: no recovery required

    • Test the database: select count(1) from v$database;

    • alter database backup controlfile to trace as '/b1/newtracefile.trc';

    • shutdown immediate


  • Delete all control files in the clone location: *.ctl example:

    • confirm with - find /u[0-9][0-9]/{clonelocation} -name "*.ctl"

    • then delete - find /u[0-9][0-9]/{clonelocation} -name "*.ctl" -exec rm {} \;


In the newly created trace file:

  • Remove second half of file (starts at the section: "Set #2. RESETLOGS case")

  • Remove all comment lines (they begin with #)

  • Remove blank space between -- STANDBY LOGFILE and DATAFILE

  • At top insert: connect / as sysdba

  • Change line: startup nomount to: startup nomount pfile={location of new cloned init file}

  • Change line: create controlfile to: create controlfile set database "{newDBname}" resetlogs noarchivelog

  • Change line: alter datbase open; to: alter database open resetlogs;


In the init{newSID}.ora :

  • change the db_name, instance_name, service_names, dispatchers parameter to the new DB name.

  • sqlplus /nolog

    • sql> @/b1/newtracefile.trc

  • confirm updated dbname: select * from v$database;



for name in arch audit bdump cdump create pfile udump

do

mkdir -p /u02/srcdb1/${name}

done


for id in 01 02 03 04 05 06 07 08 09 10 11 12

do

mkdir -p /u${id}/srcdb1 ; chown -R oracle:dba /u${id} ; chmod -R 775 /u${id}

done

HP-UX EMS config / tips

HPUX config and tips:

The Event Monitoring Services are a part of the Online Diagnostics. This part is also called HW-Monitoring. The HW-Monitors watch for the Hardware and report via different notification channels to the user or sysadmin.


The Hardware monitors are divided into Event and Status monitoring.

Run the Hardware Monitoring Request Manager by typing:

/etc/opt/resmon/lbin/monconfig

This tool is stored in /etc/opt/resmon/lbin and has only a character interface. After installation of Event monitoring there are some monitors already configured.


The GUI to configure Hardware Monitor request is used with SAM. When SAM is started there is a entry Resource Management. This entry shows a new submenu with an entry like Event Monitoring Service. This will start the GUI interface.

1 custom hardware Event monitoring request: All events (hardware problems) from all monitors will be sent to the pager group (see /etc/mail/aliases) this is done via monconfig. The Status monitoring requests are configured via SAM (Resource Management/Event Monitoring Service) or via the following command: /opt/resmon/bin/emsui /opt/resmon/bin/EMSconfig.ui The only things that can be monitored via this GUI are: filesystem space available status events and number of jobs in job queues JobQueues status events. We are: monitoring number of jobs in job queues and available MB on filesystems if below 70MB.



• Files Installed - EMS Bundles:

EMS-Config.EMS-GUI, EMS-Core.EMS_CORE

/opt/resmon/..

/etc/opt/resmon/..

/var/opt/resmon/..

• Startup scripts:

Starts EMS persistence client: /sbin/init.d/ems

based on config file: /etc/rc.config.d/ems

Starts the EMS SNMP subagent: /sbin/init.d/emsa

based on config file: /etc/rc.config.d/emsagtconf

• EMS Daemons started:

At system boot:

Persistence Client: /etc/opt/resmon/lbin/p_client

EMS SNMP subagent: /etc/opt/resmon/lbin/emsagent

At configuration time upon client connect:

Registrar: /etc/opt/resmon/lbin/registrar


p_client (persistence client) is started by init (1M), and respawned by init if it dies.

p_client checks for dead monitors and restarts them (and any outstanding monitoring requests). Default interval is every 2 minutes (interval set in /etc/opt/resmon/config)

p_client runs at system startup to restart monitors and any outstanding monitoring requests

For EMS configuration problems, refer to:

/etc/opt/resmon/log/client.log

For EMS monitor problems, refer to:

/etc/opt/resmon/log/api.log

For EMS framework problems, refer to:

/etc/opt/resmon/log/registrar.log



These three files are the most interesting files from EMS. But there is also the default log file/var/opt/resmon/event.log. This file will be used for HW Monitoring and default

Notification if Text file is used.

The three logfiles will grow and when they reached about 500kB then they are automatically

moved to <logfile>.old. If the logfile is increased to 500kB it will be moved again.




fbackup optimal config file

For HP-UX, fbackup is very slow on new drives like a DLT4 drive.  So use a config file with the following settings to get the fastest backup results.  See the HPUX man page for fbackup:
http://docs.hp.com/en/B2355-60127/fbackup.1M.html

Here are my recommendations:
blocksperrecord 256
records 32
checkpointfreq 1024
readerprocesses 6
maxretries 5
retrylimit 5000000
maxvoluses 200
filesperfsm 2000

blocksperrecord, checkpointfreq, and filesperfsm are the key vlaues to be concerned with.

restricting ftp access on HPUX

HP-UX:  how to restrict access to ftp

See man pages for: ftphosts and ftpaccess

/etc/ftpd/ftphosts contains the username and possibly the hostnames that are allowed to connect via ftp on our HP box.


default config files on HP-UX

Looking for default (factory delivered) copies of configuration files in HPUX:

/usr/newconfig .... subdirs underneath


kerberos integration with Active Directory(2000) on HP-UX

This is what I did to setup our HP UX11i box with Kerberos integration with AD


  1. create a service type user account in AD. In the case below the username is: kermit

  2. Run the ktpass command on a domain controller using the syntax below.

  3. Copy the krb5.keytab file to the HPUX box under /etc/krb5.keytab

  4. Edit the /etc/krb5.conf file, pointing to the correct domain and domain controller.



ktpass utility is included in the Windows 2000 support tools.


On domain controller:

E:\>ktpass -princ host/amisys@MYDOMAIN.COM -mapuser kermit -pass ***** -out krb5.keytab

Successfully mapped host/mybox to kermit.

Key created.

Output keytab to krb5.keytab:


Keytab version: 0x502

keysize 49 host/mybox@MYDOMAIN.COM ptype 1 (KRB5_NT_PRINCIPAL) vno 1 etype 0x1 (D

ES-CBC-CRC) keylength 8 (0x10ade54f832551ba)

Account has been set for DES-only encryption.


copied krb5.keytab to /etc/krb5.keytab and set owner: root:sys and permissions: 600


copied pam.krb5 to /etc/pam.conf


Setup Kerberos config file:

[libdefaults]

default_realm = MYDOMAIN.COM

default_tgs_enctypes = DES-CBC-CRC

default_tkt_enctypes = DES-CBC-CRC

ccache_type = 2


[realms]

MYDOMAIN.COM = {

kdc = camelot.MYDOMAIN.COM:88

kpasswd_server = camelot.MYDOMAIN.COM:464

}


[domain_realm]

.mydomain.com = MYDOMAIN.COM


[logging]

kdc = FILE:/var/log/krb5kdc.log

admin_server = FILE:/var/log/kadmin.log

default = FILE:/var/log/krb5lib.log


chmod 644 /etc/krb5.conf

Virtual Array 7100 / 7400 command view stuff

Managing SAN disk array subsystem:


NOTE: must run the following variable set in your telnet session in order to display X apps on your PC: export DISPLAY=myhostname:0 where 'myhostname' is your PC's name. You also must have the X client manager running on your PC.

Command View SDM (Storage Device Management) – software used to manage the array


VAnum1 – the 'alias' name of the Virtual Array disk system


directory of binaries: /opt/sanmgr/commandview/client/sbin


launcher – X client for managing the disk and creating LUNs. On LUN Management tab, Logical LUNs, you can create LUNs.

define LUN: This term is an acronym for Logical Unit. It is used as the primary means for dividing the entire capacity of the array into smaller, individually addressable, units. When created, contains no data. Read operations directed to this logical drive will return the format pattern until writes have been performed on the same locations.


cvui – command line menu based interface for managing the array. It's nice in the fact that it displays the command being run when you select a menu item. You can also log the commands and their results to a file if you wish.


cmdviewVA VAnum1 – Same as launcher, but skips first dialog listing the VA selection screen.


Then run sam, go under "Disks and File Systems/Disk Devices" to configure the volume group, logical volume(s), file system, etc.



listing free and used space on disks:

list kbytes of disk usage; use without 's' option to display all the files

du -sk /directory/path


pretty listing of total space allocated, used and free.

df -k /filesystem_mount

df -k /u* -- shows all /u00-u12 files system stats

oracle tips

Startup scripts:

/sbin/init.d/oracle

/sbin/init.d/sqlnet

/sbin/init.d/agentctl*

/sbin/init.d/oemctl*

(other similiary named files are in: /etc/rc.config.d)


Connecting to database with sysdba privledges from sqlplus command:

sqlplus "/ as sysdba"


Check if database started with a pfile or spfile:

in sqlplus:

SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type"

FROM sys.v_$parameter WHERE name = 'spfile';


Check if database is in archive log mode:

in sqlplus do: archive log list


Converting from pfile to spfile or vice-verse:

CREATE PFILE FROM SPFILE;

CREATE SPFILE FROM PFILE;


Creating password file:

orapwd file=$ORACLE_HOME/dbs/orapw{SID} password=sys entries=1


Archive tips: http://www.cryer.co.uk/brian/oracle/SYMoixcal.htm


Archive log:

Must be in init{SID}.ora or spfile for archive log mode to be useful: LOG_ARCHIVE_START = true

alter system archive log start

alter system archive log stop

alter system switch logfile

select log_mode from v$database;

ALTER DATABASE ARCHIVELOG;

ALTER DATABASE NOARCHIVELOG;


Alert logs stored in: /u02/${ORACLE_SID{/bdump/alert_${ORACLE_SID}.log


Get some info on memory:

sqlplus> select * from V$SGASTAT;


Oracle management server startup:

NOTE: if changing username/password for the OEM database, YOU MUST edit oracle's .profile to reflect this change.


first start repository database:

export ORACLE_SID=OEMREP

sqlplus /nolog

connect / as sysdba

startup

exit


Then start the OMS server:


oemctl start oms

oemctl ping oms - shows status without having to issue username/password

oemctl stop oms sysman/{sysman's_password}


'oemctl start oms' output should be similar to:


mybox Oracle preprod1> oemctl start oms

OEMCTL for HP-UX: Version 9.2.0.1.0 Production

Copyright (c) 1998, 2002, Oracle Corporation. All rights reserved.

Starting the Oracle Management Server....


The OMS is now started and ready.




How does one start the Oracle Intelligent Agent?

One needs to start an OIA (Oracle Intelligent Agent) process on all machines that will to be managed via OEM. The agent needs to be stopped/started when a new database is created on that node. Databases that are removed will have to be deleted manually from the OEM console.

For OEM 9i and above:


agentctl start agent

agentctl stop agent

agentctl restart -- This doesn't seem to work.....


$ agentctl


Usage:

agentctl start|stop|status|restart [agent]

agentctl start|stop|status blackout [<target>]

[-d/uration <timefmt>] [-s/ubsystem <subsystems>]


The following are valid options for blackouts

<target> name of the target. Defaults to node target.

<timefmt> is specified as [days] hh:mm

<subsystem> is specified as [jobs events collections]

defaults to all subsystems



Creating a database

dbca - database configuration assistant X-gui app.

or

  1. Create an init file and proper directory structures for values in init file. Make sure remote_login_password=NONE

  2. Change /etc/tnsnames.ora and /etc/listener.ora to contain new database values. Reload the listener: lsnrctl, the reload.

  3. set ORACLE_HOME and ORACLE_SID to proper values for new database.

  4. run sqlplus and the following (/home/oracle/createdb.sql:

    • create database soup

    • logfile group 1 ('/ora/soup/redo01.log') SIZE 100M,

    • group 2 ('/ora/soup/redo02.log') SIZE 100M,

    • group 3 ('/ora/soup/redo03.log') size 100M

    • datafile '/ora/soup/system.dbf' SIZE 575M

    • character set WE8ISO8859P1

    • national character set utf8

    • extent management local

    • undo tablespace UNDOTBS1

    • datafile '/ora/soup/undotbs01.dbf'

    • SIZE 2000M

    • default temporary tablespace temp

    • tempfile '/ora/soup/temp01.dbf'

    • size 4000M autoextend on next 50M maxsize 7000M;


Starting EM (enterprise manager) from unix (x-gui):

oemapp console


OMS navigator needs to have databases deleted from it when the database is phyisically deleted. Refreshing the node won't remove the database from the navigator. In fact, it's best to delete the node from the navigator and re-add it again.


Stop Apache web server:

$ORACLE_HOME/Apache/Apache/bin/apachectl stop



What oracle version am I running?:

SQL> select * from v$version;


BANNER

----------------------------------------------------------------

Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production

PL/SQL Release 9.2.0.1.0 - Production

CORE 9.2.0.1.0 Production

TNS for HPUX: Version 9.2.0.1.0 - Production

NLSRTL Version 9.2.0.1.0 - Production



Removing Oracle from a test server (sun box):

rm -r $ORACLE_HOME

rm -r /var/opt/oracle


Dropping a tempfile.

> sqlplus /nolog

sql> connect as sysdba


sql> alter database tempfile '/u08/mydb1/tempdave.dbf' drop;

-database altered


exit


drop tablespace logmnrts including contents;



CREATE

TEMPORARY TABLESPACE "TEMPNEW" TEMPFILE '/u09/mydb1/

TEMPNEW1.dbf' SIZE 5000M AUTOEXTEND

ON NEXT 640K MAXSIZE 7600M EXTENT MANAGEMENT LOCAL UNIFORM

SIZE 1024K;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE "TEMPNEW"


THEN


CREATE

TEMPORARY TABLESPACE "TEMP" TEMPFILE '/u07/mydb1/

TEMP01.dbf' SIZE 2500M REUSE AUTOEXTEND

ON NEXT 640K MAXSIZE 7600M EXTENT MANAGEMENT LOCAL UNIFORM

SIZE 1024K;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE "TEMP"


RMAN topics:

Recovery Manager User's Guide = a96566.pdf

Quick Start to Recovery Manager: page 75

Duplicating a Database with Recovery Manager: page 365

Recovery Manager Quick Reference = A96564.pdf

Recovery Manager Reference = A96565.pdf


Duplicating DB / random RMAN thoughts:

get a good RMAN backup of Production (takes about 10 MINUTES):

. rman target /

r shutdown immediate;

r startup mount;

r backup database;

r alter database open;

r quit



Then duplicate this backup to the auxiliary instance:

Target database must be open; auxiliary database must be started, in nomount mode.

When RMAN duplicate is finished the auxiliary database is opened.

Duplicate takes about 15 minutes.


Before running duplicate command, get the tempdata file name:

$ find /u??/mydb1/ -name "temp*"


. sqlplus "sys/null@mydb1 as sysdba"

s shutdown normal;

s startup nomount;

s quit

. rman target / auxiliary sys/null@mydb1

r duplicate target database to mydb1;

r quit


Re-add any datafiles that belong to the temp tablespace, and finish up other tasks:

. sqlplus "sys/null@mydb1 as sysdba"

s ALTER TABLESPACE TEMP

s ADD TEMPFILE '/ora/soup/temp01.dbf' SIZE 4000M REUSE;



in the auxilary init{sid}.ora and it's spfile:

DB_FILE_NAME_CONVERT=('/u00/proddb1/','/u00/mydb1/',

'/u01/proddb1/','/u01/mydb1/',

'/u03/proddb1/system01.dbf','/u05/mydb1/system01.dbf',

'/u09/proddb1/undotbs01.dbf','/u07/mydb1/undotbs01.dbf',

'/u07/proddb1/myapp_data01.dbf','/u05/mydb1/myapp_data01.dbf',

'/u08/proddb1/indx01.dbf','/u06/mydb1/indx01.dbf',

'/u03/proddb1/myapp_data02.dbf','/u02/mydb1/myapp_data02.dbf',

'/u09/proddb1/indx02.dbf','/u10/mydb1/indx02.dbf',

'/u12/proddb1/core_repository.dbf','/u12/mydb1/core_repository.dbf',

'/u06/proddb1/myapp_data02.dbf','/u05/mydb1/myapp_data02.dbf',

'/u12/proddb1/myapp_data02.dbf','/u11/mydb1/myapp_data02.dbf')

LOG_FILE_NAME_CONVERT=('/u00/proddb1/','/u00/mydb1/',

'/u01/proddb1/','/u01/mydb1/',

'/u02/proddb1/','/u02/mydb1/',

'/u03/proddb1/','/u03/mydb1/',

'/u04/proddb1/','/u04/mydb1/',

'/u05/proddb1/','/u05/mydb1/',

'/u06/proddb1/','/u06/mydb1/',

'/u07/proddb1/','/u07/mydb1/',

'/u08/proddb1/','/u08/mydb1/',

'/u09/proddb1/','/u09/mydb1/',

'/u10/proddb1/','/u10/mydb1/',

'/u11/proddb1/','/u11/mydb1/',

'/u12/proddb1/','/u12/mydb1/')



CREATE SPFILE FROM PFILE='/u01/app/oracle/admin/DUP/pfile/init.ora';


recreate tempfile in temp tablespace.

delete tempfile in OS first.


/u02/mydb1/temp01.dbf


ALTER TABLESPACE "TEMP"

ADD TEMPFILE '/u02/mydb1/temp01.dbf' SIZE 4000M REUSE;


HP-UX performance utils

MeasureWare (aka HP OpenView Performance Agent (OVPA)) – MWA (agent)

(NOTE The name MeasureWare Agent (MWA) has been replaced with HP

OpenView Performance Agent (OV Performance Agent or OVPA) for

UNIX and the name PerfView for UNIX has been replaced with OV

Performance Manager for UNIX throughout this documentation.

However, the process names and software components operationally

remain MeasureWare Agent (MWA) and PerfView.)


/opt/perf/examples/ - example config files

/opt/perf/bin/perfstat – checks status of agent processes

/var/opt/perf/datafiles – raw binary data files kept here

/var/opt/perf - config files kept here

alarmdef – alarm definition config file

parm - overall parameters config file


/opt/perf/bin/utility – outputs data from logfiles to stdout or files

/opt/perf/bin/extract – makes copies of raw binary data files for archival purposes or exports data from log files to standard format (csv, etc.)


mwa stop servers - stop mwa servers: alarm server, scopeux, etc. -- needed if you see a defunct process continually coming up: possible alarmdef file setting screwed up or corrupt.


Usage = mwa <action> <subsys> <parms>

<action> = status, start, stop, restart, demo, version

<subsys> = scope, server, alarm, db, desktop, all

<parms> = -midaemon <miparms>

See man midaemon for <miparms>

<action> and <subsys> may be entered in any order,

but if <parms> is supplied, then it must be entered last

Defaults: <action>=start, <subsys>=all, <parms>=""

note: mwa stop alarm is not valid.

mwa stop server will stop alarms and servers.



ARM (Applicaton Response Measurement): tracking application response as a whole as apposed to opposed to monitoring individual process.

GlancePlus – glance or (x) gpm

top – display top processes

uptime - system load, users and time since last boot

PRM – Process Resource Management: assigns levels of CPU/MEM/DISK/Application resources to particular users or processes. Sounds kind-of cool

printing tips for HP-UX

Add/remove printers by using SAM.

Optionally you may add jetdirect connected printers via: /opt/hpnpl/admin/hppi


Directories:

/var/spool/lp/request/{printername} = spool area for print jobs


disable printername = disable lp subsystem from sending data to the printer

enable printername = enable lp subsystem to send data to the printer

(the above commands are like using the "pause printing" function in windows)


Start/stop users from sending print jobs to the queue.

accept printername = allow the lp spooler to accept requests for the printer

reject printername = do NOT allow the lp spooler to accept requests for the printer

(the above commands are similar to turning on/off sharing on a printer in windows)


lpstat –t = display all printers status and output jobs (full report)

lpstat -pprintername = displays the specified printer's status

lpstat -s = print summary status for all printers

lpstat -o = list all output jobs on all printers

lpstat -oprintername = list all output jobs on the specified printers

lpstat -d Lists the system default printer

lpstat (no options) Lists the user's outstanding printer requests


man net_ljx000 = displays man page for net_ljx000 model script which display options the printer can accept.


lp –d printername filename = prints filename to the printer named: printername


lp –d printername –o options filename = prints filename to the printer named: printername using the printer specific options (such as landscape, nb, etc.)


list of common –o options:

c = compressed text

letter = 8.5 X 11

legal = 8.5 X 14

fp# = font pitch; Set the font pitch to <#> characters per inch.

lpi<#> = Print specified lines per inch, where <#> is 1, 2, 3, 4, 5, 6, 12, 16, 24, or 48.

duplex = prints on both sides of page

landscape = landscape orientation

portrait = portrait orientation (standard, default)


To cancel jobs

Either hit the cancel button on the laserjet or use the cancel command:

commonly used:

cancel printer12-123 - Cancels the printer12-123 job request

cancel printer12 - Cancels the currently serviced job on printer: printer12

cancel -e printer12 - Cancels all jobs (all users) on printer: printer12

cancel -udavid printer12 -Cancels all jobs submitted by user: david on printer: printer12



cancel Man page:

cancel Command

The cancel command cancels requests that were made with the lp

command, even if they are currently printing. At least one id or

printer must be specified.

The cancellation of a request that is currently printing frees the

printer to print its next available request.

id ... Specifies one or more requests. id is a request ID

returned by lp or lpalt.


printer ... Specifies one or more printers. printer is the name of

a printer, not a class. Either cancel the request that

is currently printing on each printer, or, if an -a, -

e, or -u option is specified, specify the printer on

which to perform the corresponding operation.


-a Remove all requests the user owns on each printer. The

owner is determined by the user's login name and the

host name of the machine where the lp command was

invoked.


-e Empty the spool queue of all requests for each printer.

Only users with appropriate privileges can use this

option.


-i Cancel only local requests.


-uuser Remove any requests belonging to user. You can repeat

the -u option to specify more users. Only users with

appropriate privileges can use this option.



Sometimes users will receive the following:

From: lp@mybox.mydomain.com

To: david@mybox.mydomain.com


error code 2 in request printer12-555 on printer printer12



They receive the message because of either hitting cancel on the printer's control panel (most likely), or there's a problem with the Jetdirect timing.




reset or query the GSP on HP systems

Reset the GSP - basically reboots the GSP, it DOES NOT reboot the server itself.  Use this when you receive the message:  "Request for console write access failed":

stty +resetGSP < /dev/GSPdiag1

See if the GSP is functional:
stty +queryGSP < /dev/GSPdiag1

resources:
http://docs.hp.com/en/B3920-90091/ch03s07.html

vim tips - folding / mutiple windows (viewports)

multiple windows / "viewports" - http://www.linux.com/article.pl?sid=06/05/04/1544258
folding (collapsing) lines/sections - http://www.linux.com/article.pl?sid=06/05/18/1915233

5.27.2006

netsh error - winsock corrupt

If you get this error when opening netsh:
Initialization Function InitHelperDll in IPMONTR.DLL failed to start with error code 11003

and it pauses for a long time before bringing up the netsh> prompt, then most likely the Winsock2 is corrupt, to recover delete the Winsock and Winsock2 subtrees from CurrentControlSet\Services and reboot, then reinstall TCPIP:  http://support.microsoft.com/kb/811259

5.23.2006

sum / total column adding in HPUX yields floating point notation

awk on HP-UX seems to use exponent notation instead of floating point notation like I'm used to in Tru64.  For example adding up (summing) a column in HPUX with large numbers yields an exponent number, not very useful to me.  To fix this behavior, use the OMFT variable in awk.  See the man page for awk for more info.

example:
ll /tmp| awk -v OFMT="%.f" 'sum += $5 {print sum}'

5.22.2006

convert LF to CRLF

Use the following to convert Unix to dos text files in cygwin on windows:
awk '{ print $0 "\r"}' unix.txt > dos.txt

source: http://www.datasavantconsulting.com/roland/tr.html

\r - carriage return
\n - line feed

5.18.2006

passwd prompts for old password

HP-UX:  Created account with UID 0, tried to change password using passwd.  Passwd prompted for the "old password" even though I was logged in as root.  The man page for passwd explains why:
Superusers are not prompted for old passwords unless they are attempting to change the superuser's password in a trusted system.


5.17.2006

UNIX Rosetta Stone

http://bhami.com/rosetta.html compare various Unix commands. If you don't know what Rosetta Stone means, look it up: http://www.answers.com/rosetta+stone&r=67


tags: unix comparision guide *nix tru64 aix hp-ux solaris irix linux freebsd openbsd netbsd sco differences matrix

5.16.2006

job name not known error

In HP-UX when trying to suspend (CTRL-Z) a process/job or when running a job in the background i.e: sleep 30 &   then running the jobs command, if you get message: <job name not known> then you'll need to defined the HISTFILE and HISTSIZE variables to fix the issue.

$ sleep 30 &
[1]     19870

$ jobs
[1] +  Running                    <job name not known>

or suspending the running command with CTRL-Z

$ sleep 20
[1] + Stopped                     <job name not known>

fixed by setting HISTFILE and HISTSIZE:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=200334 (ITRC login required)

export HISTFILE=$HOME/.history
export HISTSIZE=2000

$ sleep 20
[1] + Stopped                     sleep 20

5.15.2006

tail the mail log in HP-UX

mtail - tails the mail.log file (/var/adm/syslog/mail.log) on HP-UX systems.  It may be found on other *nix systems...

5.02.2006

Extra line breaks problem - Outlook 2003

How to stop Outlook from removing and screwing up the format. query: extra line breaks message removed outlook 2003

Two ways: Put two space at the beginning of each line: Article that describes the problem

Or turn off the option in Outlook 2003: Tools, Options, E-mail Options, uncheck: remove extra line breaks in plain text messages. Found this from the Jan 11, 2006 response to the article from "David".

learn HP-UX

One way to learn HP-UX commands is to use the key shell (keysh).  If you have a terminal that supports function keys, such as Reflection for HP, key shell will turn those function keys into prompts for different commands.  Once a command is finished, you'll see the exact command that is submitted to the shell, which makes learning the options easy.

Another good way to get familiar with HP systems is to use the HP-UX Software Recovery Handbook.  You can find individual PDF chapters for the handbook on HP's ITRC (I.T. Resource Center):  http://itrc.hp.com  (login required).  Look under the "knowledge trees" for "HP-UX Software Recovery Handbook"

Disable USB mass storage in Windows

Article discusses data security issues with USB mass storage devices and links to a MS article showing how to disable the drivers:
TechRepublic Blog: How secure is your data?

HOWTO: Use Group Policy to disable USB, CD-ROM, Floppy Disk and LS-120 drivers