Tuesday, April 14, 2009

enable only sftp for identied user and disable ssh

Goal: only allow sftp to list of users and disable ssh.

Generally if ssh is enable, user can do both ssh as well as sftp. But some time business need that list of user should be able to do the sftp only and ssh for these users should be disabled.

1. To achieve this check openssh is installed on you unix box.

2. Start ssh service "/etc/init.d/sshd start"

2. Run command "env|grep -i shell" to find the default shell for user.

3. find the path of sftp-server in /usr/lib. (in my env. OEL5 path is /usr/libexec/openssh/sftp-server)

4. Run cammand to change the shell for user:
usermod -s /usr/libexec/openssh/sftp-server

5. now try to do the ssh with this user
ssh @localhost

This will not work.

6. Now try sftp @localhost

This will work.


After this user will be able to do only sftp and ssh would not work for these users for which login shell has been changed.

Thursday, July 31, 2008

How to set Display for local ip on RHEL5/OEL5

1. Check the current display setting:
echo $DISPLAY
:0.0
2. With this xclock will work.
3. Now suppose we have local m/c ip-address: 10.1.12.55
4. Set the display as
export $DISPLAY=10.1.12.55:0.0
5. Xclock
Can't open display on 10.1.12.55
6. set DISPLAY to :0.0
export DISPLAY=:0.0
7. Start gdmsetup, go to security , un-check the "Deny TCP connections to Xserver"
8. reeboot or restart gdm :
gdm-restart
9. Now set display as localip:
export DISPLAY=10.1.12.55:0.0
10. run xclock

Friday, January 18, 2008

Internet Connection with GPRS enabled mobile with bluethoot on Linux

Step1: Get GPRS service enabled on ur mobile.
Step2: Get the setting of modem for mobile from ISP.
Step3: Login on Linux m/c with gnome.
Step4: From mobile scan the bluetooth of laptop. and set password "1"
Step5: On linux notebook, will get bluetooth request from mobile, type passwd: "1".
Step6: start kppp on linux.
Step7: go to configure create new account , give connection name and phone-no: "*99***1#" in dial section. Leave the rest of setting as default.
Step8: Now go to modem settings , add new modem:
supply modem name, modem -device (/dev/rfcomm0),any connection speed(115200)
Step9: Now connect.

Incase of any query please conntact Manoj.Kumar.Jha@gmail.com.

Monday, November 26, 2007

Storage migration for database with asm.

TASK: Storage migration for database with asm.

Setup Used:

OS : RHEL4 update 4
Database : 10gR2 with two node RAC with ASM.
Extra info: Multipathing
Storage: Currently the storage spaces are from two SAN box. Six TB from one HITACHI-SAN and one-TB from second EMC2-SAN box. And requirement is they have to migrate all the data to EMC2 SAN box to release the space from HITACHI SAN box.

Approach Used in this document can be split into two parts:

Part1: Mark new disk(LUN) as asm disk and assign these disk to existing disks, so that same number of disk are added to disk groups as they exist in current setup to make make sure that there is not any re-balancing issues. Once the balancing operation is complete, old disk can be dropped from disk group and also can be delete from asm disk list.

PART2 : Migrate ocr and voting disk to new storage.

Advantage: This will minimize down-time.
Disadvantage: Performance of live system may go down and asm disk rebalancing will take time depending upon the ASM_POWER_LIMIT init parameter setting.

Current Setup:
Two node RAC, with oracle asm and os multipathing enabled.
Currently database has 7TB storage in 14 luns. ie. each lun of 500GB.
And 6 TB from one Hitachi-SAN, 1 TB from EMC2-SAN this is mirrored to Hitachi.
Finally we have to migrate complete database to new storage (7TB) allocated from EMC2-SAN only.


DB-Servers name/Instance-Name: riddb1/PROD1, riddb2/PROD2
Oracle User os-id: oraprod on both node.

PART1:
Step1: login on riddb1 as root:

root@riddb1: ls -ltr /dev/mapper/

output would be like :

brw-rw---- 1 root disk 253, 1 Apr 18 11:57 mpath0
brw-rw---- 1 root disk 253, 4 Apr 18 11:57 mpath1
brw-rw---- 1 root disk 253, 10 Apr 18 11:57 mpath10
brw-rw---- 1 root disk 253, 3 Apr 18 11:57 mpath11
brw-rw---- 1 root disk 253, 12 Apr 18 11:57 mpath12
brw-rw---- 1 root disk 253, 13 Apr 18 11:57 mpath13
brw-rw---- 1 root disk 253, 15 Apr 18 11:57 mpath15
brw-rw---- 1 root disk 253, 6 Apr 18 11:57 mpath16
brw-rw---- 1 root disk 253, 2 Apr 18 11:57 mpath2
brw-rw---- 1 root disk 253, 14 Apr 18 11:57 mpath3
brw-rw---- 1 root disk 253, 11 Apr 18 11:57 mpath4
brw-rw---- 1 root disk 253, 8 Apr 18 11:57 mpath5
brw-rw---- 1 root disk 253, 5 Apr 18 11:57 mpath6
brw-rw---- 1 root disk 253, 9 Apr 18 11:57 mpath7
brw-rw---- 1 root disk 253, 0 Apr 18 11:57 mpath8
brw-rw---- 1 root disk 253, 7 Apr 18 11:57 mpath9


Note : the above are block device.

copy the out put of these.

