Samstag, 20. Juli 2019

Prepare a HP ProLiant DL160 G6 Ubuntu 18.04

For playing a little bit I bought a used HP ProLiant DL160 G6 server.

It is my first server to bring up, so I get some help from a friend :-) and struggle over some points regarding of the age of the server.

Ok, let's start:

First I set a static IP in the BIOS (get in with F10)
Then I have to create a RAID device. It's really easy:
  • start the server
  • wait until the configuration menu of the RAID controller appears and get in
  • choose "Create logical drive"
  • select the devices you want and which RAID
    • for me I had 2 devices and select RAID0 cause it is a non-production server
  •  confirm and that's it
To install the OS I used a minimal ISO of Ubuntu 18.04 and take my RAID0 device as one partition.


Updating the HP firmware:

I had a CPxxxxx.cexe file which I copied on the server. There I tried to execute this file but this didn't work for me. It was not possible to unpack the archive. So I started the system again with a Live USB 32 bit System and tried it there. But the same issue.
The solution:
  • copy the CPxxxxx.cexe file in a own directory
  • execute ./CPxxxxx.cexe --unpack=/path/to/actual/dir
  • ./CPxxxxx.cexe now works

Backup the BIOS:


To be continued....

Samstag, 1. Juni 2019

Migration of a Postgresql database in OpenShift

I'm working with an OpenShift 3.11 HA cluster where I deployed a Red Hat Single Sign On Application for authorization using a template of the catalouge. This template create a single Pod for the SSO and another one for a Postgresql 9.5 database to get the data persistent.
After collecting some experience with this application I decided to deploy a new one which should be redundant and each Pod should be schedule on a different node. So I would like to migrate the data from the Postgresql database of the first application.

I found following workaround which works for me. The way to it I describe at the bottom of this article ;-)

Ok, let's start:
Let's say we have the following Pods:
old Postgresql Pod: sso-postgresql
new Postgresql Pod: sso-new-postgresql
name of the database: root
user of the database: user1

First we have to create a custom dump from the Postgresql database which hosts the data:

oc rsh sso-postgresql

sh-4.2$ mkdir tmp
sh-4.2$ cd tmp
sh-4.2$ pg_dump -Fc root > db.dump
sh-4.2$ exit
oc rsync sso-postgresql:/opet/app-root/src/tmp </local/path>

Then we switch to the actual project in OpenShift and sync the Postgresql dump into the new Postgresql Pod. By the way, this Pod has to be created with the same database name and credentials like the ole one

oc project sso-new
oc rsync <local/path> sso-new-postgresql:/var/lib/pgsql/data/

The output of this command will look like this:

sending incremental file list

./

db.dump



sent 306,145 bytes received 131 bytes 204,184.00 bytes/sec

total size is 305,961 speedup is 1.00

rsync: failed to set permissions on "/var/lib/pgsql/data/.": Operation not permitted (1)

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]

error: exit status 23

The error has no meaning for us, so we can go further

Now you have to pause all Pods with a connection to the new database

oc resume pause dc <Pods>

For the next steps we log in the new Postgresql Pod

oc rsh sso-new-postgresql

sh-4.2$ cd /var/lib/pgsql/data
Check that the db.dump is there

Now we enter the workaround cause a normal restore didn't worked for me:


sh-4.2$ psql --list

List of databases

Name | Owner | Encoding | Collate | Ctype | Access privileges

-----------+----------+----------+------------+------------+-----------------------

postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |

root | user1 | UTF8 | en_US.utf8 | en_US.utf8 |

template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +

| | | | | postgres=CTc/postgres

template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +

| | | | | postgres=CTc/postgres

(4 rows)

Delete the database root
sh-4.2$ dropdb -U user1 root

Then create a new one 

sh-4.2$ createdb -O user1 root

Check if this new database is empty:

sh-4.2$ psql root_entw

psql (9.5.14)

Type "help" for help.



root_entw=# \dt

No relations found.

root_entw=# \q

Then make the restore in this new database:

sh-4.2$ pg_restore -d root_entw -U userv1c --clean --if-exists --create db_c.dump

