quarta-feira, 29 de maio de 2013

Instalar o VNC Server no Debian ou Ubuntu.

Primeiro instale o TightVNC server. Utilizando o comando abaixo: 

# apt-get install tightvncserver

Configurar o servidor VNC para poder logar com o usuário que terá acesso ao servidor

# vncserver &

Será solicitado o cadastro de uma senha de acesso.
Após isso, será criado um diretorio oculto no home do usuário.

Edite esse arquivo

# vi ~/.vnc/xstartup

Esta copia do xstartup esta configurada para acessar o Gnome.

#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid black
gnome-session &

Crie no /etc/init.d/ o arquivo vncserver 

# vi /etc/init.d/vncserver

E entre com o conteúdo abaixo:


#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="usuario de acesso ao VNC"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"

# Color depth (between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.
NAME="my-vnc-server"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
     start)
             log_action_begin_msg "Starting vncserver for user '${USER}' on    localhost:${DISPLAY}"
             su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
             ;;

     stop)
              log_action_begin_msg "Stoping vncserver for user '${USER}' on     localhost:${DISPLAY}"
              su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
              ;;

    restart)
              $0 stop
              $0 start
              ;;
esac

exit 0

Execute o comando abaixo para deixar inicialização automática

# chmod a+x /etc/init.d/vncserver
# update-rc.d vncserver 99

Iniciar o vncserver e testar

# /etc/init.d/vncserver start




Instalar o PHP5 com suporte ao ORACLE no Debian Squeeze

Neste procedimento foi utilizado o ambiente abaixo.
 

Debian 6
Apache 2.2
Php 5.3.3-7
Oci8

Requisitos

Instale os pacotes abaixo:

# apt-get install php5-dev build-essential php-pear alien libaio1

Oracle

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

Faça o download do Oracle dependendo do seu sistema operacional

Basic – oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
Devel – oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm

Após concluído o download, execute o comando para converter os arquivos rpm para deb

# alien oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
# alien oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm

Instale os pacotes debian

# dpkg -i oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.deb
# dpkg -i oracle-instanclient11.2.-devel-11.2.02.0-1.i386.deb

OCI

Instalando o pacote OCI8

# pecl install oci8

Obs: Será solicitado o caminho do oracle client, deixe em branco e pressione enter que ele encontrará automaticamente.

Configurando o PHP.

OCI8 instalado agora é só informar ao PHP para utilizar a extensão.
Crie um arquivo chamado oci8.ini com o conteúdo: extension=oci8.so
Salve o arquivo na pasta /etc/php5/conf.d/ e reinicie o Apache.
Reinicie o apache

# /etc/init.d/apache restart

Diretórios Oracle

Crie os diretórios de configuração

# mkdir -p '/usr/lib/oracle/11.2/client/network/admin'

Variáveis do ORACLE

edite o arquivo /etc/init.d/apache2 inclua as seguintes linhas

ORACLE_HOME='/usr/lib/oracle/11.2/client'
ORACLE_SID=NBS
TNS_ADMIN=${ORACLE_HOME}/network/admin
export ORACLE_HOME
export ORACLE_SID
export TNS_ADMIN
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
echo "Oracle Home: $ORACLE_HOME"
echo "Oracle SID: $ORACLE_SID"
echo "Oracle LD_LIBRARY_PATH: $ORACLE_HOME"
echo "Oracle TNS_ADMIN: $TNS_ADMIN"
echo Starting Apache

Arquivo PHP para testar.

conexao.php

//oracle connection variables

$ora_user = 'USUARIO'; //username
$ora_pass = 'SENHA DO BANCO'; //user password
$ora_host = 'IP DO SERVIDOR OU HOSTNAME"'; //host name or server ip address
$ora_db = 'NOME DO BANCO'; //database name

// place variable into oci_connect function, then place funtion in variable

$ora_conn = oci_connect($ora_user,$ora_pass,'//'.$ora_host.'/'.$ora_db);

// error handling

if (!ora_conn){ // if variable $ora_conn fails to connect

// do the following if it fails

$ora_conn_erno = oci_error(); // insert oci_error() function into variable
echo ($ora_conn_erno['message']."\n"); // print the $ora_conn_erno variable/oci_error() function selecting only the message (human readable)
oci_close($ora_conn); // close the connection just in case php doesn't close it

} else {

// if it doesn't fail it will proceed with the rest of the script

echo "Connection Succesful\n"; //echo message if connection does not error
oci_close($ora_conn); // close the connection

}

?>

Habilitar multipath no debian 4 e 5 utilizando o XIV


Instalar os pacotes abaixo:

# aptitude install multipath-tools-boot multipath-tools firmware-qlogic firmware-bnx2 sysfsutils
# reboot

Criar o arquivo multipath.conf com o conteudo abaixo:

###############################################################################
# Multipath.conf file for IBM Storage
# IMPORTANT: If you change multipath.conf settings after the DM MPIO devices
# have already been configured, be sure to rerun "multipath".
###############################################################################
#
#
# defaults:
#
#     polling_interval   : The interval between two path checks in seconds.
#   
#     failback           : The failback policy should be set to "immediate"
#                          to have automatic failback, i.e. if a higher
#                          priority path that previously failed is restored,
#                          I/O automatically and immediately fails back to
#                          the preferred path.
#
#    no_path_retry       : Use this setting in order to deal with transient
#                          total path failure scenarios. Indicates that the if
#                          all paths are failed for 10 checks (iterations of
#                          the checkerloop) then will set the device to
#                          .fail_if_no_path. so that I/O will not stay queued
#                          forever and I/O errors are returned back to the
#                          application. This value should be adjusted based on
#                          the value of the polling_interval. Basically, with a
#                          larger polling_interval, this means that the amount
#                          of time of allowed total path failure will be
#                          longer, since the tolerance time is
#                          (no_path_retry * polling_interval) seconds.
#                          SHOULD NOT BE USED WITH .features..

#    rr_min_io           : The number of IOs to route to a path before switching
#                          to the next path in the same path group
#
#    path_checker        : The default 'readsector0' path checker uses SCSI
#                          READ (opcode 0x28) which doesn't work in clustered
#                          environments. TUR (Test Unit Ready) does work in
#                          clustered environments with storage that subscribes
#                          to the SCSI-3 spec.
#
#    user_friendly_names : With this value set to .yes., DM MPIO devices will
#                          be named as .mpath0., .mpath1., .mpath2., etc. ...
#                          The /var/lib/mulitpath/bindings file is
#                          automatically generated, mapping the .mpathX. name
#                          to the wwid of the LUN. If set to "no", use the
#                          WWID as the alias. In either case this be will be
#                          overriden by any specific aliases in this file.
#
#
defaults {
    polling_interval    30
        failback            immediate
        no_path_retry       5
        no_path_retry       5
        rr_min_io           100
        path_checker        tur
        user_friendly_names yes
        }


#
#  devices    : List of per storage controler settings, overrides default
#              settings (device_maps block), overriden by per multipath
#              settings (multipaths block)
#
#  vendor     : Vendor Name
#
#  product    : Product Name
#
#  path_grouping_policy : Path grouping policy to apply to multipath hosted
#                         by this storage controller
#
#  prio_callout : The program and args to callout to obtain a path
#              weight. Weights are summed for each path group to
#              determine the next PG to use case of failure.
#              NOTE: If no callout then all paths have equals weight.
#
#

devices {
        device {
                vendor "IBM"
                product "2810XIV"
                selector "round-robin 0"
                path_grouping_policy multibus
                rr_min_io 15
                path_checker tur
                failback 15
                no_path_retry queue
                polling_interval 3
        }

}

multipaths {
         multipath {
                  wwid <lun do disco do sistema>
                  alias system
                  path_grouping_policy failover
                  path_selector "round-robin 0"
         }



}

devnode_blacklist {
             devnode "*"
             }

blacklist {
             devnode "sda"
          }


Após a criação do arquivo, execute os comandos abaixo:

# multipath -F
# /etc/init.d/multipath-tools restart
# multipath -ll

Verifique se foi criado os dispositivos

# ls /dev/mapper/

Após isso devemos atualizar o grub.

# update-initramfs -u
# update-grub
# reboot

Ativar multipath no squeeze

1. Instalação dos pacotes do multipath

# aptitude install multipath-tools-boot multipath-tools firmware-qlogic

2. Reiniciar

Depois de reiniciar vai entrar na prompt do initramfs.
Executar o comando

# ls /dev/mapper/

Verificar e anotar os ids do disco.

3. Entrar no grub e colocar no lugar do root=<UIDdoDisco> trocar para <Lun>

4. Depois de dar o boot, favor alterar no grub o caminho para efetivar o boot pelo multipath.

Ativando Bonding no Debian Squeeze

Instalação Primeiro instale o pacote ifenslave-2.6, necessario para ativar bonding:

# apt-get install ifenslave-2.6

Shutdown / Desconfigure Interfaces Existentes

# ifdown eth0 (Repeat for all interfaces included in the bond)
# /etc/init.d/networking stop

Configuração Modifique o arquivo /etc/network/interfaces:

auto bond0 iface

bond0 inet static
    address 10.31.1.5
    netmask 255.255.255.0
    network 10.31.1.0
    gateway 10.31.1.254
    slaves eth0 eth1
    bond-mode active-backup
    bond-miimon 100
    bond-downdelay 200
    bond-updelay 200

Iniciando nova interface

# ifup bond0
# /etc/init.d/networking start

cat /sys/class/net/bond0/bonding/mode

terça-feira, 21 de maio de 2013

Configurando o dvd como repositorio local do RHEL

