I'm facing difficulties installing the MongoDB community server on Manjaro Linux.
There isn't official documentation on how to install it on Arch-based systems and Pacman can't find it in the AUR repos.
Has anyone ever tried to install it?
Here is what I did to install.
As the package is not available in the official Arch repositories and can't be installed using pacman, you need to follow a few steps to install it.
First, you need to get the URL for the repo of prebuilt binaries from AUR. It can be found here and by the time of writing this it was https://aur.archlinux.org/mongodb-bin.git
Simply clone the repo in your home directory or anywhere else. Do git clone https://aur.archlinux.org/mongodb-bin.git, then head to the cloned directory, cd mongodb-bin.
Now, all you need to do is to run makepkg -si command to make the package. the -s flag will handle the dependencies for you and the -i flag will install the package.
After makepkg finishes its execution, don't forget to start mongodb.service. Run systemctl start mongodb and if needed enable it with systemctl enable mongodb.
Type mongo in the terminal and if the Mongo Shell runs you are all set.
Later edit (8.2.2021): This package is now available in AUR.
It is available in AUR, so you can view it with pamac with -a flag,
eg.
pamac search -a mongodb-bin
pamac info -a mongodb-bin
And, then build and install with (this can be done after manually cloning too) -
pamac build mongodb-bin
Note that there's also a package named mongodb, but mongodb-bin is a newer release (you can check the version numbers by search or info arguments)
I've been using mongodb via docker for a couple of years.
In my experience, it's easier than installing the regular way. (assuming you already have docker installed)
1. Ensure you have docker installed
If you don't already have it, you can install via pacman/pamac, because it's in the official Arch/Manjaro package repositories. The easiest way is to run the following command:
sudo pacman -S docker
2. Run a single docker command
sudo docker run -d -p 27017:27017 -v ~/mongodb_data:/data/db mongo
This command will run mongodb on a port 27017, and place its data files into a folder ~/mongodb_data.
If you're running this command for the first time, it will also download all the required files.
Now you're successfully running a local instance of mongodb, and you can connect it with your favorite db management tool or from your code.
Related
After installing PHP7.1 using this on CentOS7
https://webtatic.com/packages/php71/
Running
php -v
Results in
-bash: php: command not found
The install worked but PHP is not there - have I missed a step?
Since you have installed php from webtatic, you'll need to install the cli SAPI.
To do that you need to run:
sudo yum install php71w-cli
After the installation, try running the below to see if it works:
php --version
https://webtatic.com/packages/php71/
Contained in the php71w-cli package, this SAPI allows running scripts from the command-line, and also has a built-in web server for development-use. Located at /usr/bin/php
I had similar issues on my computer. For me the command was just renamed to php7 or php71. So if have the same issue please create a symlink.
Find out where your php7 file is residing
$ which php7
/usr/bin/php7
Symlink this file
sudo ln -s /usr/bin/php7 /usr/bin/php
Test that this is working
php -v
Your problem should be solved. Only case might be that you need to change newly created file as executable or change the owner/group.
Please let me know if this was helpful.
As mentioned above, I need to install only the mongo shell on a RHEL instance (machine A).
I have a mongodb server on a separate instance (machine B) and need to connect to that from A to run mongodump and mongorestore commands.
I tried looking it up on the web but all I got was instructions to install the complete mongodb package.
Any help appreciated.
Official documentation says that you should be fine installing mongodb-org-shell only.
Create a repository file at sudo vim /etc/yum.repos.d/mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
gpgcheck=1
enabled=1
sudo yum clean all
sudo yum install mongodb-org-shell-4.0.2
mongo <mongo-server-ip> Note: Step 4 will not work in all cases. You need to check proper command to connect to remote mongo server.
Source: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
You can follow the official tutorial on installing mongodb, and instead of installing the main package that will install all the packages, just install the package containing mongoshell
Please follow below steps.
Create a file /etc/yum.repos.d/mongodb.repo
Update the above file to contain:
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
sudo yum install -y mongodb-org-shell-2.6.9
mongo mongo-db_server_IP:27017/database_name -u username -p password
You might want to install mongosh (MongoDB Shell) instead. The legacy mongo shell has been deprecated since MongoDB v5.0 and replaced by mongosh. From the mongosh docs:
The new MongoDB Shell, mongosh, offers numerous advantages over the
legacy mongo shell, such as:
Improved syntax highlighting.
Improved command history.
Improved logging.
Currently mongosh supports a subset of the mongo shell
methods. Achieving feature parity between mongosh and the mongo shell
is an ongoing effort.
To maintain backwards compatibility, the methods that mongosh supports
use the same syntax as the corresponding methods in the mongo shell.
To see the complete list of methods supported by mongosh, see MongoDB
Shell Methods.
Further reference: Compatibility Changes with Legacy mongo Shell
Head to Mongo download page; download your required package regarding your operating system. Finally follow the instruction of your operating system to install the package.
Especially to install mongo or mongosh:
download .tgz file and untar the file into /usr/local/
add /usr/local/mongo/ into the shell profile (e.g. ~/.bashrc) and restart your terminal
For more information read the docs.
P.S.: mongo in the path should be vary based on the version of the downloaded package.
I tried to install postgresql-9.3-postgis-2.1 or postgresql-9.1-postgis-2.1 for a cloned app, but I can only get postgresql-9.4-postgis-2.1 on my Ubuntu docker image which is build from python:2.7 image.
I looked into the image and found it's on a Ubuntu 14.04.1 image. I tries to install postgis on my Xubuntu 14.04.2 VM, everything is OK.
How could I get the installation works OK?
Dockerfile is pretty easy:
FROM python:2.7
RUN mkdir /workspace
RUN mkdir /data
WORKDIR /workspace
RUN apt-get update
RUN apt-get install postgresql postgresql-common postgresql-9.3-postgis-2.1
Error code is very normal too:
E: Unable to locate package postgresql-9.3-postgis-2.1
E: Couldn't find any package by regex 'postgresql-9.3-postgis-2.1'
Please provide more information, like the dockerfile and the errors you get.
From your comment it appears you load the python libraries before the postgresql libraries. I assume that your python app needs postgresql access and that it uses one of the python wrappers around the postgresql C libraries.
If that is the case then install the postgresql libraries before installing the python libraries, and do not forget to add the -dev libraries.
What I do in such a case is to make a minimal docker image, start a root shell in the container and do the install manually, take notes and use them to update the docker file. Alternatively you can run
$ docker exec -t -i bash -i
to get a shell in the container and try out what needs to be done.
Thanks for everyone who tried to help me! Though I finally fix this myself, there is nothing wrong with the Dockerfile which is pretty simple, but the image I chose is not a typical Ubuntu image, the docker office use buildpack-deps:jessie instead of ubuntu:14.04 image:
https://github.com/docker-library/python/blob/master/2.7/Dockerfile
It caused different behavior in docker and Ubuntu VM.
Finally, I build a Python image from Ubuntu:12.04 and fixed this issue.
This started as a question, but I think I've figured out most of the parts, so am posting it here for reference. It is relatively involved, but I think it may be useful to others contemplating this scenario.
I'm a newb with some of these areas, so if mistakes are made in regards to security issues in Apache or other bad practices, please correct.
Also note that, as it stands, the local development version that is produced from following the steps below no longer has git enabled on it due to changes between it and the production code. So I will keep the local git repo in another location.
Desired Behaviour
Option One:
Replicate my current Python 2.7, Bottle, MongoDB OpenShift application locally to speed up development time (during git push etc).
Option Two (if significantly easier):
Replicate my current Python 2.7, Bottle, MongoDB Openshift application locally *without the OpenShift platform* to speed up development time.
Current Behaviour
I have a Python 2.7, Bottle, MongoDB application on OpenShift.
My current workflow is:
Edit locally.
git add --all
git commit -m "here is a message"
git push origin master (this updates the live site on openshift)
git push github master (this updates github repo)
Obviously this is not ideal for developing due to the time each push takes before I can see the results.
Directory Structure
This is the structure of my app now that it is running locally:
Environment
Linux Mint 17 Cinnamon
Steps To Replicate Locally
01) MongoDB 2.4.9 - DONE
Install instructions for MongoDB 2.4.9 on Linux Mint 17:
http://docs.mongodb.org/v2.4/tutorial/install-mongodb-on-ubuntu
02) RockMongo 1.1 (which requires Apache, PHP and MongoDB Driver) - DONE
sudo apt-get install apache2 php5
sudo apt-get install php5-dev php5-cli
sudo apt-get install php-pear
pear version
pecl version
sudo pecl install mongo
At this point, I was prompted with something that included [no] and I just pressed Enter.
cd /etc/php5/apache2
sudo vi php.ini
Add this to the end of the file:
extension=mongo.so
Then restart:
/etc/init.d/apache2 restart
Then install RockMongo:
cd /var/www/html
wget https://github.com/iwind/rockmongo/archive/1.1.7.zip
unzip 1.1.7.zip
mv rockmongo-1.1.7 rockmongo
rm 1.1.7.zip
03) Create clean virtualenv environment and install packages to it - DONE
virtualenv is a Python package that lets you create independent, virtual environments containing their own Python installation and packages.
Install virtualenv through Synaptic Package Manager.
How To Create
https://code.google.com/p/modwsgi/wiki/VirtualEnvironments
By the author of mod_wsgi, Graham Dumpleton.
Why To Create
http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
This article is so brilliant it almost make me want to cry, kudos, kudos.
Commands
Before doing the following, install python2.7-dev, libxml2-dev, libxslt1-dev and apache2-dev via Synaptic Package Manager to resolve errors when doing pip installs later.
# change to your html folder
cd /var/www/html
# this will create a folder called ENV that contains its own instance
# of python without inheriting your system's installed python packages.
# it will also install independent instances of pip and setuptools.
# the --no-site-packages option is the default setting in recent versions
# however I added it just to be sure.
virtualenv --no-site-packages ENV
New python executable in ENV/bin/python
Installing setuptools, pip...done.
# you can 'activate' the virtual environment so that each time you use
# pip it automatically installs packages in the virtual environment.
# change to your virtual environment folder
cd /var/www/html/ENV
# activate the virtual environment
source bin/activate
# you can deactivate this by typing 'deactivate` and it is also
# automatically deactivated each time you close the terminal.
deactivate
# from time to time you can save the names of the packages you have
# installed to your virtual environment via pip to a text file with:
pip freeze > requirements.txt
# note, after installing virtualenv as shown above, you will have some
# packages installted by default.
pip freeze
argparse==1.2.1
wsgiref==0.1.2
# requirements.txt would allow installation of all required packages via:
pip install -r requirements.txt
# install packages, whilst virtualenv is activated
pip install bottle
pip install https://github.com/FedericoCeratto/bottle-cork/archive/master.zip
pip install requests
pip install pymongo==2.6.2
pip install beautifulsoup4
pip install lxml
pip install Beaker
pip install pycrypto
pip install pillow
pip install tldextract
04) Copy existing application files to new location - DONE
cp -r path/to/open_shift_apps/my-app/. /var/www/html
05) Remove files and folder unnecessary for *local* production from var/www/html - DONE
rm -r data
rm -r libs
rm -r .openshift
rm -r .git
rm setup.py
rm setup.pyc
rm setup.pyo
06) mod_wsgi - DONE
Through Synaptic Package Manager.
Apache wouldn't work for me unless mod_wsgi was installed at system level, ie it didn't work when mod_wsgi was installed within virtualenv.
07) Understand the relationship between the Apache server, mod_wsgi and your application - DONE
Apache
To run a dynamic website locally, you need a server, in this case we used Apache.
mod_wsgi
mod_wsgi is an Apache module which extends Apache so that rules can be added to its configuration which point to your Python code so that it can be run when a user visits a particular path.
08) Configure Apache rules
/etc/apache2/sites-available/000-default.conf
WSGIPythonHome /var/www/html/ENV
WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages:/var/www/html/wsgi
<VirtualHost *:80>
# for all content in static folder - css, js, img, fonts
Alias /static/ /var/www/html/wsgi/static/
# for rockmongo
Alias /rockmongo /var/www/html/rockmongo
<Directory /var/www/html/rockmongo>
Order deny,allow
Allow from all
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIScriptAlias / /var/www/html/wsgi/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When a user visits a particular path, Apache looks for an application object which contains code which will run your Python program.
In this case, the object is located at wsgi/application and is triggered when the user goes to localhost.
/var/www/html/wsgi/application
from mybottleapp import application
09) Check file ownership and permissions
If things don't work at any stage of the process, be sure to look at the permissions of your local files. Not having the right permissions could mean that your application is not imported.
10) mongodump from OpenShift and mongorestore locally
How to mongodump from OpenShift and mongorestore locally on MongoDB 2.4.9?
Further Reading
How Python web frameworks, WSGI and CGI fit together
https://docs.python.org/2/howto/webservers.html
http://wsgi.readthedocs.org/en/latest/servers.html
https://code.google.com/p/modwsgi/
https://www.python.org/dev/peps/pep-0333
http://bottlepy.org/docs/dev/deployment.html#apache-mod-wsgi
I'm trying to imagine a workflow that could be applied on a scientific work environment. My work involves doing some scientific coding, basically with Python, pandas, numpy and friends. Sometimes I have to use some modules that are not common standards in the scientific community and sometimes I have to integrate some compiled code in my chain of simulations. The code I run is most of the time parallelised with IPython notebook.
What do I find interesting about docker?
The fact that I could create a docker containing my code and its working environment. I can then send the docker to my colleges, without asking them to change their work environment, e.g., install an outdated version of a module so that they can run my code.
A rough draft of the workflow I have in mind goes something as follows:
Develop locally until I have a version I want to share with somebody.
Build a docker, possibly with a hook from a git repo.
Share the docker.
Can somebody give me some pointers of what I should take into account to develop further this workflow? A point that intrigues me: code running on a docker can lunch parallel process on the several cores of the machine? e.g., an IPython notebook connected to a cluster.
Docker can launch multiple process/thread on multiple core. Multiple processes may need the use of a supervisor (see : https://docs.docker.com/articles/using_supervisord/ )
You should probably build an image that contain the things you always use and use it as a base for all your project. (Would save you the pain of writing a complete Dockerfile each time)
Why not develop directly in a container and use the commit command to save your progress on a local docker registry? Then share the final image to your colleague.
How to make a local registry : https://blog.codecentric.de/en/2014/02/docker-registry-run-private-docker-image-repository/
Even though you'll have a full container, I think a package manager like conda can still be a solid part of the base image for your workflow.
FROM ubuntu:14.04
RUN apt-get update && apt-get install curl -y
# Install miniconda
RUN curl -LO http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
RUN bash Miniconda-latest-Linux-x86_64.sh -p /miniconda -b
RUN rm Miniconda-latest-Linux-x86_64.sh
ENV PATH=/miniconda/bin:${PATH}
RUN conda update -y conda
* from nice example showing docker + miniconda + flask
Wrt doing source activate <env> in the Dockerfile you need to:
RUN /bin/bash -c "source activate <env> && <do something in the env>"