Postgresql en Fedora 31: conectar a la BD

En un breve artículo hemos visto como instalar e inicializar Postgresql en Fedora 31.

Instalé e intenté conectar con PgAdmin3 sin éxito. La única manera en la que conseguía conectar era convirtiéndome en le usuario postgres en el SO.

Los logs de postgresql en Fedora están en la ruta: /var/lib/pgsql/data/log

Un vistazo y ví:
2019-12-14 19:04:59.627 CET [26263] LOG: could not connect to Ident server at address "::1", port 113: Connection refused
2019-12-14 19:04:59.627 CET [26263] FATAL: Ident authentication failed for user "postgres" 2019-12-14 19:04:59.627 CET [26263] DETAIL: Connection matched pg_hba.conf line 84: "host all all ::1/128 ident"

Hay distintas maneras de solucionarlo, una sencilla (poco elegante a mi juicio) es habilitar el acceso basado en contraseñas con encriptación md5.

La solución editar el fichero: /var/lib/pgsql/data/pg_hba.conf y dejar línea de autenticación para que se haga con md5:
host all all ::1/128 md5

Hay que hacer algo más, poner una contraseña al usuario postgres en el servidor porque la validación que hemos configurado utilizará el propio servidor para permitir o denegar el acceso por el puerto predeterminado de postgresql.

Configurar una la contraseña del usuario se hace entrando a la BD desde el SO como usuario postgres. Utilizamos la CLI de postgres:
su
- postgres
psql
postgres=
# \password postgres

Gracias a Jordanspheire por su artículo User “postgres” Has No Password Assigned

Postgresql en Fedora 31: inicializar la BD

La base de datos Postgresql merece un artículo aparte para comentar porqué elegirla, en este artículo -y probablemente en alguno más- comentaré las peculiaridades de instalarla y configurarla sobre Fedora 31.

La instalación de Postgresql está disponible en otros artículos, documentada con detalle. Hay dos cosas que sí destaco:

  1. Se dispone de varios rpm’s con el nombre de Postgresql, el que instala el RDBMS es el postgresq-server.
  2. Una vez instalado, parece que no va, la razón es que hay que inicializar la instalación. Se consigue con el comando initdb.

Aquí copio dónde se ubica el comando initdb y que pertenece al paquete postgresql:

# whereis initdb initdb: /usr/bin/initdb /usr/share/man/man1/initdb.1.gz
# rpm -qf /usr/bin/initdb postgresql-server-11.6-1.fc31.x86_64

Iniciamos el servicio como root:
systemctl status postgresql

Tecleamos para inicializar la BD:
postgresql-setup --initdb

How to modify every day login in Linux

Every time you log into a *NIX machine you are wellcomed by a text banner that varies from one *NIX to other, even among Linux distributions.

If you want to customized this message it’s fairly easy, you only have to edit (as a root) the file /etc/motd and the next login will show your new message of the day.

My two cents to a so simple task is enrich your file writting inside some ASCII art. For instance, you may use figlet to writte inside the /etc/motd file your hostname. In short:

  1. Be sure you have figlet installed in your system or install: in Fedora; type yum list figlet or (lazy way) yum list figl* and figlet may appears in one of both list, installed or available package.
  2. Add different messages to each login with fortunes. First, be sure you have fortunes installed in your Fedora and then, edit your .profile and add an invocation to the fortunes program.
    For instance, I add this:
    echo -n "### Fortune for "
    echo -n `date +%d\-\%m\-\%Y`
    echo " ###"
    /usr/games/fortune

    I get this:
    ### Fortune for 22-04-2018 ###
    Computers are useless. They can only give you answers.
    -- Pablo Picasso

    BTW, I recommend to writte the full path to the fortune’s binary ’cause it’s installed out of the usual $PATH.

If you research a few over thhe Internet you may find differente fortunes collections, such The Simpsons, or my favorites inspired by BOFH.

Why am i going to “play” with a Rasperry Pi? (Update 31/03/2018)

Why am i going to “play” with a Rasperry Pi? Short answer; for educational purposes.

No the little bit more explained why I decide to sset up a Rasperry Pi, but also going to the point:

  • I’m very bad with hardware, so it’s a little bit challenging for me
  • a very good friend gift me its Raspberry Pi 1 (512Mb RAM) and it was collecting dust
  • I may obtain something useful at the end of the process, for instance, a media server, a little NAS, whatever.
  • I’m going to refresh my former sysadmin skills; file system formatting, installing different OS’s flavours, setting up a network, etc.
  • It’s a wide documented process so it keeps my attention in making the right thing, not in solve a new problem never before seen.

So, again, for educational purposes, mixing up fun with refreshing basic skills.

Update 31/03/2018:
Raspian up & running on an Raspberry Pi 1 model. Reasons for Raspbian:

  • Main reason: It forces me to get out of my usual Red Hat / CentOS / Fedora distro to a Debian based one. I hope this helps me in a future for getting the LP1 Certification
  • General purpose (I’m not looking for a particular functinality), I’m satisfied if it acts as a ssh gateway to the rest of home network
  • Well documented, this is a must since learn something new requires make mistakes. For example, I bought a USB – WiFi here you got how seting WiFi up via the command line, because command line always teches more than graphical interfaces IMHO

Dnf update problems and how to solve them

One of my workstations runs Fedora for a quite long. I’ve been following practices from my previous technical job and take easy to upgrade the distro or to switch the “lates-what-ever-technology” you would imagine.

I’ve finally adopt dnf command instead of yum to manage the command lines. It has being going well but suddenly I’ve started to received this error message in the terminal:

Traceback (most recent call last):
File "/bin/dnf", line 36, in
main.user_main(sys.argv[1:], exit_code=True
File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 185, in user_main
errcode = main(args)
File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 84, in main
return _main(base, args)
File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 115, in _main
cli.configure(map(ucd, args))
File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 981, in configure
self.optparser.usage = self.optparser.get_usage()
File "/usr/lib/python2.7/site-packages/dnf/cli/option_parser.py", line 255, in get_usage
usage += "%-25s %s\n" % (name, summary)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 40: ordinal not in range(128)

So I decide to go back to the trusty well worker yum.

Finally I’ve found how to solve the problem, by typing this:

  1. export LANG=C
  2. dnf clean all
  3. … and then you may type dnf clean all just is case
  4. Finally, type dnf update and everything must be settled and done, and your system gonna work with dnf or yum, as you wish