Install NodeJS and MongoDB on CentOS 7

As always, I’m sharing my personal notes here. I’ve used virtual machines for development since the first version of VMware. I’ve been using DigitalOcean’s services for some time. I generally use their CentOS 7 install.

NodeJS

The NodeJS site presents us with a set of choices.

OptionsI’m generally using the version 6 line. Click on Other Downloads to get a list of current versions. At the bottom, there is a link that says, Installing Node.js via package manager. There is a link that says, Enterprise Linux and Fedora.

It gives the following setup line which installs the relevant repo files:

 
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

At this point installing NodeJS is a simple:

yum -y install nodejs

Some native add-ons from

npm

require build tools. If you anticipate needing those, install:

yum -y install gcc-c++ make

MongoDB

Installing MongoDB’s community edition requires creating a yum repo file, a a system configuration file, and then a reboot.

vim /etc/yum.repos.d/mongodb-org-3.2.repo

and fill it with the following text:

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

which allows MongoDB to be installed with a simple:

yum install -y mongodb-org
service mongod start
chkconfig mongod on

Getting Rid of Warnings

If you use the mongo client, you’ll notice the following warnings:

Server has startup warnings:
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]

The soft rlimits warning can be fixed by creating a file:

 vim /etc/security/limits.d/90-nproc.conf

and putting the following line in it:

mongod     soft    nproc     64000

and rebooting the system.

The transparent_hugepage warnings can be fixed by creating a file:

vim /etc/init.d/disable-transparent-hugepages

and filling it with:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    re='^[0-1]+$'
    if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]]
    then
      # RHEL 7
      echo 0  > ${thp_path}/khugepaged/defrag
    else
      # RHEL 6
      echo 'no' > ${thp_path}/khugepaged/defrag
    fi

    unset re
    unset thp_path
    ;;
esac

ensuring it runs at startup:

chmod 755 /etc/init.d/disable-transparent-hugepages
chkconfig --add disable-transparent-hugepages

and then, finally, rebooting. The mongo client should start without warnings now:

 
MongoDB shell version: 3.2.9
connecting to: test
>

 

 

Posted in SysAdmin | Tagged , , , , , , , | Leave a comment

Notes on Signing Keys for PhoneGap Build

As always, this site contains notes to myself which others may (or may not) find useful. They may contain errors. Corrections and clarification is gratefully accepted. I apologize that these notes are somewhat abbreviated.

Android

The instructions on the Adobe PhoneGap Build web site don’t properly display on all platforms. The core information is as follows.

Google uses the Java keytool program, which creates a database of cryptographic keys & certificates. If you have Java installed, keytool should be available. The example command is as follows:

$ keytool -genkey -v -keystore [keystore<em>name].keystore -alias [alias</em>name] -keyalg RSA -keysize 2048 -validity 10000

iOS

iOS is more complicated. This requires access to an Apple machine running OS X.

The first step  is to ensure that your Keychain Access program has the latest root certificate. As of this writing (16 June 2016) it is AddTrust External CA Root with an expiration date of 30 May 2020 at 4:48:38 a.m. (I solved this with a web search.)

Create a Distribution Certificate

Next, log into your developer.apple.com account. From the top menu, go to your Account. On the left-hand vertical bar, select Certificates, IDs & Profiles. Create an iOS certificate with the type iOS Distribution.

Create a .p12 File

Download the certificate and load it into Keychain Access. (The certificate should have a submenu showing your private key. If it is not there, you can’t export it as a .p12 file.) Right click on the certificate and export it as a .p12 file.

Load Devices for “Ad Hoc” Testing

To bypass the Apple gatekeepers for testing, you need to specify the unique device IDs (UDID) for every iOS device that the app is allowed to run on. Those are listed under Devices on the left-hand side.

Create a Provisioning File

If you want to bypass the Apple gatekeepers for testing, you need to create a new iOS provisioning file with the type Ad Hoc under the Distribution heading. This will allow to choose the certificate, application ID, and the UDIDs to enable for testing.

If you’re to the point where you want to submit your app through the Apple store, create a provisioning file with the type App Store under the Distribution heading. You will not be given the choice of selecting specific UDIDs this turn.

Loading Keys in the PhoneGap Build Site

Lastly, log into the Adobe PhoneGap Build site and go to Edit Account. The second tab is Signing Keys. Under the appropriate OS, hit the add a key … button and upload your keystore (in the case of Android) or .p12 and provisioning files (in the case of iOS).

These keys should be ready to use for building your app.

 

Posted in Programming | Tagged , , , , , | Leave a comment

Installing a PhoneGap App On an iOS Device Using iTunes

Preliminary Steps

To produce an iOS build using the PhoneGap Build web site, one must have created a signing certificate and provisioning list for the devices that the app is allowed to run on. These notes assume that this has been done, and there is a successful build on the PhoneGap Build web site.

Loading into iTunes

The first step, and the first potential roadblock, is loading the app into iTunes.

  1. Plug in the iOS device into the computer and select the device.
  2. Download the .ipa file from the PhoneGap Build site.
  3. Drag and drop the .ipa file onto iTune.

This is where the first “gotcha” may turn up. The .ipa file does not have Apple’s blessing. By default OS X will refuse to load any un-blessed apps.

skitch

This can, however be changed in the Security preferences.

skitch

Use the lock symbol to allow for changes to the security settings, then choose “Anywhere” in the “Allow apps downloaded from:” section.

skitch

OS X will give a final warning about the dangers of doing this, and that the setting will revert to after a certain amount of time.

skitch

 

Now the app should show up in the list of apps to load onto the iOS device, and will be loaded when you sync the device.

Hydration Hanging

Hydration is a wonderful development tool that will automatically fetch the latest version of the app from the PhoneGap Build web site. (It must be removed before submitting the app to Apple for review.) However, when one starts the app,  it will sometimes hang.

To kill the hung app, the Apple support web site has an excellent tip.

Posted in Computer, Mac | Tagged , , , , , , | Leave a comment

CentOS 7 Firewall Configuration

CentOS 7 uses firewalld for its default firewall. DigitalOcean has a nice overview on the basics of firewalld here.

 

Posted in SysAdmin | Tagged , , , , | Leave a comment

Korad KA3005P Serial Programming

korad-ka3005pThis is a cheap lab bench power supply that given its flaws is a surprisingly solid piece of equipment. I wouldn’t call this a precision power supply, but its tolerances and ripple are acceptable for ordinary bench work. (And really, if you’re doing precision work, you’ll invest in a precision supply anyhow.)

There are two methods for communicating with the unit: a serial interface and a proprietary binary USB interface. One may use either the DB-9 connector or USB to access the serial interface.

I wrote a Python wrapper for the serial protocol to encapsulate the various tidbits  of information I’ve encountered on the  Internet. The firmware is buggy and there are various gotchas. Hopefully the Python wrapper will address the worst of the problems one might encounter.

Posted in Micro & Hardware, Programming | Tagged , , , , | 1 Comment

CSS Specificity Overview

Chris Coyier has a nice overview of CSS specificity,  or why my CSS doesn’t override their CSS.

Posted in Programming | Leave a comment

Git Cheat Sheet

An acquaintance sent this to me last year and I thought the link might be useful to others before I deleted the old e-mails.

Git Cheat Sheet by Tower

I haven’t looked at Tower’s GUI since their version 1 beta so I can’t comment on their product. However git is git and that makes the cheat sheet useful.

(I settled into using SourceTree for my daily work a while ago.)

 

Posted in Programming | Leave a comment