Kategori: Sorunlu Teknoloji

  • RAID1 array’i yeniden yapılandırma.

    Önceki yazımızda RAID arrayde bulunan bozuk diskin nasıl tespit edileceğini görmüştük. Bu yazımızda bozuk diskin yerine takılan yeni diskin array’e nasıl ekleneceğini göreceğiz. Normalde ubuntu sunucular bu işi yeni disk takılıp sistem açıldıktan sonra otomatik olarak yapmaya başlayabiliyor, ancak zaman zaman sorunlar ile karşılaşmak mümkün oluyor. Örneğin benim vereceğim örnekte md1 array’i nedense inactive durumda. Bu sorunla yüzleştiğimizde neler yapılabilir beraber bakalım:

    (Not: bu işlemleri yaparken, herhangi bir veri kaybı yaşamanızdan sorumlu olmadığımı tekrar belirtmek isterim. Önceki yazıda bulunan kurallar aynen bu yazı için de geçerli.)

    Öncelikle yeni diskte eş bölümleri oluşturmamız gerekmekte. Bunun için elimizde bulunan ikinci diskin bölümlerini ve Boot kaydını aynen yeni diske geçirmemiz gerekiyor. Bu işlemler için sırası ile şunları yapacağız:

    Öncelikle ikinci diskin bölümleme tablosunun bir kopyasını yeni diske çıkartalım.

    Hatırlayacağınız üzere bozulan diskimiz “sda” sağlam olan diskimiz de “sdb” idi. Ancak yanlış işlem yapmamanız için öncelikle dolu ve boş diskin hangisi olduğuna sisteminizden bakın:

    # fdisk -l

    Disk /dev/sda: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x55555555

    Disk /dev/sda doesn’t contain a valid partition table

    Disk /dev/sdb: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00088969

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 262 2102562 fd Linux raid autodetect
    /dev/sdb2 263 295 265072+ fd Linux raid autodetect
    /dev/sdb3 296 91201 730202445 fd Linux raid autodetect

    Disk /dev/md0: 2152 MB, 2152923136 bytes
    2 heads, 4 sectors/track, 525616 cylinders
    Units = cylinders of 8 * 512 = 4096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/md0 doesn’t contain a valid partition table

    Disk /dev/md2: 747.7 GB, 747727224832 bytes
    2 heads, 4 sectors/track, 182550592 cylinders
    Units = cylinders of 8 * 512 = 4096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/md2 doesn’t contain a valid partition table

    Benim sistemimde dolu olan disk “/dev/sdb” boş olan yeni disk ise “/dev/sda” olarak görünmekte. Buna göre sdb’deki bölümleme tablosunu aşağıdaki komut ile “sda”ya kopyalayacağız:

    # sfdisk -d /dev/sdb | sfdisk /dev/sda

    Checking that no-one is using this disk right now …
    OK

    Disk /dev/sda: 91201 cylinders, 255 heads, 63 sectors/track

    sfdisk: ERROR: sector 0 does not have an msdos signature
    /dev/sda: unrecognized partition table type
    Old situation:
    No partitions found
    New situation:
    Units = sectors of 512 bytes, counting from 0

    Device Boot Start End #sectors Id System
    /dev/sda1 3906 4209029 4205124 fd Linux raid autodetect
    /dev/sda2 4209030 4739174 530145 fd Linux raid autodetect
    /dev/sda3 4739175 1465144064 1460404890 fd Linux raid autodetect
    /dev/sda4 0 – 0 0 Empty
    Warning: no primary partition is marked bootable (active)
    This does not matter for LILO, but the DOS MBR will not boot this disk.
    Successfully wrote the new partition table

    Re-reading the partition table …

    If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
    to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
    (See fdisk(8).)

    İşlemin başarılı olup olmadığını tekrar “fdisk -l” komutu vererek çıktıdan görebilirsiniz. Eğer şöyle bir çıktı ile karşıltıysanız işlem başarılı demektir:

    # fdisk -l

    Disk /dev/sda: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x55555555

    Device Boot Start End Blocks Id System
    /dev/sda1 1 262 2102562 fd Linux raid autodetect
    /dev/sda2 263 295 265072+ fd Linux raid autodetect
    /dev/sda3 296 91201 730202445 fd Linux raid autodetect

    Disk /dev/sdb: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00088969

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 262 2102562 fd Linux raid autodetect
    /dev/sdb2 263 295 265072+ fd Linux raid autodetect
    /dev/sdb3 296 91201 730202445 fd Linux raid autodetect

    Disk /dev/md0: 2152 MB, 2152923136 bytes
    2 heads, 4 sectors/track, 525616 cylinders
    Units = cylinders of 8 * 512 = 4096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/md0 doesn’t contain a valid partition table

    Disk /dev/md2: 747.7 GB, 747727224832 bytes
    2 heads, 4 sectors/track, 182550592 cylinders
    Units = cylinders of 8 * 512 = 4096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/md2 doesn’t contain a valid partition table

     Bu işlemden sonra Boot record’u kopyalayacağız, önce boot recordun kopyasını dosyaya yazıyoruz:

    # dd if=/dev/sdb of=sdb.part bs=1024k count=1
    1+0 records in
    1+0 records out
    1048576 bytes (1.0 MB) copied, 0.0249217 s, 42.1 MB/s

    # dd if=sdb.part of=/dev/sda bs=1024k count=1
    1+0 records in
    1+0 records out
    1048576 bytes (1.0 MB) copied, 0.00123787 s, 847 MB/s

    Bölümleme işlemleri bittikten sonra sda arrayleri sdb’den geri alma işlemine başlayabiliriz:

    # mdadm –manage /dev/md0 –add /dev/sda1
    mdadm: added /dev/sda1

    # mdadm –manage /dev/md1 –add /dev/sda2
    mdadm: added /dev/sda2

    # mdadm –manage /dev/md2 –add /dev/sda3
    mdadm: added /dev/sda3

     Bu mirrorlama işlemleri arka planda devam etmektedir. Durumu görmek için “cat /proc/mdstat” komutunu verebilirsiniz. An be an takip etmek isterseniz şu komut ile konsolun birisinde monitörleme yapabilirsiniz:

    # watch -n .5 cat /proc/mdstat

    .5 rakamı güncellenme sıklığını saniye cinsinden belirtir 0.5 saniye anlamındadır değer 1 yaparak saniyede bir güncellenmesini sağlayabilirsiniz. Mirrorlama işlemi süresi diskin boyutu ve makinenin gücüne ayrıca başka işlem yapılıp yapılmadığına göre değişiklik göstermektedir.

    Every 0.5s: cat /proc/mdstat Tue Jul 23 13:42:47 2013

    Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] [linear] [multipath]
    md1 : active raid1 sda2[0] sdb2[1]
    264960 blocks [2/2] [_U]
    resync=DELAYED

    md2 : active raid1 sda3[2] sdb3[1]
    730202368 blocks [2/1] [_U]
    [=====>……………] recovery = 2.2% (16135936/730202368) finish=151.9min speed=78334K/sec

    md0 : active raid1 sda1[0] sdb1[1]
    2102464 blocks [2/2] [UU]

    unused devices: <none>

    Yukarıdaki görüntüde arrayler görünmekte ve bunların bazılarında ufak tefek farklar bulunmakta, bunları açıklamak gerekirse;

    • [2/2] [2/1] gibi ibareler md arrayine bağlı bölümlerin kaç tanesinin çalışır durumda olduğunu göstermektedir. md0 arrayinde 2 bölümde çalışır durumda.
    • [UU] [_U] gibi ibarelerde ise “U” harfi kullanımda olan bölümlemeleri göstermektedir. “_” ise kullanımda olmayan bölümlemeyi işaret eder.
    • md0 cihazı aktif ve sda1 bölümünün kopyası oluşturulmuş. Şu an sorunsuz bir şekilde çalışmakta.
    • md1 cihazı resync için “DELAYED” durumunda sıra beklemekte. ikinci bölümleme arraye eklenmiş ancak kullanıma açılmamış
    • md2 cihazında şu an resync yapılmakta bu yüzden henüz o da kullanıma açılmamış durumda.

    Sonraki yazımız karşılaşılan sorunlar ile nasıl başa çıkılacağına dair olacak.

  • Ubuntu sunucuda RAID1 array içindeki bozuk diski bulmak.

    RAID1 sistemdeki diskin bir tanesi bozulduğu zaman izlenecek yöntemler:

    Öncelikli işlem sistem henüz açık iken yedek almaktır. Her zaman yedeğinizi alın! Bu işlem sonucunda sisteminizde oluşabilecek sorunlardan tamamen siz sorumlusunuz. Ben yaptım oldu ancak sizin sistemde de aynı sonucu vermeme olasılığı her zaman vardır ve veri kaybı yaşamanız bu olasılık dahilindedir. Bu yüzden bu adımları uygularken yaşayacağını hiçbir kayıptan ben sorumlu değilim. 🙂

    Canlı sistemin yedeğini aldıktan sonra bozuk diskin hangisi olduğunu bilmiyorsanız öncelikle bunu tespit etmemiz gerekir.

    Sistemde root kullanıcı haklarına nail olup (# sudo -s) /var/log/ altındaki messages log dosyasının içine bakarak bozuk diskin hangisi olduğunu anlayabiliriz. Örnek olarak benim messages dosyasının içeriğini aşağıya ekledim:

    kernel: [ 540.541685] ata3.00: configured for UDMA/133
    kernel: [ 540.541698] sd 2:0:0:0: [sda] Unhandled sense code
    kernel: [ 540.541701] sd 2:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
    kernel: [ 540.541704] sd 2:0:0:0: [sda] Sense Key : Medium Error [current] [descriptor]
    kernel: [ 540.541709] Descriptor sense data with sense descriptors (in hex):
    kernel: [ 540.541711] 72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00
    kernel: [ 540.541721] 00 40 3b 8b
    kernel: [ 540.541725] sd 2:0:0:0: [sda] Add. Sense: Unrecovered read error – auto reallocate failed
    kernel: [ 540.541730] sd 2:0:0:0: [sda] CDB: Read(10): 28 00 00 40 3b 8b 00 00 03 00
    kernel: [ 540.541981] ata3: EH complete

    Yukarıda görüldüğü üzere “sd 2:0:0:0: [sda] Sense Key : Medium Error [current] [descriptor]” ve “sd 2:0:0:0: [sda] Add. Sense: Unrecovered read error – auto reallocate failed” satırları “sda” olarak bağlanmış olan diskte “medya hatası” ve “kurtarılamayan okuma hatası” hatası olduğunu söylemekte.

    Eğer sda diskin kasanın içindeki hangi disk olduğu konusunda bir fikriniz yoksa sistemi kapatıp disk sökmeye başlamadan önce hangi diski sökmeniz gerektiğini diskin seri numarasına bakarak şu şekilde bulabilirsiniz:

    # hdparm -i /dev/sda | grep SerialNo
    Model=SAMSUNG HD753LJ, FwRev=1AA01118, SerialNo=S13UJ90SXXXXXX

    İkinci olarak şu yöntem ile de seri numarasını bulabilirsiniz:

    # /sbin/udevadm info –query=property –name=sda | grep ID_SERIAL
    ID_SERIAL=SAMSUNG_HD753LJ_S13UJ90SXXXXXX
    ID_SERIAL_SHORT=S13UJ90SXXXXXX

    Eğer S.M.A.R.T. verilerini okumayı biliyorsanız mevcut RAID1 yapısındaki iki diskin S.M.A.R.T. verilerine bakarak hangi diskin bozuk olduğunu ve seri numarasını bulabilirsiniz.

    # smartctl -x /dev/sda

    Bu komut çıktısı çok uzun olduğu ve ekstra açıklamalar gerektiği için yazıyı daha uzatmamak adına buraya eklemiyorum. S.M.A.R.T. verisi nasıl okunur bunu başka bir konuda işleyeceğiz.

    Hangi diski sökmemiz gerektiğini öğrendiğimize göre artık sistemi kapatıp doğru diski değiştirebiliriz. Diski değiştirdikten sonra sistemi tekrar yükleyip RAID array’i yapılandırma işine girişeceğiz.

  • Defining Motherboard, CPU and BIOS info in Linux terminal

    In this article, I’m going to explain how to read motherboard, cpu and bios information under linux terminal.

    Reading Motherboard Information:

    # sudo dmidecode -t 2

     

    Reading Motherboard Serial Number:

    # sudo dmidecode -t 2 | grep Serial

     

    And OEM Information:

    # sudo dmidecode -t 11

    (daha&helliip;)

  • Migrating WLM contacts to another account…

    That is not easy to migrate contacts to another account. Almost painful to figuring out how to do it, because of live.com gui and MS law. If your contact list larger than 70 contacts your migration takes a long as contacts count/70 days. According to MS law you can send invitation  to 70 persons per day. I can’t find any way to migrate whole contacts in one basic step. But, I can show you how you can migrate your contacts as quick as possible without lost in live.com account menus.

     

    Now lets login to your account where contact list available in.

    Then went to “Messenger” with your mouse on top of the screen. That move opens Messenger Menu and click on “Contacts”.

    Now move on to “Manage” to open Manage Menu then click “Export”. Save the file to your computer, and log out from this account.

     

    It’s time to log in new account. When you logged in repeat the moves above until Manage Menu opens. On Manage Menu click “Import”. When you click import live.com redirect you to another page.

    Now click on “Another Windows Live account” under “Add people from.

  • “Yeniden” Merhaba dünya!

    blacole/js virüs saldırısının ardından siteyi kökten temizleyip yeniden kurmaya karar verdim ve işte buradayım. Yeniden aranızdayım…

  • Preparing virtual environment for running with apache mod_wsgi & postgresql

    For completing postgresql requirements of virtual environment, install “libpq-dev” and “python-dev” packages, outside of virtual environment.

    $ deactivate (if you are in virtual environment)
    $ sudo apt-get install libpq-dev python-dev

    Re-activate virtual environment and install psycopg2 from pip repo.

    $ pip install psycopg2

    By the way, in the name of  conformist approach install ipython in virtual environment.

    $ pip install ipython

    PostgreSQL engine and python connection libraries are ready.
    Now, lets prepare wsgi file for current project. (I assumed apache and mod_wsgi installed and configured) I’m going to use /var/www/project path for example for environment root in wsgi file.

    ENV_DIR = [‘/var/www/project’]

    import site, os, sys

    base = os.path.dirname(__file__)
    sys.path.insert(0, base)
    sys.path.append(os.path.dirname(base))

    # Remember original path.
    prev_sys_path = list(sys.path)

    # Add each new site-packages directory.

    for directory in ENV_DIR:

    site.addsitedir(directory)

    # For taking new directories to the front reorder path.

    new_sys_path = []
    for item in list(sys.path):

    if item not in prev_sys_path:

    new_sys_path.append(item)
    sys.path.remove(item)

    sys.path[:0] = new_sys_path
    os.environ[‘PYTHON_EGG_CACHE’] = ‘/tmp/project_eggs’
    sys.stdout = sys.stderr
    os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘%s.settings’ % os.path.basename(base)
    from django.core.handlers.wsgi import WSGIHandler
    application = WSGIHandler()

    Place the wsgi file above into root of the django project which created inside of the virtual environment directory (eg. /var/www/project/django/)

    So wsgi file is ready, and we can configure apache to use this wsgi file:

    <VirtualHost *:80>

    WSGIDaemonProcess project_name user=username group=usergroup processes=3 threads=15 inactivity-timeout=120 maximum-requests=50 python-path=/var/www/project/lib/pyton2.7/site-packages
    WSGIProcessGroup project_name
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptAlias / /var/www/project/django/wsgi
    ServerName project_name.com
    ServerAdmin admin@project_name.com
    CustomLog /var/www/project/django/log/access_log combined
    ErrorLog /var/www/project/django/log/error_log
    Alias /static “/var/www/project/django/static”

    </VirtualHost>

    Save this file under /etc/apace/sites-available as “project.conf”

    Run “$ a2ensite project.conf” command and restart (or reload) the apache service.

    Now you can see the running django installation at “http://www.project_name.com”

  • Installing Django-CMS over Python Virtual Environment on Ubuntu based systems

    Prepare for virtual environment:

    $ sudo apt-get install python-setuptools python-dev build-essential
    $ sudo easy_install pip
    $ sudo pip install virtualenv

    Creating a virtual environment:

    $ virtualenv example_env -p python2.7 –no-site-packages –distribute

    Activating virtual environment:

    $ source example_env/bin/active

    Installing Django and Django-CMS in to virtual environment:

    $ pip install PIL
    $ pip install django-cms

    the command above is also installs those required packages:

    django
    django-mptt
    django-classy-tags
    django-sekizai
    south
    html5lib

    Thats all. Library installation on virtual environment is complete. On the next, how to run django-cms on django with apache…

     

    Note: If you want to exit from virtual environment just type this:

    $ deactivate

  • Webfaction Surprise/Sürprizi…

    Today I’ve got an e-mail form Webfaction. “Today we’re happy to announce that our shared hosting plan has been upgraded from 80MB of app memory to 256MB! This applies not only to new customers but to all existing accounts as well.” they said. It’s been very nice surprise.

    —————————————

    Bu gün Webfaciton’dan bir e-posta aldım. Diyorlar ki “Bu gün mutlulukla duyuruyoruz ki, paylaşımlı barındırma planımızda bulunan 80 MB uygulama belleği 256MB’a yükseltilmiştir! Bu sadece yeni müşteriler için değil, tüm mevcut müşteriler için geçerlidir.” . Çok güzel bir sürpriz oldu.

  • Installing 64Bit Python, iPython environment to Windows Server 2008

    Download latest python installer in to windows server 2008 and install it.
    Download http://peak.telecommunity.com/dist/ez_setup.py from setuptools (http://pypi.python.org/pypi/setuptools) and run with python

    python ez_setup.py

    And after all download ipython source for windows environment (http://archive.ipython.org/release/0.11/ipython-0.11.zip) Extract it and install by the command below:

    python setup.py install

    Thats all….

  • Linux dd komutunun durumunu izlemek

    Aşağıdaki komut ile dd programının PID’i öğrenilir.

    $ pgrep -l ‘^dd$’
    8789 dd
    $

    USR1 sinyali dd programına gönderilir:

    $ kill -USR1 8789
    $
    dd programı sinyali alır almaz o anki istatistikleri ekrana basar ve kaldığı yerden işlemine devam eder.
    Örnek:

    $ dd if=/dev/random of=/dev/null bs=1K count=100
    0+14 records in
    0+14 records out
    204 bytes (204 B) copied, 24.92 seconds, 0.0 kB/s

    Devamlı izleme yapmak için watch komutu ile izleme sağlanabilir. Aşağıdaki komut 10 saniyede bir dd programının istatistik çıktısını basmasını sağlar.

    $ watch -n 10 kill -USR1 8789