Thursday, August 19, 2010

Windows - Create file to test filesystem - utility

To create a file filled with zero's on windows;

fsutil file createnew name-of-file.txt 2000 (this is the length in bytes)

This will create a new file with 2000 bytes.


This can usefull for copy / perfomance disk testing.
.
.

Wednesday, August 11, 2010

Varnish - cache "invention" - Load balacing squid's

I tested load balacing squid proxys with HAproxy, and it was nice, then i had a crazy thought;
"what if i used varnish, and load-balance "and" cache at the same time...?"

Varnish its a great software for reverse-caching webservers... i'm not using it for what it was created, but i had this crazy idea...:P

Well, i took varnish and started "inventing" a way...

This is my setup to load-balance and cache, with varnish, 3 squid's :P (yep, crazy i know):

Request---> varnishd:8080 --> refered has "webfarm"
            /    |    \
           /     |     \
       proxy1  proxy2  proxy3

config file: default.vcl

 backend proxy1 {
     .host = "10.30.1.171";
     .port = "8080";
 }


 backend proxy2 {
     .host = "10.30.1.172";
     .port = "8080";
 }

 backend proxy3 {
     .host = "10.30.1.173";
     .port = "8080";
 }

 director webfarm round-robin {
 {
  .backend = proxy1;
 }
 {
  .backend = proxy2;
 }
 {
  .backend = proxy3;
 }
 }

 sub vcl_recv {
  if (client.ip == "10.1.5.10" )
   { set req.backend = webfarm; }
}.


Well it worked...but i'm not very sure about the perfomance...varnish was not created for this :P
.

HAproxy - LoadBalancer - balancing 3 squid's

Trying to loadbalance requests across 3 squid-cache proxys, very nice, i'm enjoiyng HAproxy a lot, great software.

Here it goes:

Client request <-----> HAproxy <---> squid1 \ 
                               <---> squid2  -- web
                               <---> squid3 /


Config file: haproxy.cfg

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #nbproc 2
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000



# reverse proxy-squid
listen  webfarm 0.0.0.0:8000
        mode http
        cookie  SERVERID insert indirect nocache
        balance roundrobin
        option httpclose
        option forwardfor header X-Client
        server  squid1 10.30.1.171:8080 check inter 2000 rise 2 fall 5
        server  squid2 10.30.1.172:8080 check inter 2000 rise 2 fall 5
        server  squid3 10.30.1.173:8080 check inter 2000 rise 2 fall 5


listen admin_stats 0.0.0.0:81
        mode http
        stats uri       /stats
        stats realm     Global\ statistics
        stats auth      username:password

        #errorloc       502     http://192.168.114.58/error502.html
        #errorfile      503     /etc/haproxy/errors/503.http
        errorfile       400     /etc/haproxy/errors/400.http
        errorfile       403     /etc/haproxy/errors/403.http
        errorfile       408     /etc/haproxy/errors/408.http
        errorfile       500     /etc/haproxy/errors/500.http
        errorfile       502     /etc/haproxy/errors/502.http
        errorfile       503     /etc/haproxy/errors/503.http
        errorfile       504     /etc/haproxy/errors/504.http

 
------------------------------ EOF ------------------------------------



.
To access the haproxy stats, use: (the "uri" defined)
http://webfarm:81/stats

Well it works, very nice, and it does backend servers check, and statistics NICE !
.

Monday, July 26, 2010

Active Directory Database - Files

Important files of Active Directory.

Active Directory Database is stored in %systemroot%\NTDS\
the DB file is ntds.dit

The files in this directory, and what they do;
1:ntds.dit : this is the main database file for active directory.
2:edb.log  : When a transaction is performed to AD database, it will be stored to this file, and then after it will be sent to the Database
3:res1.log : Used as a reserved free space, in case of disk low space, default size is 10MB.
4:res2.log : Same of the above.
5:edb.chk  : Records transactions committed to the AD database. During shutdown, "shutdown statement" is written to this file, if it is not found during system startup the AD database checks the edb.log for updated information.

Ntdsutil: tool that can verify database integrity

.

Tuesday, June 29, 2010

Linux - Tools to view disk activity

Here are some tools to find out what process is "eating" your resources:

  • iotop
  • vmstat
  • lsof
  • atop
  • strace -e trace=open "aplication"

.

Friday, June 25, 2010

HAproxy - LoadBalancer - Simple config

I'm testing HAproxy, here is my first simple configuration:
- 1 haproxy server -> Serving 2 backend webservers

Request ---> haproxy:80  ---refered as "webfarm"
                 |          
                / \
            moss1  moss2

Config file: haproxy.cfg

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #nbproc 2
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen  webfarm 0.0.0.0:80
        cookie  SERVERID insert indirect nocache
        balance roundrobin
        server  moss1 10.30.1.61:80 cookie check inter 2000 rise 2 fall 5
        server  moss2 10.30.1.62:80 cookie check inter 2000 rise 2 fall 5

listen admin_stats 0.0.0.0:81
        mode http
        stats uri       /my_stats
        stats realm     Global\ statistics
        stats auth      username:password

        #errorloc       502     http://192.168.114.58/error502.html
        #errorfile      503     /etc/haproxy/errors/503.http
        errorfile       400     /etc/haproxy/errors/400.http
        errorfile       403     /etc/haproxy/errors/403.http
        errorfile       408     /etc/haproxy/errors/408.http
        errorfile       500     /etc/haproxy/errors/500.http
        errorfile       502     /etc/haproxy/errors/502.http
        errorfile       503     /etc/haproxy/errors/503.http
        errorfile       504     /etc/haproxy/errors/504.http


To access haproxy stats:
http://webfarm:81/my_stats

It's working nice, i have to continue tests and try more configuration settings.

.

Wednesday, June 2, 2010

Ubuntu 10.04 - tips - boot in graphic mode

I'm trying Ubuntu (finaly...i wasn't a big fan...but it's growing :)

I installed Lucid Lynx, desktop version, but i'm using it as my second workstation, so i wanted to "tweak it" a little bit.

To boot in text mode, i did some search and found that Ubuntu desktop is configured to work in graphic mode in almost every runlevel

So we can config grub to boot in text mode:
edit /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

add "text"
to the options.

And i also stopped some services:
/etc/rc2.d/
# mv S70bluetooth K70bluetooth

I must confess that the package management of debian based systems is the best (in my humble opinion)

I'm very impressed with "apt-get" ;)
.

Tuesday, June 1, 2010

Logging in Apache - don't log favicon.ico

Apache logs a lot of info, but it can be configured.

Here is a brief description of what i've done to apache config, so that it would not log some hits, for example "favicon.ico", here it goes:

First i altered /etc/apache2/apache2.conf (other systems can be httpd.conf)

I don't want to log agents...
In these lines:
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined


I modified to look like this:
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O" vhost_combined

A lot less info about agent's ;)

Now for the sites, in the file /etc/apache2/sites-available/default i added this:
SetEnvIf Request_URI "^/favicon\.ico$" dontlog

then on the line that has the CustomLog entry:
CustomLog /var/log/apache2/access.log combined env=!dontlog

After this the favicon.ico continues to log in the error.log, so i created a zero size file in /var/www/
# cat /dev/null > favicon.ico

I know it's not the best for debugging but i like it better like this, i think it's better for reading ;)
.

Saturday, March 6, 2010

Roll Back Windows Patch - KB


On a Windows box, regulary we should patch and update, on any box, on any operating system updates are important.


But what if after a patch or KB.exe on your pc/server you receive a "blue screen" error?


There is a way of "rolling-back"!
1. Boot from your Windows XP CD or DVD and start the recovery console.
Once you are in the Repair Screen..
2. Type this command: CHDIR $NtUninstallKB977165$\spuninst
3. Type this command: BATCH spuninst.txt
4. Type this command: systemroot
5. When complete, type this command: exit


This should do it.



Tuesday, March 2, 2010

Problem with Squid - signal 6

Squid-cache on a linux machine, was crashing repeatedly with the error:
$ exited due to signal 6

After lots of logs reading and net hunting i found out that this error was corrected on a newer version of squid.

The error was on the following version:
Squid Cache: Version 2.5.STABLE6

I upgraded to:
Squid Cache: Version 2.5.STABLE11
So i upgraded and .... no more crashes.

Some tips and commands that helped on troubleshooting:
Read squid logs:
 - /var/log/squid
     - cache.log


Verify squid cache directory:
- /var/spool/squid

Verify message logging:
 - /var/log/messages

Commands:
to rebuild cache:  squid -z

to start with debug: squid -d 3 -F -N -X
-d 3  --- more debug level
-F     --- don't service any request until cache is rebuild
-N    --- no daemon level
-X     --- force full debug