Thursday, July 31, 2014

Solaris 11 Repository

configure proxy
# export https_proxy=http://proxy.goweekend.ca:8888

Update local repository
# pkg set-publisher -G '*' -M '*' -g file:///root/repo/repo solaris
# pkgrecv -s http://pkg.oracle.com/solaris/release/ -d /root/repo/repo '*'


# pkg info kerberos-5

-> if is not installed, you will need to recreate your local repo with Solaris11.1 repo image, then you will be able to install the pkg
* full repository can be downloaded from document "Where to download Oracle Solaris ISO images and Update Releases ( Doc ID 1277964.1 )"
* then follow instructions http://docs.oracle.com/cd/E26502_01/html/E28985/copyrepo1.html#scrolltoc

-> if is installed, in order to update it, you will need to recreate your local repository with the full repo of Solaris 11.1 + SRU 20.5
* SRU iso image can be downloaded from document "Oracle Solaris 11.1 Support Repository Updates (SRU) Index ( Doc ID 1501435.1 )" 

Wednesday, July 30, 2014

Solaris 11: Recover pam.conf

Get OK Prompt
1. ssh to ILOM console
2. From the ILOM prompt , type the below.

-> set /HOST send_break_action=break
-> start /SP/console to get to the ok prompt.

Manual system reset from the ILOM prompt.

-> set /HOST/bootmode script="setenv auto-boot? false"
-> reset /SYS


{0} ok probe-scsi-all
This command may hang the system if a Stop-A or halt command
has been executed.  Please type reset-all to reset the system
before executing this command.
Do you wish to continue? (y/n) y
/pci@400/pci@2/pci@0/pci@e/scsi@0

FCode Version 1.00.63, MPT Version 2.00, Firmware Version 9.05.00.00

Target 9
  Unit 0   Disk   HITACHI  H109060SESUN600G A690    1172123568 Blocks, 600 GB
  SASDeviceName 5000cca0562b9db8  SASAddress 5000cca0562b9db9  PhyNum 0
Target a
  Unit 0   Removable Read Only device   TEAC     DV-W28SS-W       1.0A
  SATA device  PhyNum 7
Target b
  Unit 0   Disk   HITACHI  H109060SESUN600G A690    1172123568 Blocks, 600 GB
  SASDeviceName 5000cca0562bd16c  SASAddress 5000cca0562bd16d  PhyNum 1

/pci@400/pci@1/pci@0/pci@b/pci@0/usb@0,2/hub@2/hub@3/storage@2
  Unit 0   Removable Read Only device    AMI     Virtual CDROM   1.00

{0} ok devalias

screen                   /pci@400/pci@1/pci@0/pci@0/pci@0/display@0
mouse                    /pci@400/pci@1/pci@0/pci@b/pci@0/usb@0,2/hub@2/device@4/mouse@1
net3                     /pci@500/pci@1/pci@0/pci@5/network@0,1                        
net2                     /pci@500/pci@1/pci@0/pci@5/network@0                          
dvd                      /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p7                     
disk5                    /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p5                     
disk4                    /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p4                     
disk3                    /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p3                     
disk2                    /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p2                     
disk1                    /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p1                     
disk0                    /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p0                     
disk                     /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@p0                     
scsi0                    /pci@400/pci@2/pci@0/pci@e/scsi@0                             
scsi                     /pci@400/pci@2/pci@0/pci@e/scsi@0                             
rcdrom                   /pci@400/pci@1/pci@0/pci@b/pci@0/usb@0,2/hub@2/hub@3/storage@2/disk@0
rkeyboard                /pci@400/pci@1/pci@0/pci@b/pci@0/usb@0,2/hub@2/device@4/keyboard@0  
rscreen                  /pci@400/pci@1/pci@0/pci@0/pci@0/display@0:r1280x1024x60            
net1                     /pci@400/pci@1/pci@0/pci@4/network@0,1                              
net0                     /pci@400/pci@1/pci@0/pci@4/network@0                                
net                      /pci@400/pci@1/pci@0/pci@4/network@0                                
virtual-console          /virtual-devices@100/console@1                                      

{0} ok boot dvd -s

login with username/password   : root/solaris

Mostly the pool name for root file system is (rpool)

# zpool import |grep -i pool:
pool:rpool

# zpool  import -f rpool   (to import root pool)
# mkdir /a
# zfs set mountpoint=/a rpool/ROOT/solaris
# zfs mount rpool/ROOT/solaris

Recover pam.conf

set back mount points to original and export the pool

# umount /a
# zfs set mountpoint=/ rpool/ROOT/solaris
# zpool export rpool
# halt