Step2: Get luns of 500 GB each and now assing these lun to riddb1,ridb2 servers now.
Step3: If require to reboot of servers to luns visible on these server, shutdown instances PROD1 and PROD2 and asm intances +ASM1, +ASM2
Step4: Startup +ASM1, ASM2 and PROD1 and PROD2 instances. And start the application to do the normal production activities.
Step5: Login as root on both servers and issue below command:

root@riddb1: ls -ltr /dev/mapper/
root@riddb2: ls -ltr /dev/mapper/

And you will see that new block devices has been added. This can be differentiated by output of step1 and step 5.

Step6: root@riddb1: cd /etc/init.d/

./oracleasm querydisk ORAVOL1 ORAVOL2 ORAVOL3 ORAVOL4 ORAVOL5 ORAVOL6 ORAVOL7 ORAVOL8 ORAVOL9 ORAVOL10 ORAVOL11 ORAVOL12 ORAVOL13 ORAVOL14 ORAVOL15 ORAVOL16


Disk "ORAVOL1" is a valid ASM disk on device [253, 4]
Disk "ORAVOL2" is a valid ASM disk on device [253, 2]
Disk "ORAVOL3" is a valid ASM disk on device [253, 14]
Disk "ORAVOL4" is a valid ASM disk on device [253, 11]
Disk "ORAVOL5" is a valid ASM disk on device [253, 8]
Disk "ORAVOL6" is a valid ASM disk on device [253, 5]
Disk "ORAVOL7" is a valid ASM disk on device [253, 0]
Disk "ORAVOL8" is a valid ASM disk on device [253, 7]
Disk "ORAVOL9" is a valid ASM disk on device [253, 3]
Disk "ORAVOL10" is a valid ASM disk on device [253, 10]
Disk "ORAVOL11" is a valid ASM disk on device [253, 12]
Disk "ORAVOL12" is a valid ASM disk on device [253, 13]

Unable to open ASM disk "ORAVOL13": No such file or directory
Unable to open ASM disk "ORAVOL14": No such file or directory
Unable to open ASM disk "ORAVOL15": No such file or directory
Unable to open ASM disk "ORAVOL16": No such file or directory

Step7: The last few lines of above result show that, there is no asm disk with name ORAVOL13 onward. So we can create asm disk from ORAVOL13 onward.

Step8: Note down the minor of new devices from out put of step 5: eg: minor of mpath16 is 6 thus dm disk will be dm-6.

Step9: Mark the newly assinged disks as asm disk
[root@riddb1 init.d]# ./oracleasm createdisk ORAVOL13 '/dev/dm-6'
./oracleasm createdisk ORAVOL14 '/dev/dm-xx'

simillarly create other asm disks.

Note: repeat the step 1-9 on riddb2 to mark the new luns on this server as asm disks.

Step10: login as oracle user (oraprod) on riddb1:
oraprod@riddb1$

export ORACLE_SID=+ASM1
sqlplus "/ as sysdba"

Step11: Determine the no. of disks assinged to ORAVG1 and ORAVG2
export ORACLE_SID=+ASM1
sqlplus "/ as sysdba"

select * from v$asm_disk;
select * from v$asm_diskgroup;

So we will add same no. of disk as they exists to both disk groups, so the re-balancing can be done.

alter system set asm_diskstring='ORCL:*' ;

alter diskgroup 'ORAVG1' add disk 'ORCL:ORAVOL13';
alter diskgroup 'ORAVG2' add disk 'ORCL:ORAVOL14';
....

