Geek Resolutions – THE UPDATE

Did I say I was going to buy a Galaxy Note 2? Oh, I change my mind so fast.

The Nexus 4 went on sale again. And I bought it. Ask me, WHY RENATA, WHY DID YOU BUY THE NEXUS?

So, I’ve been on a 3-year-contract with Bell since December 2010. They keep sending me messages suggesting that, for a “small fee”, I can buy a new phone and renew my contract for another three years. Let’s do some math here.

If I wanted a Galaxy Note 2, I’d have to pay, right now:
- 150 to be able to have a new phone
- 200 for the Galaxy on a three year contract

350 + taxes and I would be trapped in a contract for 3 years again. To get the Galaxy contract free, it would cost me 150 + 700 (price of the phone, unlocked). I’m not that crazy.

Now, here comes the Nexus.

Google delivered me an unlocked, carrier-free phone for 400, taxes included. It’s an awesome phone. Really awesome. I won’t do another review because there are plenty of reviews everywhere. I’m happy with my choice, and my bank account is even happier.

I recommend the Nexus to everyone who’s trapped on a carrier contract.

Geek 2013 Resolutions

Very, very simple New Year’s Resolutions.

1. New Android Phone. I’ll go with the Samsung Galaxy Note II. My Desire Z is too slow for today’s apps, and the screen is cracked. But I intend to play with its hardware anyway.

2. New Macbook. Now, this is tricky. I’d like a new Macbook Air 11′ – we’re in January and, if MacRumors got it right, I’d have to wait about 6 months for a fresh Air – but with Retina display. Which is not that much, but it’s also not tomorrow.

I don’t have lots of resolutions. I don’t need lots of things. Yep, that’s it.

Quick MySQL Replication Setup

I will describe here how to quickly setup Master/Slave replication on MySQL Enterprise 5.5

Master Setup

  1. Obtain MySQL Enterprise rpms from Oracle.
  2. Procedures for installation: yum localinstall MySQL-(packagename). The server is called “server-advanced”, the client “client-advanced” and the libs are under shared and shared-compat. There are a couple more packages offered. You should have a repository available as libaio is needed by the server.
  3. Save the default /etc/my.cnf to /etc/my.cnf.default in case you need to reset your mysql installation
  4. Edit the my.cnf with optimized values. Make sure you have the following variables setup correctly (although you only need the server-id):
    server-id = x
    read_only = (0|1)
    report-host = w.x.y.z
    relay-log = xxxxxx
    log-bin = yyyyyy
  5. Starting mysql for the first time:
    Create initial databases: run from the command line mysql_install_db
    Start mysql by running /etc/init.d/mysql start
  6. In case mysql doesn’t start, check if the tables created under /var/lib/mysql are readable by the mysql:mysql user & group. If not, chown -R mysql:mysql accordingly and try restarting
  7. Creating a user for replication: Go to mysql prompt:
    mysql> CREATE USER 'user'@'%' IDENTIFIED BY 'password';
    mysql>GRANT REPLICATION SLAVE ON *.* TO 'user'@'%';
  8. On mysql prompt, type “show slave hosts” to list slaves, and “show master status” to, obviously, see master status.

Slave Setup

Each slave is setup the same way.

  1. Obtain MySQL Enterprise from Oracle
  2. Procedures for installation: yum localinstall MySQL-(packagename). The server is called “server-advanced”, the client “client-advanced” and the libs are under shared and shared-compat. There are a couple more packages offered. You should have a repository available as libaio is needed by the server.
  3. Save the default /etc/my.cnf to /etc/my.cnf.default in case you need to reset your mysql installation
  4. Edit the my.cnf with optimized values. The only things you really need here are relay-log and server_id.
  5. Create initial databases: run from the command line mysql_install_db
  6. Start mysql by running /etc/init.d/mysql start
  7. In case mysql doesn’t start, check if the tables created under /var/lib/mysql are readable by the mysql:mysql user & group. If not, chown -R mysql:mysql accordingly and try restarting
  8. Starting the slave: go to mysql prompt:
    mysql> change master to master_host='your.master.host.server', master_user='user', master_password='password';
    mysql> start slave;
    mysql> show slave status;

