Lista pentru picnic

Manualul micului grataragiu – episodul 1, cu masina

Lista cu lucrurile necesare unui gratar de succes.

Departamentul bucatarie

  • Caserole pentru restul de mici ramasi
  • Sare + condimente (mustar, condimente pentru gratar) + muraturi
  • Gratar + carbuni + spirt + bricheta + ustensile + perie curatat + caramizi
  • Servetele + prosoape de hartie
  • Fata de masa
  • Pahare, farfurii, tacamuri de plastic
  • Ceaun pentru fiert apa/cafea
  • Carne: carne de gratar pui/porc, mici, carnati
  • Bauturi: bere (cu/fara alcool), sucuri, apa plata de la minim 500 m adancime
  • Apa pentru spalat pe maini si pentru stins jarul – de la minim 2000 m adancime
  • Briceag cu desfacator de sticle si conserve
  • Lada frigorifica + sacosa frigorifica + termos
  • Saci de gunoi
  • Dezinfectant de maini / sapun

Departamentul confort

  • Patura / Saltea
  • Anti-tantari
  • Scaune
  • Umbrela soare

Departamentul entertainment

  • Carti de joc + scrabble + rummy + table
  • Manele + boxe deranjat fauna pe o raza de 1km

Safety measures

  • Haine de schimb pentru dezastre
In partea a 2-a, cu gratarul in spate (varianta cicloturistica) …

How to create CentOS 6.2 64-bit EBS AMI Image from scratch

After spending about three days to get this thing going and create my own CentOS distro, I would like to share this tutorial with everyone interested building his own virtual machine into the AWS cloud.

Long story short, here we go:

1. Create new Amazon 64-bit t1.micro instance

Use all defaults. We’ll use this instance to create our own machine. Since it has YUM, it suits perfectly into our scenario.

- Launch it
- Connect to it via SSH
- Apply all updates

 # sudo yum -y update
 # sudo yum install -y MAKEDEV

2. Create the disk for the new system

2.1 From AWS console go to “Volumes” and create a new volume of 50GB

2.2 Attach this volume to your micro instance as /dev/sdg
Note: Create in same zone as your running instance!
Note: Inside the instance would be seen as /dev/xvdg disk device

2.3 Partition the new volume

- Start fdisk

# fdisk /dev/xvdg

- Press ‘p’

 Disk /dev/xvdg: 53.7 GB, 53687091200 bytes
 255 heads, 63 sectors/track, 6527 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0xd5e37c4b
 Device Boot Start End Blocks Id System
 Command (m for help):

- Press
- ‘n’ – Create new partition
- ‘p’ – Create primary partition
- ’1′ – Create first partition
- ENTER – Start with 1st cylinder
- ENTER – End at last cylinder

- Overview again the configuration with ‘p’

 Disk /dev/xvdg: 53.7 GB, 53687091200 bytes
 255 heads, 63 sectors/track, 6527 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0xd5e37c4b
 Device Boot Start End Blocks Id System
 /dev/xvdg1 1 6527 52428096 83 Linux
 Command (m for help):

- Press ‘w’ to commit changes
- sync – to sync with disk
- Create new ext4 filesystem on the new /dev/xvdg1 device

# mkfs.ext4 /dev/xvdg1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

2.4 Mount the new partition into the system so we can prepare it

# mkdir /mnt/image/
# mount /dev/xvdg1 /mnt/image

Populate the partition with a clean system

2.5 Create the special devices

# mkdir -p /mnt/image/{dev,etc,proc,sys}
# /sbin/MAKEDEV -v -d /mnt/image/dev -x console
# /sbin/MAKEDEV -v -d /mnt/image/dev -x null
# /sbin/MAKEDEV -v -d /mnt/image/dev -x zero
# mount --bind -t proc proc /mnt/image/proc
# mount --bind -t sysfs sysfs /mnt/image/sys
# mount --bind /dev/ /mnt/image/dev/

2.6 Install YUM

