Rubén Ortiz » Centos http://www.rubenortiz.es Blog personal de Rubén Ortiz Mon, 16 Jan 2012 08:09:38 +0000 en hourly 1 http://wordpress.org/?v= CentOS – deshabilitar selinuxhttp://www.rubenortiz.es/2011/10/11/centos-deshabilitar-selinux/ http://www.rubenortiz.es/2011/10/11/centos-deshabilitar-selinux/#comments Tue, 11 Oct 2011 07:21:59 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4832 Para hacerlo al momento sin esperar a reinicio

1
# setenforce 0


Cambiar configuración para siguientes reinicios

1
2
3
4
5
6
7
8
9
10
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
]]>
http://www.rubenortiz.es/2011/10/11/centos-deshabilitar-selinux/feed/ 0
MongoDB en CentOShttp://www.rubenortiz.es/2011/10/06/mongodb-en-centos/ http://www.rubenortiz.es/2011/10/06/mongodb-en-centos/#comments Thu, 06 Oct 2011 11:17:49 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4810 ¿Qué es MongoDB? Buena pregunta, ¿hay algún médico en la sala? Pues es una base de datos orientada a documentos, un concepto bastente diferente del SQL.

MongoDB wasn’t designed in a lab. We built MongoDB from our own experiences building large scale, high availability, robust systems. We didn’t start from scratch, we really tried to figure out what was broken, and tackle that. So the way I think about MongoDB is that if you take MySql, and change the data model from relational to document based, you get a lot of great features: embedded docs for speed, manageability, agile development with schema-less databases, easier horizontal scalability because joins aren’t as important. There are lots of things that work great in relational databases: indexes, dynamic queries and updates to name a few, and we haven’t changed much there. For example, the way you design your indexes in MongoDB should be exactly the way you do it in MySql or Oracle, you just have the option of indexing an embedded field.

– Eliot Horowitz, 10gen CTO and Co-founder

Acabamos de conocernos pero lo poco que he visto me gusta, al menos, la documentación es amplia y precisa. En este post tratamos la instalación y cuatro comandos de newbie

La instalación se lleva a cabo en CentOS 6 64 bits.
Editamos nuestro repositorio de CentOS:

1
2
# cd /etc/yum.repos.d
# vim mongodb.10gen.repo
1
2
3
4
[10gen]
name=10gen Repository
baseurl=http://downloads.mongodb.org/distros/centos/5.4/os/x86_64/
gpgcheck=0
1
2
3
# sudo yum install mongo-stable-server
# sudo /etc/init.d/monod start
# chkconfig mongod on

Primeros pasos:

Accedemos por consola a nuestro MongoDB

1
2
3
4
-bash-4.1# mongo
MongoDB shell version: 1.6.5
connecting to: test
>

Una vez dentro, listamos bases de datos a las que estamos conectados

1
2
3
> show dbs
admin
local

Cambiamos a otra base de datos o creamos una de cero

1
2
> use prueba
switched to db prueba

Añadimos y salvamos un documento

1
2
3
4
5
6
7
8
9
> post={
... 'title':'aprendiendo mongodb',
... 'content':'base de datos orientada a documentos???? lol'
... }
{
"title" : "aprendiendo mongodb",
"content" : "base de datos orientada a documentos???? lol"
}
> db.blog.insert(post)

Hacemos query de todos los documentos

1
2
> db.blog.find()
{ "_id" : ObjectId("4e8d8a2b9699783129d48d61"), "title" : "aprendiendo mongodb", "content" : "mongodb es una base de datos orientada a documentos...LOL" }

Query de un documento

1
2
3
4
5
6
7
> db.blog.findOne()
{
"_id" : ObjectId("4e8d8a2b9699783129d48d61"),
"title" : "aprendiendo mongodb",
"content" : "mongodb es una base de datos orientada a documentos...LOL"
}
>

Query de documentos en base a un valor especifico

1
2
3
> db.blog.find({'title':'aprendiendo mongodb'})
{ "_id" : ObjectId("4e8d8a2b9699783129d48d61"), "title" : "aprendiendo mongodb", "content" : "mongodb es una base de datos orientada a documentos...LOL" }
>

