dimarts, 27 de juny de 2017

template lxc para proxmox

descargar de

http://download.proxmox.com/images/system/

debian-9.0-standard_9.0-2_amd64.tar.gz

dissabte, 24 de juny de 2017

error 0xc0000000e arrancada windows 10

després de la creació del disc ssd en gpt i veure que aquesta imatge em serviria per les instal·lacions en les màquines i5 pero no en els cores, donat que no té efi per 'entendre l'arrancada' he tingut que fer:


  1. pas amb easeus partition de conversió del disc gpt a mbr, he utilitzat aquesta eina donat que preserva les dades 
  2. bcdedit /export     per guarda l'arrancada
  3. ren c:/boot/bcd bcd.old
  4. bootrec /rebuilbcd


altres coses he provat pero finalment aquest ha estat la  recepta funcional


diumenge, 18 de juny de 2017

zentyal , després de reiniciar un servei executar regles post-iptables

per que una classe determinada tingui unes regles personalitzades en reiniciar el servei de firewall, d'aquesta manera permetem l'accés a steam d'aquesta aula, necessari per un projecte.

/etc/zentyal/hooks/firewall.postservice

#!/bin/bash
#iptables -t nat -I premodules 1 -s 10.1.6.0/24 -p tcp -m tcp --dport 80 -j ACCEPT
#https://support.steampowered.com/kb_article.php?ref=8571-GLVN-8711
#LOG TO STEAM
iptables -I FORWARD 1 -s 10.1.6.0/24 -p tcp --dport 27015:27030 -j ACCEPT
iptables -I FORWARD 1 -s 10.1.6.0/24 -p udp  --dport 27015:27030 -j ACCEPT
#STEAM CLIENT
iptables -I FORWARD 1 -s 10.1.6.0/24 -p tcp  --dport 27036:27037 -j ACCEPT
iptables -I FORWARD 1 -s 10.1.6.0/24 -p udp  --dport 27000:27036 -j ACCEPT
iptables -I FORWARD 1 -s 10.1.6.0/24 -p udp  --dport 4380 -j ACCEPT
#LITEN SERVERS
iptables -I FORWARD 1 -s 10.1.6.0/24 -p tcp  --dport 27015 -j ACCEPT
#STEAMWORK SP2P
iptables -I FORWARD 1 -s 10.1.6.0/24 -p udp  --dport 3478 -j ACCEPT
iptables -I FORWARD 1 -s 10.1.6.0/24 -p udp  --dport 4379:4380 -j ACCEPT

proxmox, montar en lxc un recurs nfs

On the proxmox host

add

mount fstype=nfs,

to


/etc/apparmor.d/lxc/lxc-default-with-mounting

then reload apparmor
service apparmor reload

dimecres, 14 de juny de 2017

problemas drbd

Drbd-problema   no aconsegueixo el primary/secondary

drbroot@drbd0heartbeat:~# drbd-overview
0:r0/0  StandAlone Secondary/Unknown UpToDate/DUnknown

root@drbd1heartbeat:~# drbd-overview
0:r0/0  WFConnection Primary/Unknown UpToDate/DUnknown /var/lib/mysql ext4 32G 6.7G 24G 23%

Canvi ordre d’arrancada, reinicio només un d'ells

root@drbd0heartbeat:~# drbd-overview
0:r0/0  StandAlone Primary/Unknown UpToDate/DUnknown /var/lib/mysql ext4 32G 6.6G 24G 23%

ot@drbd1heartbeat:~# drbd-overview
0:r0/0  WFConnection Secondary/Unknown UpToDate/DUnknown

Split brain

root@drbd0heartbeat:~# grep split /var/log/syslog
Jun 14 16:51:58 drbd0heartbeat kernel: [    6.652069] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0
Jun 14 16:51:58 drbd0heartbeat kernel: [    6.653058] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0 exit code 0 (0x0)
Jun 14 16:51:58 drbd0heartbeat kernel: [    6.653204] block drbd0: helper command: /sbin/drbdadm split-brain minor-0
Jun 14 16:51:58 drbd0heartbeat kernel: [    6.654109] block drbd0: helper command: /sbin/drbdadm split-brain minor-0 exit code 0 (0x0)
Jun 14 16:54:25 drbd0heartbeat kernel: [    6.708203] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0
Jun 14 16:54:25 drbd0heartbeat kernel: [    6.709194] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0 exit code 0 (0x0)
Jun 14 16:54:25 drbd0heartbeat kernel: [    6.709339] block drbd0: helper command: /sbin/drbdadm split-brain minor-0
Jun 14 16:54:25 drbd0heartbeat kernel: [    6.710279] block drbd0: helper command: /sbin/drbdadm split-brain minor-0 exit code 0 (0x0)
Jun 14 16:59:15 drbd0heartbeat kernel: [  295.508074] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0
Jun 14 16:59:15 drbd0heartbeat kernel: [  295.509099] block drbd0: helper command: /sbin/drbdadm initial-split-brain minor-0 exit code 0 (0x0)
Jun 14 16:59:15 drbd0heartbeat kernel: [  295.509244] block drbd0: helper command: /sbin/drbdadm split-brain minor-0
Jun 14 16:59:15 drbd0heartbeat kernel: [  295.510053] block drbd0: helper command: /sbin/drbdadm split-brain minor-0 exit code 0 (0x0)


