Last active
August 8, 2018 11:58
-
-
Save emgee3/0852cccc1a1fd1c418d3 to your computer and use it in GitHub Desktop.
Revisions
-
emgee3 revised this gist
Oct 25, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ set -o pipefail # # CONFIGURATION SECTION # export MONGO_VERSION="r2.4.12" # Which version of MongoDB, which corresponds to a git tag # You can list available versions with `git tag | grep -v "rc"` # inside the mongo git respository -
emgee3 revised this gist
Oct 25, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ set -o pipefail # # CONFIGURATION SECTION # export MONGO_VERSION="r2.4.12." # Which version of MongoDB, which corresponds to a git tag # You can list available versions with `git tag | grep -v "rc"` # inside the mongo git respository @@ -51,7 +51,7 @@ fi # Compilation will fail without 2+ GB of RAM and/or SWAP export TOTAL_RAM=`free -mt | grep Total | awk '{print $2}'` if [ ${MONGO_VERSION} = "r2.4.12" ]; then export RAM_NEEDED=3000 else export RAM_NEEDED=5000 @@ -85,7 +85,7 @@ git checkout "${MONGO_VERSION}" # PATCHING # if [ "${MONGO_VERSION}" = "r2.4.12" ]; then # fix for BOOST bug https://svn.boost.org/trac/boost/ticket/7242 patch SConstruct <<EOF -
emgee3 revised this gist
Jul 30, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/usr/bin/env bash # # Compile and install MongoDB with SSL support # tested an works on Ubuntu 12.04 LTS x64 and Ubuntu 14.04 LTS x64 # -
emgee3 revised this gist
Jul 22, 2014 . 1 changed file with 33 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env bash # # bash script to compile and install MongoDB with SSL support # tested an works on Ubuntu 12.04 LTS x64 and Ubuntu 14.04 LTS x64 # @@ -15,9 +15,9 @@ set -o pipefail # CONFIGURATION SECTION # export MONGO_VERSION="r2.4.10" # Which version of MongoDB, which corresponds to a git tag # You can list available versions with `git tag | grep -v "rc"` # inside the mongo git respository # Self-signed SSL Certificate settings export SSL_HOSTNAME="${HOSTNAME}" # Should be FQDN of your MongoDB server export SSL_C="US" # Country @@ -50,14 +50,21 @@ fi # Compilation will fail without 2+ GB of RAM and/or SWAP export TOTAL_RAM=`free -mt | grep Total | awk '{print $2}'` if [ ${MONGO_VERSION} = "r2.4.10" ]; then export RAM_NEEDED=3000 else export RAM_NEEDED=5000 fi if [ ${TOTAL_RAM} -lt ${RAM_NEEDED} ]; then echo "Compiliation needs more than ${TOTAL_RAM} ram/swap space" >&2 exit 1 fi # # PREREQUSITIES # @@ -73,30 +80,40 @@ git clone git://github.com/mongodb/mongo.git cd /usr/src/mongo git checkout "${MONGO_VERSION}" # # PATCHING # if [ "${MONGO_VERSION}" = "r2.4.10" ]; then # fix for BOOST bug https://svn.boost.org/trac/boost/ticket/7242 patch SConstruct <<EOF 709a710,711 > "-Wno-unused-function", > "-Wno-unused-local-typedefs", EOF # MongoDB will compile and install properly but will error on the stacktrace test # if this patch isn't applied, which will cause this script to return a failed exit code. # snatched from http://git.alpinelinux.org/cgit/aports/plain/testing/mongodb/mongodb-2.4.4-fix-sharedclient.patch patch src/mongo/SConscript <<EOF 459c459 < LIBDEPS=['stacktrace', --- > LIBDEPS=['stacktrace', 'foundation', 'mongocommon', 'alltools', EOF fi # # COMPILATION and INSTALLATION # # this takes ~40 min on a Digital Ocean 2 core/2GB RAM droplet scons core install --64 --ssl -j4 --no-glibc-check --prefix=/usr # run the post-install script which makes the mongo user, creates the data folder # and sets various permissions @@ -139,7 +156,7 @@ openssl req \ -keyout mongodb.key \ -out mongodb.crt # configure mongo to use the key/cert cat mongodb.key mongodb.crt > mongodb.pem cat >> /etc/mongodb.conf <<EOF -
emgee3 revised this gist
Jul 22, 2014 . 1 changed file with 48 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,32 +8,42 @@ set -e set -u set -o pipefail # set -x #debugging # # CONFIGURATION SECTION # export MONGO_VERSION="r2.4.10" # Which version of MongoDB, which corresponds to a git tag # You can list available versions with `git tag | grep -v "rc"` # inside the mongo git respository # Self-signed SSL Certificate settings export SSL_HOSTNAME="${HOSTNAME}" # Should be FQDN of your MongoDB server export SSL_C="US" # Country export SSL_ST="California" # State export SSL_O="Radiant" # Organization export SSL_DAYS="3650" # Valid for in days == 10 years # # SANITY CHECKS # # See http://blog.mongodb.org/post/137788967/32-bit-limitations if [ "${HOSTTYPE}" != "x86_64" ]; then echo "MongoDB should be installed on a 64-bit OS" >&2 exit 1 fi # A non-scientific test compiling MongoDB showed it used around 11 GB storage at its peak cd /usr/src export FREE_SPACE=$(($(stat -f --format="%a*%S" .))) export FREE_SPACE_NEEDED=14000000000 # ~14 GB if [ "${FREE_SPACE}" -le "${FREE_SPACE_NEEDED}" ]; then echo "Not enough free space in /usr/src" >&2 exit 1 fi @@ -46,6 +56,11 @@ if [ ${TOTAL_RAM} -lt 3000 ]; then fi # # PREREQUSITIES # # install all the prerequsite packages needed for compilation export DEBIAN_FRONTEND=noninteractive aptitude install build-essential scons git-core libssl-dev libboost-filesystem-dev \ @@ -65,25 +80,26 @@ patch SConstruct <<EOF > "-Wno-unused-local-typedefs", EOF # MongoDB will compile and install properly but will error on the stacktrace test # if this patch isn't applied, which will cause this script to return a failed exit code. # snatched from http://git.alpinelinux.org/cgit/aports/plain/testing/mongodb/mongodb-2.4.4-fix-sharedclient.patch patch src/mongo/SConscript <<EOF 459c459 < LIBDEPS=['stacktrace', --- > LIBDEPS=['stacktrace', 'foundation', 'mongocommon', 'alltools', EOF # # COMPILATION and INSTALLATION # # this takes ~40 min on a Digital Ocean 2 core/2GB RAM droplet scons core install --release --64 --ssl -j4 --no-glibc-check --prefix=/usr # run the post-install script which makes the mongo user, creates the data folder # and sets various permissions cd /usr/src/mongo/debian chmod +x postinst ./postinst configure @@ -92,7 +108,7 @@ chmod +x postinst cp mongodb.upstart /etc/init/mongodb.conf cp mongodb.conf /etc # create a logrotate script so our log files don't overflow cat > /etc/logrotate.d/mongodb-server <<EOF /var/log/mongodb/*.log { weekly @@ -105,14 +121,19 @@ cat > /etc/logrotate.d/mongodb-server <<EOF } EOF # # CONFIGURE SSL # # generate a self-signed SSL key/cert cd /etc/ssl openssl req \ -new \ -newkey rsa:4096 \ -x509 \ -days ${SSL_DAYS} \ -nodes \ -subj "/C=${SSL_C}/ST=${SSL_ST}/O=${SSL_O}/CN=${SSL_HOSTNAME}" \ -keyout mongodb.key \ @@ -126,3 +147,10 @@ sslOnNormalPorts = prefer sslPEMKeyFile = /etc/ssl/mongodb.pem EOF # # CLEANUP # cd ~ rm -rf /usr/src/mongo -
emgee3 created this gist
Jul 22, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,128 @@ #!/usr/bin/env bash # # Bash script to compile and install MongoDB with SSL support # Tested on Ubuntu 14.04 LTS x64 # set -e set -u set -o pipefail # set -x #for debug # Update these config lines as needed export MONGO_VERSION="r2.4.10" export SSL_HOSTNAME="${HOSTNAME}" export SSL_C="US" export SSL_ST="California" export SSL_O="Radiant" # See http://blog.mongodb.org/post/137788967/32-bit-limitations if [ "${HOSTTYPE}" != "x86_64" ]; then echo "MongoDB should be installed on a 64-bit OS" >&2 exit 1 fi cd /usr/src # A non-scientific test compiling MongoDB showed it used around 11 GB storage at its peak export FREE_SPACE=$(($(stat -f --format="%a*%S" .))) export FREE_SPACE_NEEDED=14000000000 # ~14 GB if [ "${FREE_SPACE}" -le "${FREE_SPACE_NEEDED}" ]; then echo "Not enough free space ub /usr/src" >&2 exit 1 fi # Compilation will fail without 2+ GB of RAM and/or SWAP export TOTAL_RAM=`free -mt | grep Total | awk '{print $2}'` if [ ${TOTAL_RAM} -lt 3000 ]; then echo "Compiliation needs more than 2GB ram/swap space" >&2 exit 1 fi # install all the prerequsite packages needed for compilation export DEBIAN_FRONTEND=noninteractive aptitude install build-essential scons git-core libssl-dev libboost-filesystem-dev \ libboost-program-options-dev libboost-system-dev libboost-thread-dev \ -q -y # clone the source from github, and check out the proper release git clone git://github.com/mongodb/mongo.git cd /usr/src/mongo git checkout "${MONGO_VERSION}" # fix for BOOST bug https://svn.boost.org/trac/boost/ticket/7242 patch SConstruct <<EOF 709a710,711 > "-Wno-unused-function", > "-Wno-unused-local-typedefs", EOF cd /usr/src/mongo/src/mongo # MongoDB will compile and install properly but will error on the stacktrace test # if this patch isn't applied, which will return a failed exit code for the scripts # snatched from http://git.alpinelinux.org/cgit/aports/plain/testing/mongodb/mongodb-2.4.4-fix-sharedclient.patch patch SConscript <<EOF 459c459 < LIBDEPS=['stacktrace', --- > LIBDEPS=['stacktrace', 'foundation', 'mongocommon', 'alltools', EOF cd /usr/src/mongo # compile and install # this takes a while scons core install --release --64 --ssl -j4 --no-glibc-check --prefix=/usr # run the post-install script which makes the Mongo user and sets up permissions cd /usr/src/mongo/debian chmod +x postinst ./postinst configure # configure upstart and create base config file cp mongodb.upstart /etc/init/mongodb.conf cp mongodb.conf /etc # rotate the log files cat > /etc/logrotate.d/mongodb-server <<EOF /var/log/mongodb/*.log { weekly rotate 10 copytruncate delaycompress compress notifempty missingok } EOF # generate a self-signed SSL key/cert cd /etc/ssl openssl req \ -new \ -newkey rsa:4096 \ -x509 \ -days 3650 \ -nodes \ -subj "/C=${SSL_C}/ST=${SSL_ST}/O=${SSL_O}/CN=${SSL_HOSTNAME}" \ -keyout mongodb.key \ -out mongodb.crt # configure mongo to use the key/cert cat mongodb.key mongodb.crt > mongodb.pem cat >> /etc/mongodb.conf <<EOF sslOnNormalPorts = prefer sslPEMKeyFile = /etc/ssl/mongodb.pem EOF