Links

]]>
http://www.rubenortiz.es/2011/10/06/mongodb-en-centos/feed/ 0
Linux – montar swaphttp://www.rubenortiz.es/2011/10/03/linux-montar-swap/ http://www.rubenortiz.es/2011/10/03/linux-montar-swap/#comments Mon, 03 Oct 2011 13:18:51 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4801 Apunte sobre swap. Mejor que esté y lo puedas utilizar, que lo tengas que utilizar y no lo hayas montado. Tenemos una máquina sin swap activo pero con la partición ya formateada.

1
2
3
4
5
6
7
8
# fdisk -l
Disk /dev/sda: 274.8 GB, 274877906944 bytes
255 heads, 63 sectors/track, 33418 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

...
/dev/sda4           33158       33419     2096128   82  Linux swap / Solaris
...

Utilizamos mkswap para configurar el área de swap

1
# mkswap -f /dev/sda4

Y finalmente, activamos la swap del sistema

1
# swapon /dev/sda4

Link
http://lissot.net/partition/partition-08.html

]]>
http://www.rubenortiz.es/2011/10/03/linux-montar-swap/feed/ 0
CentOS 6http://www.rubenortiz.es/2011/07/18/centos-6/ http://www.rubenortiz.es/2011/07/18/centos-6/#comments Mon, 18 Jul 2011 10:16:27 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4685 Lanzamiento de CentOS 6 ya disponible. Esta distribución tiene como kernel la versión 2.6.32. Se han subido de versión paquetes como Apache, MySQL, PHP, etc.El MTA es ahora postfix, no sendmail.

Links

http://centos.org/
http://wiki.centos.org/Manuals/ReleaseNotes/CentOS6.0
http://isoredirect.centos.org/centos/6/isos/x86_64/
http://isoredirect.centos.org/centos/6/isos/i386/

]]>
http://www.rubenortiz.es/2011/07/18/centos-6/feed/ 0
CentOS 5 – compilar e instalar NMAPhttp://www.rubenortiz.es/2011/07/08/centos-5-compilar-e-instalar-nmap/ http://www.rubenortiz.es/2011/07/08/centos-5-compilar-e-instalar-nmap/#comments Fri, 08 Jul 2011 12:56:39 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4636 Compilando NMAP

1
2
3
4
5
6
7
8
9
# yum install gcc gcc-c++
# wget http://nmap.org/dist/nmap-5.51.tgz
# tar xf nmap-5.51.tgz
# cd nmap-5.51
# ./configure
# make
# make install
# whereis nmap
nmap: /usr/local/bin/nmap /usr/share/nmap
]]>
http://www.rubenortiz.es/2011/07/08/centos-5-compilar-e-instalar-nmap/feed/ 0
Centos 5 – instalar Mtophttp://www.rubenortiz.es/2011/05/03/centos-5-instalar-mtop/ http://www.rubenortiz.es/2011/05/03/centos-5-instalar-mtop/#comments Tue, 03 May 2011 09:57:15 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4406 Vamos a ver como instalar mtop. Mtop, es un software desarrollado para trabajar contra el motor de base de datos Mysql. Mtop monitoriza MySQL Server mostrando las queries que están tardando más tiempo en completarse. Incluye características como zooming sobre el proceso para mostrar la query completa, explicación de la optimización de la query y matar queries. Además, nos aporta estadísticas de rendimiento del servidor, información de la configuración y consejos de tunning.

1. Instalación

Antes de la instalación necesitamos instalar un rpm no oficial del repositorio de DagWiers

1
2
<strong># wget http://dag.wieers.com/rpm/packages/perl-Curses/perl-Curses-1.23-1.el5.rf.x86_64.rpm</strong>
# rpm -ivh perl-Curses-1.23-1.el5.rf.x86_64.rpm
1
2
3
4
5
6
7
<strong># cd /usr/local/src
# wget http://downloads.sourceforge.net/project/mtop/mtop/v0.6.6/mtop-0.6.6.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmtop%2Ffiles%2Fmtop%2Fv0.6.6%2F&amp;ts=1304411062&amp;use_mirror=ignum
# tar xf mtop-0.6.6.tar.gz
# cd mtop-0.6.6
# perl Makefile.PL
# make
# make install</strong>

