środa, 20 listopada 2013

mdadm "lost" discs

A few days ago I had to stop my systems. One of them had different kind of storage like: luns, nfs and software raids. After turned on system I realized that I had had no software raid. I checked if everything was connected and checked if discs exists.
mdadm --examine /dev/sd[b-t] /dev/sdc: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : da8f3a5d:10f75bee:f074ba7e:f0494c09 Update Time : Tue Dec 11 13:59:58 2012 Checksum : d24bdccc - correct Events : 0 Chunk Size : 512K Device Role : Active device 7 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdd: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : c4d19ddc:f5dc1884:c6ef0844:3abe1c66 Update Time : Tue Dec 11 13:59:58 2012 Checksum : 98af3bd - correct Events : 0 Chunk Size : 512K Device Role : Active device 8 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sde: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : 51e205a2:40aa348f:3f2041a9:872d3e1f Update Time : Tue Dec 11 13:59:58 2012 Checksum : f868715b - correct Events : 0 Chunk Size : 512K Device Role : Active device 9 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdf: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : 1832c689:2cb35bfc:d2c97cf5:d84c985d Update Time : Tue Dec 11 13:59:58 2012 Checksum : d7e592ea - correct Events : 0 Chunk Size : 512K Device Role : Active device 0 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdg: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : 5a9a6781:53904dfc:0f5789c9:e0df60e8 Update Time : Tue Dec 11 13:59:58 2012 Checksum : 2e4df89a - correct Events : 0 Chunk Size : 512K Device Role : Active device 1 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdh: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : afa5008b:efc248ab:5ab3bce0:2def6ad1 Update Time : Tue Dec 11 13:59:58 2012 Checksum : e71fa223 - correct Events : 0 Chunk Size : 512K Device Role : Active device 2 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdi: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : c8e16d74:a1940d4c:5a802c6a:5173a94c Update Time : Tue Dec 11 13:59:58 2012 Checksum : 76000112 - correct Events : 0 Chunk Size : 512K Device Role : Active device 3 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdj: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : 53051171:604d9634:a7f5c2b6:14c2bddd Update Time : Tue Dec 11 13:59:58 2012 Checksum : 38d6a16e - correct Events : 0 Chunk Size : 512K Device Role : Active device 4 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdk: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : fc3706df:d1f2df92:f50a37a7:55fd1845 Update Time : Tue Dec 11 13:59:58 2012 Checksum : 5ce4ca18 - correct Events : 0 Chunk Size : 512K Device Role : Active device 5 Array State : AAAAAAAAAA ('A' == active, '.' == missing) /dev/sdl: Magic : a92b4efc Version : 1.2 Feature Map : 0x0 Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0 Name : synat2:0 (local to host synat2) Creation Time : Tue Dec 11 13:59:58 2012 Raid Level : raid0 Raid Devices : 10 Avail Dev Size : 47997696 (22.89 GiB 24.57 GB) Data Offset : 2048 sectors Super Offset : 8 sectors State : clean Device UUID : 6ae2fd1e:30297e6c:4a26a015:2edcfe2c Update Time : Tue Dec 11 13:59:58 2012 Checksum : ccc9a512 - correct Events : 0 Chunk Size : 512K Device Role : Active device 6 Array State : AAAAAAAAAA ('A' == active, '.' == missing)
Than I realized that in my mdadm.conf were entries with /dev/dm-*. It means that something was wrong because in /dev I had only 4 entries contained dm*. It turned out that my multipath configuration blocked other dm-* devices to be discovered. I switched dm to disk/by-id.
root@testing:~# cat /etc/mdadm/mdadm.conf | grep -v ^# CREATE owner=root group=disk mode=0660 auto=yes HOMEHOST MAILADDR root DEVICE /dev/disk/by-id/scsi-SATA_MARVELL_*
Did:
root@testing:~# mdadm --assemble --scan
and
root@testing:~# mount -a
Now everything works as it should.

wtorek, 29 października 2013

FreeBSD access via Xen console

