Monday, September 19, 2011

T-SQL Query designing on Microsoft SQL Server 2005

--Create Database


USE [Employee]
GO


CREATE TABLE employeetest
(employeeID int NOT NULL PRIMARY KEY,
FirstName nvarchar(50) NOT NULL,
LastName nvarchar(50) NOT NULL,
PhoneNumber int NOT NULL)


--Grouping Results using GROUP BY


SELECT Title,
COUNT (*) as EmployeeHavingTitle
FROM
HumanResources.Employee
GROUP BY 
Title




--Returning Unique Values using DISTINCT 
--DISTINCT >> To avoid duplicate records


SELECT DISTINCT 
Title
FROM
HumanResources.Employee


--combining Results using Union Operator


SELECT * FROM Production.ProductCategory
UNION
SELECT 5, 'Test Category',NEWID(), '02/02/2011'
UNION ALL
SELECT * FROM Production.ProductCategory




--Returning Differences using INTERSECT
--To display records which are 'common' between two queries


SELECT * FROM Production.ProductCategory WHERE ProductCategoryID IN (1,2,3,4)
INTERSECT
SELECT * FROM Production.ProductCategory WHERE ProductCategoryID IN (1,2,3)


--Returning Differences using EXCEPT
--To display records which are 'uncommon' between two queries


SELECT * FROM Production.ProductCategory WHERE ProductCategoryID IN (1,2,3,4)
EXCEPT
SELECT * FROM Production.ProductCategory WHERE ProductCategoryID IN (1,2,3)


/*Returining related data with JOIN conditions */


--Returning matching rows using the INNER JOIN condition


SELECT 
PC.Title as PersonTitle
PC.FirstName,
PC.LastName,
HE.Title as PositionTitle,
HE.VacationHours,
HE.SickLeaveHours
FROM
HumanResources.Employee HE
INNER JOIN
Person.Contact PC ON HE.ContactID = PC.ContactID
WHERE
HE.SalariedFlag = 1
ORDER BY
LastName, FirstName


--Returning all rows from one table using OUTER JOIN (RIGHT/LEFT) condition

SELECT 
PP.(Name),
PP.Rating,
PP.Comments
FROM
Production.Product PP
LEFT OUTER JOIN
Production.ProductReview PR ON PP.ProductID = PR.ProductID
ORDER BY
PP.(Name)


USE [master]
GO


IF DB_ID(N'employee') IS NOT NULL
DROP DATABASE employee
GO


--Creating a simple database
CREATE DATABASE (CS) ON PRIMARY
(
NAME = N'CS_data',
FILENAME = N'C:\Program files\Microsoft SQL Server\MSSQL.1\MSSQL\data\cs.mdf'
)
LOG ON
(
NAME = N'CS_log',
FILENAME = N'C:\Program files\Microsoft SQL Server\MSSQL.1\MSSQL\data\cs.ldf'
)


--Creating a database with filegroups
CREATE DATABASE (CS) ON PRIMARY
(
NAME = N'CS_primary1',
FILENAME = N'C:\Program files\Microsoft SQL Server\MSSQL.1\MSSQL\data\cs_primary1.ndf'
)




USE [ktm]
/* Creating Tables */
--Create Train table
CREATE TABLE trains(
TrainID int IDENTITY(1,1) NOT NULL,
Source nvarchar(100) NOT NULL,
Destination nvarchar(100) NOT NULL,
StartDate smalldatatime NOT NULL CONSTRAINT DF_Train_Date DEFAULT (getdate()),
RunningFlag bit NULL CONTRAINT DF_Train_RunningFlag DEFAULT (1),
CONTRAINT PK_Train PRIMARY KEY CLUSTERED (TrainID) ON [PRIMARY])


--Create CCTV table
CREATE TABLE cctv
VideoID int IDENTITY(1,1) NOT NULL,
SeriesID smallint NOT NULL,
VideoName nvarchar(100) NOT NULL,
Lenth float NOT NULL,
[size] numeric (2,2) NOT NULL,
CreationDate datetime NOT NULL,
CONTRAINT PK_cctv PRIMARY KEY CLUSTERED (VideoID) ON [PRIMARY])


--Create Ticket table
CREATE TABLE cctv
TicketID int IDENTITY(1,1) NOT NULL,
Source nvarchar(100) NOT NULL,
TicketCounterNumber int NOT NULL,
Price money NOT NULL,
VideoID int NOT NULL,
CreationDate datetime NOT NULL,
CONTRAINT PK_Ticket PRIMARY KEY CLUSTERED (Source) ON [PRIMARY])


--Create Data Types
--Create IC Number for malaysians
CREATE TYPE ICN varchar(12) NULL


/*Creating Defaults */
--Create Default for an empty IC number
CREATE DEFAULT DF_ICN AS '123-20-19901'


/*Creating Check Constraints */
--Add check constraint to StartDate column of Trains
ALTER TABLE Train1 WITH CHECK ADD CONSTRAINT CK_TrainCheckDate CHECK (StartDate>='1/1/1990')