Nos debería salir algo así

1
2
3
4
5
6
7
8
9
10
<strong>-bash-3.2# make install</strong>
Manifying blib/man1/mkill.1
Manifying blib/man1/mtop.1
Installing /usr/local/bin/mkill
Installing /usr/local/bin/mtop
Installing /usr/local/lib/perl5/5.8.8/cpan2spec.pl
Installing /usr/local/share/man/man1/mtop.1
Installing /usr/local/share/man/man1/mkill.1
Writing /usr/local//lib64/perl5/5.8.8/x86_64-linux-thread-multi/auto/mtop/.packlist
Appending installation info to /usr/local//lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

2. Ejecución

Ahora deberíamos poder ejecutar mtop de la siguiente forma

# /usr/local/bin/mtop –host=localhost –dbuser=root –password=password

y veremos algo así

3. Explicación de Valores
n Threads: running, cached
Los n Threads representa cuantos threads ha alojado mysqld. Un thread es alojado por cada conexión de usuario. Los threads adicionales son usados para replicación.

Queries/slow: Total queries / Total SLOW QUERIES
El primer número es el total de queries enviadas al servidor desde el último inicio o el último FLUSH STATUS. El segundo número es el número de queries que han tomado más tiempo que el la variable long_query_time

Cache Hit: Cache hit ratio
Esto es el porcentaje de tiempo que una lectura de key es accedida desde el key buffer cache.

Opened tables: tables opened
MySQL tiene cache para tablas abiertas. Si ‘opened tables’ es algo alta, puede que tu cache sea demasiado pequeña.

RRN: Handler_read_rnd_next
Número de peticiones para lectura de la siguiente fila en el archivo de datos (datafile). Esto será alto si estás haciendo escaneo de tablas. Generalmente esto sugiere que tus tablas no están siendo indexadas adecuadamente o que tus queries no están diseñadas para tomar ventaja de los índices.

TLW: Table_locks_waited
Número de veces que una table lock no pudo ser acceda inmediatamente y se tuvo que esperar. Si es alto, y tu tienes problemas de rendimiiento, debes optimizar primero tus queries y entonces partir tus tablas o usar replicación.

SFJ: Select_full_join
Número de joins sin keys (si esto no es 0, deberías comprobar adecuadamente los índices de tus tablas)

SMP: Sort_merge_passes
Número de “merge”
Number of merges passes the sort algoritm have had to do. Si este valor es alto deberías considerar incrementar el sort_buffer

QPS: Questions per second
El número total de comandos SQL manejados por el servidor MySQL desde su inicio o el último FLUSH STATUS.

mtop [--host={mysql_host}] [--dbuser={mysql_user}]
[--password={mysqluser_pw}] [--seconds={refresh}] [--[no]idle]
[--filter-user={regex}] [--filter-host={regex}] [--filter-db={regex}]
[--filter-command={regex}] [--filter-state={regex}] [--filter-info={{regex}}]
[--fold-select-columns]
[--user={user}] [--manualrefresh] [--slow={seconds}] [--vs|veryslow={seconds}]
[--vvs|veryveryslow={seconds}]

mtop –help

mtop –version

Links

]]>
http://www.rubenortiz.es/2011/05/03/centos-5-instalar-mtop/feed/ 0
CentOS 5 – Instalar Nginx desde código fuentehttp://www.rubenortiz.es/2011/04/18/centos-5-instalar-nginx-desde-codigo-fuente/ http://www.rubenortiz.es/2011/04/18/centos-5-instalar-nginx-desde-codigo-fuente/#comments Mon, 18 Apr 2011 10:57:06 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4348 Vamos a ver como compilar e instalar Nginx (“engine x”) desde fuente en CentOS 5.

Compilación e Instalación

1
2
3
4
5
6
7
<strong># yum install pcre pcre-devel openssl openssl-devel
# cd /usr/local/src/
# wget http://nginx.org/download/nginx-1.0.0.tar.gz
# tar xf nginx-1.0.0.tar.gz
# cd nginx-1.0.0
# ./configure --prefix=/usr/local/nginx --without-http_autoindex_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --conf-path=/usr/local/nginx/etc/nginx.conf --with-http_stub_status_module
# make && make install</strong>

