Mostrando postagens com marcador mongo. Mostrar todas as postagens
Mostrando postagens com marcador mongo. Mostrar todas as postagens

quarta-feira, 20 de fevereiro de 2019

Debian 9 and MongoDB

Debian 9 and MongoDB


This week I upgraded my Mint running under Debian 9.3 (LMDE 3).  

See:

lucio@lucio:~$ cat /etc/debian_version 
9.3


So, I installed Mongo using the default repository. My current version of python 3 is 3.5.3, and I do not want to update python because I'm afraid to break my project - maybe I have to upgrade the pip packages if I did.


Ok... I tried updating python and using it with Mongo 4.0, but the numpy didn't work...and maybe many others too. So, I gave up.


Installing Mongo

lucio@lucio:~$ sudo apt install mongodb



So, this are the versions of my installations.

lucio@lucio:~/desenv/project$ python3 -V
Python 3.5.3

lucio@lucio:~$ mongod --version
db version v3.2.11
git version: 009580ad490190ba33d1c6253ebd8d91808923e4
OpenSSL version: OpenSSL 1.0.2q  20 Nov 2018
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64


It worked fine!

Restoring backups

It's easy restoring backups in Mongo, just use mongorestore - mongorestore <backup path>.

lucio@lucio:~$ mongorestore desenv/project/dump/20190207/



--- 

Installing Mongo 4.0


I will record here the step by step to install Mongo 4.0 in Debian 9.

Make sure you have the curl installed. If not, install it.

lucio@lucio:~$ sudo apt install curl

Install the key of mongodb repository.

lucio@lucio:~$ curl https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -

Create the file mongodb-org-4.0.list:

lucio@lucio:~$ sudo vim /etc/apt/sources.list.d/mongodb-org-4.0.list

This will open a new blank file. Paste in the following:

deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main

Save and close the file, then update your package cache:

lucio@lucio:~$ sudo apt update

Install the mongodb-org package to install the server and some supporting tools:

lucio@lucio:~$ sudo apt install mongodb-org

Finally, enable and start the mongod service to get your MongoDB database running:

lucio@lucio:~$ sudo systemctl enable mongod
lucio@lucio:~$ sudo systemctl start mongod

Check if Mongo is running:

lucio@lucio:~$ sudo systemctl status mongod

That's all!!!



quarta-feira, 27 de julho de 2016

Instalando MongoDB 3.2 no Linux Mint Debian Edition


Passo a passo seguindo as orientações do site do Mongo: link


1. Importar a chave pública usada pelo sistema de gerenciamento de pacotes

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

2. Adicione o repositório do MongoDB 3.2 no sourcelist do seu sistema

echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

3. Atualize a lista de pacotes dos repositórios

sudo apt-get update

4. Instale  os pacotes do MongoDB

4.1 Para instalar a última versão estável do MongoDB

sudo apt-get install -y mongodb-org

4.2 Para instalar uma versão específica

sudo apt-get install -y mongodb-org=3.2.8 mongodb-org-server=3.2.8 mongodb-org-shell=3.2.8 mongodb-org-mongos=3.2.8 mongodb-org-tools=3.2.8

5. Verifique o status do serviço do mongod

O daemon do MongoDB tem o nome de mongod e pode ser verificado em /etc/init.d/mongod
sudo service mongod status
Caso o serviço esteja parado, inicie-o
sudo service mongod start
Por padrão os arquivos do mongo ficam em /var/lib/mongodb e o log em /var/log/mongodb

Caso queira alterar os caminhos, modifique em /etc/mongod.conf
Veja em systemLog.path e storage.dbPath para maiores informações.

6. Entre no shell do mongo

mongo

Para sair

Entre com o comando quit() no shell do mongo ou Ctrl + c
> quit()

Aviso do transparent_hugepage

Caso recebe o seguinte aviso ao entrar no shell do mongo, siga as orientações propostas no site do mongoBD. Fonte: link

** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
**        We suggest setting it to 'never'

1. Crie o seguinte script no /etc/init.d

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

2. Cole o seguinte conteúdo no script

#!/bin/sh
### 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

    unset thp_path
    ;;
esac

3. Torne o script executável

sudo chmod 755 /etc/init.d/disable-transparent-hugepages

4. Configure o iniciar o script no boot do sistema

Para Debian/Ubuntu:

sudo update-rc.d disable-transparent-hugepages defaults

Para SUSE:

sudo insserv /etc/init.d/disable-transparent-hugepages

Para Red Hat, CentOS, Amazon Linux, and derivatives:

sudo chkconfig --add disable-transparent-hugepages


Para remover o MongoDB


1. Pare o serviço do mongod

sudo service mongod stop

2. Remova os pacotes

sudo apt-get purge mongodb-org*

3. Remova os diretórios dos arquivos do MongoDB

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb