{"id":183,"date":"2017-03-28T09:37:35","date_gmt":"2017-03-28T07:37:35","guid":{"rendered":"http:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/?p=183"},"modified":"2017-03-30T08:19:00","modified_gmt":"2017-03-30T06:19:00","slug":"icinga2-incl-icingaweb2-und-icinga-director-umziehen-auf-andere-hardware","status":"publish","type":"post","link":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/2017\/03\/28\/icinga2-incl-icingaweb2-und-icinga-director-umziehen-auf-andere-hardware\/","title":{"rendered":"Icinga2 incl. Icingaweb2 und Icinga Director Klonen"},"content":{"rendered":"<p>Notizen zu dem Szenario:<\/p>\n<p>Ich m\u00f6chte mir Arbeit ersparen und Klone eine bestehende Icinga2 Installation um diese auf einem anderen Rechner einzusetzen. Nach dem Umzug muss nat\u00fcrlich einiges angepasst werden (neue Certs, Datenbank leeren usw.) damit ich eine neue Ausgangsbasis erhalte.<\/p>\n<p>An dieser Stelle stehen die Schritte die notwendig sind \/ waren (vermutlich im Detail unvollst\u00e4ndig):<\/p>\n<p>Nach dem Klonen, welches ich bevorzugt mit einem auf einem PXE Server installierten Clonezilla vornehme, erhalte ich ein identisches System, wie das Quellsystem.<\/p>\n<p>Als allererstes ist es sinnvoll vor weiteren \u00c4nderungen die Director &#8211; Datenbank zu leeren. Am besten soweit installiert mittels phpmyadmin.\u00a0 Man kann freilich auch die Objekte einzeln aus dem Director l\u00f6schen, was aber schnell relativ aufw\u00e4ndig ist.<\/p>\n<p>&nbsp;<\/p>\n<p>Nach dem ersten Start am besten erst mal den icinga2 Prozess anhalten mittels\u00a0systemctl stop icinga2.service (bei systemd basierten Distributionen, alternativ \/etc\/init.d\/icinga2 stop ).<\/p>\n<p>Zu \u00e4ndern sind hier erst mal prim\u00e4r:<\/p>\n<ul>\n<li>Hostnamen (vor allem wichtig auch f\u00fcr die Anpassung der Icinga Certs)<\/li>\n<li>IP &#8211; Adresse<\/li>\n<li>ggf. Anpassung der \/etc\/hosts und \/etc\/resolv.conf<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Anpassung der Icinga2 Einstellungen:<\/p>\n<p><a href=\"https:\/\/dokuwiki.nausch.org\/doku.php\/centos:web_c7:icinga:director\" target=\"_blank\">https:\/\/dokuwiki.nausch.org\/doku.php\/centos:web_c7:icinga:director<\/a><\/p>\n<p><a href=\"https:\/\/dokuwiki.tachtler.net\/doku.php?id=tachtler:icinga2_-_director\" target=\"_blank\">https:\/\/dokuwiki.tachtler.net\/doku.php?id=tachtler:icinga2_-_director<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"icinga_stoppen\" class=\"sectionedit6\">Icinga stoppen<\/h3>\n<div class=\"level3\">\n<p>Nachfolgender Befehl stoppt den <a class=\"urlextern\" title=\"https:\/\/www.icinga.org\/\" href=\"https:\/\/www.icinga.org\/\" target=\"_blank\" rel=\"nofollow noopener\">Icinga<\/a>-Dienst\/Daemon:<\/p>\n<pre class=\"code\"> # systemctl stop icinga2.service<\/pre>\n<\/div>\n<h3 id=\"datenloeschung\" class=\"sectionedit7\">Datenl\u00f6schung<\/h3>\n<div class=\"level3\">\n<p>Anschlie\u00dfend sollen nachfolgende Verzeichisse mit nachfolgenden Befehlen geleert werden:<\/p>\n<pre class=\"code\"> # rm \/var\/lib\/icinga2\/* -f\r\n # rm \/var\/lib\/icinga2\/api\/zones\/* -rf\r\n # rm \/var\/lib\/icinga2\/api\/repository\/* -f\r\n # rm \/var\/lib\/icinga2\/api\/packages\/* -rf\r\n # rm \/var\/lib\/icinga2\/api\/log\/* -f\r\n # rm \/var\/lib\/icinga2\/repository\/* -f\r\n # rm \/var\/lib\/icinga2\/ca\/* -f<\/pre>\n<p>und<\/p>\n<pre class=\"code\"># rm \/var\/cache\/icinga2\/* -f<\/pre>\n<p>und entfernen die bereits erzeugten <strong>Zertifikate<\/strong>:<\/p>\n<pre class=\"code\"># rm \/etc\/icinga2\/pki\/* -f<\/pre>\n<\/div>\n<h3 id=\"konfigurationssicherung\" class=\"sectionedit8\">Konfigurationssicherung<\/h3>\n<div class=\"level3\">\n<p>Mit nachfolgenden Befehl kann die bisher durchgef\u00fchrte Konfiguration gesichert werden:<\/p>\n<pre class=\"code\"># tar czfv icinga2-config-backup.tar.gz \/etc\/icinga2 -C \/root\r\n...<\/pre>\n<\/div>\n<h3 id=\"etc_icinga2_zonesconf\" class=\"sectionedit9\">\/etc\/icinga2\/zones.conf<\/h3>\n<div class=\"level3\">\n<p>Nachfolgender Inhalt solltein der Konfigurationsdatei <code>\/etc\/icinga2\/zones.conf<\/code> stehen, falls nicht kann dieser auf nachfolgenden Inhalt zur\u00fcckgesetzt werden:<\/p>\n<pre class=\"code bash\"><span class=\"sy0\">\/*<\/span>\r\n <span class=\"sy0\">*<\/span> Endpoint and Zone configuration <span class=\"kw1\">for<\/span> a cluster setup\r\n <span class=\"sy0\">*<\/span> This <span class=\"kw3\">local<\/span> example requires <span class=\"sy0\">`<\/span>NodeName<span class=\"sy0\">`<\/span> defined <span class=\"kw1\">in<\/span>\r\n <span class=\"sy0\">*<\/span> constants.conf.\r\n <span class=\"sy0\">*\/<\/span>\r\n\u00a0\r\nobject Endpoint NodeName <span class=\"br0\">{<\/span>\r\n  host = NodeName\r\n<span class=\"br0\">}<\/span>\r\n\u00a0\r\nobject Zone ZoneName <span class=\"br0\">{<\/span>\r\n  endpoints = <span class=\"br0\">[<\/span> NodeName <span class=\"br0\">]<\/span>\r\n<span class=\"br0\">}<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span>\r\n <span class=\"sy0\">*<\/span> Defines a global zone containing templates,\r\n <span class=\"sy0\">*<\/span> etc. synced to all nodes, <span class=\"kw1\">if<\/span> they accept\r\n <span class=\"sy0\">*<\/span> configuration. All remote nodes need\r\n <span class=\"sy0\">*<\/span> this zone configured too.\r\n <span class=\"sy0\">*\/<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span>\r\nobject Zone <span class=\"st0\">\"global-templates\"<\/span> <span class=\"br0\">{<\/span>\r\n  global = <span class=\"kw2\">true<\/span>\r\n<span class=\"br0\">}<\/span>\r\n<span class=\"sy0\">*\/<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span>\r\n <span class=\"sy0\">*<\/span> Read the documentation on how to configure\r\n <span class=\"sy0\">*<\/span> a cluster setup with multiple zones.\r\n <span class=\"sy0\">*\/<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span>\r\nobject Endpoint <span class=\"st0\">\"master.example.org\"<\/span> <span class=\"br0\">{<\/span>\r\n  host = <span class=\"st0\">\"master.example.org\"<\/span>\r\n<span class=\"br0\">}<\/span>\r\n\u00a0\r\nobject Endpoint <span class=\"st0\">\"satellite.example.org\"<\/span> <span class=\"br0\">{<\/span>\r\n  host = <span class=\"st0\">\"satellite.example.org\"<\/span>\r\n<span class=\"br0\">}<\/span>\r\n\u00a0\r\nobject Zone <span class=\"st0\">\"master\"<\/span> <span class=\"br0\">{<\/span>\r\n  endpoints = <span class=\"br0\">[<\/span> <span class=\"st0\">\"master.example.org\"<\/span> <span class=\"br0\">]<\/span>\r\n<span class=\"br0\">}<\/span>\r\n\u00a0\r\nobject Zone <span class=\"st0\">\"satellite\"<\/span> <span class=\"br0\">{<\/span>\r\n  parent = <span class=\"st0\">\"master\"<\/span>\r\n  endpoints = <span class=\"br0\">[<\/span> <span class=\"st0\">\"satellite.example.org\"<\/span> <span class=\"br0\">]<\/span>\r\n<span class=\"br0\">}<\/span>\r\n<span class=\"sy0\">*\/<\/span><\/pre>\n<\/div>\n<h3 id=\"etc_icinga2_constantsconf\" class=\"sectionedit10\">\/etc\/icinga2\/constants.conf<\/h3>\n<div class=\"level3\">\n<p>Nachfolgender Inhalt solltein der Konfigurationsdatei <code>\/etc\/icinga2\/constants.conf<\/code> stehen, falls nicht kann dieser auf nachfolgenden Inhalt zur\u00fcckgesetzt werden:<\/p>\n<pre class=\"code bash\"><span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> This <span class=\"kw2\">file<\/span> defines global constants <span class=\"kw2\">which<\/span> can be used <span class=\"kw1\">in<\/span>\r\n <span class=\"sy0\">*<\/span> the other configuration files.\r\n <span class=\"sy0\">*\/<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span> The directory <span class=\"kw2\">which<\/span> contains the plugins from the Monitoring Plugins project. <span class=\"sy0\">*\/<\/span>\r\nconst PluginDir = <span class=\"st0\">\"\/usr\/lib64\/nagios\/plugins\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span> The directory <span class=\"kw2\">which<\/span> contains the Manubulon plugins.\r\n <span class=\"sy0\">*<\/span> Check the documentation, chapter <span class=\"st0\">\"SNMP Manubulon Plugin Check Commands\"<\/span>, <span class=\"kw1\">for<\/span> details.\r\n <span class=\"sy0\">*\/<\/span>\r\nconst ManubulonPluginDir = <span class=\"st0\">\"\/usr\/lib64\/nagios\/plugins\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span> The directory <span class=\"kw2\">which<\/span> you use to store additional plugins <span class=\"kw2\">which<\/span> ITL provides user contributed <span class=\"kw3\">command<\/span> definitions for.\r\n <span class=\"sy0\">*<\/span> Check the documentation, chapter <span class=\"st0\">\"Plugins Contribution\"<\/span>, <span class=\"kw1\">for<\/span> details.\r\n <span class=\"sy0\">*\/<\/span>\r\nconst PluginContribDir = <span class=\"st0\">\"\/usr\/lib64\/nagios\/plugins\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/*<\/span> Our <span class=\"kw3\">local<\/span> instance name. By default this is the server<span class=\"st_h\">'s hostname as returned by `hostname --fqdn`.\r\n * This should be the common name from the API certificate.\r\n *\/\r\n\/\/const NodeName = \"localhost\"\r\n\u00a0\r\n\/* Our local zone name. *\/\r\nconst ZoneName = NodeName\r\n\u00a0\r\n\/* Secret key for remote node tickets *\/\r\nconst TicketSalt = \"\"<\/span><\/pre>\n<\/div>\n<h3 id=\"etc_icinga2_icinga2conf\" class=\"sectionedit11\">\/etc\/icinga2\/icinga2.conf<\/h3>\n<div class=\"level3\">\n<p>Nachfolgender Inhalt solltein der Konfigurationsdatei <code>\/etc\/icinga2\/icinga2.conf<\/code> stehen, falls nicht kann dieser auf nachfolgenden Inhalt zur\u00fcckgesetzt werden:<\/p>\n<pre class=\"code bash\"><span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> Icinga <span class=\"nu0\">2<\/span> configuration <span class=\"kw2\">file<\/span>\r\n <span class=\"sy0\">*<\/span> - this is where you define settings <span class=\"kw1\">for<\/span> the Icinga application including\r\n <span class=\"sy0\">*<\/span> <span class=\"kw2\">which<\/span> hosts<span class=\"sy0\">\/<\/span>services to check.\r\n <span class=\"sy0\">*<\/span>\r\n <span class=\"sy0\">*<\/span> For an overview of all available configuration options please refer\r\n <span class=\"sy0\">*<\/span> to the documentation that is distributed <span class=\"kw2\">as<\/span> part of Icinga <span class=\"nu0\">2<\/span>.\r\n <span class=\"sy0\">*\/<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> The constants.conf defines global constants.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude <span class=\"st0\">\"constants.conf\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> The zones.conf defines zones <span class=\"kw1\">for<\/span> a cluster setup.\r\n <span class=\"sy0\">*<\/span> Not required <span class=\"kw1\">for<\/span> single instance setups.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude <span class=\"st0\">\"zones.conf\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> The Icinga Template Library <span class=\"br0\">(<\/span>ITL<span class=\"br0\">)<\/span> provides a number of useful templates\r\n <span class=\"sy0\">*<\/span> and <span class=\"kw3\">command<\/span> definitions.\r\n <span class=\"sy0\">*<\/span> Common monitoring plugin <span class=\"kw3\">command<\/span> definitions are included separately.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude <span class=\"sy0\">&lt;<\/span>itl<span class=\"sy0\">&gt;<\/span>\r\ninclude <span class=\"sy0\">&lt;<\/span>plugins<span class=\"sy0\">&gt;<\/span>\r\ninclude <span class=\"sy0\">&lt;<\/span>plugins-contrib<span class=\"sy0\">&gt;<\/span>\r\ninclude <span class=\"sy0\">&lt;<\/span>manubulon<span class=\"sy0\">&gt;<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> This includes the Icinga <span class=\"nu0\">2<\/span> Windows plugins. These <span class=\"kw3\">command<\/span> definitions\r\n <span class=\"sy0\">*<\/span> are required on a master node when a client is used <span class=\"kw2\">as<\/span> <span class=\"kw3\">command<\/span> endpoint.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude <span class=\"sy0\">&lt;<\/span>windows-plugins<span class=\"sy0\">&gt;<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> This includes the NSClient++ check commands. These <span class=\"kw3\">command<\/span> definitions\r\n <span class=\"sy0\">*<\/span> are required on a master node when a client is used <span class=\"kw2\">as<\/span> <span class=\"kw3\">command<\/span> endpoint.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude <span class=\"sy0\">&lt;<\/span>nscp<span class=\"sy0\">&gt;<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> The features-available directory contains a number of configuration\r\n <span class=\"sy0\">*<\/span> files <span class=\"kw1\">for<\/span> features <span class=\"kw2\">which<\/span> can be enabled and disabled using the\r\n <span class=\"sy0\">*<\/span> icinga2 feature <span class=\"kw3\">enable<\/span> <span class=\"sy0\">\/<\/span> icinga2 feature disable CLI commands.\r\n <span class=\"sy0\">*<\/span> These commands work by creating and removing symbolic links <span class=\"kw1\">in<\/span>\r\n <span class=\"sy0\">*<\/span> the features-enabled directory.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude <span class=\"st0\">\"features-enabled\/*.conf\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> The repository.d directory contains all configuration objects\r\n <span class=\"sy0\">*<\/span> managed by the <span class=\"st_h\">'icinga2 repository'<\/span> CLI commands.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude_recursive <span class=\"st0\">\"repository.d\"<\/span>\r\n\u00a0\r\n<span class=\"sy0\">\/**<\/span>\r\n <span class=\"sy0\">*<\/span> Although <span class=\"kw1\">in<\/span> theory you could define all your objects <span class=\"kw1\">in<\/span> this <span class=\"kw2\">file<\/span>\r\n <span class=\"sy0\">*<\/span> the preferred way is to create separate directories and files <span class=\"kw1\">in<\/span> the conf.d\r\n <span class=\"sy0\">*<\/span> directory. Each of these files must have the <span class=\"kw2\">file<\/span> extension <span class=\"st0\">\".conf\"<\/span>.\r\n <span class=\"sy0\">*\/<\/span>\r\ninclude_recursive <span class=\"st0\">\"conf.d\"<\/span><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Danach am besten den Director als Modul deaktivieren und entfernen sowie physisch l\u00f6schen. In der Datenbank das Schema samt Inhalten l\u00f6schen (am einfachsten mit phpmyadmin).<\/p>\n<p>Danach mittels git die aktuelleste Version klonen &#8230;<\/p>\n<p>\/usr\/share\/icingaweb2\/modules# git clone https:\/\/github.com\/Icinga\/icingaweb2-module-director.git director<\/p>\n<p>Sowie danach vorgehen wie bei einer Erst\/Neu\u00a0 Installation (DB-Schema erstellen lassen).<\/p>\n<p>Es kann sein, das danach noch Deploys angezeigt werden &#8211;&gt; Ausf\u00fchren lassen. In meinem Fall lief das ohne Fehler durch, es wurde ein Host (localhost) neu erzeugt und angezeigt.<\/p>\n<p>Danach sollte nur der Monitoring Server selbst angezeigt werden.<\/p>\n<p>&nbsp;<\/p>\n<p>weitere Links:<\/p>\n<p>Graphite\/Grafana Konfiguration:<\/p>\n<p>https:\/\/www.linuxfrickeln.de\/visualisierung-von-performancedaten-in-der-icingaweb2-gui\/<\/p>\n<p>https:\/\/dokuwiki.nausch.org\/doku.php\/centos:web_c7:icinga:graphite<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&#8230;..to be continued<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Notizen zu dem Szenario: Ich m\u00f6chte mir Arbeit ersparen und Klone eine bestehende Icinga2 Installation um diese auf einem anderen Rechner einzusetzen. Nach dem Umzug muss nat\u00fcrlich einiges angepasst werden (neue Certs, Datenbank leeren usw.) damit ich eine neue Ausgangsbasis erhalte. An dieser Stelle stehen die Schritte die notwendig sind \/ waren (vermutlich im Detail unvollst\u00e4ndig): Nach dem Klonen, welches ich bevorzugt mit einem auf einem PXE Server installierten Clonezilla vornehme, erhalte ich ein identisches System, wie das Quellsystem. Als allererstes ist es sinnvoll vor weiteren \u00c4nderungen die Director &#8211; Datenbank zu leeren. Am besten soweit installiert mittels phpmyadmin.\u00a0 Man kann freilich auch die Objekte einzeln aus dem Director l\u00f6schen, was aber schnell relativ aufw\u00e4ndig ist. &nbsp; Nach dem ersten Start am besten erst mal den icinga2 Prozess anhalten mittels\u00a0systemctl stop icinga2.service (bei systemd basierten Distributionen, alternativ \/etc\/init.d\/icinga2 stop ). Zu \u00e4ndern sind hier erst mal prim\u00e4r: Hostnamen (vor allem wichtig auch f\u00fcr die Anpassung der Icinga Certs) IP &#8211; Adresse ggf. Anpassung der \/etc\/hosts und \/etc\/resolv.conf &nbsp; &nbsp; Anpassung der Icinga2 Einstellungen: https:\/\/dokuwiki.nausch.org\/doku.php\/centos:web_c7:icinga:director https:\/\/dokuwiki.tachtler.net\/doku.php?id=tachtler:icinga2_-_director &nbsp; Icinga stoppen Nachfolgender Befehl stoppt den Icinga-Dienst\/Daemon: # systemctl stop icinga2.service Datenl\u00f6schung Anschlie\u00dfend sollen nachfolgende Verzeichisse mit nachfolgenden Befehlen geleert werden: # rm \/var\/lib\/icinga2\/* [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":16,"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/posts\/183\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datenwerkstatt.bayern\/datenwerkstatt-bayern\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}