USE [AdventureWorks]
GO
--Creating Non-Clustered Indexes
CREATE NONCLUSTERED INDEX [IX_HR_Employee] ON [HumanResources].[Employee] 
([Title] ASC, [BirthDate] ASC)
WITH
(PAD_INDEX = OFF,
SORT_IN_TEMPDB = OFF,
DROP_EXISTING = OFF,
IGNORE_DUP_KEY = OFF,
ONLINE = ON) ON [PRIMARY]


--Creating Standard Views
CREATE VIEW HumanResources.vEmployeeTime
AS
SELECT 
hre.EmployeeID,
pc.FirstName,
pc.LastName,
hre.Title,
hre.VacationHours,
hre.SickLeaveHours
FROM
HumanResources.Employee hre
JOIN
Person.Contact pc ON hre.ContactID = pc.ContactID
WHERE
SalariedFlag = 1
AND
CurrentFlag = 1




--Creating Indexed Views
CREATE VIEW Sales.vixAllTimeSales
WITH SCHEMABINDING
AS
SELECT 
pr.Name,
SUM(sod.OrderQty) as TotalQuantity,
SUM(soh.SubTotal) as TotalSales,
COUNT_BIG(*) as NumSales
FROM
Production.Product pr
INNER JOIN
Sales.SalesOrderDetail sod ON pr.ProductID = sod.ProductID
INNER JOIN
Sales.SalesOrderHeader soh ON sod.SalesOrderID = soh.SalesOrderID
WHERE
pr.ProductSubcategoryID = 1
GROUP BY
pr.Name
Go




--Creating Unique Clusterd Index


CREATE UNIQUE CLUSTERED INDEX IX_AllTimeBikeSales
ON Sales.vixAllTimeBikeSales (Name)

SELECT * FROM Sales.vixAllTimeBikeSales




--Creating Partitioned Views


--Distributed Partition Views


--Server1


CREATE TABLE sales.Customers_west
(
CustomerID int PRIMARY KEY,
TerritoryID int CHECK (TerritoryID BETWEEN 1 AND 5) NULL,
CustomerType nchar (1) NOT NULL
)


INSERT Sales.Customers_west
(CustomerID, TerritoryID, CustomerType)
SELECT 
CustomerID, TerritoryID, CustomerType
FROM 
sales.Customer
WHERE 
TerritoryID BETWEEN 1 AND 5


CREATE VIEW Sales.vCustomers
AS
SELECT * FROM Sales.Customers_West




/* Creating Stored Procedures */


--Basic Stored Procedure


CREATE PROCEDURE Sales.spGetYearlyBikeSales
AS
SELECT
pr.Name,
YEAR(soh.OrderDate) as SalesYear,
SUM(sod.OrderQty) as TotalQuantity,
SUM(soh.SubTotal) as TotalSales
FROM
Production.Product pr
INNER JOIN
Sales.SalesOrderDetail sod ON pr.ProductID = sod.ProductID
INNER JOIN
Sales.SalesOrderHeader soh ON sod.SalesOrderID = soh.SalesOrderID
WHERE 
pr.ProductSubcategoryID = 1
GROUP BY
pr.Name, YEAR(soh.OrderDate)
ORDER BY
pr.Name, YEAR(soh.OrderDate)



Sales.spGetYearlyBikeSales




--Stored Procedure with Input Parameters


CREATE PROCEDURE sales.spGetYearlyProductSalesByID
@ProductCategoryID int
AS
SELECT
pr.Name,
YEAR(soh.OrderDate) as SalesYear,
SUM(sod.OrderQty) as TotalQuantity,
SUM(soh.SubTotal) as TotalSales
FROM
Production.Product pr
INNER JOIN
Sales.SalesOrderDetail sod ON pr.ProductID = sod.ProductID
INNER JOIN
Sales.SalesOrderHeader soh ON sod.SalesOrderID = soh.SalesOrderID
WHERE 
pr.ProductSubcategoryID = @ProductCategoryID
GROUP BY
pr.Name, YEAR(soh.OrderDate)
ORDER BY
pr.Name, YEAR(soh.OrderDate)


EXEC sales.spGetYearlyProductSalesByID 4


--Stored Procedure with using wild cards


CREATE PROCEDURE HumanResources.spGetEmployeeByName
@FirstName nvarchar(50) = '%',
@LastName nvarchar(50) = '%'
AS
SELECT
pc.Title,
pc.FirstName,
pc.Lastname,
pc.EmailAddress,
pc.Phone,
hre.BirthDate,
hre.HireDate
FROM
HumanResources.Employee hre
JOIN
Person.Contact pc ON hre.ContactID = pc.ContactID


WHERE
pc.FirstName LIKE @FirstName + '%'
AND
pc.LastName LIKE @LastName + '%'


EXEC HumanResources.spGetEmployeeByName DEFAULT,'a'


/* Creating User-defined Fuctions */


--Creating SCALAR Fuctions


CREATE FUNCTION ufnFormatCurrency (@Amount Money)
RETURNS VarChar(100)
AS
BEGIN
RETURN '$' + CONVERT(VarChar, CONVERT (Money, @Amount),1)
END

---Usage


SELECT 
p.Name,
soh.OrderDate,
soh.SubTotal as SubTotalWithoutFuction,
dbo.ufnFormatCurrency(soh.SubTotal) as SubTotal,
dbo.ufnFormatCurrency(soh.TaxAmt) as TaxAmount,
dbo.ufnFormatCurrency(soh.Freight) as Freight,
dbo.ufnFormatCurrency(soh.TotalDue) as TotalDue
FROM
Sales.SalesOrderHeader soh
JOIN
Sales.SalesOrderDetail sod ON soh.SalesOrderID = Sod.SalesOrderID
JOIN
Production.Product p ON sod.ProductID = p.ProductID
WHERE
Year(soh.OrderDate) = 2004



---Data Access Scalar Function


CREATE FUNCTION ufnGetProductStock (@ProductID int)
RETURNS int
AS
BEGIN
DECLARE @ret int

SELECT
@ret = SUM(ppi.Quantity)
FROM
Production.ProductInventory ppi
WHERE
ppi.ProductID = @ProductID
IF (@ret IS NULL)
SET @ret = 0
RETURN @ret
END


--Usage


SELECT 
Name,
dbo.ufnGetStock(ProductID) AS Supply
FROM 
Production.Product




---Data Access Scalar User Defined Function


CREATE FUNCTION ufnGetProductStock (@ProductID int)
RETURNS int
AS
BEGIN
DECLARE @ret int

SELECT 
@ret = SUM(ppi.Quantity)
FROM 
Production.ProductInventory ppi
WHERE
ppi.ProductID = @ProductID
IF (@ret IS NULL)
SET @ret = 0
RETURN @ret
END


---Usage 
SELECT 
Name,
dbo.ufnGetProductStock(ProductID) AS Supply
FROM
Production.Product




--Creating Inline Table - Valued Functions


CREATE FUNCTION sales.ufnStoreYTDSales (@StoreID int)
RETURNS Table
AS
RETURN
(
SELECT
p.Name,
SUM(sod.LineTotal) AS YTDSales
FROM
Production.Product AS p
JOIN
sales.SalesOrderDetail AS sod ON sod.ProductID = p.ProductID
JOIN
sales.SalesOrderHeader AS soh ON soh.SalesOrderID = sod.SalesOrderID

WHERE 
soh.CustomerID = @StoreID
GROUP BY
p.ProductID, P.Name
)




---Usage 
SELECT * FROM Sales.ufnStoreYTDSales(1)

---Creating a Parameterized View From an Inline Table-Valued Function


CREATE FUNCTION Sales.ufnStoreWithDemographics (@StoreID int)
RETURNS Table
AS
RETURN
(
SELECT
*
FROM
Sales.vStoreWithDemographics
WHERE
CustomerID = @StoreID
)

--Usage


SELECT * FROM Sales.ufnStoreWithDemographics(1)


/* Working with TABLE Encryption */


--Encryption


ALTER FUNCTION ufnFormatCurrency (@Amount Money)
RETURNS VarChar(100)
WITH ENCRYPTION
AS
BEGIN
RETURN '$' + CONVERT(VarChar, CONVERT(Money,@Amount),1)
END




NOTE: All above queries are tested using built-in tables, databases & templates of Microsoft SQL 2005. Some are self-created. 
[Source Reference: Nuggets for SQL 2005]

Monday, September 12, 2011

ZFS in Sun (Oracle) Solaris 10


Zettabyte File System(ZFS)
====================

Major Feature:

>> 256 quadrillion zettabytes

What is Zettabytes?
(Terabytes-Petabytes-Exabytes-Zettabytes)

which zpool

zpool list  - lists pools

zpool create pool1 c0t1d0

Full disk in Pool

mount

/pool1 rw

ls -l /pool1

zpool list

Zpool Pool Status:
Online
Degraded
Faulted
Offline
Unavailable
zfs list

zfs mount

zpool status

zpool status -v pool1

zpool destroy pool1 (to remove)

zpool status

zpool create pool1 c0t0d0

Creating File System Under pool:

zfs create pool1/home

zfs list

SET QUOTA...

zfs set quota=1G pool1/home

zfs list

Creating Userbased file system under pool1/home

zfs create pool/home/u1

zfs set quota=500M pool1/home/u1

zfs list

zfs get -r quota pool1

zfs get -r compression pool1

<There are lots of Variables like that>

Adding Storage:

zpool add pool1 c0t2d0

Configuring DNS(BIND) in Sun (Oracle) Solaris 10


CONFIGURING BIND DNS SERVER:
==============================

pkginfo -x |grep -i bind

SUNWbind  - main Bind package
SUNWbindr - Service management

pkgchk -l SUNWbindr

pkgchk -l SUNWbind

dig mail.yahoo.com

dig mail.yahoo.com ns

dig mail.yahoo.com mx

By default /var/named and /etc/named.conf does not exist

create /etc/named.conf



options {
directory "/var/named";
};

###Special zone of root of DNS###

zone "." {
type hint;
file "db.cache";
};

###Reverse zone###

zone "0.0.127.in-addr.arpa" {
type master;
file "db.127.0.0";
};

zone "0.16.172.in-addr.arpa" {
type master;
file "db.172.16.0";
};

###Forward Zone###

zone "unix.com" {
type master;
file "db.unix.com";
};

Save and exit

Download hint file,

mkdir /var/named

cd /var/named/

wget ftp://ftp.rs.internic.net/domain/named.root

ls -l

mv named.root db.cache

Creating Zone Files:

>> reverse lookup zone

gedit /var/named/db.127.0.0

@ IN SOA pc1.unix.com. root.unix.com. (
2011062001 ; Serial number
7200 ; Refresh Interval
3600 ; Retry Interval
86400 ; Expiry
600 ); Minimum TTL

NS pc1.

1 IN PTR localhost.

save & exit

gedit /var/named/db.172.16.0

@ IN SOA pc1.unix.com. root.unix.com. (
2011062001 ; Serial number
7200 ; Refresh Interval
3600 ; Retry Interval
86400 ; Expiry
600 ); Minimum TTL

NS pc1.

1 IN PTR pc1.

##1 is for 172.16.0.1##

save & exit

gedit /var/named/db.172.16.0

@ IN SOA pc1.unix.com. root.unix.com. (
2011062001 ; Serial number
7200 ; Refresh Interval
3600 ; Retry Interval
86400 ; Expiry
600 ); Minimum TTL

NS pc1.

1 IN PTR pc1.

##1 is for 172.16.0.1##

save & exit


gedit /var/named/db.unix.com

@ IN SOA pc1.unix.com. root.unix.com. (
2011062001 ; Serial number
7200 ; Refresh Interval
3600 ; Retry Interval
86400 ; Expiry
600 ); Minimum TTL

NS pc1.

pc1 IN  A 172.16.0.1
pc2 IN  A 172.16.0.2


save & exit

svcadm enable dns/server

svcs -l dns/server

dig @localhost pc1.unix.com


vi /etc/resolv.conf

domain unix.com
search unix.com
nameserver 172.16.0.1
nameserver 8.8.8.8

dig @localhost www.google.com
1655ms


dig @localhost www.google.com
1ms

NOTE: Always works as caching-only NS


gedit /var/named/db.unix.com

@ IN SOA pc1.unix.com. root.unix.com. (
2011062002 ; Serial number
7200 ; Refresh Interval
3600 ; Retry Interval
86400 ; Expiry
600 ); Minimum TTL

NS pc1.unix.com.

    IN  MX  10 pc1.unix.com.

pc1 IN  A 172.16.0.1
pc2 IN  A 172.16.0.2


save & exit


svcadm restart dns/server

dig @localhost pc1.unix.com mx


gedit /var/named/db.unix.com

@ IN SOA pc1.unix.com. root.unix.com. (
2011062003 ; Serial number
7200 ; Refresh Interval
3600 ; Retry Interval
86400 ; Expiry
600 ); Minimum TTL

NS pc1.unix.com.

    IN  MX  10 pc1.unix.com.

pc1 IN  A 172.16.0.1
pc2 IN  A 172.16.0.2
www CNAME ns1.unix.com.

save & exit

svcadm restart dns/server


dig @localhost www.unix.com cname

Volume manger and RAID 0,1 and 5 configuration in Sun (Oracle) Solaris 10


VOLUME MANAGER & RAID 
=======================

1.Volume Types:
RAID 0
Concatenation or stripe
RAID 1
mirror
RAID 5
Stripting with Parity
2. Soft partitions - LARGE STORAGES

3. Hot Spare pools - Spare storage to use when Raid1 or 5 has failed

4. State datebase Replica - Must be created to created volumes

5. Data sets - Used for Clustering Solaris / failover

Can not create volumes using format



HOW TO CREATE SDR

wbem service should be running

check using,

/etc/init.d/init.wben status
running on port 898

which smc

smc

This computer>Storage>Enhanced storage

[supply root password]

Volumes Hotsparepool SDR datasets

mount

df

GO TO SDR

Action>create replica

Diskset > do nothing   >> NEXT

Slices ...

select slice is not mounted in MOUNT Command

IF not present Create few from format command

run smc again

refresh

c0t1d0s0 and c0t1d0s1

select 2 slices

8192 x 2

Select one if you want

Once you have two SDR created check from SDR

CREATING RAID0
==============

c0t1d0s0
c0t2d0s0

Make sure Two disks/slices have SDR

smc

Volumes > Create new volume

Don't create replica

Concatetination RAID0

NOTE: it writes data one of one, only when first is full



STRIPE RAID0

Note: It writes both disks/slices togather (for performances)

Select STRIPE RAID0

volume name d0

will create /dev/md/dsk/d0

SELECT both slices that you have created

NOTE : SAME SIZE in Stripe

next

NO HOT SPARE POOL

next

Command in CMD:

/usr/sbin/metainit d0 1 2 c0t1d0s0 c0t2d0s0

finish

Check RAID0 of d0 in volumes

Right click and properties ... Show..

To format

newfs /dev/md/rdsk/d0

mkdir /raid1

mount /dev/md/dsk/d0 /raid1

df -h

gedit /etc/vfstab

/dev/md/dsk/d0 /dev/md/rdsk/d0 /raid1 ufs 2 yes -

save and exit



properties of SDR

you must see a u

active and up to date

CREATING RAID 1 (Mirror):
======================

umount /raid1

smc

delete last created RAID0

Volume>Create volume

Follow same wizard

Select RAID1 (Mirror)

No hot spare pool

Command line tool,

metainit d0 1 1 c0t1d0s0

NOTE: 1 slice only

next next finish

refresh

Follow same step for one

Stripe 0

d1

command line tool,

metainit d1 1 1 c0t2d0s0

Now should be able to see two volumes

HOw to create mirror

Create volume:

No SDR

Select : Mirror

d2

d0 and d1 Concatination RAID0

select first for Source

Select Target for destination

READ Option: Round Robin
Write : Paralle
Passnumber:1

next

Command line tool,

metainit d2 -m d0
metattach d2 d1

finish

d2

properties :

Size is half of total amount of space

we can add and deattach sub-mirrors

newfs /dev/md/rdsk/d2

mkdir /mirror

mount /dev/ms/dsk/d2 /mirror

df -h


gedit /etc/vfstab

/dev/md/dsk/d2 /dev/md/rdsk/d2 /mirror ufs 2 yes -

save exit


Creating RAID 5(Stripe with parity):
==========================

Make sure you have three slices

umount /mirror

Delete all volumes

Volume> Create volumes

select RAID5

Volumename:

d0

c0t1d0s0 10gb
c0t1d0s1 10gb
c0t2d0s0 10gb

select three SAME SIZE slices

next

interface 16kb

no Hot spare pool

command line tool,

metainit d0 -r c0t1d0s0 c0t1d0s1 c0t2d0s0

finish

refresh

d0

20gb

10+10+10 = 20 GB in RAID5

****

which metastat

metastat d0

status ....

newfs /dev/md/rdsk/d0

mkdir /raid5

mount /dev/md/dsk/d0 /raid5


gedit /etc/vfstab

/dev/md/dsk/d0 /dev/md/rdsk/d0 /raid5 ufs 2 yes -

Patch Management in Sun (Oracle) Solaris 10


Patching Solaris 10 using Shell/GUI: 

Register your copy of Solaris first on a website(some cases its free)

Update Manager is used for Updating Solaris>>

Applications>Utilities>Update Manager

which updatemanager

/usr/bin/updatemanager

[Use Update manager to Register]

Its a GUI TOOL!! :)

Fill up the form!

and SUN SUBCRIPTION KEY

No compulsory to type key (NOTE: Without key it limit updates)

Continues without KEY

Finish

Checks for latest patches which is applicable

Default DIRECTORY for downloading patches is :

/var/sadm/spool

[Can change from Preference option in GUI]

tick mark on patch to download and install

you will see 12912.jar.tmp

[tmp means its still downloading]
NOTE: Look for smaller size patch for demo

Clicking the patch will give discription

We can download patches manually from,

http://Sunsolve.sun.com

open in mozilla and look for SunOS and patch num

[Only look for x86 versions]

Command Version of PATCH management:

[smpatch  - CLI of update manager]

smpatch analyze   - Analysis of patches

Patchid - Built - Description

Dump everything into a text file and use it for updating

smpatch analyze > patch_list.txt



ls -ltr patch_list.txt

smpatch analyze -x idlist=patch_list.txt

[This command processes only patches available in the list]

NOTE: Keep 1 or 2 names only


smpatch analyze -i 121309-03

>>To check dependancies

smpatch download -i 121309-03

>> This will download and store in /var/sadm/spool



smpatch add -i 121309-03

>> for installing specific patch

After installing check in updatemanager

smpatch get

>> to see variables of Updatemanager

cd /var/sadm/spool/patch

ls -ltr

cd 121309-03

tail log

>> displays log file related to specific log

smc

management tools> System config> patches

here shows list of installed patches

Action>Add patch

local or remote location

patchadd >> This command is to install unsigned patches


LOOK FOR UNSIGNED PATCH and COPY the ID
http://sunsolve.sun.com

Download specific patch using PATCHFINDER

unzip 122670-01.zip

patchadd /tmp/122670-01

patchadd -p

>> printing all installed patches

patchrm 122670-01

>> to remove installed patch

use Updatemanager to verify

smpatch update

to check / validated patches

shows installed patches

Package Management in Sun (Oracle) Solaris 10


Shell based Package management:

pkginfo|add|rm|chk

pkginfo - information of package
pkgadd - to install package
pkgrm - to remove package
pkgchk - to check package

pkginfo::

pkginfo - all installed packages

pkginfo -l |less

pkginfo -l SFWblue

