ś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"}}}])