QR Code – A new model of bar code

19 08 2008

Title in portuguese: “QR Code – O novo modelo de código de barra”

I found a QR Code in my company and I needed to decode the message. Of course, I did not know that the image was a QR Code. I searched about this and I found an interesting technology that I was not aware of it.

QR code is a matrix code (two-dimensional bar code) that is getting very used around the world. QR code was created by a Japonese company “Denso-Wave” in 1994. This technology delivers a technique to decode a two-dimensional bar code at a high speed. That is the reason of the name “Quick Response Code”.

Better than a traditional bar code, QR also has a great store capacity:

Numeric only – 7089 Characters

Alphanumeric – 4296 Characters

QR Code is very powerful because you can store a variety of information on this, for examle, customer name and address in only one tag.

Also, the simple way to read a QR Code is influencing this technology utilization. Using a simple mobile with a VGA cam and a simple software you can decode and read a QR Code tag anywhere.So, you can use your mobile or a PC with webcam to decode any QR Code today. (Download it for your mobile @ http://reader.kaywa.com)

Here you can see a comercial from QR Code in Japan.

Some companies are using this technology as part of marketing Ads. In Brazil, Fast Shop (www.fastshop.com.br) was the first company to use this kind of interactivity in marketing Ads. Also, Pet Shop Boys launched a Video Clip using QR Code:

I am reading some articles and I noticed the impact of this technology for Augmented Reality. This provides an instant interactivity with the content. Users walking in the street do not need to write an web address, for example, a QR Code can take them direct to the website with just a click using a mobile. Also, users can save a lot of information with just one click (See QR Code Capacity). This combines real data with a virtual data generated by a computer to bring a new experience to the users. Imagine if you can use your mobile to see a dynamic image in your mobile from a static image in the real world. This effect is like pictures in terror movies, the pictures move and interact with the scenario. It brings to consumers a new sensation of an interactive environment. An environment that users can interact to get a new sensation of reality.

Feel free to comment this post.





How to change a failed disk on a mirrored volume – Veritas Storage

14 08 2008

Title in portuguese: “Como substituir um disco falho em um volume espelhado – Veritas Storage”.

In this article I will show how to change a failed disk on a Veritas Mirrored volume.

In this example we are assuming the VolM volume as a mirrored volume composed by two disks.

The volume is active and synch. We will simulate a physical failure in a disk that composes this mirrored volume.

We will replace this failed disk and synch the volume with a new disk.

To check that the volume is Active and Synch:

bash-3.00# vxprint
v  VolM         –            ENABLED  ACTIVE   20480    SELECT
pl VolM-01      VolM         ENABLED  20480    -        ACTIVE   –       -
sd c1t1d0-02    VolM-01      ENABLED  20480    0        -        -       -
pl VolM-02      VolM         ENABLED  ACTIVE   20480    CONCAT    -        RW
sd c1t2d0s2-02  VolM-02    ENABLED 10240    20480    0         c1t2d0   ENA

Let’s suppose that occurred a physical failure with one disk (c1t2d0).

To check the Volume Status:

bash-3.00# vxprint
v  VolM         fsgen        ENABLED  20480    -        ACTIVE   –       -
pl VolM-01      VolM         ENABLED  20480    -        ACTIVE   –       -
sd c1t1d0-02    VolM-01      ENABLED  20480    0        -        -       -
pl VolM-02      VolM         DISABLED 20480    -        NODEVICE –       -
sd c1t2d0s2-02  VolM-02      DISABLED 20480    0        NODEVICE –       -

At this point, you can notice that the volume is still active but the
Plex VolM-02 composed by a sub-disk from Disk c1t2d0 is not active due
to a physical problem. Volume VolM is still active because it was
configured using a mirror layout therefore the whole data is also stored
in the good disk (c1t1d0).
Note: If this volume was configured as a simple strippe volume, sorry, you would have no data now.

The next steps will describe how to add a new disk to Solaris in order to replace the failed one and recover the mirror.

1-)  Connect the new disk on the server

2-) Force solaris to recognize the new disk:

bash-3.00# devfsadm
bash-3.00# prtvtoc /dev/dsk/[device-name]

3-) To VxVM recognize the disk:

bash-3.00# vxdctl enable