Notes

  • server_id must be unique (and under (2^32)-1, which is a very big number and I really doubt we’re going to have that many DBs in our lives)
  • read_only is 0 if server mode is read/write and 1 if server mode is read-only
  • report-host is the name your host is going to report to the master (and is going to show up in the “show slave hosts” lists. Write something meaningful here.
  • These instructions work for MySQL Enterprise 5.5. If you’re going to upload a dump to the master, be sure to stop the slaves before.

If you need detailed information, MySQL Official Replication Howto to the rescue. It’s good!

Na riqueza e na pobreza

Uma das coisas que me chamou a atenção aqui no Canadá foi a simplicidade do canadense médio, se você comparar com o brasileiro médio de uma cidade do mesmo porte. De modo geral, o canadense é mais bem pago, tem mais benefícios (sistema de saúde público que funciona, escola pública decente), mais segurança, ou seja, se preocupa com menos coisas e, portanto, acaba tendo mais dinheiro sobrando. Claro que compram besteiras. Mas existe muito menos a necessidade de comprar besteiras pra mostrar que “tá podendo”, uma coisa muito comum no Brasil.

Por exemplo, eu nunca, nunca vou me esquecer da Preta Gil dizendo pra quem quisesse ouvir que ia comprar o iPhone “G3″. Só porque podia. Ela não tinha a menor idéia de pra que o iPhone servia, se seria útil pra ela, do que se tratava, nem sequer sabia o nome direito. Mas ia comprar e estava anunciando pra todo mundo. É o retrato do brasileiro padrão: usa todo o dinheiro possível e imaginável para comprar o que não precisa para mostrar para os outros que pode. Quantas pessoas você conhece que querem um iPhone / Macbook / produto da moda e não sabem muito bem o que fazer com ele, poderiam usar algo que custa 1/10 do preço no lugar, e investir o resto do dinheiro em algo mais útil para si mesmos (uma viagem para outro país, aprender idiomas, tantas coisas) ? Existe essa geração de pessoas que compra gadgets caros e bonitinhos para passar tempo no reddit/facebook/twitter/pinterest.

Claro que existe esse tipo de pessoa retardada aqui também, mas é menos comum em centros urbanos. As pessoas se preocupam bastante em se informar como vão gastar o dinheiro, para não gastar dinheiro à toa. Existe uma cultura (que acho muito válida) de que dinheiro é uma coisa séria – os jovens começam a contribuir para as finanças da casa com summer jobs em McDonalds e KFCs da vida durante as férias escolares, não importa quanto dinheiro sua família tenha. A maior parte usa transporte público pra ir trabalhar, e muita gente vai de bicicleta. As pessoas não ligam para “coisas de marca”, como os nossos vizinhos dos EUA, o importante é que seja duradouro e barato. Ninguém está interessado em gastar 200 pratas em um produto que vai ser trocado ano que vem. Se ele durar cinco anos, aí é outra história.

Observem como isso é TÃO diferente da cultura de não dar valor ao dinheiro de um país tão POBRE quanto o Brasil. Porque, numa boa, “em desenvolvimento” é um eufemismo muito chato, e pro país crescer vocês têm que parar de se esconder atrás de eufemismos. A minha impressão é que o Brasil está tentando virar uma cópia dos EUA, e isso é assustador. Não façam isso, lá não deu muito certo.

Building new Apache stuff for CentOS

Building apr

  1. Download apr : http://apache.skazkaforyou.com/apr/apr-1.4.6.tar.bz2
  2. rpmbuild -tb apr-1.4.x.tar.bz2
  3. It will most likely complain about dependencies, some silly message like: expat-devel is needed by apr-1.4.6
  4. To get rid of these messages, install all required dependencies by running: yum install expat-devel
  5. Then make sure to run rpmbuild -tb apr-14.x-tar-bz2 again. When it exit 0, search for your RPM in rpmbuild/RPMS/ directory. You are going to find two rpms there:

    apr-1.4.6-xxxx-.rpm
    apr-devel-1.4.6-xxxx.rpm

    yum install both, so your rpm library is updated

Building apr-utils

It’s a very similar process to building apr.

  1. Download apr-util: http://apache.skazkaforyou.com//apr/apr-util-1.4.1.tar.bz2
  2. Fix dependenciex by yum install’ing required packages. It requires freetds-devel, which is only available under EPEL.
  3. rpmbuild -tb apr-util-1.4.1-x.tar.bz2
  4. It will generate all the following packages under rpmbuild/RPMS:

    apr-util-dbm-1.4.1-1.x86_64.rpm
    apr-util-ldap-1.4.1-1.x86_64.rpm
    apr-util-odbc-1.4.1-1.x86_64.rpm
    apr-util-sqlite-1.4.1-1.x86_64.rpm
    apr-util-devel-1.4.1-1.x86_64.rpm
    apr-util-mysql-1.4.1-1.x86_64.rpm
    apr-util-openssl-1.4.1-1.x86_64.rpm
    apr-util-1.4.1-1.x86_64.rpm
    apr-util-freetds-1.4.1-1.x86_64.rpm
    apr-util-nss-1.4.1-1.x86_64.rpm
    apr-util-pgsql-1.4.1-1.x86_64.rpm

  5. yum install apr-util-*rpm

Building httpd

  1. Download httpd http://apache.skazkaforyou.com//httpd/httpd-2.4.2.tar.bz2
  2. It’s not as simple as they state in httpd documentation because of a build bug that requires distcache for httpd and there’s no such thing for CentOS. THEN HOW DO WE DO IT?
    It’s kind of simple. When you rpmbuild -tb httpd-2.4.x-tar.bz2, rpmbuild created a default httpd.spec file under rpmbuild/SPEC/httpd.spec – GO FIND THAT FILE NOW. Now, edit that file and get the lines that references to distcache (mod_socache) and comment them out . Save this file SOMEWHERE ELSE, or it will get overwritten.
  3. Save your tarball under rpmbuild/SOURCES/.
  4. rpmbuild -ab httpd.spec
  5. If you run into this error:

    RPM build errors:
    Installed (but unpackaged) file(s) found:
    /usr/share/man/man8/fcgistarter.8.gz

    Edit the httpd.spec file and find these lines so they look like this (second line will be added):

    %{_mandir}/man8/rotatelogs.8*
    %{_mandir}/man8/fcgistarter.8*

  6. Now run :

    rpmbuild --clean httpd.spec
    rpmbuild --ab httpd.spec

  7. It should work. For real. Good luck, people.
  8. Now, just yum install everything else and be happy!

Pride

Brazilian Pride has already happened, and Toronto Pride Week starts next weekend. I am really excited about Pride events, even though I am a boring straight person.

As a Brazilian, I come from a society where people seem to care too much about others do with their lives, which includes who they love and kiss and everything else. I couldn’t care less and I just want people to be happy. Canada is centuries ahead and most people don’t care if you like men, women, both, what you like to wear, but there are still some idiots who care, meaning there are still some things to be done.

So, when I say I support Pride, I am there standing for all these people who need their rights to be the same as mine. Having a relationship with the person I love in public is a non-issue. I can kiss, I can hug, I can tell everyone about it and they will think it’s ok. I want to live in a world where everyone can talk about their love life like I talk about mine.

And, let’s face it, if someone can’t look at a couple kissing because of their gender, then someone has a problem, and it’s not the couple.

Like we say here, in Canada we don’t call it “same-sex marriage”, we just call it “marriage”.

Hostnames and Oracle XE

So, you changed your server hostname and you have Oracle XE running. And you think life’s simple and beautiful. It isn’t. You wish. Changing hostnames is. Oracle is always like that boyfriend (or girlfriend) you had in high school, full of issues and never happy and always needy. Yeah, I despise Oracle, that attention whore.

So, here’s the deal, after some research, what it takes to make Oracle ready for some change in your life, some brand new hostnames:

#1 Find your tsnames.ora and listener.ora files. They are probably located somewhere very intuitive and easy, like /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/lol/omgtehinternet/

#2 Change the contents of tsnames.ora

FROM

XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oldhostname.olddomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)

TO

XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = newhostname.newdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)

Do exactly the same thing with listener.ora

Restart oracle-xe and please, don’t be a fool like me and make sure your SElinux policies are correct before you go nuts and think everything is totally messed up. The errors you get from SeLinux are as intuitive as the oracle path.

Good luck!