To allow access via xen console you need to change /etc/ttys:

-ttyu0 /usr/libexec/getty std.9600 dialup off secure
+ttyu0 /usr/libexec/getty std.9600 dialup on secure

Than add few lines into /boot/loader.conf :

boot_multicons="YES"
boot_serial="YES"
comconsole_speed=9600
console="comconsole,vidconsole"

Now you can restart server.
Now you can access to FreeBSD console via xen:

[root@xenserver1 ~]# xl console "FreeBSD 9.2"

FreeBSD/amd64 (tanatos) (ttyu0)

login:
To end session on console please enter Ctrl+]

piątek, 25 października 2013

Xen add new virtual disc

Once I need to attach new disk on my VM machine. To do this I need make steps below :

1) Get storage UUID:

[root@xenserver1 ~]# xe sr-list 
uuid ( RO)                : 4e98e18e-1215-4fdb-baec-924bbef2a67e
          name-label ( RW): Remote ISO Library on: /mnt/iso_import
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : f30a1ead-37f2-0e3c-9583-073c176fc111
          name-label ( RW): Removable storage
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): udev
        content-type ( RO): disk


uuid ( RO)                : 419c98d3-1d98-3049-c579-439c31b33fd4
          name-label ( RW): XenServer Tools
    name-description ( RW): XenServer Tools ISOs
                host ( RO): xenserver1
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : a9329bfa-e13e-2edd-8414-5920f03f27e5
          name-label ( RW): ISOS
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : cb128245-3dcb-9de6-319d-681cede9553f
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): xenserver1
                type ( RO): udev
        content-type ( RO): iso


uuid ( RO)                : f6375e1e-0ab7-b11c-e9dd-677da4436e15
          name-label ( RW): Local storage
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): lvm
        content-type ( RO): user
2) Create virtual disc:
[root@xenserver1 ~]# xe vdi-create name-label="zfs1" sr-uuid=f6375e1e-0ab7-b11c-e9dd-677da4436e15 type=user sm-config:type=raw virtual-size=10GiB
34a899b3-b3dd-4531-aee9-1fafb57517ca
[root@xenserver1 ~]# xe vdi-create name-label="zfs2" sr-uuid=f6375e1e-0ab7-b11c-e9dd-677da4436e15 type=user sm-config:type=raw virtual-size=10GiB
20c384f6-0504-4c7f-a3cf-08d28c6c0dc6
[root@xenserver1 ~]# xe vdi-list name-label=zfs1
uuid ( RO)                : 34a899b3-b3dd-4531-aee9-1fafb57517ca
          name-label ( RW): zfs1
    name-description ( RW): 
             sr-uuid ( RO): f6375e1e-0ab7-b11c-e9dd-677da4436e15
        virtual-size ( RO): 10737418240
            sharable ( RO): false
           read-only ( RO): false


[root@xenserver1 ~]# xe vdi-list name-label=zfs2
uuid ( RO)                : 20c384f6-0504-4c7f-a3cf-08d28c6c0dc6
          name-label ( RW): zfs2
    name-description ( RW): 
             sr-uuid ( RO): f6375e1e-0ab7-b11c-e9dd-677da4436e15
        virtual-size ( RO): 10737418240
            sharable ( RO): false
           read-only ( RO): false
3) Check virtual machine UUID for whom virtual disc should be attched:
[root@xenserver1 ~]# xe vm-list 
uuid ( RO)           : 68ce65a4-01ec-4a23-9016-011aa20e59cf
     name-label ( RW): Control domain on host: xenserver1
    power-state ( RO): running


uuid ( RO)           : 66a6fcc2-b5b9-1eb9-cd26-c26d8df1e204
     name-label ( RW): Hadoop-master
    power-state ( RO): running


uuid ( RO)           : a79bc6f8-54d7-a562-ba14-4f50db2efc9b
     name-label ( RW): FreeBSD 9.2
    power-state ( RO): running