pg_restore: [archiver (db)] Error while PROCESSING TOC:

pg_restore: [archiver (db)] Error from TOC entry 3309; 1262 16385 DATABASE root_entw userv1c

pg_restore: [archiver (db)] could not execute query: ERROR: cannot drop the currently open database

Command was: DROP DATABASE IF EXISTS root_entw;



pg_restore: [archiver (db)] could not execute query: ERROR: permission denied to create database

Command was: CREATE DATABASE root_entw WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8';







pg_restore: [archiver (db)] Error from TOC entry 3312; 0 0 COMMENT EXTENSION plpgsql

pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of extension plpgsql

Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';







pg_restore: WARNING: no privileges could be revoked for "public"

pg_restore: WARNING: no privileges could be revoked for "public"

pg_restore: WARNING: no privileges were granted for "public"

pg_restore: WARNING: no privileges were granted for "public"

WARNING: errors ignored on restore: 3


Ignore the errors ;-)

Check the database for the tables

sh-4.2$ psql root_entw

psql (9.5.14)

Type "help" for help.



root_entw=# \dt

List of relations

Schema | Name | Type | Owner

--------+-------------------------------+-------+---------

public | admin_event_entity | table | userv1c

public | associated_policy | table | userv1c

public | authentication_execution | table | userv1c

public | authentication_flow | table | userv1c

public | authenticator_config | table | userv1c

public | authenticator_config_entry | table | userv1c

public | broker_link | table | userv1c

public | client | table | userv1c

public | client_attributes | table | userv1c

public | client_auth_flow_bindings | table | userv1c

public | client_default_roles | table | userv1c

public | client_initial_access | table | userv1c

public | client_node_registrations | table | userv1c

public | client_scope | table | userv1c

public | client_scope_attributes | table | userv1c

public | client_scope_client | table | userv1c

public | client_scope_role_mapping | table | userv1c

public | client_session | table | userv1c

public | client_session_auth_status | table | userv1c

public | client_session_note | table | userv1c


root_entw=# \q



Exit the Pod

sh-4.2$ exit

Resume the related Pods

After the Pods are started, check if the data is available for the Pods 

That's it!!!

-----------------------------------------------------------------------------------------------------------
So... what was the way to here??? (a long and winding road ;-))

First I tried to make a snapshot of the pvc of the postgresql Pod. But unfortunatly the plugin I'm using doesn't support pvc snapshots

Then I tried to make a full and a partial dump of the old Postgresql database and restore the dump in the new one. I tried

pg_dump root | gzip > /opt/app-root/src/tmp /sso-postgresql.gz
pg_dumpall

and in the new Postgresql Pod

psql root < /var/lib/pgsql/data/sso-postgreql

That produce only a lot of errors, but no new data in my database