he probat com diu un enllaç
primary- service mysql stop
secondary drbdadm connect all
secondary cat /proc/drbd
primary  drbdadm connect all
primary cat /proc/drbd
primary service mysql start

no ha estat suficient pq entre a funciona , 

AL FINAL HA ESTAT CONTUNDENT - solució
Try following:
On primary node
root@drbd0heartbeat:~# drbdadm connect all
On secondary node

ot@drbd1heartbeat:~# drbdadm -- --discard-my-data connect all
root@drbd1heartbeat:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
    ns:0 nr:58384 dw:58384 dr:0 al:0 bm:7 lo:1 pe:4 ua:0 ap:0 ep:1 wo:f oos:2611068
       [>....................] sync'ed:  2.4% (2611068/2669452)K
       finish: 0:00:44 speed: 58,384 (58,384) want: 43,000 K/sec

dilluns, 22 de maig de 2017

configuració drbd9 en debian8

basat en el següent article

https://www.globo.tech/learning-center/setup-drbd-9-ubuntu-16/

CONDICIÓ D'INICI
2 maquines debian8
1 disc /dev/sdb1 secundari per montar el drbd

afegir als dos servidors el reconeixement per nom

root@drbd1:~# more /etc/hosts
127.0.0.1       localhost
# 127.0.1.1      drbd1.ies-sabadell.cat  drbd1
192.168.0.180   drbd0.ies.cat  drbd0
192.168.0.181   drbd1.ies.cat  drbd1

INSTAL·LAR
apt-get update
sudo apt-get install -y drbd8-utils

ACONSEGUIR LA SINCRONITZACIÓ DE TEMPS

apt-get install -y ntp

creació d'una partició del mateix tamany a les dos màquines 

fdisk /dev/sdb
n   nova partició
p primaria

w write canvis


dd if=/dev/zero of=/dev/sdb1

als dos servidors també creem el recurs r0 associat a la partició creada i tot al fitxer /etc/drbd.conf

root@drbd1:~# more /etc/drbd.conf
# You can find an example in  /usr/share/doc/drbd.../drbd.conf.example

# include "drbd.d/global_common.conf";
# include "drbd.d/*.res";

global { usage-count no; }
common { protocol C; }

resource r0 {
on drbd1 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.0.181:7788;
meta-disk internal;
}

on drbd0 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.0.180:7788;
meta-disk internal;
}

}

carregar el modul 
modprobe drbd
crear el dispositiu mirror
drbdadm create-md r0
Then simply bring the mirror device online with this command.
drbdadm up r0
Per veure l'estat del drbd
drbd-overview cat /etc/drbd
els dos nodes son inicialment secundaris o pasius. Forçar un d'ells a ser primary
drbdadm -- --overwrite-data-of-peer primary r0/0
Finalment formatejar i montar la unitat de disc
sudo mkfs.ext4 /dev/drbd0
sudo mkdir -p /var/www/html
sudo mount /dev/drbd0 /var/www/html
In order to upgrade, do the following:
apt install software-properties-common
then
sudo add-apt-repository ppa:linbit/linbit-drbd9-stack
Finally, perform apt-get update so that Debian will recognize the updated repository. After that, you can run the apt-get upgrade to upgrade DRBD to version 9.
apt-get update
apt-get upgrade

No he aconseguir passar a la versió 9, no em troba drbd per la debian
aquest és l'error

W: No s'ha pogut obtenir http://ppa.launchpad.net/linbit/linbit-drbd9-stack/ubuntu/dists/jessie/main/binary-amd64/Packages  404  Not Found

root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
 0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:851152 dw:34403500 dr:0 al:0 bm:286 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0


SI PARO ARA drbd0

root@drbd1:~# drbd-overview cat /etc/drbd
 0:r0/0  WFConnection Secondary/Unknown UpToDate/DUnknown
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
 0: cs:WFConnection ro:Secondary/Unknown ds:UpToDate/DUnknown C r-----
    ns:0 nr:851152 dw:34403500 dr:0 al:0 bm:286 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0


SI TORNO A ENCENDRE drbd0
els dos en secundary fins que sincronitzi