The next step is to add this disk as the replacement of the failed disk.
Then, you need to add this new disk to a Disk Group using the same tag
as the failed disk.
In this example, faulted disk had the tag (c1t2d0s2).

4-) To add the new disk to the Disk Group DG1 as the replacement of the failed disk :

Note: -k force the system to take disk media from failed disk and assign to new disk.

bash-3.00# vxdg -k -g DG1 adddisk c1t2d0s2=c1t4d0

5-)To reattach the disk to the Disk Group:

bash-3.00# vxreattach

6-)To recover the volume and resynchronize the mirror:

bash-3.00# vxrecover -bs -g DG1 VolM

7-)To check if the volume is properly recovered:

bash-3.00# vxprint
v  VolM         fsgen        ENABLED  20480    -        ACTIVE   –       -
pl VolM-01      VolM         ENABLED  20480    -        ACTIVE   –       -
sd c1t1d0-02    VolM-01      ENABLED  20480    0        -        -       -
pl VolM-02      VolM         ENABLED  20480    -        ACTIVE   –       -
sd c1t2d0s2-02  VolM-02      ENABLED  20480    0        -        -

8-)To check that new disk is using the tag of failed disk:

bash-3.00# vxdisk -o alldgs list
DEVICE       TYPE            DISK         GROUP        STATUS
c1t0d0s2     auto:none       –            -            online invalid
c1t1d0s2     auto:cdsdisk    c1t1d0       DG1          online
c1t4d0s2     auto:cdsdisk    c1t2d0s2     DG1          online

Feel free to comment this article in order to improve its quality.

Reference:Veritas Storage Foundation 5.0 for UNIX Fundamentals.





Veritas Storage – How to create DG, Volumes and Filesystem

13 08 2008

Title in portuguese: “Como Criar Volumes no Veritas Storage Foundation”.

In this article I will show some RAID level types as well as how to create Disk Groups, Volumes and Filesystems on Veritas Storage Foundation.

RAID is an acronym of Redundant Array of Independent Disks. RAID is an storage propose to manage an array of disks.

RAID configuration types are classified according to the RAID level, which is defined numbers of Disks, the way data is spanned across the disks and redundancy method.

RAID LEVELS

- DISK SPANNING (RAID 0)

It is the technique to combine in one logical point space from many physical disks. There are two method for Disk Spanning:

– Concatenation: It is a linear data allocation across two or more disks.
– Example:
The volume is composed by 2 disks (A and B) using concatenation layout. Then you will write data     sequentially across the disks. System will start to write data in disk A and it will go to disk B as soon as disk A is full.
– Stripping: It is an alternating equal-size data allocation across multiple disks.
- Example:
The volume is composed by 2 disks (A and B) using stripping layout. System spreads data across multiple disks.

- DATA REDUNDANCY (RAID 1)

RAID 1 type is focused to protect data against disk failure.

- Mirroring: It is the method to have two or more copies of data in different physical disks.

- RESILIENCE

Resilient volume combines two layout to build a volume.

- RAID 0 + 1: It is a combination of Level 0  (Stripping) and Level 1 (Mirroring)

- RAID 1 + 0: It is a combination of Level 1 (Mirroring) and Level 0 (Stripping).

*There are more RAID Levels that were not mentioned here.

I am going to show how to create a mirroring volume and a stripping volume on Veritas Storage Foundation.(I am going to use Veritas SF 5.0 running on Solaris 10).

The first step is to check quantity of disks you have available on the server. A simple way to check this on solaris is using format utility:

bash-3.00# format

Searching for disks…done

AVAILABLE DISK SELECTIONS:

0. c1t0d0 <DEFAULT cyl 4092 alt 2 hd 128 sec 32>

/pci@0,0/pci15ad,1976@10/sd@0,0

1. c1t1d0 <DEFAULT cyl 7 alt 2 hd 64 sec 32>

/pci@0,0/pci15ad,1976@10/sd@1,0

2. c1t2d0 <DEFAULT cyl 7 alt 2 hd 64 sec 32>

/pci@0,0/pci15ad,1976@10/sd@2,0

3. c1t3d0 <DEFAULT cyl 2 alt 2 hd 64 sec 32>

/pci@0,0/pci15ad,1976@10/sd@3,0

Also, you can check disks available to Veritas Storage Foundation using vxdisk command:

bash-3.00# vxdisk -o alldgs list

DEVICE TYPE DISK GROUP STATUS