pkginfo -x |grep - i emacs

To search installed specific packages

pkginfo -i |grep -i emacs

pkgchk ::

pkgchk -v SFWblue  -lists files included in package

pkgchk -lp /opt/sfw/bin/bluefish
  - which a packge this file belongs to?


pkgadd:::

To download free packages:
www.sunfreeware.com
www.blastwave.org/mirrors.php


pkgadd -d  tO install packgages


Spool directory: /var/spool/pkg


Download one package from www.sunfreeware.com

or use DVD


Right click on packge and "Copy link location"
using nano

wget <control+v>


Downloaded packages
:


pkgadd -d nano-1.2.4.*

Configuring SWAP partition in Sun (Oracle) Solaris 10


Creating/Adding Swap file: 

which swap

swap -l     : lists swap devices/space

swap -s     : lists total and used swap space


mkfile 512m /data2/swap2


cd /data2

ls -ltr


file swap2

swap -a /data2/swap2

[to add swap file to swap]

swap -l
swap -s

mounting in vfstab

/data2/swap2 - - swap - no -

How to remove swap file?

swap -d /data2/swap2

format> partition

Creating Swap partition:

swap -a /dev/c0t1d0s6

swap -l

swap -s


Partitioning in Sun (Oracle) Solaris 10

How to Create Paritition and Mount in Solaris 10?


Partitions are called 'Slices' in Solaris

df

df -h

VTOC = volume Table of contents

<FDISK not required in SPARC, because of using SCSI>