Then I found a tip that pg_restore works better with a custom dump format. So I created a cutom dum and tried the direct restore in the new Pod (see documentation of Postgresql https://www.postgresql.org/docs/9.5/app-pgrestore.html)
But again... only errors and no expected data

After many experiments (and learned a lot how to act with Postgresql) suddenly it works... I tried to figure out what I've done in my experiments ans recogniszed, that I once deleted the first database. I deleted it to make a pg_restore expecting the restore would also create the database new. But this didn't happened. So I created the database new. But I forgotten bevore deleting the database to notice which tables are inside (shit). And so I tried again the restore, but I only say the errors thinking the restore was not succesful. But after leaving the pod and check the data in the application -surprise- the data was there.

I was using this workaround many times, and every time it was a success.

If someone outside there has a better idea to realize such a migration, please tell me... I'm more an OpenShift specialist than a Postgresql master... 









Montag, 6. Mai 2019

Deja Dup Probleme Ubuntu 16.04 nach 18.04

Nachdem ich mein System mit Ubuntu 18.04 neu aufgesetzt hatte, wollte ich meine Daten aus meinem vorhandenen Backup, welches ich mit DejaDup unter Ubuntu 16.04 erzeugt hatte, wieder einspielen.
Zu meinem Entzetzen musste ich feststellen, dass DejaDup unter 18.04 die Daten nicht mehr erkannte. Bei der Wiederherstellung kam es immer wieder zu Fehlermeldungen und dem Abbruch der Wiederherstellung.

Auf meiner Suche nach der Lösung versuchte ich es mit Hinweisen wie unter
https://wiki.ubuntuusers.de/Deja_Dup/ die mich leider nicht weiter brachten, da sie für mich nicht funktionierten.

Die Lösung war dann, eine VM mit Ubuntu 16.04 zu erzeugen, die einen Austausch Ordner mit dem Gastsystem unterhält.

Innerhalb der VM habe ich mit DejaDup dann einzelne Ordner wieder hergestellt. Hat man genügend Speicher zur Verfügung, kann man auch das ganze Backup wiederherstellen, was für meinen Fall jedoch nicht möglich war.

Um nun einzelne Ordner oder Dateien wieder herstellen zu können, öffnet man den Dateimanager Nautilus unter Ubuntu 16.04, wechselt in den Ordner, in der die Daten ursprünglich lagen und ruft mit der rechten Maustaste das Kontextmenü auf. Dort gibt es einen Menüpunkt "Fehlende Dateien wiederherstellen".

Nachdem dieser ausgewählt wurde, erscheint Fenster von DejaDup, welches auffordert, dass Backup auszuwählen, aus welchem wieder hergestellt werden soll. Danach startet DejaDup den Einlesevorgang, der etwas Zeit in Anspruch nehmen kann.

In der Liste, die nach Beendigung des Einlesevorgangs zu sehen ist, können die Dateien und Ordner ausgewählt werden, die wiederhergestellt werden sollen. Et voilá... Danach stehen die Dateien wieder zur Verfügung und können über den Austausch Ordner auf das Gast-System gezogen werden.

Ach ja: Über eine Besonderheit bin ich noch gestolpert! Möchte man Dateien z.B. aus dem Download Ordner wiederherstellen, wird man beim ersten Versuch feststellen, dass der Eintrag "Fehlende Dateien wiederherstellen" im Kontextmenü nicht zu sehen ist. Die Lösung hierfür liegt darin, dass das DejaDup auf dem System noch nicht konfiguriert wurde und in der Standard-Konfiguration von DejaDup der Download-Ordner in der Liste der zu ignorierenden Ordnern enthalten ist. Löscht man aus dieser Liste den Download-Ordner raus und fügt ihn in die Liste der zu sichernden Ordner ein, so erscheint im Kontextmenü nun auch der Eintrag zum wiederherstellen der Dateien

Donnerstag, 14. März 2019

kubectl für entfernten Minikube einrichten

Herausforderung
Auf meinem lokalen Rechner habe ich einen minikube installiert und gestartet. Aus einer VM heraus, möchte ich auf den minikube mit kubectl zugreifen

Thematik:
Wie informiere ich kubectl darüber, wo sich der minikube befindet?

Lösung:
  • Anlegen einer ~/.kube/config
  • Kopieren aller relevanten Zertifikate
Wird der minikube installiert und gestartet wird auf dem Hostsystem ein Verzeichnis ~/.kube angelegt. In diesem Verzeichnis wird wiederum die Datei "config" abgelegt, die alle notwendigen Daten für den Zugriff auf den minikube enthält.
Innerhalb der ~/.kube/config wird auf Zertifikate verwiesen, die bei der Installation des minikube unter ~./minikube abgelegt wurden.

Meine Lösung war nun folgende:

In der VM, die kubectl enthält:
$ mkdir ~/.kube
$ mkdir ~/.minikube

vom Host des minikube aus
$ scp ~/.kube/* user@remoteVm:/home/user/.kube/
$ scp ~/.minikube/* user@remoteVm:/home/user/.minikube/

In der VM:
$ sed -i 's/user_host/user_vm/g' ~/.kube/config

danach sollte ein
$kubectl cluster-info

ein Ergebnis zeigen

Der Host, wie auch die VM laufen mit Xubuntu 18.04

Update 2019-04-03

Möchte man auch mit Docker arbeiten, sollte der verwendete System-User noch der Gruppe "docker" hinzugefügt werden:
$ usermod -aG docker <user>