# mkdir -p /mnt/image/var/lib/rpm
# rpm --rebuilddb --root=/mnt/image
# rpm --import --root=/mnt/image http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
# wget http://mirror.centos.org/centos/6.2/os/x86_64/Packages/centos-release-6-2.el6.centos.7.x86_64.rpm
# rpm -ivh --root=/mnt/image/ --nodeps centos-release-6-2.el6.centos.7.x86_64.rpm
# vim /mnt/image/etc/yum.conf
[main]
cachedir=/mnt/image/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/mnt/image/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# yum -c /mnt/image/etc/yum.conf --installroot=/mnt/image install -y rpm-build yum openssh-server dhclient

2.7 – Configure the networking on the new machine
Note: eth0 must be configured to automatically get its address via dhcp

# cat > /mnt/image/etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
EOF
# cat > /mnt/image/etc/sysconfig/network <<EOF
NETWORKING=yes
HOSTNAME=MyCentOS
NOZEROCONF=yes
NETWORKING_IPV6=no
IPV6INIT=no
IPV6_ROUTER=no
IPV6_AUTOCONF=no
IPV6FORWARDING=no
IPV6TO4INIT=no
IPV6_CONTROL_RADVD=no
EOF
# cat /etc/resolv.conf > /mnt/image/etc/resolv.conf

Note: This will copy host’s resolv.conf to new instance. In my case, the resolv.conf looks like this:

# cat /etc/resolv.conf
 ; generated by /sbin/dhclient-script
 search us-west-2.compute.internal
 nameserver 172.16.0.23

2.8 – Configure the disk system

# cat > /mnt/image/etc/fstab <<EOF
/dev/xvde1    /         ext4    defaults,noatime  1    1
tmpfs         /dev/shm  tmpfs   defaults          0    0
devpts        /dev/pts  devpts  gid=5,mode=620    0    0
sysfs         /sys      sysfs   defaults          0    0
proc          /proc     proc    defaults          0    0
EOF

2.9 CHROOT into the new system and start installing

# chroot /mnt/image/ su -
# yum -y groupinstall base core

Disable SELinux

# vim /etc/sysconfig/selinux
SELINUX=disabled
Create a password for root, just in case
# passwd

2.10 Configure your SSH access on the future host
In this step we are going to create a new user ec2-user in the Amazon images spirit

 # adduser ec2-user
 # passwd ec2-user

And change the password to something, even your mamma cannot remember.

Next we will enable the system to retrieve automatically the PEM public key pair defined in the AWS console so you can login with your AWS key pairs.

Open /etc/rc.d/ec2-user-key and append the following snippet:

# vim /etc/rc.d/ec2-user-key

#!/bin/bash
# chkconfig: 2345 99 10
# description: Retrieve Amazon PEM key for the ec2-user
# processname: Amazon
# Retrieve Amazon PEM key for ec2-user
EC2_SSH_KEY=`curl -m 20 --fail --silent http://169.254.169.254/2011-05-01/meta-data/public-keys/0/openssh-key`
if [ $? -eq 0 ];
then
        EC2_USER="ec2-user"
        EC2_SSH_DIR="/home/$EC2_USER/.ssh"
        if [ ! -f "$EC2_SSH_DIR/authorized_keys" ];
        then
                if [ ! -d "$EC2_SSH_DIR" ];
                then
                    action "Creating $EC2_SSH_DIR"
                    mkdir -p $EC2_SSH_DIR
                    chown $EC2_USER:$EC2_USER $EC2_SSH_DIR
                    chmod 700 $EC2_SSH_DIR
                fi
                EC2_DESTFILE="$EC2_SSH_DIR/authorized_keys"
                action "One time only - copying public PEM file to $EC2_DESTFILE"
                echo $EC2_SSH_KEY > $EC2_DESTFILE
                chmod 600 $EC2_DESTFILE
		chown $EC2_USER:$EC2_USER $EC2_DESTFILE
                success "OK"
        fi
else
        echo "Failed to retrieve the SSH PEM key from key server"
        failure ""
fi

To clarify some things above. The URL http://169.254.169.254 is accessible only from within Amazon machines, not from your browser. Also, the URL is hardcoded, doesn’t matter what zone you are located in (not tested).

The script tries to retrieve the public key and save it to authorized_keys, if the file does not already exists. Along the way checks if the directory tree exists, if not, tries to create it and assign appropriate rights, so SSH wouldn’t crap itself.

Now make the script executable

# chmod +x /etc/rc.d/ec2-user-key
# chkconfig --add ec2-user-key

