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