en este punto, tenemos instalado Nginx en el path /usr/local/nginx/ y su archivo de configuración está localizado en /usr/local/nginx/etc/nginx.conf.

Probaremos primero si Nginx funciona correctamente

1
2
3
4
5
6
<strong>
# /usr/local/nginx/sbin/nginx
# ps axuf |grep nginx</strong>
root     22291  0.0  0.1   7204   812 pts/0    S+   12:27   0:00      \_ grep nginx
root     21778  0.0  0.0  18600   692 ?        Ss   12:26   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody   21779  0.0  0.1  18996  1424 ?        S    12:26   0:00  \_ nginx: worker process

Sólo queda que naveguemos por la ip para ver si vemos el mensaje de bienvenida

Welcome to nginx!

Seguidamente, sería útil tener en nuestro PATH la ruta de Nginx.

1
2
3
# echo 'export PATH=$PATH:/usr/local/nginx/sbin/' >> /etc/profile.d/nginx.sh
# chmod a+x /etc/profile.d/nginx.sh
# export PATH=$PATH:/usr/local/nginx/sbin/

Un comando útil de nginx es el que nos comprueba si el archivo de configuración es correcto

1
2
3
<strong># nginx -t</strong>
nginx: the configuration file /usr/local/nginx/etc/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/etc/nginx.conf test is successful

Vamos a configurar brevemente Nginx con algunas opciones, este último paso, será diferente según sea el hardware donde correrá Nginx. Respecto al usuario, cambiaremos el usuario de nobody a nginx

