Tag Archive for 'linux'

RHEL5, yum + proxy = Error

En un RedHat EL 5, al hacer un yum con proxy recibo el siguente mensaje: “Error: Cannot open/read repomd.xml file for repository: rhel-i386-server-5″

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)

# export http_proxy="http://localhost:8888"
# yum update
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
Error: Cannot open/read repomd.xml file for repository: rhel-i386-server-5

En el proxy recibimos lo siguiente:

[Fiddler] Request Header parsing failed. Request was:
43 4F 4E 4E 45 43 54 20 78 6D 6C 72 70 63 2E 72 68 6E 2E 72 65 64 68 61  CONNECT xmlrpc.rhn.redha
74 2E 63 6F 6D 3A 34 34 33 20 48 54 54 50 2F 31 2E 31 0D 0A 0D 0A        t.com:443 HTTP/1.1....

Encontre la solucion googleando un poco (solo una pagina hablaba de ello), pero probe la solucion y funciono:

It’s a bug in the crypto lib of python. It doesn’t add the HOST in the
headers of the HTTP/1.1.

Hay que editar el fichero /usr/lib/python2.4/site-packages/M2Crypto/httpslib.py en la maquina y añadir la linea siguiente entre las lineas 165 y 166:

msg = msg + "Host: %s:%d\\r\\n" % (self._real_host, self._real_port)

Quedando asi:

    def _get_connect_msg(self):
        """ Return an HTTP CONNECT request to send to the proxy. """
        msg = "CONNECT %s:%d HTTP/1.1\\r\\n" % (self._real_host, self._real_port)
        msg = msg + "Host: %s:%d\\r\\n" % (self._real_host, self._real_port)
        if self._proxy_auth:
            msg = msg + "%s: %s\\r\\n" % (self._AUTH_HEADER, self._proxy_auth)
        msg = msg + "\\r\\n"
        return msg

Una vez hecho esto, ya funciona bien:

# yum check-update
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Setting up repositories
rpmforge                  100% |=========================| 1.1 kB    00:00
rhel-i386-server-5        100% |=========================| 1.4 kB    00:00
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 1.5 MB    00:00
################################################## 6175/6175
primary.xml.gz            100% |=========================| 1.1 MB    00:05
################################################## 3219/3219

iSCSI entre una Solaris (Initiator) y un Linux (target)

Respondiendo al comentario de gonzo34 a ese post solicitando mas informacion sobre como usar iSCSI en Solaris, voy a poner aqui mis notas sobre el tema.

En el linux, que “exporta” por iSCSI el disco (o el lvol), instalamos el iSCSI Target. Una vez instalado, indicamos al demonio qué disco/lvol exportar (por ejemplo el /dev/vg01/lviscsi01):

# vi /etc/ietd.conf
#IncomingUser nwsmith secretsecret
Target iqn.2006-06.com.alegrome:storage.lvm
Lun 0 /dev/vg01/lviscsi01
Alias iscsitest01

Iniciamos el demonio (o lo reiniciamos):

# service iscsi-target start
Starting iSCSI target service:    [  OK  ]

Comprobamos que este arriba el demonio:

# netstat -ntlp | grep 3260
tcp  0  0  0.0.0.0:3260  0.0.0.0:*  LISTEN 3160/ietd
# tail /var/log/messages
Jan 14 15:59:02 server kernel: iSCSI Enterprise Target Software - version 0.4.5
Jan 14 15:59:02 server kernel: iotype_init(91) register fileio
Jan 14 15:59:03 server kernel: target_param(109) d 1 8192 262144 65536 2 20 8 0
Jan 14 15:59:03 server iscsi-target: ietd startup succeeded

alegrome# cat  /proc/net/iet/volume
tid:1 name:iqn.2006-06.com.alegrome:storage.lvm
        lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg01/lviscsi01

Ahora en la solaris (cambiar IP por la IP del Linux):

# iscsiadm add discovery-address IP:3260

# iscsiadm modify discovery --sendtargets enable

# iscsiadm list discovery
Discovery:
        Static: disabled
        Send Targets: enabled
        iSNS: disabled

# devfsadm -v -i iscsi
devfsadm[752]: verbose: symlink /dev/dsk/c1t2d0s0 -> ../../devices/iscsi/disk@0000iqn.2006-06.com.alegrome%3Astorage.lvm0001,0:a
[...]

Ya vemos el disco con el format:

# format
Searching for disks...done

c1t2d0: configured with capacity of 1008.00MB

AVAILABLE DISK SELECTIONS:
       0. c0t0d0 
          /pci@1f,0/pci@1,1/ide@3/dad@0,0
       1. c1t2d0 
          /iscsi/disk@0000iqn.2006-06.com.alegrome%3Astorage.lvm0001,0
Specify disk (enter its number): ^D

Vemos los targets descubiertos:

# iscsiadm list target
Target: iqn.2006-06.com.alegrome:storage.lvm
        Alias: -
        TPGT: 1
        ISID: 4000002a0000
        Connections: 1
...

Y mas informacion sobre cada uno:

# iscsiadm list target-param -v iqn.2006-06.com.alegrome:storage.lvm
Target: iqn.2006-06.com.alegrome:storage.lvm
        Alias: -
        Bi-directional Authentication: disabled
        Authentication Type: NONE
        Login Parameters (Default/Configured):
                Data Sequence In Order: yes/-
                Data PDU In Order: yes/-
                Default Time To Retain: 20/-
                Default Time To Wait: 2/-
                Error Recovery Level: 0/-
                First Burst Length: 65536/-
                Immediate Data: yes/-
                Initial Ready To Transfer (R2T): yes/-
                Max Burst Length: 262144/-
                Max Outstanding R2T: 1/-
                Max Receive Data Segment Length: 8192/-
                Max Connections: 1/-
                Header Digest: NONE/-
                Data Digest: NONE/-
        Configured Sessions: 1

Por otra parte en la Linux, vemos la session iSCSI:

alegrome# cat  /proc/net/iet/session
tid:1 name:iqn.2006-06.com.alegrome:storage.lvm
        sid:281475681353792 initiator:iqn.1986-03.com.sun:01:0800209efab9.46bc3c8b
                cid:0 ip:192.168.0.30 state:active hd:none dd:none

Espero que le sirva a alguien ;-)

µTorrent en Linux (III): Tuning TCP/IP

En este nuevo post de mi serie sobre µTorrent en Linux, hablaré de los parametros de kernel que he modificado en mi maquina para intentar optimizar el tema de conexiones.

La verdad es que he cojido estos parametros de algun manual sobre como tunear un servidor para tener un buen rendimiento cuando asume muchas conexiones, lo cual deberia servir en nuestro caso.

Estas lineas se introducen en el fichero /etc/sysctl.conf y para cargarlas usamos el comando: sysctl -p. Ahi van los parametros, con comentarios:

# Enable fast recycling of TIME-WAIT sockets status

net.ipv4.tcp_tw_recycle=1

# tcp_fin_timeout is the time to hold a socket in state
# FIN-WAIT-2 when the socket is closed at the server.

net.ipv4.tcp_fin_timeout=30

# One of the problems found in servers with many simultaneous TCP
# connections is the large number of connections that are open but unused.
# TCP has a keepalive function that probes these connections and
# drops them after tcp_keepalive_time

net.ipv4.tcp_keepalive_time=1800

# max OS send buffer size (wmem) and receive buffer size (rmem)
# for queues on all protocols (8388608=8MB)

net.core.wmem_max=8388608
net.core.rmem_max=8388608

# In addition, you should also use the following commands for send and receive
# buffers. They specify three values: minimum size, initial size, and maximum
# size. The third value must be the same as or less than the value of
# wmem_max and rmem_max.

net.ipv4.tcp_rmem = 4096 87380 8388608
net.ipv4.tcp_wmem = 4096 87380 8388608

# When the server is heavily loaded or has many clients with bad connections
# with high latency, it can result in an increase in half-open connections.
# This is very common for Web servers, especially when there are many dial-up
# users. These half-open connections are stored in the backlog connections
# queue. You should set this value to at least 4096 (the default is 1024).

net.ipv4.tcp_max_syn_backlog=4096

# don't cache ssthresh from previous connection
net.ipv4.tcp_no_metrics_save = 1

Lo cierto es que no tengo datos para comparar si va mejor asi, pero el caso es que a mi me va de fabula!

µTorrent en Linux (II): Gestión del ancho de banda

Siguiendo con la serie de posts sobre como montar un servidor de bittorent en Linux, hablaré esta vez del tema del ancho de banda.

En efecto, Bittorent es un protocolo muy goloso: en pocas palabras, se suele comer todo el ancho de banda disponible (si le dejas).

Para bajar rapido, eso puede ser genial! Pero si queremos poder hacer algo mas, como navegar por ejemplo, conviene restringir un poco el Bittorrent.

En mi caso, uso el “scheduler” de µTorrent para lograrlo:
* Durante la noche (de 01:00 a 07:00 entre semana, y de 01:00 a 10:00 el fin de semana), cuando no me importa poder navegar o no (porque duermo!), lo dejo en “Full Speed”, es decir que no restrinjo. Si µTorrent tiene algo encolado para bajar/subir, podra disfrutar de todo el ancho de banda disponible.
* El resto del dia, limito el uTorrent a 90kB/s en bajada y 15kB/s en subida, asi no se come todo el ancho de banda.
* Cuando no se esta bajando nada, no suele consumirse casi nada de ancho de banda (logicamente).

utorrent bandwidth scheduler

µTorrent en Linux (I): Introducción

utorrent_logo.pngPara bajar los capitulos de mi series preferidas, no he encontrado ningun cliente Bittorrent mejor que µTorrent:
* es muy pequeño y consume poco
* no necesita instalacion,
* soporta RSS (programar el µTorrent para que baje una serie es mas facil que programar el video!).

Lo malo es que es para Windows. En casa tengo un servidor de ficheros corriendo Debian y esto me obligaba a mantener encendido tambien otro equipo con Windows. En Linux probe Azureus, pero no conseguir hacer funcionar ningun plugin de RSS. Ademas el consumo de Azureus (Java) era mucho mayor.

Hasta que probe µTorrent bajo Wine en Debian, y funciono perfectamente.

Bajamos Wine y µTorrent:

# apt-get install wine
$ wget http://download.utorrent.com/1.7.5/utorrent.exe

En mi caso, como mi Linux hace de servidor, no suele tener conectado ni monitor ni teclado (salvo casos que los necesite). Por lo tanto, no tiene entorno grafico, pero µTorrent (y Wine) necesitan un entorno grafico para correr. Para resolver este problema, he instalado el paquete vncserver.

Es un servidor X que corre en background (frame buffer). Es decir que esta en memoria, no en un monitor. Para poder interactuar con el, lo haremos de forma remota con un cliente VNC. Es perfecto para poder lanzar µTorrent en el servidor.

Para bajar VNCserver:

# apt-get vncserver

En este post, vamos a suponer que lanzo µTorrent en el puerto 4567, con el usuario utorrent.

Abrimos el firewall del linux, para permitir conexiones entrantes al puerto del µTorrent:

# Apertura puerto 4567 para uTorrent
iptables -A INPUT -i eth0 -p tcp --dport 4567 -m state --state NEW -j ACCEPT

Lanzamos el servidor X vncserver. En mi caso, lo lanzo en el display :2 :

utorrent@servidor$ vncserver :2

Vemos que vncserver lanza Xrealvnc con un monton de opciones:

utorrent  10784     1  4 15:22 pts/0    00:10:12 Xrealvnc :2 -desktop X -httpd /usr/share/vnc-java -auth /home/utorrent/.Xauthority -geometry 796x576 -depth 24 -pixelformat bgr888 -rfbwait 120000 -rfbauth /home/utorrent/.vnc/passwd -rfbport 5902 -fp /usr/share/fonts/X11/misc/ -co /etc/X11/rgb

Al abrir el display :2, el servidor VNC escucha en el puerto 5900+2=5902. Para levantar µTorrent, vamos a conectarnos desde otro equipo con un cliente VNC a nuestro servidor (en el cliente indicaremos “servidor::5902″).

Al desconectarnos, no pasara nada, todo lo que teniamos sigue corriendo en el vncserver.

Para lanzar µTorrent, ejecutaremos:

DISPLAY=:2 wine ~/.wine/drive_c/Program\ Files/uTorrent/uTorrent.exe

(En mi caso, he copiado el binario uTorrent.exe en la ruta ~/.wine/drive_c/Program\ Files/).

Si es la primera vez que lanzamos Wine, saldra un pequeño asistente, indicar tipo de equipo “Windows XP”. Luego, configurar el µTorrent. (En mi caso, he conservado la configuracion de µTorrent que tenia bajo Windows, copiando los ficheros de configuracion de µTorrent en la misma ruta que el binario en Linux).

Podemos ver que µTorrent en Linux no requiere muchos recursos:

top - 06:48:06 up 9 days,  9:01,  3 users,  load average: 0.07, 0.26, 0.68
Tasks: 112 total,   2 running, 110 sleeping,   0 stopped,   0 zombie
Cpu(s):  2.3%us,  2.6%sy,  0.0%ni, 94.4%id,  0.3%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:    256972k total,   253344k used,     3628k free,     3672k buffers
Swap:   735852k total,    56760k used,   679092k free,    72680k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
13873 utorrent   18   0 2597m  10m 4948 S  2.3  4.2  31:05.70 uTorrent.exe
13877 utorrent   15   0  4076  712  544 S  1.6  0.3   6:41.99 wineserver

Aqui van algunos pantallazos del µTorrent corriendo en mi Linux:
pict0004.gif pict0005.gif pict0002.gif

En futuros posts hablaré de los siguientes temas:
* notificacion automatica por email de nuevos ficheros bajados,
* scripts arranque/parada: para que arranquen el vncserver y µTorrent cuando arranca la maquina, sin que tengamos que hacer nada nosotros.
* monitorizacion: para que siempre este arriba nuestro servidor µTorrent. Si se cae, volver a levantarlo. (Monitorizacion de puerto y proceso)
* tuning tcp/ip linux: Algunos cambios de parametros de TCP/IP. Dada la naturaleza de Bittorrent, se van a abrir y cerrar muchas conexiones en la maquina. Puede venir bien modificar algunos parametros para optimizar el tema de conexiones.




Close
Powered by ShareThis