Monte o DVD dá seguinte forma:
# mount -o loop /dev/hdc /media/dvdrom

Se for uma ISO da seguinte forma:
# mount -o loop /home/user/rhel-xxx.iso /media/dvdrom

Crie o arquivo do repositorio:
# vi /etc/yum.repos.d/dvd.repo

No arquivo de configuração criado, coloque os dados abaixo: 

[dvd] 
name=DVD for RHEL5 
baseurl=file:///media/dvdrom/Server 
enabled=1 
gpgcheck=0

Instalando fontes Microsoft TrueType no RHEL, passo a passo


Instalado o utilitário rpm-build:

    # yum install rpm-build

Em seguida, instale o utilitário cabextract, disponível em:

   http://www.rpmfind.net/linux/rpm2html/search.php?query=cabextract

O download do arquivo mais recente especificação para msttcorefonts:
 
   curl -O http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec  

Crie um arquivo ~/.rpmmacros contendo uma linha:

   %_topdir %(echo $HOME)/rpmbuild

A seguir crie os diretórios necessários:

   # mkdir -p ~/rpmbuild/BUILD
   # mkdir -p ~/rpmbuild/RPMS/noarch

Construindo o rpm:

   # rpmbuild -bb msttcorefonts-2.5-1.spec  

Se tudo der certo, deve ser criado um arquivo msttcorefonts-2.5-1.rpm dentro do diretorio ~/rpmbuild/RPMS/noarch.

Fontes da pesquisa:

http://corefonts.sourceforge.net
http://www.sysarchitects.com/node/112



Habilitando SSL no Apache2

Instale os pacotes necessários #

# aptitude install openssl ssl-cert

Crie o certificado
# openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout 
/etc/apache2/apache.pem

Defina a permissão para o arquivo criado

# chmod 600 /etc/apache2/apache.pem

Habilite o suporte a SSL no apache2 da seguinte forma:

# a2enmod ssl

Edite o arquivo /etc/apache2/sites-available/<virtual host>, adicionando as seguintes linhas:

<VirtualHost *:443>
        ServerName www.<dominio>.am.gov.br
        ServerAdmin webmaster@localhost

        SSLEngine on
        SSLCertificateFile /etc/apache2/apache.pem

       DocumentRoot /var/www/<domínio>/
       <Directory /var/www/<domínio>/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride AuthConfig All
                # AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

       ErrorLog ${APACHE_LOG_DIR}/error.log

       # Possible values include: debug, info, notice, warn, error, crit,
       # alert, emerg.
       LogLevel warn

       CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>                    

Reinicie o Apache

# apache2ctl restart

Instalação SVN + AD + WEBDAV no Debian 7

1. Instalar os pacotes abaixo:

apt-get install websvn php5-ldap libapache2-svn

2. Habilitar os modulos abaixo no apache2.

a2enmod dav_fs authnz_ldap

3. Modificar o arquivo vi /etc/websvn/apache.conf

As linhas conforme abaixo:

Alias /websvn /usr/share/websvn

<Directory /usr/share/websvn> 
      ## No MultiViews
      DirectoryIndex index.php
      Options FollowSymLinks
      ## MultiViews
      #DirectoryIndex wsvn.php
      #Options FollowSymLinks MultiViews
      ## End MultiViews
      Order allow,deny
      Allow from all

      AuthBasicProvider ldap
      AuthType Basic
      AuthzLDAPAuthoritative off
      AuthName "Subversion Repository Web Browsing"
      AuthLDAPURL "ldap://<ip ou nome do servidor AD:389/DC=exemplo,DC=local?sAMAccountName?sub?(objectClass=*)" NONE
      AuthLDAPBindDN "CN=<Usuário para consulta no AD>,CN=Users,DC=exemplo,DC=local"
      AuthLDAPBindPassword  <Senha do usuário>
      require valid-user
 
     <IfModule mod_php4.c>
            php_flag magic_quotes_gpc Off
            php_flag track_vars On
     </IfModule>
 </Directory>

<Location /svn>
        DAV svn
        SVNPath /var/lib/svn
        AuthBasicProvider ldap
        AuthType Basic
        AuthzLDAPAuthoritative off
        AuthName "Subversion Repository"
        AuthLDAPURL "ldap://<ip ou nome do servidor AD> :389/DC=exemplo,DC=local?sAMAccountName?sub?(objectClass=*)" NONE
        AuthLDAPBindDN "CN=<Usuário para consulta no AD>,CN=Users,DC=exemplo,DC=local"
        AuthLDAPBindPassword  <Senha do usuário>
        Require  ldap-group  CN=<grupo do AD>,CN=Users,DC=exemplo,DC=local
</Location>


4. Criar o repositorio via shell

# svnadmin create /var/lib/svn
# chown www-data.www-data /var/lib/svn
# chmod 755 /var/lib/svn

OBS: Esse procedimento pode ser aplicado utilizando uma base OpenLDAP.