Go back to ILOM
-> set /HOST/bootmode script="setenv auto-boot? true"
-> reset /SYS

Monday, July 28, 2014

Sparc: Assign Static IP Address to NET MGT Port

set /SP hostname=sun-rsc

set /SP system_identifier=sun-t42

Assign a Static IP Address to the NET MGT Port

-> set /SP/network pendingipdiscovery=static
-> set /SP/network pendingipaddress=17.15.20.63
-> set /SP/network pendingipgateway=17.15.20.1
-> set /SP/network pendingipnetmask=255.255.255.0
-> show /SP/network
-> set /SP/network commitpending=true
-> show /SP/network

-> set /SP/clock timezone=America/Toronto

Tuesday, July 22, 2014

Solaris 11: Configure network interface


 Setup DNS

Check DNS and make sure domain & search are present

    # cat /etc/resolv.conf
    domain  dcs.bbk.ac.uk
    search  dcs.bbk.ac.uk
    nameserver      193.61.1.1
    nameserver      193.61.2.2

Update service if required:

    # sudo svccfg
    svc:> select dns/client
    svc:/network/dns/client> setprop config/domain = astring: "dcs.bbk.ac.uk"
    svc:/network/dns/client> setprop config/search = astring: "dcs.bbk.ac.uk"
    svc:/network/dns/client> setprop config/nameserver = net_address: (193.61.1.1  193.61.2.2)
    svc:/network/dns/client> select dns/client:default
    svc:/network/dns/client> refresh
    svc:/network/dns/client> validate
    svc:/network/dns/client> exit


# netadm list

# netadm enable -p ncp DefaultFixed

# dladm show-phys
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net1              Ethernet             unknown    0      unknown   igb1
net3              Ethernet             unknown    0      unknown   igb3
net0              Ethernet             up         100    full      igb0
net2              Ethernet             unknown    0      unknown   igb2
net4              Ethernet             up         10     full      usbecm2

# ipadm create-ip net1
# ipadm show-if
IFNAME     CLASS    STATE    ACTIVE OVER
lo0        loopback ok       yes    --
net0       ip       ok       yes    --
net1       ip       down     no     --
net4       ip       ok       yes    --
# ipadm create-addr -T static -a 13.5.210.16/24 net1/sun     13.5.210.16/24
net4/v4           static   ok           169.254.182.77/24
lo0/v6            static   ok           ::1/128
net0/v6           addrconf ok           fe80::210:e0ff:fe57:ebe4/10

# ipadm show-if
IFNAME     CLASS    STATE    ACTIVE OVER
lo0        loopback ok       yes    --
net0       ip       ok       yes    --
net1       ip       ok       yes    --
net4       ip       ok       yes    --
# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
net0/v4           static   ok           13.5.210.6/24
net1/sun         static   ok           13.5.210.16/24
net4/v4           static   ok           169.254.182.77/24
lo0/v6            static   ok           ::1/128
net0/v6           addrconf ok           fe80::210:e0ff:fe57:ebe4/10

# nscfg export svc:/network/dns/client:default

Tuesday, July 15, 2014

Confluence Development

http://stackoverflow.com/questions/14585365/how-do-i-create-text-file-for-confluence-and-then-import-it-as-a-confluence-wiki 
 
import sys
import xmlrpc.client
import os
import re

# Connects to confluence server with username and password
site_URL = "YOUR_URL"
server = xmlrpc.client.ServerProxy(site_URL + "/rpc/xmlrpc")

username = "YOUR_USERNAME"
pwd = "YOUR_PASSWORD" 
token = server.confluence2.login(username, pwd)

# The space you want to add a page to
spacekey = "YOUR_SPACENAME"

# Retrives text from a file
f = open('FileName.txt', 'r')
content = f.read()
f.close()

# Creates a new page to insert in the new space from text file content
newpage = {"title":"NEW_PAGENAME", "space":spacekey, "content":content}
server.confluence2.storePage(token, newpage)

server.confluence2.logout(token)

Securing Oracle Database

http://docs.oracle.com/cd/B28359_01/network.111/b28531/guidelines.htm#CHDGIEJE

http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm


Monday, July 14, 2014

Oracle SQLPLUS change output format

set feedback off
set trimspool on
set pagesize 10000
set linesize 1000
set heading off

Friday, July 11, 2014

Complete Checklist for Manual Upgrades to 11gR2 (Doc ID 837570.1)


https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=550009615142183&id=837570.1&_afrWindowMode=0&_adf.ctrl-state=igytrxho8_97


Determine PFILE or SPFILE is used to start up database.

SQL> show parameter spfile;
SQL> SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type"
FROM sys.v_$parameter WHERE name = 'spfile';

