Category Archives: Linux - Page 6

How to restore windows MBR from linux

Just install collection of boot loaders (usually already installed)
And use DD, Luke 🙂 🙂

  #aptitude install syslinux
  #sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda
  # aptitude search syslinux
  i   syslinux                                                               - collection of boot loaders                                                      
  i   syslinux-common                                                        - collection of boot loaders (common files)

Some interesting search word statistic resources.

For one article (other project, not it.randomthemes) I look fore some “search engine” wordstat.
Google and Yandex provides it. Here are links:

https://adwords.google.com/select/KeywordToolExternal
http://google.com/insights/search/#geo=RU&cmpt=q
http://wordstat.yandex.ru/

How to use GIT + bitbucket

Finally I decide to move all my projects from SVN to Git.
And my friends recommend https://bitbucket.org/ – perfect place for hosting projects. Absolutely free for small groups (up to 5 accounts as I remember.)
+ Jira + wiki etc.

So, your register, create first repo then commit files.
It`s very trivial, but I always forget syntax. 🙂

  git init
  git remote add origin https://ksi_sergey@bitbucket.org/ksi_sergey/ruby-mail-filter.git
  git add .
  git status
  git commit -m "First commit"
  1 files changed, 44 insertions(+), 0 deletions(-)
  create mode 100755 filter.rb

And Push

  git push -u origin master
  Password:
  Counting objects: 3, done.
  Delta compression using up to 4 threads.
  Compressing objects: 100% (2/2), done.
  Writing objects: 100% (3/3), 755 bytes, done.
  Total 3 (delta 0), reused 0 (delta 0)
  remote: bb/acl: ksi_sergey is allowed. accepted payload.
  To https://ksi_sergey@bitbucket.org/ksi_sergey/ruby-mail-filter.git
   * [new branch]      master -> master
  Branch master set up to track remote branch master from origin.
  $:~/Ruby Mail Filter$

Done 🙂

Magic keys linux.

Today we had interesting issue.
One server completely stalled, due to file system crash. I mean – reboot, shutdown -r now, init 6 not working.
In this case your can use magic keys (SysRq) remotely via /proc/sys/trigger

  echo b > /proc/sysrq-trigger - send Alt + SysRq + B to kernel

Alt + SysRq + B – Makes Immediate reboot without sync of file systems, action is the same as RESET pressed.

Additional information:
http://en.wikipedia.org/wiki/Magic_SysRq_key
Thanks to out colleague Yuriy for this information. Useful.

SVN issues (sometimes it`s difficult to recall)

How to get youngest revision version

  ~$svnlook youngest /var/lib/svnmirror

How to check repo (Damn it takes huge ammount of time) more then 3 month for 301914 revisions. And CPU usege runs high, so if your store content at SVN (it`s really not a good idea…) an your need to veryfy it, better to do verifycation on dedicated powerful server.

  
  ~$svnadmin verify /home/svn/content/

Add all new created files to SVN

 ~$svn st | grep "^?" | awk '{print $2}' | xargs svn add

netperf – measuring network bandwidth

Netperf is much better way to measure network bandwidth, then using ftp/sftp, as many OPS do.

stx153:~# aptitude search netperf 
p   netperf                                                   - Network performance benchmark                                      
stx153:~# aptitude install netperf

Remove startup links, we don`t need netperf to be started at runtime.

stx153:~# update-rc.d -f netperf remove
 Removing any system startup links for /etc/init.d/netperf ...
   /etc/rc0.d/K20netperf
   /etc/rc1.d/K20netperf
   /etc/rc2.d/S20netperf
   /etc/rc3.d/S20netperf
   /etc/rc4.d/S20netperf
   /etc/rc5.d/S20netperf
   /etc/rc6.d/K20netperf
stx153:~# 
#/etc/init.d/netperf start

How to test:
There are a lot of netperf options, in general, but usually we need only test and CPU.

:~#man netperf
:~# netperf -H server.mydomain.com -c -C
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to server.mydomain.com (10.253.46.1) port 0 AF_INET : demo
Recv   Send    Send                          Utilization       Service Demand
Socket Socket  Message  Elapsed              Send     Recv     Send    Recv
Size   Size    Size     Time     Throughput  local    remote   local   remote
bytes  bytes   bytes    secs.    10^6bits/s  % S      % S      us/KB   us/KB
 87380  87380  87380    10.09        86.29   8.67     2.37     65.847  18.012 

Apache Debugging

As usual…

After some changes apache start producing segfauls.

#vi /etc/apache2/apache2.conf

CoreDumpDirectory /tmp/apache2-cores

#ulimit -c unlimited

#/etc/init.d/apache2 restart

 

Now apache will put core files to /tmp/apache2-cores (don`t forget to create folder with sufficient rights.)

Testing

#kill -11 PID
#ls /tmp/apache2-cores

All woring, we can observer core.

 

Now launch your ugly script causing cores.

Run GDB.

#gdb /usr/sbin/apache2 /tmp/apache2-cores/core

Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal 11, Segmentation fault.
[New process 26683]
#0 0xf7662caf in memcpy () from /lib/libc.so.6
(gdb) where
#0 0xf7662caf in memcpy () from /lib/libc.so.6
#1 0xf63ef13f in restore_class () from /usr/lib/php5/20060613+lfs/eaccelerator.so
#2 0xf63ed390 in eaccelerator_compile_file () from /usr/lib/php5/lfs/eaccelerator.so
#3 0xf6987e73 in compile_filename () from /usr/lib/apache2/modules/libphp5.so
#4 0xf69d2bbf in ?? () from /usr/lib/apache2/modules/libphp5.so
#5 0x00000008 in ?? ()
#6 0xfff5de20 in ?? ()
#7 0xfff5dda8 in ?? ()
#8 0xf698aa8e in ?? () from /usr/lib/apache2/modules/libphp5.so
#9 0x08bfe23d in ?? ()
#10 0x08bfd240 in ?? ()
#11 0xfff5dda4 in ?? ()
#12 0xf69c912e in ?? () from /usr/lib/apache2/modules/libphp5.so
#13 0xf52edc24 in ?? ()
#14 0xfff5e024 in ?? ()
#15 0x00000000 in ?? ()
(gdb)

This mean segfault occurs at eaccelerator. When eaccelerator tries to put bytecode to disk.
Damn. As usual all accelerators are crap. 🙁

Disable eaccelerator at /etc/php5/conf-d/xxxx.ini
and restart apache.
Error gone. According to my experience and experience of my colleges, all accelerators creates segfault on some applications. If your want stability, better to extend number of servers. But if accelerator is working for you – your are lucky guy! 🙂

Hello %USERNAME%!

Some time ago, I start my IT wiki ksimute.trancom.ru, but it`s in russian language.

So only few people can read it. 🙁 I decide to continue writing in english, to share knowlage with more people. And to move data from my former job domain to my own domain.

I really hope that this blog will help somebody 🙂 in their job.  Because it`s usually helps me to solve issues.

P.S. Excuse my english. It`s realy bad, but usually everyone understand, what I`am talking about.

Sergey.