uuid ( RO)           : 8ac1c052-8448-6d9b-0a55-6e91e5be406c
     name-label ( RW): FreeBSD10
    power-state ( RO): halted


uuid ( RO)           : 03070e1e-2b04-5e4b-87f9-5db7d69131bb
     name-label ( RW): Hadoop-slave2
    power-state ( RO): running


uuid ( RO)           : d122b3bf-e914-83b0-5761-1430f205fa9c
     name-label ( RW): Hadoop-slave1
    power-state ( RO): running
In my case it was FreeBSD 9.2 (uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b)

4) Get allowed numbers for VBD devices:

[root@xenserver1 ~]# xe vm-param-get uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b param-name=allowed-VBD-devices 
1; 2
5) Create virtual disc attached to VM:
[root@xenserver1 ~]# xe vbd-create device=1 vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b vdi-uuid=34a899b3-b3dd-4531-aee9-1fafb57517ca bootable=false mode=RW type=Disk
f43711c3-be1e-a869-8888-408d94a70656
[root@xenserver1 ~]# xe vbd-create device=2 vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b vdi-uuid=20c384f6-0504-4c7f-a3cf-08d28c6c0dc6 bootable=false mode=RW type=Disk
5dcf7ad9-f4ec-b3e3-ea0c-8edd0d35d53d
6) Optionally if you have Xen tools on board you can plug virtual disc live.
[root@xenserver1 ~]# xe vbd-plug uuid=f43711c3-be1e-a869-8888-408d94a70656
If everything goes right you should have new discs attached and working on virtual machine. On system:
shamrock@tanatos:~ % dmesg | grep xbd
xbd0: 30720MB  at device/vbd/768 on xenbusb_front0
xbd0: attaching as ada0
xbd1: 10240MB  at device/vbd/5632 on xenbusb_front0
xbd1: attaching as ada2
xbd2: 10240MB  at device/vbd/832 on xenbusb_front0
xbd2: attaching as ada1
On Xen:
[root@xenserver1 ~]# xe vbd-list vm-name-label=FreeBSD\ 9.2
uuid ( RO)             : 5dcf7ad9-f4ec-b3e3-ea0c-8edd0d35d53d
          vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
    vm-name-label ( RO): FreeBSD 9.2
         vdi-uuid ( RO): 20c384f6-0504-4c7f-a3cf-08d28c6c0dc6
            empty ( RO): false
           device ( RO): hdc


uuid ( RO)             : f43711c3-be1e-a869-8888-408d94a70656
          vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
    vm-name-label ( RO): FreeBSD 9.2
         vdi-uuid ( RO): 34a899b3-b3dd-4531-aee9-1fafb57517ca
            empty ( RO): false
           device ( RO): hdb


uuid ( RO)             : 17d014d8-0d28-76e9-b6dc-f8944a0c0244
          vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
    vm-name-label ( RO): FreeBSD 9.2
         vdi-uuid ( RO): a74f372f-2fcd-4121-a241-bd1e960a069c
            empty ( RO): false
           device ( RO): hda

środa, 23 października 2013

Create local ISO repository

Create with lvcreate place for repository:
[root@xenserver1 ~]# lvcreate -L 30G -n ISO2 VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15
Make proper file system:
[root@xenserver1 ~]# mkfs.ext3 /dev/VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15/ISO2 
Add lines to /ec/rc.local
[root@xenserver1 ~]# vi /etc/rc.local 

ISO=/dev/VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15/ISO2
lvchange -ay $ISO
mount $ISO /mnt/iso_import

It's very important not to change /etc/fstab !!!

Last thing is to mount everything without restart:
[root@xenserver1 ~]# ISO=/dev/VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15/ISO2
[root@xenserver1 ~]# lvchange -ay $ISO
[root@xenserver1 ~]# mount $ISO /mnt/iso_import
[root@xenserver1 ~]# xe-mount-iso-sr /mnt/iso_import -o bind
Result:
[root@xenserver1 ~]# xe sr-list
uuid ( RO)                : 4e98e18e-1215-4fdb-baec-924bbef2a67e
          name-label ( RW): Remote ISO Library on: /mnt/iso_import
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : f30a1ead-37f2-0e3c-9583-073c176fc111
          name-label ( RW): Removable storage
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): udev
        content-type ( RO): disk