One more thing on security. Edit your /etc/ssh/sshd_config and set the following things:

PermitRootLogin no
PermitEmptyPasswords no
GSSAPIAuthentication no # most likely you won't be needing that

2.11 Configure the grub bootloader

# cd /boot/
# mv initramfs-2.6.32-220.13.1.el6.x86_64.img old_initramfs-2.6.32-220.13.1.el6.x86_64.img
# mkinitrd --force initramfs-2.6.32-220.13.1.el6.x86_64.img 2.6.32-220.13.1.el6.x86_64
# cat > /boot/grub/grub.conf <<EOF
default=0
timeout=3
title EC2
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-220.13.1.el6.x86_64 ro root=/dev/xvde1 rd_NO_PLYMOUTH selinux=0 console=hvc0 loglvl=all sync_console console_to_ring earlyprintk=xen nomodeset
initrd /boot/initramfs-2.6.32-220.13.1.el6.x86_64.img
EOF
# ln -s /boot/grub/grub.conf /boot/grub/menu.lst
# ln -s /boot/grub/grub.conf /etc/grub.conf
# exit

2.12 Unmount the whole thing

# sync
# umount /mnt/image/dev
# umount /mnt/image/proc
# umount /mnt/image/sys
# umount /mnt/image/

Note: if it doesn’t work, use “lsof | grep /mnt” and kill remaining processes
Note: cat /etc/mtab to see if everything is unmounted

3 Take a snapshot of the drive from the AWS console

4 Create a new image from the snapshot

Please select appropriate Kernel ID. For my image I choose aki-f837bac8  (zone us-west-2)
Note: Kernel ID depends on: AWS zone (us, eu, west, east etc.), boot disk (hd00 ebs, or hd0 from S3 back-end)and architecture (i386 or x86_64).
The list of kernels can be consulted here: http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/UserProvidedkernels.html#AmazonKernelImageIDs

Note: For the root device, choose /dev/sda and NOT the default /dev/sda1!

5 Launch the image into a new t1.micro instance and check the results

Note: Use same kernel as defined above in step 4
Note: You need to authenticate with SSH and key created above!

References:
This tutorial was built using the following tutorials
1. http://paranumeral.blogspot.com/2012/01/centos-62-64bit-aws-ec2-ami-creation.html – Thanks for the detailed info!
2. http://davidatenney.wordpress.com/2012/04/12/creating-your-own-centos-6-2-x86_64-ebs-ami-on-amazon-with-pv-grub-kernel/ – Thanks for answering
3. http://blog.bashton.com/2012/how-to-make-your-own-centos-6-amis/
4. http://www.practicalclouds.com/content/guide/
5. http://amazonaws.michael–martinez.com/
6. http://www.coderchris.com/linux/how-to-mount-an-amazon-ebs-disk-as-a-drive-in-linux-centos/2011/01/31
7. http://wiki.sysconfig.org.uk/display/howto/Build+your+own+Core+CentOS+5.x+AMI+for+Amazon+EC2
8. http://lists.centos.org/pipermail/centos/2011-January/105377.html
9. http://www.ioncannon.net/system-administration/1205/installing-cent-os-5-5-on-ec2-with-the-cent-os-5-5-kernel/

 

Edit:
Fixed step 2.12  - SSH access using Amazon’s PEM keys

Ce ne mai minte McDonald’s astazi

Tot incerc de azi-dimineata sa citesc HotNews si imi sare o reclama enervanta cat tot ecranul. Ghici cine are bani sa puna o reclama cat tot ecranul?

“Din ce sunt facuti cartofii prajiti de la McDonald’s? Din cartofi, desigur. Din acei cartofi pe care ii cumperi de la piata si ii pregatesti la tine in bucatarie…”

 

 

 

 

 

 

Ce reclama! Aproape te face sa crezi. Mai ales cand te uiti la poza atent proiectata de masina de reclama marca McD’s. Practic iti gadila papilele gustative si incepi sa stergi ecranul cu servetele.

