Mongodb (Database)
Jump to navigation
Jump to search
MongoDB
Install
- from sources (https://github.com/mongodb/mongo/releases):
# shared/opt install schema v1.5.6 #### as common user #### # define applications vars export SOFTWARE_PATH="/home/shared/opt/software" export NAME="mongodb" export VERSION="4.4.6" export URL="https://github.com/mongodb/mongo/archive/r${VERSION}.tar.gz" su - -w SOFTWARE_PATH,NAME,VERSION #### as root #### # install packages and prepare destination path apt-get -q -y install wget coreutils findutils < /dev/null apt-get -q -y install gcc libcurl4-openssl-dev liblzma-dev python3 python3-pip < /dev/null mkdir -m 777 "${SOFTWARE_PATH}/tmp_install/" "${SOFTWARE_PATH}/${NAME}_${VERSION}/" exit #### as common user #### umask 0027 cd "${SOFTWARE_PATH}/tmp_install" wget -c --no-check-certificate "${URL}" tar -xzf "r${VERSION}.tar.gz" cd "mongo-r${VERSION}" python3 -m pip install -r etc/pip/compile-requirements.txt # define compiler flags optimizations (from debian dpkg-buildflags command) export CFLAGS="-g0 -O2 -fstack-protector-strong -Wformat -Werror=format-security -mtune=native -pipe" export LDFLAGS="-s -Wl,-z,relro" # configure, build and install python3 buildscripts/scons.py MONGO_VERSION="${VERSION}" DESTDIR="${SOFTWARE_PATH}/${NAME}_${VERSION}/" install-core strip -s ${SOFTWARE_PATH}/${NAME}_${VERSION}/bin/mongod strip -s ${SOFTWARE_PATH}/${NAME}_${VERSION}/bin/mongo strip -s ${SOFTWARE_PATH}/${NAME}_${VERSION}/bin/mongos cd su - -w SOFTWARE_PATH,NAME,VERSION #### as root #### # ensure permissions to destination path cd "${SOFTWARE_PATH}" chown -R root:users "${NAME}_${VERSION}" find "${NAME}_${VERSION}" -type d -exec chmod a-s,u+rwx,g+rx,g-w,o-rwx {} \; find "${NAME}_${VERSION}" -type f -exec chmod a-s,u+rw,g+r,g-w,o-rwx {} \; rm -rf tmp_install ln -s -f -T "${NAME}_${VERSION}" "${NAME}" exit #### as common user #### # test the application mkdir /tmp/mongodata "${SOFTWARE_PATH}/${NAME}/bin/mongod" --dbpath /tmp/mongodata --syslog --fork "${SOFTWARE_PATH}/${NAME}/bin/mongo" "${SOFTWARE_PATH}/${NAME}/bin/mongod" --dbpath /tmp/mongodata --syslog --shutdown rm -rf /tmp/mongodata/