uuid ( RO)                : 419c98d3-1d98-3049-c579-439c31b33fd4
          name-label ( RW): XenServer Tools
    name-description ( RW): XenServer Tools ISOs
                host ( RO): xenserver1
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : cb128245-3dcb-9de6-319d-681cede9553f
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): xenserver1
                type ( RO): udev
        content-type ( RO): iso


uuid ( RO)                : f6375e1e-0ab7-b11c-e9dd-677da4436e15
          name-label ( RW): Local storage
    name-description ( RW): 
                host ( RO): xenserver1
                type ( RO): lvm
        content-type ( RO): user

How to add network interface to VM on Citrix Xen via console

Check interfaces:
[root@xenserver1 ~]# xe pif-list 
uuid ( RO)                  : cc9937fa-0435-7664-a73a-c9bfa803e50e
                device ( RO): eth3
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): e7a75876-ee65-950e-7975-6751eca3795b


uuid ( RO)                  : 3a5ef383-650a-ded9-d636-4c86a6831443
                device ( RO): eth1
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): bd91ea1e-6184-4f7b-6360-0134f39b9751


uuid ( RO)                  : 4c04ef06-9707-67ac-1859-6e6617d507a7
                device ( RO): eth2
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): 8d829397-e8d1-fdc2-b62d-8b23cf6da7dd


uuid ( RO)                  : 41b55f45-91ff-90e1-0a13-dbb680e744e9
                device ( RO): eth0
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): 78613a9f-aede-edc6-39f4-40c4c5883de2


uuid ( RO)                  : 72ff5545-3d4b-5038-aa15-dc93998b8dab
                device ( RO): eth0
    currently-attached ( RO): true
                  VLAN ( RO): 21
          network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
Create internal interface - not bounded to any physical interface :
[root@xenserver1 ~]# xe network-create name-label="anylan" name-description="anylan for testing"
919b5b1c-201f-fed2-c39d-21946f278bdc
Create tagged network interface bounded to physical NIC:
[root@xenserver1 ~]# xe network-create name-label="vlan402" name-description="VLAN 402" 
d5b6969c-eff4-79b2-0088-7740f8a9b492


[root@xenserver1 ~]# xe vlan-create network-uuid=d5b6969c-eff4-79b2-0088-7740f8a9b492 pif-uuid=41b55f45-91ff-90e1-0a13-dbb680e744e9  vlan=402
7dadd3ec-b8a2-5b40-0855-0ef365dc9f00
Example pif-list after adding new interface
[root@xenserver1 ~]# xe pif-list 
uuid ( RO)                  : 7dadd3ec-b8a2-5b40-0855-0ef365dc9f00
                device ( RO): eth0
    currently-attached ( RO): true
                  VLAN ( RO): 402
          network-uuid ( RO): d5b6969c-eff4-79b2-0088-7740f8a9b492


uuid ( RO)                  : cc9937fa-0435-7664-a73a-c9bfa803e50e
                device ( RO): eth3
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): e7a75876-ee65-950e-7975-6751eca3795b


uuid ( RO)                  : 3a5ef383-650a-ded9-d636-4c86a6831443
                device ( RO): eth1
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): bd91ea1e-6184-4f7b-6360-0134f39b9751


uuid ( RO)                  : 4c04ef06-9707-67ac-1859-6e6617d507a7
                device ( RO): eth2
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): 8d829397-e8d1-fdc2-b62d-8b23cf6da7dd


uuid ( RO)                  : 41b55f45-91ff-90e1-0a13-dbb680e744e9
                device ( RO): eth0
    currently-attached ( RO): true
                  VLAN ( RO): -1
          network-uuid ( RO): 78613a9f-aede-edc6-39f4-40c4c5883de2


