{"id":1799,"date":"2018-02-06T18:16:53","date_gmt":"2018-02-06T18:16:53","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=1799"},"modified":"2018-02-06T18:26:22","modified_gmt":"2018-02-06T18:26:22","slug":"recovering-librenms-from-crashed-xenserver-vm","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/recovering-librenms-from-crashed-xenserver-vm\/","title":{"rendered":"Recovering LibreNMS from crashed XenServer VM"},"content":{"rendered":"<p>Had a LibreNMS instance crash, or the VM crashed, not bootable anymore.\u00a0 Was able to boot it up on a CentOS iso with rescue mode, which gave me access to the files.\u00a0 So the idea is to manually copy off the LibreNMS files and LibreNMS database and import them to a new LibreNMS instance<\/p>\n<p>Issues<\/p>\n<ul>\n<li>Need to access the the system files<\/li>\n<li>MySQL doesn&#8217;t start in a chroot environment, so no way to do a mysqldump &#8212;\u00a0 (Has to do with systemv or something)<\/li>\n<\/ul>\n<p><strong>Steps<\/strong><\/p>\n<ol>\n<li>Create new LibreNMS VM with a new instance of LibreNMS installed<\/li>\n<li>Gain access to the crashed system<\/li>\n<li>Copy over LibreNMS MySQL databases to new LibreNMS instance<\/li>\n<li>Copy over LibreNMS files &#8220;\/opt\/librenms&#8221; to new LibreNMS instance<\/li>\n<li>Clean up.\u00a0 Set users on directories, check SELinux etc.<\/li>\n<\/ol>\n<h1>1. Installing New LibreNMS VM<\/h1>\n<ul>\n<li>Guide for Ubuntu\/Debian distro&#8217;s <a href=\"http:\/\/www.incredigeek.com\/home\/install-librenms-on-ubuntu-with-https\/\">here<\/a><\/li>\n<li>Guide for for Fedora\/CentOS\/RedHat <a href=\"http:\/\/www.incredigeek.com\/home\/install-librenms-on-centos\/\">here<\/a><\/li>\n<\/ul>\n<h1>2. Gaining access to crashed VM<\/h1>\n<p>There can be a couple of ways to gain access to a crashed XenServer VM.\u00a0 One of the easiest ways is to boot up in recovery mode and go through the installers rescue mode.\u00a0 Guide to boot up XenServer VM in recovery mode <a href=\"http:\/\/www.incredigeek.com\/home\/how-to-boot-a-xenserver-vm-into-recovery-mode\/\">here<\/a>.<\/p>\n<p>The installer rescue mode should detect the OS and mount everything.\u00a0 If not you should be able to mount the root partition manually.<\/p>\n<p>Once booted up, you&#8217;ll need to enable network access if your going to use sftp or scp to copy files.\u00a0 There are a few different ways to do this<\/p>\n<ul>\n<li>Run &#8220;dhclient&#8221; to pull an address via DHCP<\/li>\n<li>Set a static IP address\n<ul>\n<li>Guide for Ubuntu\/Debian distro&#8217;s <a href=\"http:\/\/www.incredigeek.com\/home\/how-to-set-a-static-ip-address-in-ubuntu-and-debian\/\">here<\/a><\/li>\n<li>Guide for fedora\/CentOS\/RedHat <a href=\"http:\/\/www.incredigeek.com\/home\/how-to-set-a-static-ip-address-on-centos-fedora-or-red-hat-linux\/\">here<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>3.Copy LibreNMS Mysql Database<br \/>\n<\/strong><\/p>\n<p>Backup the LibreNMS MySQL database directory<\/p>\n<pre>tar czvf librenms_mysql.tgz \/var\/lib\/mysql<\/pre>\n<p>Use scp or sftp to copy it to the new LibreNMS instance<\/p>\n<pre>scp librenms_mysql.tgz user@new_LibreNMS_ip<\/pre>\n<p>Now on the new LibreNMS instance we need to run the following few commands<\/p>\n<pre>systemctl stop mariadb\r\nrm -rf \/var\/lib\/mysql\/*\r\ntar xzvf librenms_mysql.tgz -C \/\r\nchown -R mysql:mysql \/var\/lib\/mysql<\/pre>\n<p><strong>4. Copy LibreNMS directory <\/strong><\/p>\n<p>Backup the LibreNMS directory<\/p>\n<pre>tar czvf librenms.tgz \/opt\/librenms<\/pre>\n<p>Use scp or sftp to copy it to the new LibreNMS instance<\/p>\n<pre>scp librenms.tgz user@new_LibreNMS_ip<\/pre>\n<p>Now on the new LibreNMS instance we need to run the following few commands<\/p>\n<pre>rm -rf \/opt\/librenms\/*\r\ntar xzvf librenms.tgz -C \/\r\nchown -R librenms:librenms \/opt\/librenms<\/pre>\n<p><strong>5. Clean up<\/strong><\/p>\n<p>Disable SELinux if you have not already.\u00a0 Guide <a href=\"http:\/\/www.incredigeek.com\/home\/how-to-enabledisable-selinux\/\">here<\/a><\/p>\n<p>Restart apache, and start mysql.\u00a0 If your on Ubuntu, the services are named apache2 and mysql<\/p>\n<pre>systemctl restart httpd\r\nsystemctl restart mariadb<\/pre>\n<p>That should get it working, if not try a reboot.<\/p>\n<p><strong>Special notes<\/strong><\/p>\n<p>The whole MySQL directory needs to be copied, there are innodb files that will keep MySQL from starting if they are not copied.<\/p>\n<p>There is some good info here<br \/>\n<a href=\"https:\/\/stackoverflow.com\/questions\/1795176\/how-to-change-mysql-data-directory\"> https:\/\/stackoverflow.com\/questions\/1795176\/how-to-change-mysql-data-directory<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Had a LibreNMS instance crash, or the VM crashed, not bootable anymore.\u00a0 Was able to boot it up on a CentOS iso with rescue mode, which gave me access to the files.\u00a0 So the idea is to manually copy off &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/recovering-librenms-from-crashed-xenserver-vm\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,4,264,24,352,3,135,22,28],"tags":[353,7,136,389,275],"class_list":["post-1799","post","type-post","status-publish","format-standard","hentry","category-centos-linux","category-command-line","category-debian","category-fedora-2","category-librenms","category-linux","category-mysql","category-redhat-linux","category-ubuntu","tag-librenms","tag-linux-2","tag-mysql-2","tag-nms","tag-xenserver"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/1799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=1799"}],"version-history":[{"count":18,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/1799\/revisions"}],"predecessor-version":[{"id":1845,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/1799\/revisions\/1845"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=1799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=1799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=1799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}