{"id":1859,"date":"2017-11-10T11:11:28","date_gmt":"2017-11-10T16:11:28","guid":{"rendered":"http:\/\/lisa.rushworth.us\/?p=1859"},"modified":"2017-11-10T11:36:15","modified_gmt":"2017-11-10T16:36:15","slug":"openhab-cloud-connector-prerequisites","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=1859","title":{"rendered":"OpenHAB Cloud Installation Prerequisites"},"content":{"rendered":"<p>We started setting up the OpenHAB cloud server locally, and the instructions we had found omitted a few important steps. They say &#8216;install redis&#8217; and &#8216;install mongodb&#8217; without providing any sort of post-install configuration.<\/p>\n<p><strong>Redis<\/strong><br \/>\n# This is optional &#8211; if you don&#8217;t set a password, you&#8217;ll just get a warning on launch that a password was supplied but none is required. While the service is, by default, bound to localhost &#8230; I still put a password on everything just to be safe<\/p>\n<pre>vi \/etc\/redis.conf # Your path may vary, this is Fedora. I've seen \/etc\/redis\/redis.conf too<\/pre>\n<p># Find the requirepass line and make one with your password<\/p>\n<pre>480 # requirepass foobared\r\nrequirepass Y0|_|RP@s5w0rdG03s|-|3re<\/pre>\n<p># Restart redis<\/p>\n<pre>service redis restart<\/pre>\n<p>Mongo:<br \/>\n# Install mongo (dnf install mongo mongo-server)<br \/>\n# start mongodb<\/p>\n<pre>service mongod start<\/pre>\n<p># launch mongo client<\/p>\n<pre>mongo<\/pre>\n<p># Create user in admin database<\/p>\n<pre>db.createUser({user: \"yourDBUser\", pwd: \"yourDBUserPassword\", roles: [{role: userAdminAnyDatabase\", db: \"admin\"}]});\r\nexit<\/pre>\n<p># Modify mongodb server config to use security<\/p>\n<pre>vi \/etc\/mongod.conf<\/pre>\n<p># remove remarkes before &#8216;security: &#8216; and &#8216;authorization&#8217; &#8211; set authorization to enabled:<\/p>\n<pre>99 # secutiry Options - Authorization and other security settings\r\n100 security:\r\n101 # Private key for cluster authentication\r\n102 #keyFile: &lt;string&gt;\r\n103\r\n104 # Run with\/without security (enabled|disabled, disabled by default)\r\n105 authorization: enabled\r\n<\/pre>\n<p># restart mongo<\/p>\n<pre>service mongod restart<\/pre>\n<p>#Launch mongo client supplying username and connecting to the admin database<\/p>\n<pre>mongo -uyourDBUser -p admin<\/pre>\n<p># it will connect and prompt for password &#8211; you can use db.getUser to verify the account (but you just logged into it, so that&#8217;s a bit redundant)<\/p>\n<pre>MongoDB shell version: 3.2.12\r\nEnter password:\r\nconnecting to: admin\r\n&gt; &gt; db.getUser(\"yourDBUser\");\r\n{\r\n        \"_id\" : \"admin.yourDBUser\",\r\n        \"user\" : \"yourDBUser\",\r\n        \"db\" : \"admin\",\r\n        \"roles\" : [\r\n                {\r\n                        \"role\" : \"userAdminAnyDatabase\",\r\n                        \"db\" : \"admin\"\r\n                }\r\n        ]\r\n}<\/pre>\n<p># Create the openhab database &#8212; mongo is a bit odd in that &#8220;use dbname&#8221; will switch context to that database if it exists *and* create the databse if it doesn&#8217;t exist. Bad for typo-prone types!<\/p>\n<pre>use yourDBName;<\/pre>\n<p># Create the user in the openhab database<\/p>\n<pre>db.createUser({user: \"yourDBUser\", pwd: \"yourDBUserPassword\", roles: [{role: readWrite\", db: \"yourDBName\"}]});<\/pre>\n<p># You can use get user to verify it works<\/p>\n<pre>db.getUser(\"yourDBUser\");\r\nexit<\/pre>\n<p># Now you can launch the mongo client connecting to the openhab database:<\/p>\n<pre>mongo -uyourDBUser -p yourDBName<\/pre>\n<p># It will prompt for password and connect. At this point, you can use &#8220;node app.js&#8221; to launch the openhab cloud connector. Provided yourDBUser, yourDBUserPassword, and yourDBName match what you&#8217;ve used in the config file &#8230; it&#8217;ll connect and create a bunch of stuff<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We started setting up the OpenHAB cloud server locally, and the instructions we had found omitted a few important steps. They say &#8216;install redis&#8217; and &#8216;install mongodb&#8217; without providing any sort of post-install configuration. Redis # This is optional &#8211; if you don&#8217;t set a password, you&#8217;ll just get a warning on launch that a &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63],"tags":[430,428,429,44,426,427],"class_list":["post-1859","post","type-post","status-publish","format-standard","hentry","category-home-automation","tag-mongo","tag-mongod","tag-mongodb","tag-openhab","tag-openhab-cloud","tag-redis"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/1859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1859"}],"version-history":[{"count":2,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/1859\/revisions"}],"predecessor-version":[{"id":1861,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/1859\/revisions\/1861"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}