uuid ( RO)                  : 72ff5545-3d4b-5038-aa15-dc93998b8dab
                device ( RO): eth0
    currently-attached ( RO): true
                  VLAN ( RO): 21
          network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
Check VM to attach new interface: we need to know number of devices and vm-uuid.
[root@xenserver1 ~]# xe vm-list 
uuid ( RO)           : 68ce65a4-01ec-4a23-9016-011aa20e59cf
     name-label ( RW): Control domain on host: xenserver1
    power-state ( RO): running


uuid ( RO)           : 66a6fcc2-b5b9-1eb9-cd26-c26d8df1e204
     name-label ( RW): Hadoop-master
    power-state ( RO): running


uuid ( RO)           : a79bc6f8-54d7-a562-ba14-4f50db2efc9b
     name-label ( RW): FreeBSD 9.2
    power-state ( RO): running


uuid ( RO)           : 8ac1c052-8448-6d9b-0a55-6e91e5be406c
     name-label ( RW): FreeBSD10
    power-state ( RO): halted


uuid ( RO)           : 03070e1e-2b04-5e4b-87f9-5db7d69131bb
     name-label ( RW): Hadoop-slave2
    power-state ( RO): running


uuid ( RO)           : d122b3bf-e914-83b0-5761-1430f205fa9c
     name-label ( RW): Hadoop-slave1
    power-state ( RO): running

[root@xenserver1 ~]# xe vif-list vm-name-label=FreeBSD\ 9.2
uuid ( RO)            : 49a107e2-0e81-a9dd-0595-218c07fe1af8
         vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
          device ( RO): 2
    network-uuid ( RO): 56d7fd62-ba47-c12c-e371-bc7908739ad1


uuid ( RO)            : 03932dbf-d7e4-ed7d-d649-ac431a97d962
         vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
          device ( RO): 1
    network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
Attach interface to VM:
[root@xenserver1 ~]# xe vif-create network-uuid=d5b6969c-eff4-79b2-0088-7740f8a9b492 vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b device=3 mac=random
758cf24a-2904-f3aa-8ed4-17d6ffebf032

[root@xenserver1 ~]# xe vif-create network-uuid=919b5b1c-201f-fed2-c39d-21946f278bdc  vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b  device=4 mac=random
3504d19f-2413-e066-6d30-1878adfbd117
Result:

[root@xenserver1 ~]# xe vif-list vm-name-label=FreeBSD\ 9.2
uuid ( RO)            : 49a107e2-0e81-a9dd-0595-218c07fe1af8
         vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
          device ( RO): 2
    network-uuid ( RO): 56d7fd62-ba47-c12c-e371-bc7908739ad1


uuid ( RO)            : 758cf24a-2904-f3aa-8ed4-17d6ffebf032
         vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
          device ( RO): 3
    network-uuid ( RO): d5b6969c-eff4-79b2-0088-7740f8a9b492


uuid ( RO)            : 03932dbf-d7e4-ed7d-d649-ac431a97d962
         vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
          device ( RO): 1
    network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc


uuid ( RO)            : 3504d19f-2413-e066-6d30-1878adfbd117
         vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
          device ( RO): 4
    network-uuid ( RO): 919b5b1c-201f-fed2-c39d-21946f278bdc
Depends of configuration probably you'll need to shutdown your machine and start it again thus system could determine network interface.

wtorek, 22 października 2013

FreeBSD 9.2 XEN xenbusb_nop_confighook_cb

Recently I tried run FreeBSD 9.2 on my Citrix Xen machine with HVM support. After booting I got error: xenbusb_nop_confighook_cb This error got me confused. I'd searched awhile and found solution : http://web.archiveorange.com/archive/v/jbzpKsnhTPhFFEuQuYTP
root@pruebas:/root # diff -u /usr/src/sys/kern/subr_autoconf.c-defecto /usr/src/sys/kern/subr_autoconf.c
--- /usr/src/sys/kern/subr_autoconf.c-defecto	2012-10-10 13:51:27.000000000 +0200
+++ /usr/src/sys/kern/subr_autoconf.c	2012-10-10 18:21:51.000000000 +0200
@@ -133,16 +133,17 @@
 	/* Block boot processing until all hooks are disestablished. */
 	mtx_lock(&intr_config_hook_lock);
 	warned = 0;