root@drbd1:~# drbd-overview cat /etc/drbd
 0:r0/0  SyncTarget Secondary/Secondary Inconsistent/UpToDate
        [>....................] sync'ed:  0.1% (4944/4944)Mfinish: 0:52:44 speed: 1,260 (1,260) want: 1,360 K/sec
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
 0: cs:SyncTarget ro:Secondary/Secondary ds:Inconsistent/UpToDate C r-----
    ns:0 nr:857404 dw:34409752 dr:0 al:0 bm:286 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:5058416
        [>....................] sync'ed:  0.3% (4936/4944)Mfinish: 0:39:31 speed: 2,084 (2,084) want: 3,040 K/sec
root@drbd1:~#

continua
root@drbd1:~# drbd-overview cat /etc/drbd
 0:r0/0  SyncTarget Secondary/Secondary Inconsistent/UpToDate
        [============>.......] sync'ed: 65.9% (1688/4944)Mfinish: 0:00:49 speed: 34,856 (25,460) want: 36,920 K/sec
root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
 0: cs:SyncTarget ro:Secondary/Secondary ds:Inconsistent/UpToDate C r-----
    ns:0 nr:4262360 dw:37814708 dr:0 al:0 bm:511 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:1653460
        [============>.......] sync'ed: 67.5% (1612/4944)Mfinish: 0:00:46 speed: 35,064 (25,648) want: 38,520 K/sec

se disparó consumo de red y uso de disco

root@drbd1:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
 0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
    ns:0 nr:5915820 dw:39468168 dr:0 al:0 bm:613 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

root@drbd1:~# drbd-overview cat /etc/drbd
 0:r0/0  Connected Secondary/Secondary UpToDate/UpToDate

MISSATGES DEL SYSLOG

May 22 00:14:48 drbd1 kernel: [83618.112489] block drbd0: helper command: /sbin/drbdadm before-resync-target minor-0
May 22 00:14:48 drbd1 kernel: [83618.113577] block drbd0: helper command: /sbin/drbdadm before-resync-target minor-0 exit code 0 (0x0)
May 22 00:14:48 drbd1 kernel: [83618.113586] block drbd0: conn( WFSyncUUID -> SyncTarget ) disk( Outdated -> Inconsistent )
May 22 00:14:48 drbd1 kernel: [83618.113591] block drbd0: Began resync as SyncTarget (will sync 5064668 KB [1266167 bits set]).
May 22 00:17:01 drbd1 CRON[2464]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
May 22 00:17:49 drbd1 kernel: [83800.029781] block drbd0: Resync done (total 181 sec; paused 0 sec; 27980 K/sec)
May 22 00:17:49 drbd1 kernel: [83800.029787] block drbd0: updated UUIDs 716CEB055F69D08C:0000000000000000:82078DA323F1657E:82068DA323F1657F
May 22 00:17:49 drbd1 kernel: [83800.029792] block drbd0: conn( SyncTarget -> Connected ) disk( Inconsistent -> UpToDate )
May 22 00:17:49 drbd1 kernel: [83800.030037] block drbd0: helper command: /sbin/drbdadm after-resync-target minor-0
May 22 00:17:49 drbd1 kernel: [83800.031152] block drbd0: helper command: /sbin/drbdadm after-resync-target minor-0 exit code 0 (0x0)


FINALMENT HE TINGUT QUE FER
root@drbd0:~# mount /dev/drbd0 /var/www/html
mount: /dev/drbd0 is write-protected, mounting read-only
mount: mount /dev/drbd0 on /var/www/html failed: El tipus de mitjà  no és và lid
root@drbd0:~# drbdadm -- --overwrite-data-of-peer primary r0

POSAR DRBD0 COM A PRIMARY
root@drbd0:~# cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 1A9F77B1CA5FF92235C2213
 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:5064668 nr:0 dw:0 dr:5066084 al:0 bm:327 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
root@drbd0:~# mount /dev/drbd0 /var/www/html


ja ho puc montar , miro en drbd1
root@drbd1:/var# mount /dev/drbd0 /var/www/html
mount: /dev/drbd0 is write-protected, mounting read-only
mount: mount /dev/drbd0 on /var/www/html failed: El tipus de mitjà  no és và lid


com es secondary, només de lectura.


EL SEGÜENT ARTICLE SERÀ , sobre el drbd montarem una ip flotant amb heartbeat
https://www.globo.tech/learning-center/high-availability-heartbeat-drbd-ubuntu-16/







diumenge, 21 de maig de 2017

entrar via ssh sin contraseña (clave publica autorizada)

Generant la clau en parella publica privada

ssh-keygen -t rsa

genera dos fitxers
  • Clau privada: ~/.ssh/id_rsa
  • Clau publica: ~/.ssh/id_rsa.pub
afegir la clau generada al servidor
jo abans la renombre
mv id_rsa.pub publicaservidor1.pub

ho envien a l'altre ordinador

scp publicaservidor1.pub @:/home//.ssh/

finalment 

dintre de la carpeta .ssh creació del document authorized_keys y le afegim el contingut de ll'arxiu amb la clau pública:
touch authorized_keys
cat id_rsa.pub >> authorized_keys