Wednesday, July 9, 2014

Solaris: Set Up Automatic Data Collection

  1. Become the root role.
  2. Run the svcadm enable system/sar:default command.This version of the sadc command writes a special record that marks the time when the counters are reset to zero (boot time).
  3. Edit the /var/spool/cron/crontabs/sys crontab file.

    Note - Do not edit a crontab file directly. Instead, use the crontab -e command to make changes to an existing crontab file.

    # crontab -e sys
  4. Uncomment the following lines:
    0 * * * 0-6 /usr/lib/sa/sa1
    20,40 8-17 * * 1-5 /usr/lib/sa/sa1
    5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A

Enable Audit in Oracle Database



select * from DBA_STMT_AUDIT_OPTS;


select * from DBA_OBJ_AUDIT_OPTS;


select * from DBA_AUDIT_TRAIL;

AUDIT ALL BY USER BY ACCESS;

AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY USER BY ACCESS;

SELECT * FROM audit_actions;

NOAUDIT  SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE;

NOAUDIT ALL;

TRUNCATE TABLE AUD$;

Oracle: Find Oracle User Session ID with OS process id

SQL> select * from v$process;

SQL> SELECT a.sid, b.spid FROM v$session a, v$process b
WHERE a.paddr = b.addr
and b.spid = 10099;

Solaris: Calculate Memory Consumed by project

# ps -e -o pid,user,project,rss,vsz,zone,comm >/tmp/3-9309294501_ps.out

# ipcs -mAZ >/tmp/3-9309294501_ipcs.out

# echo "::walk proc p| ::print -t proc_t p_cred |::print struct cred cr_projid|::grep ".==0t101" |::eval '<p=K'" |mdb -k > /tmp/3-9309294501_mdb_ora_procs.out

# echo "::walk proc p| ::print -t proc_t p_cred |::print struct cred cr_projid|::grep ".==0t101" |::eval '<p=K' |::pmap" | mdb -k 

# echo "::cat /tmp/3-9309294501_mdb_ora_procs.out|::pmap; ::cat /tmp/3-9309294501_mdb_ora_procs.out |::ps" | mdb -k >/tmp/3-9309294501_pmap.out


# cat 3-9309294501_pmap.out |egrep -v '(^S|^R|^Z)'| awk '{print $3}' | grep -v SIZE | sed -e 's/k//g' | awk '$1 < 1500000 {x=x+$1} END {print x/1024/1024}'

# prstat -J -c 1 1
# prstat -a -s rss -c 1 1

Thursday, July 3, 2014

Oracle Fix Missing Datafile

To fix the missing user tablespace,
1. Create a new tablespace
2. Drop the old tablespace
3. Change the new tablespace name to old tablespace name
4. Change affected user default tablespace to new one.

Example:
1.  Create a new tablespace
create tablespace USERS datafile '/data6/GOWEEK/USERSPACE.dbf' size 200M autoextend on next 500k maxsize 500m;

2. Drop the old tablespace    
DROP TABLESPACE USERSPACE INCLUDING CONTENTS AND DATAFILES;       

3. Change new table space name  
ALTER TABLESPACE USERS RENAME TO USERSPACE;

4. Use below script to change user default table space, you may need to change the statement

SQL> select 'ALTER USER '||username||' DEFAULT TABLESPACE USERSPACE;'  FROM DBA_USERS WHERE DEFAULT_TABLESPACE like '%_$%' and username not in('SYS','SYSTEM');

Reference:

select * from dba_data_files;

select * from dba_users;

select *  from database_properties where property_name like 'DEFAULT%TABLESPACE';

Oracle: Change datafile names

1. Using below statement to generate script to change datafile names in database

SQL> select 'alter database rename file ''' || file_name || '''' || ' to ' || '''' || SUBSTR(file_name, 1,19) || 'pfr' || SUBSTR(file_name, 24) || ''';' from dba_data_files where file_name like '%KEYWORD%' order by file_name;

and export the result into renDBfiles.sql

2. Using below statement to generate shell script to rename data files at system level

SQL> select 'mv ' || file_name || ' ' || SUBSTR(file_name, 1,19) || 'pfr' || SUBSTR(file_name, 24) from dba_data_files where file_name like '%KEYWORD%' order by file_name;


and export the result into renSysfiles.sh

3. Shutdown Database
SQL> shutdown immediate;

4. Rename data files at system level
$ ./renSysfiles.sh

5. Rename the data files at mount stage (database is not open)
SQL> startup mount;

6. Rename date files at database level
SQL> @renDBfiles.sql

7. Startup database
SQL> startup