The same way add rest of disks to disk group ORAVG1 and ORAVG2(add same no. of disk in ORAVG1 and ORAVG2 as they exits. But don't repeat this step (step 14 on riddb2.) This will make sure that error free rebalancing.

Step12: To check the rebalancing, run the script asmbalance.sql, this script can be download from metalink. The same script is given below:

====================
/*
* RUN THIS SQL*PLUS SCRIPT WHILE CONNECTED TO AN ASM INSTANCE WITH
* DISKGROUPS MOUNTED. "no rows selected" IF NO DISKGROUPS ARE MOUNTED
*/
set verify off
clear columns

/* THE FOLLOWING ERROR WILL BE REPORTED IF THIS SCRIPT IS RUN ON 10gR1

ORA-01219: database not open: queries allowed on fixed tables/views only

* This script is intended to work with 10gR2 and later. To make it work with
* 10gR1 you must remove the "_stat" in the following two defines by
* uncommenting the redefines that follow. The _stat tables eliminate disk
* header reads, but they were not available in 10.1
*/
define asm_disk = v$asm_disk_stat
define asm_diskgroup = v$asm_diskgroup_stat
/* for 10.1 uncomment the following redefines
define asm_disk = v$asm_disk
define asm_diskgroup = v$asm_diskgroup
*/

/*
* Query to see if any diskgroups are out of balance
*/
column "Diskgroup" format A30
column "Diskgroup" Heading " Columns Described in Script||Diskgroup Name"

/*
* The imbalance measures the difference in space allocated to the fullest and
* emptiest disks in the disk group. Comparision is in percent full since ASM
* tries to keep all disks equally full as a percent of their size. The
* imbalance is relative to the space allocated not the space available. An
* imbalance of a couple percent is reasonable
*/
column "Imbalance" format 99.9 Heading "Percent|Imbalance"


/*
* Percent disk size varience gives the percentage difference in size between
* the largest and smallest disks in the disk group. This will be zero if
* best practices have been followed and all disks are the same size. Small
* differences in size are acceptible. Large differences can result in some
* disks getting much more I/O than others. With normal or high redundancy
* diskgroups a large size varience can make it impossible to reduce the
* percent imbalance to a small value.
*/
column "Varience" format 99.9 Heading "Percent|Disk Size|Varience"

/*
* Minimum percent free gives the amount of free disk space on the fullest
* disk as a percent of the disk size. If the imbalance is zero then this
* represents the total freespace. Since all allocations are done evenly
* across all disks, the minimum free space limits how much space can be
* used. If one disk has only one percent free, then only one percent of the
* space in the diskgroup is really available for allocation, even if the
* rest of the disks are only half full.
*/
column "MinFree" format 99.9 Heading "Minimum|Percent|Free"

/*
* The number of disks in the disk group gives a sense of how widely the
* files can be spread.
*/
column "DiskCnt" format 9999 Heading "Disk|Count"

/*
* External redundancy diskgroups can always be rebalanced to have a small
* percent imbalance. However the failure group configuration of a normal or
* high redundancy diskgroup may make it impossible to make the diskgroup well
* balanced.
*/
column "Type" format A10 Heading "Diskgroup|Redundancy"

select
/*
Name of the diskgroup */
g.name
"Diskgroup",
/*
Percent diskgroup allocation is imbalanced */
100*(max((d.total_mb-d.free_mb)/d.total_mb)-min((d.total_mb-d.free_mb)/d.total_mb))/max((d.total_mb-d.free_mb)/d.total_mb)
"Imbalance",
/*
Percent difference between largest and smallest disk */
100*(max(d.total_mb)-min(d.total_mb))/max(d.total_mb)
"Varience",
/*
The disk with the least free space as a percent of total space */
100*(min(d.free_mb/d.total_mb))
"MinFree",
/*
Number of disks in the diskgroup */
count(*)
"DiskCnt",
/*
Diskgroup redundancy */
g.type
"Type"
from
&asm_disk d ,
&asm_diskgroup g
where
d.group_number = g.group_number and
d.group_number <> 0 and
d.state = 'NORMAL' and
d.mount_status = 'CACHED'
group by
g.name ,
g.type
;

/*
* query to see if there are partner imbalances
*
* This query only returns rows for normal or high redundancy diskgroups.
* You will not get any rows if all your diskgroups are external.
*/

/*
* This query checks how even the partnerships are laid out for the diskgroup.
* If the disks are different sizes or the failure groups are different sizes,
* then the partnerships may not be balanced. Uneven numbers of disks in
* failure groups can result with some disks having fewer partners. Uneven
* disk sizes result in some disks having more partner space than others.
* Primary extents are allocated to a disk based on its size. The secondary
* extents for those primaries are allocated on its partner disks. A disk with
* less partner space will fill up those partners more than a disk with more
* partner space. At the beginning of a rebalance, partnerships may be
* rearranged. The partnerships being dropped are marked as inactive. This
* query only examines active partnerships since it is attempting to
* evaluate problems based on the structure of the diskgroup, not the
* transient state that may exist at the moment. At the completion of a
* successful rebalance the inactive partnerships will be deleted.
*/

/*
* Partner count imbalance gives the difference in the number of partners for
* the disk with the most partners and the disk with the fewest partners. It
* may not be possible for every disk to have the same number of partners
* even when all the failure groups are the same size. However an imbalance
* of more than one indicates that the failure groups are different sizes.
* In any case it maybe impossible to get a percent imbalance of zero when
* some disks have more partners than others.
*/
column "PImbalance" format 99 Heading "Partner|Count|Imbalance"

/*
* Partner space imbalance indicates if some disks have more space in their
* partners than others. The partner space is calculated as a ratio between
* the size of a disk and the sum of the sizes of its active partners. This
* ratio is compared for all the disks. The difference in the highest and
* lowest partner space is reported as a percentage. It is impossible to
* achieve a percent imbalance of zero unless this is zero. An imbalance of
* 10% is acceptible.
* Inactive partners are not considered in this calculation since the
* allocations across an inactive partnership will be relocated by rebalance.
*/
column "SImbalance" format 99.9 Heading "Partner|Space %|Imbalance"

/*
* Failgroup Count reports the number of failure groups. This gives a sense
* of how widely the partners of a disk can be spread across different
* failure groups.
*/
column "FailGrpCnt" format 9999 Heading "Failgroup|Count"

/*
* Inactive Partnership Count reports the number of partnerships which are
* no longer used for allocation. A successful rebalance will eliminate these
* partnerships. If this is not zero then a rebalance is needed or is in
* progress.
*/
column "Inactive" format 9999 Heading "Inactive|Partnership|Count"

select
/*
Name of the diskgroup */
g.name
"Diskgroup",
/*
partner imbalance */
max(p.cnt)-min(p.cnt)
"PImbalance",
/*
total partner space imbalance */
100*(max(p.pspace)-min(p.pspace))/max(p.pspace)
"SImbalance",
/*
Number of failure groups in the diskgroup */
count(distinct p.fgrp)
"FailGrpCnt",
/*
Number of inactive partnerships in the diskgroup */
sum(p.inactive)/2
"Inactive"
from
&asm_diskgroup g ,
( /* One row per disk with count of partners and total space of partners
* as a multiple of the space in this disk. It is possible that all
* partnerships are inactive giving a pspace of 0. To avoid divide by
* zero when this happens for all disks, we return a very small number
* for total partner space. This happens in a diskgroup with only two
* failure groups when one failure group fails. */
select
x.grp grp,
x.disk disk,
sum(x.active) cnt,
greatest(sum(x.total_mb/d.total_mb),0.0001) pspace,
d.failgroup fgrp,
count(*)-sum(x.active) inactive
from
&asm_disk d ,
( /* One row per partner of a disk with partner size. We return
* size of zero for inactive partnerships since they will
* be eliminated by rebalance. */
select
y.grp grp,
y.disk disk,
z.total_mb*y.active_kfdpartner total_mb,
y.active_kfdpartner active
from
x$kfdpartner y,
&asm_disk z
where
y.number_kfdpartner = z.disk_number and
y.grp = z.group_number
) x
where
d.group_number = x.grp and
d.disk_number = x.disk and
d.group_number <> 0 and
d.state = 'NORMAL' and
d.mount_status = 'CACHED'
group by
x.grp, x.disk, d.failgroup
) p
where
g.group_number = p.grp
group by
g.name
;


============================
export ORACLE_SID=+ASM1
sqlplus "/ as sysdba"

sqlplus > @asmbalance.sql

This will show the % of rebalance of disks are pending.

Step12: Now at this time old disks can be dropped from disk group. But these disks (LUN should not be detached from servers riddb1 and riddb2 till rebalancing is complete.)

for this list
oraprod@riddb1:
export ORACLE_SID=+ASM1
sqlplus "/ as sysdba"


alter system set asm_diskstring='ORCL:*' ;
alter diskgroup 'ORAVG1' drop disk 'ORACL:ORAVOL1'.

repeat step this till all old disks of both disk group is dropped.

Step13. Get the asm disk % balance status. Once balancing is complete. The asm old disks can be deleted.

root@riddb1:
cd /etc/init.d
root@riddb1: ./oracleasm listdisks ( to List disks)
and now drop the old asm disk.


./oracleasm deletedisk ORAVOL1 ORAVOL2 ......;

Note: Once the balancing is complete then only delete asm disk. And these LUN can be removed from servers.

PART2:
Step14: Now prepare system for replacing OCR and Voting disk.

Identify the newly added LUNs(Block Devices) for OCR and voting disk.

As the LUN size for OCR and Voting disk are 100M+ arround this can be identified from list newly added LUN and size can be varified by fdisk

fdisk -l /dev/dm* |grep -i "Disk /dev/dm-"

Disk /dev/dm-23: 104 MB, 104857600 bytes
Disk /dev/dm-12: 104 MB, 104857600 bytes

ls -ltr /dev/mappers

brw-rw---- 1 oraprod dba 253, 12 Aug 21 17:31 mpath17
brw-rw---- 1 oraprod dba 253, 23 Aug 21 17:31 mpath23

Step14.1: To mark these two new LUNs as raw devices permanently, add entry in
/etc/sysconfig/rawdevices , as follows:

riddb1@root$ cat /etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/mapper/mpath0 #Old raw device
/dev/raw/raw2 /dev/mapper/mpath7 #Old raw device
/dev/raw/raw3 /dev/mapper/mpath17 #New raw device
/dev/raw/raw4 /dev/mapper/mpath23 #New raw device

Note : Once the OCR and voting disk are replace with new raw devices, the old raw devices can be commented in above file, before removal from servers.

To make the effect in this boot,

raw /dev/raw/raw3 /dev/mapper/mpath17
raw /dev/raw/raw4 /dev/mapper/mpath23

Step14.2: format the new raw devices:

dd if=/dev/zero of=/dev/raw/raw3
dd if=/dev/zero of=/dev/raw/raw4

Check the owner and permission on old raw devices and make the same on new raw devices:


Note: Earlier in my case the size of old disks for OCR and voting was 105MB, and newly allocated disk were of size 104MB. So the o

Step14.3: To identify the OCR disk check the '/etc/oracle/ocr.loc' file, which will tell the existing OCR disk.

riddb1@root$ cat /etc/oracle/ocr.loc
ocrconfig_loc=/dev/raw/raw2

The existing raw devices can be verified in: '/etc/sysconfig/rawdevices'

riddb1@roo$ cat /etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/mapper/mpath0
/dev/raw/raw2 /dev/mapper/mpath7

or by using raw -qa

Step 14.4: The existing voting disk can be verified by :

crsctl query css votedisk

As the LUN size for OCR and Voting disk are 100M+ arround this can be identified from list newly added LUN and size can be varified by fdisk

fdisk -l /dev/dm* |grep -i "Disk /dev/dm-"

Disk /dev/dm-23: 104 MB, 104857600 bytes
Disk /dev/dm-12: 104 MB, 104857600 bytes

ls -ltr /dev/mappers

brw-rw---- 1 oraprod dba 253, 12 Aug 21 17:31 mpath17
brw-rw---- 1 oraprod dba 253, 23 Aug 21 17:31 mpath23




14.5. Note: log in as the root user, because root own the OCR files.

Make sure there is a recent copy of the OCR file before making any changes:
ocrconfig –showbackup

If there is not a recent backup copy of the OCR file, an export can be taken for the current OCR file. Use the following command to generate a an export of the online OCR file:
ocrconfig –export [-s online]

If need to recover using this file, the following command can be used:
ocrconfig -import

To replace OCR device :

ocrconfig -replace ocr /dev/raw/raw3

But this failed as old raw device size and new raw device size are not same. Old one was of 105MB and new one of 104 MB. So it was throwing PROT-1 error.

To overcome this, we have simply imported the backup of ocr to new raw device as follows:

14.6: First replace new raw device in /etc/oracle/ocr.loc to mark this as OCR disk.

[root@riddb1 oracle]# cat ocr.loc
#ocrconfig_loc=/dev/raw/raw2
ocrconfig_loc=/dev/raw/raw4
local_only=FALSE

14.7. Now import backup of OCR disk to new OCR disk (raw4).

ocrconfig -import

If you want to have any OCR mirror:

ocrconfig -replace ocr /dev/raw/rawn

14.8: ADD/DELETE/MOVE Voting Disk

Note: You must be logged in as the oracle user, because oracle own the Voting Disks.

Shutdown the Oracle Clusterware (crsctl stop crs as root) on all nodes before making any modification to the voting disk. Determine the current voting disk location using:

crsctl query css votedisk

Take a backup of all voting disk:
dd if=voting_disk_name of=backup_file_name


The following can be used to restore the voting disk from the backup file created.
dd if=backup_file_name of=voting_disk_name

14.9: To add a Voting Disk, provide the full path including file name.:
crsctl add css votedisk [-force]

14.10: To delete a Voting Disk, provide the full path including file name.:
crsctl delete css votedisk [-force]

14.11: After modifying the voting disk, start the Oracle Clusterware stack on all nodes
crsctl start crs

Verify the voting disk location using
crsctl query css votedisk

14.12. Once the CRS and Voting disks are moved to new raw device, the old can removed.

Step15: Start the database and applications

Note: To make the asm disk re-balaning fast if the load on the server are low, increase the value of asm init parameters 'ASM_POWER_LIMIT' upto number of cpu-1. This improve the asm re-balancing operation performance.
If the the ASM_POWER_LIMIT is set to zero then it will not perform auto re-balancing. In this case to do the re-balancing use:

ALTER DISKGROUP REBALANCE POWER 5;

Tuesday, November 20, 2007

How to use cdma and gsm pcmcia and mobile modem in Linux

Step 1: Attach device (pcmcia card in pcmcia slot/ or incase of mobile modem attach data cable to usb port ).
Step 2: Check the /var/log/message or use 'dmesg|tail, to verify that kernel has detected the device or not. Once detected, it will show the device name

pcmcia: the driver needs updating to supported shared IRQ lines.
ttyS3: detected caps 00000700 should be 00000100
0.0: ttyS3 at I/O 0x2e8 (irq = 185) is a 16C950/954

If message show that some hardware has attached but showing some error then its kernel issue. xen kernel and some other 2.6.18.xx kernel have issue with serial port.

Step 3: check the baud_base of attached device by using

for serial device :
setserial -a /dev/ttyS3

[root@manoj-pc ~]# setserial -a /dev/ttyS3
/dev/ttyS3, Line 3, UART: 16950/954, Port: 0x02e8, IRQ: 185
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test

Step 4: check whether device is responding for modem init strings and determine the speed of modem upto which it will give the optimum speed , by using command:

wvdialconf /tmp/wvdial.conf

[root@manoj-pc ~]# wvdialconf /tmp/wvdial.conf
Scanning your serial ports for a modem.

Port Scan<*1>: S0 S1 S2
ttyS3<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS3<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS3<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.


Sorry, no modem was detected! Is it in use by another program?
Did you configure it properly with setserial?

Please read the FAQ at http://open.nit.ca/wvdial/

If you still have problems, send mail to wvdial-list@lists.nit.ca.


Note: if the device is not responding, change the baud_base value of serial device

Step 5: setserial /dev/ttyS3 baud_base 921600

[root@manoj-pc ~]# wvdialconf /tmp/wvdial.conf
Scanning your serial ports for a modem.

Port Scan<*1>: S0 S1 S2
ttyS3<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS3<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS3<*1>: ATQ0 V1 E1 -- OK
ttyS3<*1>: ATQ0 V1 E1 Z -- OK
ttyS3<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyS3<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyS3<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyS3<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyS3<*1>: Modem Identifier: ATI -- ZTEiT MODEM
ttyS3<*1>: Speed 230400: AT -- Speed 230400: AT -- Speed 230400: AT -- Max speed is 115200; that should be safe.
ttyS3<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK

Found a modem on /dev/ttyS3.
Modem configuration written to /tmp/wvdial.conf.
ttyS3: Speed 115200; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

Step 6: Using /tmp/wvdial.conf , create /etc/wvdial.conf as given below:


[Dialer Defaults]
Modem = /dev/ttyS3
Baud = 115200
SetVolume = 0
Dial-AT-OK ATDT Command =
Init1 = ATZ
FlowControl = Hardware (CRTSCTS)
Phone = #777
Username =
Password =
New PPPD = yes
Carrier Check = no
Stupid Mode = 1
Auto Reconnect = on

Step 7: now run
wvdial

Now u will get connect.

Also don't forget to add dns entry in /etc/resolve.conf , that u get from wvdial.

Step8: Instead of wvdial one can also use kppp or equivalent utility to surf.

Only trick is that some modem only respond when there is baud_base (used for serial device) vs baud rate (used in wvdial.conf for modem speed) have some specific ratio. Eg. for zte mc315 data card will respond for baud_base 921600 and baud 115200, ie. baud_base/baud=8.

Monday, November 19, 2007

Installation of fully virtualized windows-xp on RHEL5 or Oracle-EL5

Installation of fully virtualized windows-xp on RHEL5 or Oracle-EL5.

Pre-requisites:

1. RHEL5 with xen kernel should be installed. The same feature is also available on Fedora and other linux flevours.


2. Verify that CPU architect support for virtuallization.

for intel processor check: cat /proc/cpuinfo|grep -i vmx
for amd processor check: cat /proc/cpuinfo|grep -i svm

3. Enable Bios for virtualization.

4. Disable SELinux as given below :

In /etc/selinux/config, set "SELINUX=disabled".
and in /etc/grub.conf append the kernel parameter as "selinux=0".

5. Require Windows-XP CD/DVD or iso image for installation.

Reboot the Linux using xen kernel.


Steps to install fully virtuallyzed winxp on RHEL5 Linux.:

1. logon as root.


2. create a windows-xp binary image file where this installation want to store.

for this use dd command to create a binary image file.

[root@localhost xen]# dd if=/dev/zero of=/xen/winxp.img bs=1M count=15000

So I will install the xp on /xen/winxp.img, with allocated storage 15gb. The storage limit is optional.



3. Once the binary file '/xen/winxp.img' is created, start virt-manager

[root@localhost etc]# virt-manager









Note: screenshot: 1.png

Select "Local Xen Host" and click on connect.



















4. On "Virtual Machine Manager" screen, select "+New".























5. On screen "Creating a New virtual System", click forward.























6. On screen "Naming your virtual system" specify the desired "System Name". (eg: winxp).






















7. Select "Fully Virtualized" option.























8. If have iso image of "windows-xp" select "ISO Image Location" and specify the path. Or select "CD-ROM or DVD " and load media.






















9. On screen "Assigning storage space", select 'simple file' and specify "/xen/winxp.img". (i.e. the location of target where want to install windows-xp .)





















10. On screen "Allocate memory and CPU" specify the memory and cpu
resource want to allocate for virtual windows.







11. Click Finish.














12. This will open the screen for windows installation.
























13. if installation hangs on "starting windows installation". Shutdown the virtual server of winxp.
and repeat step 4-11 and when windows installation screen comes and show for "F6" key , press F5 key instead of F6 key.

















































14 Select "standard PC.." option.
















































15. Once the installation is complete.Check the device name where '/xen/winxp.img' is present.
In my case its on "sda", I have replaced one line as given below in /etc/xen/winxp

disk = [ 'file:/xen/winxp.img,hda,w', ]
with
disk = [ 'file:/xen/winxp.img,sda,w', ]























































































16. As root user write "xm create -c /etc/xen/winxp".










[root@localhost xen]# xm create -c /etc/xen/winxp
Using config file "/etc/xen/winxp".
Started domain winxp










17. if install show any boot error. Shutdown virtual server and repeat step 4-11. It will start the xp installation.

18.now write "xm create -c /etc/xen/winxp" as root user and go to 'Vitual Machine Manager' screen and select 'winxp' and click on open. Tjis will open window-xp session.





References: Virtualization.pdf,Virtual_Server_Administration.pdf

Saturday, November 17, 2007

Oracle E-Business Suite Security-- PART1: Removing Credentials from a Cloned EBS Production Database

Removing Credentials from a Cloned EBS Production Database:

When cloning a production database instance of the Oracle E-Business Suite (EBS), all production account credentials should be cleared in the cloned copy of the database. This will prevent retrieval of credentials that could be used to compromise of the integrity of the production database.

The following sequence of steps will remove production account credentials from the cloned copy of the production database and reestablish new credentials in the cloned copy. The new accounts in the cloned copy will all have the password "clone".
  1. Step 1 - Clear all credentials

  2. Step 2 - Re-establish basic accounts (for runtime: SYS,SYSTEM,APPLSYSPUB,APPLSYS,APPS + GUEST,SYSADMIN)

  3. Step 3 - Prepare scripts for setting additional passwords

  4. Step 4 - Assign new passwords to all database users not managed with EBS

  5. Step 5 - Assign new passwords to all database users managed with EBS

  6. Optional addition steps

Steps 1 - 4 are run on the database server running as oracle, using sqlplus connected as SYS or APPS; step 5 is run as applmgr on an application tier and uses the FNDCPASS command line utility.

This means that steps 1-4 can be performed the first time the cloned database is started, i.e. before it is made accessible to the network via the database TNS listener.

Step 5 is not time critical and can be performed when access to the cloned system for patch purposes is required.

All application tier processes must be stopped during this procedure.

Step 1 - Clear All Credentials

To clear all credentials in a cloned copy of a production database you must establish an shell environment with sufficient Oracle settings to run sqlplus via the BEQ driver.
The full environment could be established by your cloning process, the minimal environment is shown below

oracle$ export ORACLE_SID=
oracle$ export ORACLE_HOME=
oracle$ export PATH=$ORACLE_HOME/bin
oracle$ unset TWO_TASK

oracle$ sqlplus '/ as sysdba'

To clear all credentials in the cloned copy of a production database, run the following 3 SQL statements:

REM --- step1.sql
spool step1.lst

REM Start the database clone for the first time
startup restrict

REM Clear all production credentials from the cloned database

update SYS.user$ set
password = translate(password,'0123456789ABCDEF','0000000000000000')
where type#=1 and length(password) = 16
/
update APPLSYS.FND_ORACLE_USERID set
ENCRYPTED_ORACLE_PASSWORD='INVALID'
/

update APPLSYS.FND_USER set
ENCRYPTED_FOUNDATION_PASSWORD='INVALID',
ENCRYPTED_USER_PASSWORD='INVALID'
/
commit;

REM Shutdown the database
shutdown
exit

Now the cloned copy of the database is free from production credentials. The database was shut down in order for the unusual way of clearing the database user (schema) passwords to take effect.

Start the cloned copy of the database in preparation for steps 2, 3 and 4:

oracle$ echo startup | sqlplus '/ as sysdba' 

Step 2 - Re-establish Bootstrap Credentials

The database at the moment has no credentials, so you log on as SYS with operation system authentication.
This will allow you to establish new credentials.

oracle$ sqlplus '/ as sysdba'

The script below has comments explaining what is done in step 2.

REM --- step2.sql
spool step2.lst

REM Set a new password for a few initial database users

alter user SYS identified by CLONE;
alter user SYSTEM identified by CLONE;
alter user APPLSYSPUB identified by CLONE;
alter user APPLSYS identified by CLONE;
alter user APPS identified by CLONE;

REM Provide boot-strap info for FNDCPASS...
update APPLSYS.FND_ORACLE_USERID set
ENCRYPTED_ORACLE_PASSWORD='CLONE'
where ORACLE_USERNAME = 'APPLSYSPUB'
/

update APPLSYS.FND_ORACLE_USERID set
ENCRYPTED_ORACLE_PASSWORD='ZG' ||
'B27F16B88242CE980EF07605EF528F9391899B09552FD89FD' ||
'FF43E4DDFCE3972322A41FBB4DDC26DDA46A446582307D412'
where ORACLE_USERNAME = 'APPLSYS'
/

update APPLSYS.FND_ORACLE_USERID set
ENCRYPTED_ORACLE_PASSWORD='ZG' ||
'6CC0BB082FF7E0078859960E852F8D123C487C024C825C0F9' ||
'B1D0863422026EA41A6B2B5702E2299B4AC19E6C1C23333F0'
where ORACLE_USERNAME = 'APPS'
/
commit;

REM We run as SYS, now connect as APPS to run some plsql
connect APPS/CLONE

REM Every EBS database needs a GUEST user
select APPS.fnd_web_sec.change_guest_password( 'CLONE', 'CLONE' ) "RES"
from dual;
commit;

REM Set GUEST credential in site level profile option
set serveroutput on
declare
dummy boolean;
begin
dummy := APPS.FND_PROFILE.SAVE('GUEST_USER_PWD', 'GUEST/CLONE', 'SITE');
if not dummy then
dbms_output.put_line( 'Error setting GUEST_USER_PWD profile' );
end if;
end;
/
commit;

REM One more time for luck (avoid session caching of profiles)
connect APPS/CLONE

REM Set SYSADMIN password
select APPS.fnd_web_sec.change_password('SYSADMIN','CLONE') "RES"
from dual;
commit;
exit


The expected output from step 2 is as follows:

User altered.
User altered.
User altered.
User altered.
User altered.
1 row updated.
1 row updated.
1 row updated.
Commit complete.
Connected.
RES
------
Y Commit complete. PL/SQL procedure successfully completed. Commit complete. Connected. RES ------ Y Commit complete.
It is important to verify that no errors are reported and that the 2 returned RES values are both Y (for success).


Now the database should be able to run EBS as we have a set of bootstrap runtime users. (You will need to run AutoConfig to let the application know of the new passwords and other changes required for the cloned environment to actually run the application tier services. Don't run AutoConfig yet, we'll do that in Step 5.)

Step 3 - Prepare Scripts for Setting Additional Passwords

I this step we prepare to assign passwords to the other database users that were disabled in step 1. We use dynamically generated scripts to do this as the set of database users may be different between instances of EBS.

oracle$ sqlplus '/ as sysdba' 

The comments in script below explains what is done in step 3.

REM --- step3.sql

REM Prepare SQL and SHELL scripts to set more passwords later
spool step3.lst

REM Generate a sql script to set password for db users not managed with EBS

select 'alter user "'|| USERNAME ||'" identified by CLONE; '
from SYS.DBA_USERS
where USERNAME not in (select ORACLE_USERNAME from APPLSYS.FND_ORACLE_USERID)
and USERNAME not in ('SYS','SYSTEM');

REM Generate a shell script to set password for all base product schemas

select 'FNDCPASS apps/clone 0 Y system/clone ALLORACLE clone' from dual;

REM Generate a shell script to set password for non-EBS db users managed with EBS

select 'FNDCPASS apps/clone 0 Y system/clone ORACLE "' ||
replace(ORACLE_USERNAME,'$','\$') || '" clone'
from APPLSYS.FND_ORACLE_USERID
where READ_ONLY_FLAG = 'X'
and ORACLE_USERNAME in (select USERNAME from SYS.DBA_USERS);

REM Generate a shell script to set password for APPS/APPLSYS/APPM_mrc db users

select 'FNDCPASS apps/clone 0 Y system/clone SYSTEM APPLSYS clone' from dual;

REM Generate scripts for steps 4 & 5
spool off

HOST grep '^alter user ' step3.lst > dbusers4.sql
HOST grep '^FNDCPASS ' step3.lst > dbusers5.sh

exit

The script above calls grep to extract 2 sets of lines from the step3.lst spool file.

If you are running sqlplus on Windows, the shell redirection will fail when attempted from within sqlplus. You can perform this separation step by going to a command prompt (using the HOST command from sqlplus). If you have your MKS environment set, then you can use the grep syntax or alternatively you can use the below syntax from a cmd.exe prompt.

# alternative commands for extracting sql and shell commands from step3.lst
C:\ORACLE\Clone> findstr "^alter user " step3.lst > dbusers4.sql
C:\ORACLE\Clone> findstr "^FNDCPASS " step3.lst > dbusers5.cmd

Step 4 - Assign New Passwords to All Schemas Not Managed with EBS

This step runs the SQL script - dbusers4.sql - generated in step 3.

Sample content of dbusers4.sql listed below for illustration purposes only, you must run the one you generated on your system.


NOTE: dbusers4.sql example only!
alter user "OLAPSYS" identified by CLONE;
...
alter user "MDSYS" identified by CLONE;
alter user "ORDPLUGINS" identified by CLONE;
alter user "ORDSYS" identified by CLONE;
alter user "DBSNMP" identified by CLONE;
alter user "OUTLN" identified by CLONE;
alter user "AD_MONITOR" identified by CLONE;
alter user "EM_MONITOR" identified by CLONE;

Prior to running your script, you should review the contents for "obvious errors", this is good advice for any auto-generated scripts.


oracle$ sqlplus "/ as sysdba"


Now run the dbusers4.sql file

SQL> spool step4.lst
SQL> start dbusers4.sql
SQL> exit


The output should be a list of "User altered." lines - no error messages (ORA-nnnnn) should appear.

The database is currently running, shut it down and restart it.
To ensure that the application tier code can access the database for the 5th step you must also ensure that the database TNS-listener service is running.

oracle$ echo shutdown | sqlplus "/ as sysdba"
oracle$ echo startup | sqlplus "/ as sysdba"
oracle$ lsnrctl start

Step 5 - Assign New Passwords to All Schemas Managed with EBS

This step uses the FNDCPASS command to set the passwords for all the managed schemas and all the base product schemas. FNDCPASS must be run from an application tier node.

You need to copy the dbusers5.sh script from the working directory used by oracle in step 3.
As with any generated scripts that you run on your system, you should review the contents of the file before running it. Note for Windows users: In the unlikely event that any of the usernames contain the dollar sign "$" it has been escaped by prefixing it by a backslash "\"; on windows the backslash should be removed.

To run FNDCPASS you also need a number of environment variables set, at a minimum ensure that

  • FNDCPASS is on the shell's search PATH.

  • ORACLE_HOME points to the tools ORACLE_HOME

  • the TWO_TASK variable is set to a value that can be resolved via the $TNS_ADMIN/tnsnames.ora file to access the cloned copy of the database.

# Verify that the Oracle client environment is set to correct database
applmgr$ sqlplus apps/clone
sqlplus> select SYSDATE,NAME from v\$DATABASE;
SYSDATE NAME
--------- ---------
25-JUL-07 PRD12

applmgr$ mkdir ~/s5 ; cd ~/s5 # create new directory to hold output files
applmgr$ sh dbusers5.sh # Run the FNDCPASS shell script

Sample content of a dbusers5.sh file is listed below for illustration purposes only, run the one you generated on your system.

NOTE: dbusers5.sh example only!
   FNDCPASS apps/clone 0 Y system/clone ALLORACLE clone
FNDCPASS apps/clone 0 Y system/clone ORACLE "OWAPUB" clone
FNDCPASS apps/clone 0 Y system/clone ORACLE "ODM" clone
FNDCPASS apps/clone 0 Y system/clone ORACLE "CTXSYS" clone
FNDCPASS apps/clone 0 Y system/clone SYSTEM APPLSYS clone

Each run of FNDCPASS will generate output on the terminal and create a logfile in the current working directory, you should review these log files (example L2763902.log) for errors.

NOTE: If your version of FNDCPASS does not support the ALLORACLE mode, see Q5 in the Discussion section below.


To verify that you have assigned passwords to all the database users, run the following query and ensure that it does not return any rows.

SQL> select USERNAME,PASSWORD from DBA_USERS where PASSWORD='0000000000000000';


This concludes the clearing of account credentials from a cloned database - and the re-establishment of credentials such that the cloned database can be used for runtime and patch testing.

Additional Steps

What remains to be done is to set new passwords for additional applications users (fnd_users) or the creation of new test users, depending on what you need the cloned system for.
Changing passwords for applications users can be done using the Define User form (logged on as SYSADMIN/CLONE) or by calling FNDCPASS with the below syntax from an applmgr applications shell environment.

applmgr$ FNDCPASS apps/clone 0 Y system/clone USER  

Running AutoConfig

Before you can actually run the cloned EBS system, a number of other configuration items such as system profile options must most likely be changed for the cloned environment. Items to change typically include

  • IP addresses, hostnames and port numbers

  • Profiles containing hostnames and port numbers

    • Web interface URLs

    • Hostnames of external services (mail, print, SSO)

The cloning notes - listed in the References section below - will provide you with information on how to run AutoConfig.

AutoConfig must be run on all tiers of the cloned system to propagate password changes and other changed settings into config files.

Prior to running AutoConfig ensure that the AutoConfig CONTEXT file contains the new GUEST password and the new password for APPLSYSPUB.

Password for

A/C Variable

New Value

APPLSYSPUB

s_gwyuid_pass

CLONE

GUEST

s_guest_pass

CLONE