c1t0d0s2 auto:none – – online invalid

c1t1d0s2 auto:none – – online invalid

c1t2d0s2 auto:none – – online invalid

c1t3d0s2 auto:none – – online invalid

You can see above that there are 4 disks on the server that are available to Veritas but they have not yet been initialized by Veritas (invalid status). To use a disk on Veritas SF you need to initialize this using Veritas utilities.

NOTE: If you are going to use a disk on Veritas, pay attention that you should give this whole disk to Veritas. Disk will be formatted and you will lose all data in the disk when you are allocating a disk to Veritas Storage.

In this example the only disk that is in use for O.S Solaris is the first one. (c1t0d0s2).

We can use those 3 others disks to add on Veritas Storage.

Caution: If for a mistake we add the first disk (c1t0d0s2) to Veritas Storage, it will format the disk and erase Solaris info. We need to pay attention to get the right disks.

Let’s start allocating (initializing) those 3 disks to solaris:

bash-3.00# vxdisksetup -i c1t1d0

bash-3.00# vxdisksetup -i c1t2d0

bash-3.00# vxdisksetup -i c1t3d0

NOTE: online status means that the disk was initialized and can be used on Veritas Storage Foundation.

We have those 3 disks initialized on Veritas, then the next step is to create a Disk Group.

Disk Group
Disk Group is a collection of disks. Disk Group is very useful for management and isolation purpose.

Lets create a DG using only the fist disk initialized on Veritas (c1t1d0). We are using DG1 for the name of Disk Group.

bash-3.00# vxdg init DG1 c1t1d0

Check if  DG1 was created successfully:

bash-3.00# vxdg list

NAME STATE ID

DG1 enabled,cds 1218633322.13.vrt2

Also, check if the disk is properly assigned to DG1:

bash-3.00# vxdisk -o alldgs list

DEVICE TYPE DISK GROUP STATUS

c1t0d0s2 auto:none – – online invalid

c1t1d0s2 auto:cdsdisk c1t1d0 DG1 online

c1t2d0s2 auto:cdsdisk – – online

c1t3d0s2 auto:cdsdisk – – online

Let’s add more 2 disks to DG1:

bash-3.00# vxdg -g DG1 adddisk c1t2d0s2 c1t3d0s2

Check if the disks are properly assigned to DG1:

bash-3.00# vxdisk -o alldgs list

DEVICE TYPE DISK GROUP STATUS

c1t0d0s2 auto:none – – online invalid

c1t1d0s2 auto:cdsdisk c1t1d0 DG1 online

c1t2d0s2 auto:cdsdisk c1t2d0s2 DG1 online

c1t3d0s2 auto:cdsdisk c1t3d0s2 DG1 online

At this point we have added 3 disks into Disk Group DG1.

Next step we will create 2 different volumes in the DG1.

Volumes

A volume is a virtual storage that is used as an physical disk. Volume can be composed by many disks and have many layouts.

In this example, we are going to create two Volumes:

Volume VolS – Stripping layout using c1t1d0 and c1t2d0 disks (RAID 0).

Volume VolM – Mirroring layout using c1t2d0 and c1t3d0 (RAID 1).

To create a Stripping Volume VolS (Size=10m):

bash-3.00# vxassist -g DG1 make VolS 10m layout=stripe c1t1d0 c1t2d0s2

To check if volume VolS was created successfully:

bash-3.00# vxprint -g DG1

TY NAME ASSOC KSTATE LENGTH PLOFFS STATE TUTIL0 PUTIL0

dg DG1 DG1 – – – – – -

dm c1t1d0 c1t1d0s2 – 159488 – – – -

dm c1t2d0s2 c1t2d0s2 – 159488 – – – -

dm c1t3d0s2 c1t3d0s2 – 159488 – – – -

v VolS fsgen ENABLED 20480 – ACTIVE – -

pl VolS-01 VolS ENABLED 20480 – ACTIVE – -

sd c1t1d0-01 VolS-01 ENABLED 10240 0 – – -

sd c1t2d0s2-01 VolS-01 ENABLED 10240 0 – – -

To create a Mirroring Volume VolM (Size=10m):

bash-3.00# vxassist -g DG1 make VolM 10m layout=mirror c1t2d0s2 c1t3d0s2

To check if Volume VolM was created successfully:

bash-3.00# vxprint -g DG1

TY NAME ASSOC KSTATE LENGTH PLOFFS STATE TUTIL0 PUTIL0

dg DG1 DG1 – – – – – -

dm c1t1d0 c1t1d0s2 – 159488 – – – -

dm c1t2d0s2 c1t2d0s2 – 159488 – – – -

dm c1t3d0s2 c1t3d0s2 – 159488 – – – -

v VolM fsgen ENABLED 20480 – ACTIVE – -

pl VolM-01 VolM ENABLED 20480 – ACTIVE – -

sd c1t3d0s2-01 VolM-01 ENABLED 20480 0 – – -

pl VolM-02 VolM ENABLED 20480 – ACTIVE – -

sd c1t2d0s2-02 VolM-02 ENABLED 20480 0 – – -

v VolS fsgen ENABLED 20480 – ACTIVE – -

pl VolS-01 VolS ENABLED 20480 – ACTIVE – -

sd c1t1d0-01 VolS-01 ENABLED 10240 0 – – -

sd c1t2d0s2-01 VolS-01 ENABLED 10240 0 – – -

Note: You can see above that both Volumes were created successfully. Also, you can note the difference between stripping and mirroring volume layouts.

VolM is using two different Plex in differente disks. This means that if you lose one disk (Plex) you still have the data in the other disk (other Plex). It is the main configuration of Mirroring Volumes.

VolS is using only one Plex divided in 2 disks. This means that the data will be split in those 2 disks. If you lose one disk you would lose the whole Plex, therefore you would lose the data. This is the main configuration of Stripping Volumes. It does not provide data protection but it is very useful for performance for purpose.

Also, you can add those 2 layouts in only one layout that provide data protection and better performance. It is the case of RAID 0 + 1 or RAID 1 + 0.

In the next step we will create 2 different Filesystem using those 2 Volumes.

Filesystem

In this example we will create two filesystem:

- Filesystem fsS will use VolS. It will be mounted at /stripe mount point.

- Filesystem fsM will use VolM. It will be mounted at /mirror mount point.

To create a VxFS filesystem:

bash-3.00# mkfs -F vxfs /dev/vx/rdsk/DG1/VolS

version 7 layout

20480 sectors, 10240 blocks of size 1024, log size 1024 blocks

largefiles supported

bash-3.00# mkfs -F vxfs /dev/vx/rdsk/DG1/VolM

version 7 layout

20480 sectors, 10240 blocks of size 1024, log size 1024 blocks

largefiles supported

To mount a VxFS filesystem:

bash-3.00# mount -F vxfs /dev/vx/dsk/DG1/VolS /stripe/

bash-3.00# mount -F vxfs /dev/vx/dsk/DG1/VolM /mirror/

Now there are 2 filesystems configured and you can use it at Solaris Mount Point level.

Any data written in /stripe directory will be written in the stripping VolS volume.

Any data written in /mirror directory will be written in the mirroring VolM volume.

I hope this help you to understand how to:

  • Initialize a disk on Veritas Storage Foundation.

  • Create a Disk Group.

  • Add disks to a Disk Group.

  • Create a Stripping Volume.

  • Create a Mirroring Volume.

  • Create a VxFS Filesystem.

  • Mount a VxFS Filesystem.

Feel free to comment this article to improve its quality.

Reference: Veritas Storage Foundation 5.0 for UNIX: Fundamental – Training Book





CLOSE_WAIT Connections – Tuning Solaris

8 08 2008

This article aims to describe a way to tune TCP parameters on Solaris to get a better performance running a WebServer. I will show how the TCP connection is initiated and termintated on a high level and I will focus on how to tune TCP parameters on Solaris.

I have experienced some problems with a bunch of CLOSE_WAIT connections on Solaris affecting  the application causing delays on response time and refusing new connections.

I will start this article explaning how a connection is initiated (TCP Three-Way Handshake sequence).

Let’s use the scenario of two servers (A and B) where the server A is going to initiate the connection.

1-) The first segment SYN is sent by the node A to node B. This is a request to server synchronizes the sequence numbers.

Node A —— SYN —–> Node B

2-) Node B sends an acknowledge (ACK) about the request of the Node A. At the same time,  Node B is also sending its request (SYN) to the Node A for synchronization of its sequence numbers.

Node A <—– SYN/ACK —- Node B