Sa mergem putin pe site-ul lor si sa vedem ce contin intr-adevar acesti cartofi:

  • cartofi (fiind primul ingredient din lista, ne garanteaza ca este macar predominant)
  • ulei vegetal (un amalgam de uleiuri hidrogenate)
  • aroma naturala de vita din faina si lapte – au reusit performanta de a scoate vaca din lapte)
  • dextroza (zahar, pe intelesul tuturor)
  • acid citric, conservant, ca sa nu putrezesti in mormant
  • polifosfat de acid sodic – intretine culoarea aurie si rumena – yummy!
  • sare

Mai citim ca este preparat in ulei vegetal hidrogenat care mai contin si TBHQ (Tertiary butyl hydroquinone) si Dimethylpolysiloxane – iti dau un happy meal daca le gasesti traducerea in romana!

Saraca bunica, daca stia ca ingredientii secreti din cartofii sunt zaharul, laptele, faina si tri-butilii, cu siguranta mi-ar fi facut niste cartofi prajiti mult mai gustosi.

Si acum intrebarea catre McD’s?

Ce procent din cartofii prajiti contin in realitate cartofi selectionati atent si cu dragoste, pentru fraieri?

P.S. Evident ca nu poti pune link direct la portia mare care iti este mereu “sugerata” la magazin. Asa ca va trebui sa dati un click in plus pentru portia de 500 de calorii.

 

Update: Se pare ca McDonald’s tocmai si-a luato pe tema asta. A primit o amenda pentru reclama mincinoasa.

SMURD – Un serviciu profesionist

Aseara pe la 23.30 m-a sunat bunicul deoarece ii este rau. M-am suit repede in masina, am ajuns si ii era foarte rau, nu putea respira, senzatie de voma si frig.

Am sunat la 112 si imediat a raspuns cineva, am spus numele pacientului si se pare ca deja stia adresa. M-a redirectionat catre salvare unde am dat toate detaliile. Au spus ca trimit un echipaj SMURD. Dupa 13 minute echipajul a sosit.

Au venit doi asistenti care imediat l-au pus pe oxigen, intrucat respira foarte greu, i-au luat tensiunea (160/95), ne-au intrebat de istoricul bolilor si medicatia curent, i-au facut o electrocardiograma.  Dupa cateva minute pe oxigen, tensiunea a scazut la 150/95. Acum vine partea interesanta, aparatul folosit a comunicat prin GSM/GPRS electrocardiograma direct la spitalul de urgenta Floreasca, unde o echipa s-a autosesizat si a trimis inca un echipaj cu medici fiind suspect de infarct miocardic. Asistentii care au venit nu aveau competente pentru astfel de cazuri. L-au suit in salvare, si au plecat spre spital. Pe drum s-au intalnit cu al doilea echipaj care i-au pus perfuzii si au continuat tratamentul. Cam dupa 30 de minute au continuat drumul spre spital.

Aici interventia echipajului SMURD a luat sfarsit, fiind preluat medicii spitalului Floreasca. Felicitari pe aceasta cale serviciului care a dat dovada de profesionalism si au aratat ca sunt foarte bine dotati, atat cu masini, aparatura de tratament si telecomunicatie.

Nu la fel de bine insa a fost la spitalul Floreasca, unde am fost tinuti in suspans cateva ore, la ora 4.30 fiind scos din sala de tratament cu diagnostic de edem pulmonar si alte complicatii. Doctorul Stefan Bogdan, care l-a tratat nu a fost de gasit, asistentele ne-au trimis prin spital, ba la salon, ba la camera de garda, iar inapoi la salon si dupa ce am intrebat sorele medicale am aflat ca doctorul plecase (schimbare de garda), iar un alt doctor ne-a spus sumar ce are: edem pulmonar si multe alte complicatii.

In sfarsit, sper ca totul va fi bine.

MySQL configure UTF-8

Edit MySQL’s configuration file to default to enable UTF-8 support. Open /etc/my.cnf, or /etc/mysql/my.cnf or my.ini on Windows and add the following snippets to their appropriate sections. Restart MySQL service and you’re done.

[mysqld]
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
init_connect='SET collation_connection=utf8_general_ci'
init_connect='SET NAMES utf8'

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

Configurare router wireless UPC

De curand am trecut pe routerul wireless de la UPC (Cisco EPC2425), ca sa scap de al meu (D-Link DIR … ceva cu 2 antenet). Dupa ce am facut trecerea, reteaua wireless a mers foarte prost, cu intreruperi, deconectari …