# useradd nginx
# mkdir -p /var/log/nginx
# touch /var/log/nginx/error.log
# mkdir -p /usr/local/nginx/etc/vhosts
# cp /usr/local/nginx/etc/nginx.conf /usr/local/nginx/etc/nginx.conf.bak
# vim /usr/local/nginx/etc/nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
user  nginx;
worker_processes  8;
worker_rlimit_nofile 32768;
error_log   /var/log/nginx/error.log;
events {
    worker_connections  4096;
    use epoll;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    tcp_nopush     on;
    server_tokens off;
    keepalive_timeout  5;
    gzip  on;
    gzip_min_length 1100;
    gzip_buffers 64 8k;
    gzip_comp_level 3;
    gzip_http_version 1.1;
    gzip_proxied any;
    gzip_types text/plain application/xml application/x-javascript text/css;
    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    include                 /usr/local/nginx/etc/vhosts/*.conf;
}

Comprobamos configuración y ordenamos a Nginx que recargue la misma (sin reiniciar)

1
2
<strong># nginx -t
# nginx -s reload</strong>

Creamos script de daemon de Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/etc/nginx.conf"

lockfile=/var/lock/subsys/nginx

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

force_reload() {
    restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

Probamos el script

1
2
3
4
5
<strong>
# /etc/init.d/nginx start
# /etc/init.d/nginx stop
# /etc/init.d/nginx restart
# /etc/init.d/nginx reload</strong>

Dejamos Nginx en el arranque del sistema

1
<strong># /sbin/chkconfig nginx on</strong>

Enjoy! :)

Links
http://www.superstaradmin.co.uk/2010/12/compiling-nginx-on-centos/
http://articles.slicehost.com/2009/2/2/centos-adding-an-nginx-init-script
http://articles.slicehost.com/2009/2/2/centos-installing-nginx-from-source
http://systemadmin.es/2011/02/instalar-nginx-con-php-5-3-mediante-php-fpm-y-eaccelerator

]]>
http://www.rubenortiz.es/2011/04/18/centos-5-instalar-nginx-desde-codigo-fuente/feed/ 1
CentOS – perl conflicts with file from packagehttp://www.rubenortiz.es/2011/04/07/centos-perl-conflicts-with-file-from-package/ http://www.rubenortiz.es/2011/04/07/centos-perl-conflicts-with-file-from-package/#comments Thu, 07 Apr 2011 10:17:34 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4330 Error bastante común en la distribución CentOS. Me pasó concretamente con un CentOS 5.5 64 bits. Ejecutamos “yum update” y nos devuelve un carror de errores tipo

1
perl-5.8.8-32.el5_5.1.i386 file /usr/share/man/man1/perlxstut.1.gz from install of perl-5.8.8-32.el5_5.2.x86_64 conflicts with file from package perl-5.8.8-32.el5_5.1.i386 file /usr/share/man/man1/piconv.1.gz from install of perl-5.8.8-32.el5_5.2.x86_64 conflicts with file from package perl-5.8.8-32.el5_5.1.i386 file /usr/share/man/man1/pl2pm.1.gz from install of ...

Podemos leer que el error aparece en bastantes entornos diferentes

1
"Yeah, that seems to be a CentOS packaging error that comes up on occasion. You can read this support request regarding it here for some ideas on fixing it:"

ejecutamos

1
<strong># rpm -e perl.i386</strong>

y a continuación ya podemos ejecutar tranquilamente yum

Links
http://www.virtualmin.com/node/15794
https://www.centos.org/modules/newbb/viewtopic.php?topic_id=28412
http://forum.nginx.org/read.php?24,139270

]]>
http://www.rubenortiz.es/2011/04/07/centos-perl-conflicts-with-file-from-package/feed/ 1
CentOS 5 – instalar Varnishhttp://www.rubenortiz.es/2011/03/22/centos-5-instalar-varnish/ http://www.rubenortiz.es/2011/03/22/centos-5-instalar-varnish/#comments Tue, 22 Mar 2011 16:52:33 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=4269 ¿Qué es Varnish?
Si lo buscamos en google images, seguramente nos saldrá algo relacionado con el barniz. Pero como este es un blog sobre administración de sistemas, probablemente no vayan por ahí los tiros. Por cierto, el barniz según wikipedia: “Barniz es una disolución de una o más sustancias resinosas en un disolvente que se volatiliza o se deseca”.

Varnish es un software que se define como un acelerador web, un proxy caché y balanceador en si mismo. Podemos buscar equivalentes en otros softwares existentes como el mod_proxy de Apache, Squid, o Nginx. Varnish es distribuido en licencia BSD.

Características
Concebido desde el comienzo para sistemas operativos 64 bits
VCL (lenguaje flexible propio de Varnish)
Load balancing
Soporte parcial de ESI
No necesita reinicio en cambios de configuraciones
Soporta escritura y modificación de urls
Completo sistema de estadísticas en tiempo real

Funcionamiento
Varnish guarda los datos pedidos por cada petición en la memoria virtual y es el sistema operativo quien debe decidir que es guardado en memoria y que es paginado al disco. Esto ayuda a evitar la situación que el sistema operativo empiece a cachear información mientras es movida al disco por otra aplicación.

Cada conexión cliente es tratada por un thread independiente. Cuando el límite configurado de threads activos es alcanzado, las siguientes conexiones entrantes son repartidas a una cola, sólo cuando está cola alcanza un valor límite Varnish empezará a descartar conexiones.

Instalación
Supondremos un escenario donde tenemos un servidor web X escuchando por el puerto 80. Instalaremos Varnish de la forma más sencilla, en el mismo servidor.

Instalación de repositorio

1
2
3
4
<strong>
-bash-3.2# rpm --nosignature -i http://repo.varnish-cache.org/redhat/el5/noarch/varnish-release-2.1-2.noarch.rpm
-bash-3.2# yum install varnish
</strong>

La última versión a día de este post, es la 2.1.5-1:

1
Package varnish-2.1.5-1.x86_64 already installed and latest version

También podemos utilizar svn para descargar la rama estable de Varnish y compilar.

Activamos los servicios para arrancar desde inicio

1
2
<strong>-bash-3.2# chkconfig varnish on
-bash-3.2# chkconfig varnishlog on</strong>

Archivos a editar

1
2
3
4
<strong>-bash-3.2# rpm -qc varnish</strong>
/etc/logrotate.d/varnish
/etc/sysconfig/varnish
/etc/varnish/default.vcl

Configuraremos nuestro servidor web para que, a partir de ahora, pase a escuchar por el puerto 8080. Haremos pues, que Varnish escuche a partir de ese momento por el puerto 80.

1
<strong>-bash-3.2# vi /etc/sysconfig/varnish</strong>
1
2
3
4
5
6
7
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
             -f ${VARNISH_VCL_CONF} \
             -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
             -t ${VARNISH_TTL} \
             -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
             -u varnish -g varnish \
             -s ${VARNISH_STORAGE}"

en este archivo configuraremos las opciones como creamos conveniente. Para dejar a Varnish en el puerto 80 hemos de editar el valor VARNISH_LISTEN_PORT. Es muy conveniente detenerse en este punto y leer información relacionada.

El otro archivo importante es /etc/varnish/default.vcl. Aquí definiremos nuestro/os backends, donde enviaremos el tráfico entrante y donde Varnish obtendrá la información que se le pide.

1
2
3
4
5
<strong>-bash-3.2# vi /etc/varnish/default.vcl</strong>
backend default {
.host = “127.0.0.1″;
.port = “8080″;
}

Este sería, como decimos, el escenario más sencillo. No entraremos en complicaciones complejas de VCL. El último paso sería activar los servicios de varnish

1
2
3
4
<strong>-bash-3.2# /etc/init.d/varnish start</strong>
Starting varnish HTTP accelerator:                         [  OK  ]
<strong>-bash-3.2# /etc/init.d/varnishlog start</strong>
Starting varnish logging daemon:                           [  OK  ]

Links
http://www.vivaelpixel.com/2009/12/varnish-reverse-proxy/
http://en.wikipedia.org/wiki/Varnish_%28software%29
http://blyx.com/2009/12/08/mejorando-la-velocidad-de-alfresco-con-varnish/
http://www.varnish-cache.org/installation/redhat
http://wiki.itlinux.cl/doku.php?id=varnish:mini_howto
http://www.varnish-cache.org/docs/2.1/installation/install.html#compiling-varnish-from-source

]]>
http://www.rubenortiz.es/2011/03/22/centos-5-instalar-varnish/feed/ 0
Memcached en CentOS 5http://www.rubenortiz.es/2011/03/16/memcached-en-centos-5/ http://www.rubenortiz.es/2011/03/16/memcached-en-centos-5/#comments Wed, 16 Mar 2011 12:20:36 +0000 Rubén Ortiz http://www.rubenortiz.es/?p=1856 Breve tutorial sobre como instalar el servicio memcached (Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load). Se hace sobre un CentOS de 64 bits, para 32 bits sería ligeramente diferente.

1
2
3
4
5
6
7
8
9
10
<strong># yum install libevent-devel
# cd /usr/local/src
# wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure --prefix=/usr/local/memcached  --enable-64bit
# make && make install
# whereis memcached
memcached: /usr/local/memcached
# adduser memcached
</strong>

Corremos no como daemon sino bajo supervisión de Daemon tools

1
2
<strong># mkdir -p /usr/local/supervise/memcached
# cat  > /usr/local/supervise/memcached/run << EOF </strong>
1
2
#!/bin/bash
exec /usr/local/memcached/bin/memcached -u memcached -l 127.0.0.1 -c 1024 -m 128
1
2
3
4
5
<strong>
# EOF
# chmod +x /usr/local/supervise/memcached/run
# ln -s /usr/local/supervise/memcached/ /service/
</strong>
1
2
3
-bash-3.2# ps axuf |grep mem
root     10067  0.0  0.0   3660   372 ?        S    12:36   0:00  |   \_ supervise memcached
501      11866  0.0  0.1  68680  1104 ?        Sl   12:37   0:00  |       \_ /usr/local/memcached/bin/memcached -u memcached -l 127.0.0.1 -c 1024 -m 128

O por otro lado lo arrancamos como daemon.

# vim /etc/rc.local

1
/usr/local/memcached/bin/memcached -u memcached -d -m 256 -l 127.0.0.1 -p 11211
]]>
http://www.rubenortiz.es/2011/03/16/memcached-en-centos-5/feed/ 0