3-) Node A then send an acknowledge to Node B.

Node A —— ACK ——-> Node B

At this time the connection should be established.

Let’s show how the connections are terminated (here is the CLOSE_WAIT issue):

In the termination process, it is important to remember that each application process on each side of connection should close independently its half of connection. This terminating process consists of:

Let’s supose Node A will close its half of connection first.

1-)NodeA transmits a FIN packet to Node B.

(Established)         (Established)
Node A —- FIN —-> Node B
(FIN_WAIT1)

2-)NodeB transmits an ACK packet to Node A:

NodeA <—- ACK —- Node B
(FIN_WAIT2)          (CLOSE_WAIT)

//Here is the CLOSE_WAIT Issue. App on Node B should invoke close() method to close the connection on its end.
If the App does not invoke close() method, then it will keep the connection stuck on CLOSE_WAIT for the time specified on TCP Stack.

If you have much traffic in the server and a lot of connections on CLOSE_WAIT status it will cause some issues such as:

- Refusing new connections request.

- Slow on response time.

- High Processing Resource Utilization.

Now, I will describe some tips that helped me to solve some problems in Webservers.
It basically consists of changing some TCP parameters in Solaris that will reduce the time that a connection will be on CLOSE_WAIT, releasing this kind of connection quickly.

- TCP_TIME_INTERVAL parameter:
Description: Notifies TCP/IP on how long to keep the
connection control blocks closed. After the applications complete the
TCP/IP connection, the control blocks are kept for the specified time.
When high connection rates occur, a large backlog of the TCP/IP
connections accumulates and can slow server performance. The server
can stall during certain peak periods. If the server stalls, the
netstat command shows that many of the sockets that are opened to the
HTTP server are in the CLOSE_WAIT or FIN_WAIT_2 state. Visible delays
can occur for up to four minutes, during which time the server does
not send any responses, but CPU utilization stays high, with all of
the activities in system processes.

1-) Verify the current value of this:
ndd -get /dev/tcp tcp_time_wait_interval
2-) Set the new value
ndd -set /dev/tcp tcp_time_wait_interval 60000

(Defaul value is 240000 milliseconds = 4 minutes. Recommended is 60000 milliseconds).

- TCP_FIN_WAIT_2_FLUSH_INTERVAL
Specifies the timer interval prohibiting a connection in the FIN_WAIT_2 state to remain in that state.

1-)Verify the current value of this:
ndd -get /dev/tcp tcp_fin_wait_2_flush_interval
2-) Set the new value:
ndd -set /dev/tcp tcp_fin_wait_2_flush_interval 67500

(Default Value is 675000 milliseconds. Recommended is 67500 milliseconds).

- TCP_KEEPALIVE_INTERVAL
keepAlive packet ensures that a connection stays in an active and established state.

1-)Verify the current value of this:
ndd -get /dev/tcp tcp_keepalive_interval
2-) Set the new value:
ndd -set /dev/tcp tcp_keepalive_interval 300000

(Default Value is 7200000 milliseconds. Recommended is 15000 milliseconds).

- Connection backlog
It means that a high number of incoming connections results in failure.

1-)Verify the current value of this:
ndd -get /dev/tcp tcp_conn_req_max_q
2-) Set the new value:
ndd -set /dev/tcp tcp_conn_req_max_q 8000

(Default value is 128. Recommended is 8000)

This configuration change will help to improve the system performance, and better than this, it will help to reduce major impacts.
I have experienced situations that the application was not responding due to a lot of connections on CLOSE_WAIT status.
In my case, we identified a bug in the application and we use this tunings as an work-around.
It is very useful and it can help you when you are experiencing problems due to many connections on this state.

Reference: This article was inspirate on IBM “Tuning Solaris systems” @ WebSphere Application Server
Information Center.

Additional Info:

Local Server closes first:
ESTABLISHED -> FIN_WAIT_1-> FIN_WAIT_2 -> TIME_WAIT -> CLOSED.

Remote Server closes first:
ESTABLISHED -> CLOSE_WAIT -> LAST_ACK -> CLOSED.

Local and Remote Server close at the same time:
ESTABLISHED -> FIN_WAIT_1-> CLOSING ->TIME_WAIT -> CLOSED.

Note: This is an open article and if you have suggestions or comments on how to improve its quality. Please, let me know.