Am incercat sa intru in interfata de administrare a router-ului, dar supriza – parea protejata de username/parola. Sun la UPC si operatoarea amabila imi spune ca nu este protejata cu nicio parola. Ma instruieste ce sa schimb si fac modificarile prin telefon.

Singurul catch era ca trebuia sa trecu pe tab-ul Setup. Cand cere parola, apas ENTER de mai multe ori et voila!

M-a pus sa schimb urmatoarele setari:

  1. Wireless > Basic > New Channel si am schimbat de la 13 la 6. Aici se poate jongla pana reteaua devine stabila, in functie de retelele vecine.
  2. Wireless > Advanced > Fragmentation Threshold pus pe minim (256)
  3. Wireless > Advanced > RTS Threshold pus pe minim (0)

Dupa aceste setari, reteaua merge perfect de cateva zile – fara nicio deconectare. Insa ma deranjeaza este ca acest modem este in banda g (54 Mbps), in timp ce vechiul meu modem era in banda n (300 Mbps), si facusem si toata reteaua n.

In alta ordine de idei, cumparasem abonamentul digital deoarece televizorul Samsung LED, are decodor DVB-C intern si speram ca sa scap de cutiuta UPC. Fara sa ma documentez, am aflat cu tristete ca desi am scapat de routerul wireless si de routerul de cablu, am primit decodorul (STB – Set Top Box) UPC – mai  mare, mai urat si cu inca o telecomanda!

Move WordPress database in 3 steps

Step 1. Dump original database

$hell>mysqldump -u root -p -r latest.sql wp_database

Step 2. Create new database, add credentials & import the dump

mysql>CREATE DATABASE wp_database CHARACTER SET utf8;
mysql>GRANT ALL ON wp_database.* TO 'db_user'@'localhost' IDENTIFIED BY 'strong_password';
$hell>cat latest.sql | mysql -u root -p wp_database;

Step 3. Update database with new URL

mysql> update wp_options set option_value='http://new.website.com' where option_name in ('siteurl', 'home');

 

Quick code – Print system properties in Java

Cut’n'paste snippet for printing environment properties in Java

import java.util.Properties;
import java.util.Enumeration;

class test {
public static void main(String args[]) {
        Properties props = System.getProperties();
        Enumeration names = props.propertyNames();
        while(names.hasMoreElements()) {
                String name = names.nextElement().toString();
                String value = props.getProperty(name).toString();
                System.out.println(name+"="+value);
        }
}
}
[run/]$ javac props.java; java -cp . test

Install awstats on CentOS 6

Although the default configuration may have worked, I wanted to move the service to SSL so I can keep personal things tidy.

Step 1. Configure httpd

Copy content of /etc/httpd/conf.d/awstats.conf to /etc/httpd/conf.d/ssl.conf. At this moment, because I was getting the error “attempt to invoke directory as script: /var/www/awstats/” and “permission denied” while trying from web interface, I had to tweak also the snippet and remove ScriptAlias which came default. The final snippet looks like this:

    Alias /awstats /var/www/awstats
    <Directory /var/www/awstats>
        AddHandler cgi-script pl
        DirectoryIndex awstats.pl
        Options ExecCGI
        AllowOverride None
        Order deny,allow
        Allow from 8.8.8.8
    </Directory>

Allow from x.x.x.x restricts me to check out the statistics from my own IP. Asa note, I didn’t liked the default permission for /var/www/awstats neither, so I changed those too.

Step 2. Create awstats configuration files

During this step, basically I’ve copied the file /etc/awstats/awstats.model.conf to /etc/awstats/awstats.www.romanescu.ro.conf and edited two lines

LogFile="/var/log/httpd/www.romanescu.ro-acces.log"
SiteDomain="romanescu.ro"

Step 3. Gather statistics

Create/update statistics from command line, as root:

perl /var/www/awstats/awstats.pl -config=www.romanescu.ro

Step 4. Automate things

Using your crontab -e, add the task to cron and restart the daemon: service crond restart

0 17 * * * perl /var/www/awstats/awstats.pl -config=www.romanescu.ro >/dev/null 2>&1

I’ve set the task to run daily at 17:00 o’clock, so each evening I see updated statistics.

And that’s all, plain and simple.