-	while (!TAILQ_EMPTY(&intr_config_hook_list)) {
+	/* while (!TAILQ_EMPTY(&intr_config_hook_list)) { */
 		if (msleep(&intr_config_hook_list, &intr_config_hook_lock,
 		    0, "conifhk", WARNING_INTERVAL_SECS * hz) ==
 		    EWOULDBLOCK) {
+			printf("\n\n SARENET Individual lock name antes de unlock es : %s", intr_config_hook_lock.lock_object.lo_name);
 			mtx_unlock(&intr_config_hook_lock);
 			warned++;
 			run_interrupt_driven_config_hooks_warning(warned);
 			mtx_lock(&intr_config_hook_lock);
 		}
-	}
+	/* } */
 	mtx_unlock(&intr_config_hook_lock);
 }TAILQ_EMPTY is at queue.h : 

#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)

środa, 16 października 2013

Columbus day

Special offer from Packt Publishing - all books 50% off has been extended to 21 October 2013 - that's great news

http://bit.ly/1bqvB29

środa, 9 października 2013

Postgresql replication book review

http://www.packtpub.com/postgresql-replication/book

Recently I got book about postgresql replication  for review .
This book is great.
It describes different replication methods available in postgres in very easy way.
Besides that, it describes how replication mechanisms work, what you should know about designing database and many other aspects related to databases.
The book contains examples which can be used to one's practice.
In this book there are usefull things not only for database administrator but also for regular user who wants to know better how it works. 

poniedziałek, 7 października 2013

Read linux dmesg with date

Simple script to read dmesg from linux (contains real date no miliseconds)
----------------------------------------------------------------------------------------------------------
#!/usr/bin/python
import sys
import re
import time
import datetime
import fileinput
import os

try:
  uptime = open('/proc/uptime','r')
except IOError as (errno, strerror):
  print "Wystapil blad otwarcia pliku :\n %s\n" % (strerror)

czas = time.time()

uptime_seconds = czas-float(uptime.readline().split()[0])

p = os.popen('dmesg')

for line in p.readlines():

  re1='.*?'
  re2='(\\d+)'
  re3='(\\.)'
  re4='(\\d+)'

  rg = re.compile(re1+re2+re3+re4,re.IGNORECASE|re.DOTALL)
  m = rg.search(line)
  if m:
      int1=float(m.group(1)+m.group(2)+m.group(3))
      szukaj=(m.group(1)+m.group(2)+m.group(3))
      czas = uptime_seconds + int1
      czas = datetime.datetime.fromtimestamp(int(czas)).strftime('%Y-%m-%d %H:%M:%S')
   
      zwrot = re.sub(szukaj,czas,line.rstrip(),1)

      print zwrot

środa, 2 października 2013

MongoDB aggregation

MongoDB aggregation examples: db.posts.aggregate({$unwind:"$comments"},{$group:{_id:"$comments.author",count:{$sum:1}}},{$sort:{count:1}}) db.zip.aggregate([{$match:{$or:[{state:"CA"},{state:"NY"}]}}, {$group:{_id:{city:"$city",state:"$state"}, pop:{$sum:"$pop"}}}, {$match:{pop:{$gt:25000}}}, {$group:{_id:"$state", average:{$avg:"$pop"}}}]) db.grades.aggregate({$unwind:"$scores"} , {$match:{"scores.type":{$nin:["quiz"]}}},{$group:{_id:{student_id:"$student_id",class_id:"$class_id"},avg:{$avg:"$scores.score"}}},{$group:{_id:"$_id.class_id",average:{$avg:"$avg"}}}) db.zip.aggregate( [ {$project : {city:{$substr:["$city",0,1]},pop:1}}, {$sort : {city : 1}}, {$match: {city: /^\d.*$/}} , {$group:{_id:1,pop:{$sum:"$pop"}}}])

