Pokazywanie postów oznaczonych etykietą linux. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą linux. Pokaż wszystkie posty

ś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.

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

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