***SLICES rules in x86 using VTOC***
~ Maximum 10 slices (0 to 9)
~ Slices 2,8,9 are reserved
~ slice 2 - VTOC (Disk's label and Slices OS) So can't change
~ slices 0,1,3,4,5,6,7 allowed to used (total 7)

/dev/dsk/c0t0d0s0

's0' is reserved for root mount point
 run 'df' to check allocations

prtvtoc /dev/dsk/c0t0d0s0

/dev/dsk/c0t0d0s0

c0 : First controller
t0 : First Target (Only of SCSI Used)
d0 : First DISK
s0 : First Slice (1st partition)

ls -l /dev/dsk/c0t0d0*

format

0

FORMAT MENU:

q

cat /etc/vfstab

format

0

format> disk

format> ?

format> current

format> fdisk

CREATE PARTITION
DELETE PARTITION
..SO ON..

delete first if any...

no partitions

format> fdisk

y

Got first parition

5

format> partition

partition> print

4 Unassigned wm   0   -   0

partition> 4

Partition id tag[unassigned]
partition permission[wm]
new start cyl[0]
size [0b,0c] 5gb

partition> print

partition> quit

format> save


format> quit

To format slices:

newfs /dev/rdsk/c0t1d0s4

To automatically mount file systems during booting process:

gedit /etc/vfstab

/dev/dsk/c0t1d0s4  /dev/rdsk/c0t1d0s4 /data1  ufs 2 yes  -

To verify:

mount -a

df


Configuring Network in Sun (Oracle) Solaris 10


In order to enable Networking in Sun Solaris 10, first we have to assign IP address.


bash

cat /etc/hostname.e1000g0

<if DHCP enabled NIC card, there is no IP address>

create DefaultDomain file

cat /etc/inet/networks
 
   172.16.0.0/255.255.0.0

<Only update if subnetting used>

cat /etc/hosts

172.16.0.2 pc1

netstat -D     : DHCP config for all nics
ifconfig -a     : config for all nics

ifconfig e1000g0 dhcp status

<shows dhcp status>

cd /etc

ls -ltr hostname.e1000g0

ps -ef |grep -i agent
/sbin/dhcpagent

netstat -rn

cat hostname.e1000g0

echo "192.168.1.1" > hostname.e1000g0 && echo $?

cat hostname.e1000g0

echo "linux.com" > /etc/defaultdomian

gedit /etc/inet/networks

192.168.1.0 255.255.255.0

gedit /etc/hosts

192.168.1.2 pc1

gedit /etc/resolv.conf
nameserver 8.8.8.8

<default router is given by DHCP, so no file>

ls -ltr /etc/defaultrouter

gedit /etc/defaultrouter
192.168.1.1

reboot


restart to make changes


<If there is no Internet Connectivity, edit the following>

gedit /etc/nsswitch.conf
hosts : files dns

Wednesday, July 20, 2011

Interview Questions for 'Network Support' position










Q. Please describe the importance you place on customer service versus technical skills.

A. Most interviewers like to start with big picture questions and then work their way into more technical areas. IT is a service organization and customer service is at its core. In particular, customer service skills are just as important as technical skills, particularly in panic situations when systems are down or the user has just deleted their board  resentation that’s due in 30 minutes. We’ve all had these situations. You should be prepared to talk about a specific situation where you’ve excelled and received accolades from an end-user. If they put it in writing, mention that as well.
Q. What steps do you take when troubleshooting a networking issue?

A. As a support technician, your job is to solve problems. This question provides the interviewer with insight into your troubleshooting skills. Of course, the most important part of troubleshooting any problem is to divide the tasks of problem resolution into a systematic process of elimination, like this:
1. Define the problem.
2. Gather detailed information.
3. Consider probable cause for the failure.
4. Devise a plan to solve the problem.
5. Implement the plan.
6. Observe the results of the implementation.
7. Repeat the process if the plan does not resolve the problem.
8. Document the changes made to solve the problem.
Be prepared before the interview, so you can provide an example of these skills in action.
Q. How would you prioritize support issues?

A. It is unlikely that as a network administrator or technician you will receive problem calls one at a time. Typically, when you receive one call, you already have three people waiting for service. For this reason, you must learn to prioritize. Your answer to this question will provide the interviewer with insight into how effectively you prioritize. It’s not a trick question, though sometimes it can feel that way. You probably have a process that you use instinctually. Talk about it. It probably includes many of the following components:
o    Total network failure (affects everyone)
o    Partial network failure (affects small groups of users)
o    Small network failure (affects a small, single group of users)
o    Total workstation failure (single user can’t work at all)
o    Partial workstation failure (single user can’t do most tasks)
o    Minor issue (single user has problems that crop up now and again)

Q. Users can send e-mail locally, but cannot send e-mail to external recipients. How would you troubleshoot this situation?

A. The interviewer will run you through a series of questions like this one to see how you would use your troubleshooting skills in a common, real-life situation. He not only gets to see how your mind works, but also begins to get an insight into your technical capabilities. In your answer, be methodical in your approach, identifying the most likely possibility and testing it. Be sure to let the interviewer know that if your first attempt doesn’t work, you know how to move on to the next possibility.


Q. A user complains that when she prints a document in any application, the printer prints garbage. What is the most likely cause of the problem?

A. This question starts the behavioral interviewing questions based on real-life situations that assess your problem-solving skills and your technical skills. They will range from the general (like this question) to very specific technical questions that determine your knowledge level and skill set. Don’t worry if you don’t have all the answers. The interviewer is mostly interested in how you would resolve the situation and what resources you would use to do so.


Q. A user’s roaming profile is not accessible. Describe how you would solve this problem.

A. This question tests your troubleshooting skills. In this situation you may want to talk about which tests you would perform in order to resolve the issue. These may include:
o    Ensuring that the path to the profile directory is correct on the user’s account properties.
o    Ensuring that the server where the profile resides is accessible.
o    Ensuring that the user has Full Control permissions to the Profile directory.

Q. A user has left the company and you need to create a new user with the same rights and permissions. Please describe some of the ways to create the new user.

A. This question tests your ability to get the job done in the most efficient way possible. For example, you can create new accounts from scratch and assign the original rights to the accounts or you can simply rename the old account for the new user, which saves you a lot of time and effort.
Q. What are the first things you check when a user is experiencing problems accessing the network?

A. This question assesses your basic network troubleshooting skills. You can’t miss this one! You should be able to answer it in your sleep. You can liven up the interview by providing a funny story about user errors that you’ve encountered.
Q. What tools do you have available to you for troubleshooting?

A. At this point, the interviewer is testing your resourcefulness. This is a pretty generic question, so make sure that your answer is consistent with the overall theme of the interview. The tools available may include server log files, network analyzers, error messages, README files, telephone support, or vendor technical support web sites or CD-ROMs. Don’t forget to mention vendor-specific resources that you may use, like TechNet Online, or any other subscriptions that you may have in your bag of tricks. The final resource is of course your colleagues who may have run into this situation in the past.
Q. A user cannot access the local intranet. What would you try first in helping to determine how to narrow the problem down to the intranet?

A. Don’t make this question harder than it really is. Sometimes the interviewer will try to trip you up to test your common sense. Go for the obvious, rather than complicating the situation. In this case, simply trying to access the intranet from another workstation would help isolate the problem to the machine.
Q. Several users can’t log in to the server. What would you do to narrow the problem down to the workstations, network, or server?

A. The situation gets a little more interesting. Again, keep it simple, such as checking the serverconsole for user connections to see if other users are able to log into the server. If they can, the problem is most likely related to those users’ workstations. If they can’t, the problem is either the server or network connection.


Q. Which software troubleshooting tool could you use to determine which protocol is configured with the wrong address?

A. Questions like these assess your knowledge of troubleshooting tools that can help you resolve problems faster. In this case, a typical tool used to determine incorrectly configured addresses is a protocol analyzer. It can be used to examine the details of packets as they travel across the wire. This is a sophisticated tool that requires a deeper understanding of network protocols. Any interviewer will be impressed if you’ve used such a tool in troubleshooting.
Q. Which hardware troubleshooting tool(s) could you use to find out where a cable is routed?

A. Here’s another question regarding troubleshooting tools. In this case you might want to use a tone generator and tone locator to find out where cables are routed. These tools are alternately known as fox and hound devices. These are more advanced tools that represent a higher skill level. Whenever possible, provide an example of a sticky situation where you’ve had to rely on tools such as these for troubleshooting.
Q. Which Windows NT utility do you use to manage the major Windows NT log files?

A. Typically, the interviewer or someone more technical than the IT manager will ask you detailed operating system–specific questions to assess your knowledge of the various products. Alternately, you may be asked to take an assessment exam like Brainbench.
Q. A user calls you, complaining that he can’t access the corporate intranet web server. You try the same address, and you receive a Host Not Found error. Several minutes later, another user reports the same problem. You can still send e-mail and transfer files to another server. What is the most likely cause of the problem?

A. The interviewer will assess your skills as they relate to all aspects of networking, not just servers. This means you should be prepared to answer questions on web servers as well as local networks. In this case, because other people are experiencing the problem, the problem is most likely either network- or server-related. And because you can transfer files to and from another server, it can’t be the network. Thus, the problem is related to the web server.
Q. You are connecting a cubicle farm to your network. You install NICs in all the
workstations and run cables to a workgroup hub. You then connect the MDI port on the workgroup hub to the main hub with a standard patch cable. Upon powering up the cubicle farm computers, none of them can see the servers on the network. What could you replace to solve this problem?

A. Networking devices like hubs, switches, and routers will also be part of the technical interview. It is expected that you can speak fluently on both software and hardware issues.
Q. A user from the marketing department calls complaining that she can’t log in or see any servers on the network. Her computer operates fine otherwise. No other users from the marketing department are reporting any problems. What is the first thing you could check?

A. You should also expect to be assessed on your knowledge of the physical layer of the OSI model.
Q. You are working alone when the following calls come in:
The CEO can’t access his e-mail.
  • Your good friend can’t print.
  • A crabby user can’t log in to the network.
  • The Internet router goes down.
  • What would you do in this situation?

A. The interviewer is testing your ability to prioritize very difficult situations. Don’t worry, it’s not a trick question—you just need to apply your prioritization skills. Another critical part of this situation is the proper setting of expectations so the users who don’t end up at the top of the list aren’t upset with you. In providing your answer, don’t forget that you are part of a team. You do have the ability to delegate support to other team members while you handle the most critical task. In this situation, at the top of the list is getting the Internet router back up, because it affects the most number of people. Assisting other people can be delegated to other team members.
Q. You are installing a Windows XP–based TCP/IP network. You accidentally set workstation B to the same IP address as workstation A. Which workstation(s) will receive an error message?

A. This type of question assesses your TCP/IP configuration knowledge. It’s a common problem, but a little tricky based on the configuration mentioned above. The correct answer here is that through broadcasts, both workstations will detect if there is a duplicate IP address on the network and will display error messages to that effect.
Q. Which TCP/IP utility is most often used to test whether an IP host is up and functional?

A. TCP/IP is at the core of just about every network today. You must be familiar with the most often used commands for managing this network environment. This includes Ping, ipconfig, FTP, and tracert. You should also be ready to apply these commands and utilities to various situations, as the next question demonstrates.
Some sample additional questions include:
Which utility can you use to find the MAC and TCP/IP address of your Windows NT or 2000 workstation?
Which program can you use to upload and download files to a Unix server?
Which utility can you use to verify a packet’s path?
Q. You are the network administrator. A user calls you complaining that the performance of the intranet web server is sluggish. When you try to ping the server, it takes several seconds for the server to respond. You suspect the problem is related to a router that is seriously overloaded. Which workstation utility could you use to find out which router is causing this problem?

A. The answer here is the tracert utility, which will tell you which router is having the performance problem and how long it would take to travel between each host. You should be knowledgeable on the application of the most common IP commands for the various operating systems you support. Other questions along this line that you may run into include:
Which ipconfig switch will display the most complete listing of IP configuration information for that station?
Which Windows TCP/IP utility could you use to find out whether a server is responding on TCP port 21?
Q. Depending on the Windows client operating system version, which commands can you use to find out what is installed on a system?

A. You may run into operating system–specific questions like this one as you are being interviewed by prospective peers. You should be familiar with the most common commands. Don’t worry about memorizing command syntax. That’s what the /? is for.
Q. Which power condition occurs when the voltage level drops below 120 volts and stays below for an extended period of time?

A. Questions about power conditions don’t rank very high, though they are important. Network support technicians will be faced with many different scenarios. Be familiar with these types of conditions just in case.

Q. You are setting up a workstation for remote access to the office. The office has a modem pool configured, and it is working correctly. The required results are that the workstation and modem bank must establish a connection and that the server at the office must authenticate the workstation. Optionally, the workstation and office must be able to communicate by using a single protocol, and the workstation must be able to access all network devices at the office. The proposed solution is to install a POTS telephone line, modem cable, and modem connected to the workstation. How would you configure the protocols to achieve the desired results?

A. A question like this tests your ability to determine the best protocol solution for a given situation. With so many options available to network engineers, it’s important to understand the benefits and common denominators that will best fit a situation. In this case, TCP/IP would be the best solution. With TCP/IP installed and configured on the workstation, and TCP/IP with DHCP, as well as IPX, installed and configured on the office server, you have a common protocol for communication.