czwartek, 19 września 2013

Create "internal" VLAN for Xen Virtual Machines

1) Add the dummy interface driver to the auto-load modules:

echo dummy >> /etc/modules

2) Configure network interface  ( /etc/network/interfaces)
auto dummy0
iface dummy0 inet static
address 192.168.100.1
netmask 255.255.255.0

3) Bring up the dummy interface
ifup dummy0

4) Add line in : /etc/xen/xend-config.sxp

(network-script 'network-bridge netdev=dummy0')

5) Run the command:

/etc/xen/scripts/network-bridge start netdev=dummy0 antispoof=no

6) Check if pdummy interface is present:
ifconfig pdummy0

pdummy0   Link encap:Ethernet  HWaddr b6:a5:b4:35:a7:1a 
          inet6 addr: fe80::b4a5:b4ff:fe35:a71a/64 Scope:Link
          UP BROADCAST RUNNING NOARP PROMISC  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:532 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:28928 (28.2 KiB)


8) Attach new interface to guest domain :

xm network-attach  example.domain.guest bridge=dummy0 script=vif-bridge mac=00:16:3E:40:22:12

9) Log in to guest domain console and add new interface:


root@debian-xen:/home/shamrock# xm console example.domain.guest


Debian GNU/Linux 6.0 debian hvc0

debian login: root
Password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@debian:~# ifconfig eth1 192.168.100.200 netmask 255.255.255.0
root@debian:~# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:16:3E:40:22:12 
          inet addr:192.168.100.200  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe40:2212/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:608 (608.0 B)  TX bytes:510 (510.0 B)
          Interrupt:244

And add this to /etc/network/interfaces

auto eth1
iface eth1 inet static
 address 192.168.100.200
 gateway 192.168.100.1
 netmask 255.255.255.0

10) In Dom0 edit DomU config and add ew interface:

i.e.: /etc/xen/example.domain.guest

vif         = [ 'ip=212.85.34.12,mac=00:16:3E:0B:0A:83,bridge=eth0', 'ip=192.168.100.100,mac=00:16:3E:D7:9C:F6,bridge=dummy0' ]


11) Last thing is to set the ip_forwarding in the kernel of Dom0 and create NAT rules.

root@debian-xen:/# echo 1 >/proc/sys/net/ipv4/ip_forward
root@debian-xen:/# iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -d 0.0.0.0/0 -j MASQUERADE

środa, 14 sierpnia 2013

FortiMail - diagnozowanie tcpdump

Do diagnozowania problemów związanych z siecią na serwerach z unixem służą wszelkiego rodzaju narzędzia pokroju tcpdumpa czy wiresharka.
Także Forti posiada takie narzędzie na poziomie CLI.

Składnia polecenia:
diagnose sniffer packet {interface | all}  ‘net z.z.z.z/p and/or host x.x.x.x and/or port yyy’  [options]
W celu zawężenia poszukiwań można użyć 
net/prefix : bierze pod uwagę cały blok IP
host          : bierze pod uwagę tylko danego hosta
port          : wypisuje tylko połączenia dla danego portu
options     : dodatkowe opcje
 
Pole
Dodatkowe opcje podawane są na końcu w postaci cyfry:The Options field at the end are as follow:
1: wypisuje nagłówek pakietu
2: wypisuje nagłówek pakietu i dane zwrotne z IP
3: wypisuje nagłówek i dane z pakietu ethernetowego ( jeżęli jest dostępny)
4: wypisuje nagłówek z nazwą interface
5: wypisuje nagłówek i dane z IP wraz z nazwą interface
6: wypisuje nagłówek i dane z pakietu ethernetowego ( jeżęli jest dostępny) wraz z nazwą interface

diagnose sniffer packet any ‘net 192.168.1.0/24 and host 172.16.11.12 and port 3878′