Sunday 9 October 2016

Node: Installation and Upgrade

Node is installed using nvm and nodejs packages are install using npm.

Initial Installation

1.  Install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
2. Install node version 4
nvm install 4

Upgrade NVM and Node version

1. Upgrade nvm using
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
 
creationix/nvm/v0.32.0/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10007  100 10007    0     0   5040      0  0:00:01  0:00:01 --:--:--  5038
=> nvm is already installed in /Users/Seet/.nvm, trying to update using git
=> 
=> Source string already in /Users/Seet/.bash_profile
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="/Users/Seet/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

2. Upgrade to stable node js 5 version
nvm install 5
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v5.12.0 (npm v3.8.6)
3. Uninstall node js 4
nvm uninstall 4
4. Set nvm alias to avoid this error: "N/A: version "N/A" is not yet installed."
nvm alias default v5.12.0
5. Useful command for debugging
> nvm alias
default -> v5.12.0
node -> stable (-> v5.12.0) (default)
stable -> 5.12 (-> v5.12.0) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.6.0 (-> N/A)
> nvm debug
nvm --version: v0.32.0
$SHELL: /bin/bash
$HOME: /Users/Nebitrams
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v5.12.0
which node: $NVM_DIR/versions/node/v5.12.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.12.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v5.12.0
npm root -g: $NVM_DIR/versions/node/v5.12.0/lib/node_modules

Upgrade NPM

1. Upgrade nvm using
npm install -g npm@latest

Common Issue for Parse-server Upgrade

This is a common error during upgrade of parse-server.  After upgrade, the npm start may ends with error like this: "Cannot find module 'double-ended-queue'".

If you run npm list, you will see some missing modules such as the followings:
npm ERR! missing: double-ended-queue@^2.1.0-0, required by redis@2.8.0
npm ERR! missing: redis-commands@^1.2.0, required by redis@2.8.0
npm ERR! missing: redis-parser@^2.6.0, required by redis@2.8.0
 You can try to delete the package-lock.json and node_modules folder, following by re-install.

rm -rf package-lock.json node_modules/
npm i --no-optional
npm dedupe
npm up
Refer to https://github.com/npm/npm/issues/19393 for more information.

Friday 7 October 2016

MongoDB : regular version upgrade

The local MongoDB instance was installed using brew.

Initial Installation

  1. Install Xcode command-line toolsxcode-select --install
  2. install home-brew

Upgrade locally installed mongodb

1. Upgrade brew by running
"brew update"
2. Upgrade mongodb by running
"brew upgrade mongodb"
==> Upgrading 1 outdated package, with result:
mongodb 3.2.10
==> Upgrading mongodb
==> Installing dependencies for mongodb: openssl
==> Installing mongodb dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.el_capitan.b
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing mongodb
==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.2.10.el_capitan.b
######################################################################## 100.0%
==> Pouring mongodb-3.2.10.el_capitan.bottle.tar.gz
==> Caveats
To have launchd start mongodb now and restart at login:
  brew services start mongodb
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺  /usr/local/Cellar/mongodb/3.2.10: 18 files, 245.2M

Upgrade local mongodb from 3.4.18 to 3.6

This is to document the process of upgrading from currently installed 3.4.18 to 3.6.11.  Using brew upgrade doesn't work for me and I used brew install mongodb@3.6.  However, the drawback is I only managed to install 3.6.8 (not sure why 3.6.11 is not available).  Refer to this link for more information.  Upgrade to specific version of MongoDB

1. Prepare the data by running this using mongo shell.
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
2. Upgrade brew by running will result in installing the latest which is 4.0 as of May 2019
"brew upgrade mongodb"
3. Install a specific version by using
"brew install mongodb@3.6"
4. Update the link using
"brew unlink mongodb@3.4"
"brew link --force mongodb@3.6"
5. Open a new shell and check the default MongoDB version
mongod --version
db version v3.6.8
git version: <snipped>
OpenSSL version: OpenSSL 1.0.2r  26 Feb 2019
allocator: system
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64
5. If you see this error when you start up mongod.  Then you need to set.  Read error-while-upgrading-mongodb-from-3-2-to-3-6
IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
 6. If you need to switch back to mongodb version 3.4.  Use the brew link and unlink.  After that, you can switch back to 3.6 by unlink and link again.
"brew unlink mongodb@3.6"
"brew link --force mongodb@3.4"

Upgrade mLab mongodb version

General steps for upgrade:
  1. Check the mLab upgrade guide.
  2. Test the application in staging environment
Once all test is completed, upgrade the mLab using Tool -> version.