quinta-feira, 17 de novembro de 2022

[MongoDB] - How to install?

Hello all

As you know, I have been studying new products, and I started to play with MongoDb. 

This is being fantastic journey at the moment. 

And I have thought, while I'm learning, I can share it with you, and we can learn together.

Today, we gonna install the MongoDB for tests.

Yes, it's the first installation and the real world may be different - and it's, probably, but this post may help people like me who need a push to take the first step into a new technology. 

But just remember:
1) This work for me, but it might not work for you.
2) It's a basic install. As we go along, we'll get better and better.
This post is just for study and tests as well and it has no concern for Best Practices, at this moment.
        4) On next posts, we'll think in Best Practices and Security.

All steps we find here:

Thank you, my friend Adriano Bonacin for the Yadax Blog. The blog is helping me a lot.

So, let's go to the party!!!

For my installation, I created an EC2 instance in Free Tier from AWS using CentOS.

1) Configure yum repo.

sudo vi /etc/yum.repos.d/mongodb-org-6.0.repo 
name=MongoDB Repository

sudo yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: download.cf.centos.org
* extras: download.cf.centos.org
* updates: download.cf.centos.org
repo id                          repo name                    status
base/7/x86_64              CentOS-7 - Base              10,072
extras/7/x86_64            CentOS-7 - Extras             515
mongodb-org-6.0/7       MongoDB Repository        55
updates/7/x86_64          CentOS-7 - Updates         4,385

2) Install mongodb-org

sudo yum install -y mongodb-org
    mongodb-org.x86_64 0:6.0.3-1.el7

    Dependency Installed:
    cyrus-sasl.x86_64 0:2.1.26-24.el7_9                            
    cyrus-sasl-gssapi.x86_64 0:2.1.26-24.el7_9
    cyrus-sasl-plain.x86_64 0:2.1.26-24.el7_9
    mongodb-database-tools.x86_64 0:100.6.1-1
    mongodb-mongosh.x86_64 0:1.6.0-1.el8
    mongodb-org-database.x86_64 0:6.0.3-1.el7
    mongodb-org-database-tools-extra.x86_64 0:6.0.3-1.el7
    mongodb-org-mongos.x86_64 0:6.0.3-1.el7             
    mongodb-org-server.x86_64 0:6.0.3-1.el7
    mongodb-org-tools.x86_64 0:6.0.3-1.el7

sudo yum install -y mongodb-org-6.0.2 mongodb-org-database-6.0.2 mongodb-org-server-6.0.2 mongodb-mongosh-6.0.2 mongodb-org-mongos-6.0.2 mongodb-org-tools-6.0.2
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: download.cf.centos.org
     * extras: download.cf.centos.org
     * updates: download.cf.centos.org
    Package matching mongodb-org-6.0.2-1.el7.x86_64 already installed. Checking for update.
    Package matching mongodb-org-database-6.0.2-1.el7.x86_64 already installed. Checking for update.
    Package matching mongodb-org-server-6.0.2-1.el7.x86_64 already installed. Checking for update.
    No package mongodb-mongosh-6.0.2 available.
    Package matching mongodb-org-mongos-6.0.2-1.el7.x86_64 already installed. Checking for update.
    Package matching mongodb-org-tools-6.0.2-1.el7.x86_64 already installed. Checking for update.
    Nothing to do

3) Today, we'll use the Default Directories
    /var/lib/mongo      (the data directory)
    /var/log/mongodb (the log directory)

The package manager creates the default directories during installation, and the the owner and group name as well. The user and group are mongod.

    id mongod
    uid=996(mongod) gid=994(mongod) groups=994(mongod)

4) Install the SElinux Policy
    sudo yum install git make checkpolicy policycoreutils selinux-policy-devel
git.x86_64 0:
        selinux-policy-devel.noarch 0:3.13.1-268.el7_9.2

Dependency Installed:
m4.x86_64 0:1.4.16-10.el7             
        perl.x86_64 4:5.16.3-299.el7_9               
        perl-Carp.noarch 0:1.26-244.el7         
        perl-Encode.x86_64 0:2.51-7.el7
        perl-Error.noarch 1:0.17020-2.el7
        perl-Exporter.noarch 0:5.68-3.el7
        perl-File-Path.noarch 0:2.09-2.el7
        perl-File-Temp.noarch 0:0.23.01-3.el7
        perl-Filter.x86_64 0:1.49-3.el7
        perl-Getopt-Long.noarch 0:2.40-3.el7
        perl-Git.noarch 0:
        perl-HTTP-Tiny.noarch 0:0.033-3.el7
        perl-PathTools.x86_64 0:3.40-5.el7
        perl-Pod-Escapes.noarch 1:1.04-299.el7_9
        perl-Pod-Perldoc.noarch 0:3.20-4.el7
        perl-Pod-Simple.noarch 1:3.28-4.el7
        perl-Pod-Usage.noarch 0:1.63-3.el7
        perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 
        perl-Socket.x86_64 0:2.010-5.el7
        perl-Storable.x86_64 0:2.45-3.el7
        perl-TermReadKey.x86_64 0:2.30-20.el7
        perl-Text-ParseWords.noarch 0:3.29-4.el7
        perl-Time-HiRes.x86_64 4:1.9725-3.el7
        perl-Time-Local.noarch 0:1.2300-2.el7
        perl-constant.noarch 0:1.27-2.el7
        perl-libs.x86_64 4:5.16.3-299.el7_9
        perl-macros.x86_64 4:5.16.3-299.el7_9
        perl-parent.noarch 1:0.225-244.el7
        perl-podlators.noarch 0:2.5.1-3.el7
        perl-threads.x86_64 0:1.87-4.el7
        perl-threads-shared.x86_64 0:1.43-6.el7
        policycoreutils-devel.x86_64 0:2.5-34.el7

sudo git clone https://github.com/mongodb/mongodb-selinux
Cloning into 'mongodb-selinux'...
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 45 (delta 17), reused 25 (delta 7), pack-reused 0
Unpacking objects: 100% (45/45), done.

cd mongodb-selinux
sudo make
(cd selinux; make -f /usr/share/selinux/devel/Makefile)
make[1]: Entering directory `/root/mongodb-selinux/selinux'
Compiling targeted mongodb module
/usr/bin/checkmodule:  loading policy configuration from tmp/mongodb.tmp
/usr/bin/checkmodule:  policy configuration loaded
/usr/bin/checkmodule:  writing binary representation (version 19) to tmp/mongodb.mod
Creating targeted mongodb.pp policy package
rm tmp/mongodb.mod tmp/mongodb.mod.fc
make[1]: Leaving directory `/root/mongodb-selinux/selinux'
mkdir -p build/targeted
mv selinux/mongodb.pp build/targeted/

sudo make install
cp build/targeted/mongodb.pp /usr/share/selinux/targeted/mongodb.pp
/usr/sbin/semodule --priority 200 --store targeted --install /usr/share/selinux/targeted/mongodb.pp
libsemanage.semanage_direct_install_info: Overriding mongodb module at lower priority 100 with module at priority 200.
/sbin/fixfiles -R mongodb-enterprise-server restore || true
Warning: Skipping the following R/O filesystems:
mongodb-enterprise-server not found
/sbin/fixfiles -R mongodb-org-server restore || true
Warning: Skipping the following R/O filesystems:
/sbin/restorecon -R /var/lib/mongo || true
/sbin/restorecon -R /run/mongodb || true

5) Start Mongo DB

    sudo systemctl start mongod

    sudo mongod --version

    sudo systemctl status mongod

6) Check the startup status
    systemctl is-enabled mongod; echo $?

    sudo systemctl enable mongod

You can follow important messages on logfile:
sudo tail -f /var/log/mongodb/mongod.log

7) And that's it, your MongoDb is installed.

Yes, I know that we need to do some configurations, but we'll make this on next post.

I hope that help you!!!


Nenhum comentário:

Postar um comentário

Isso te ajudou? Comente...

Postagem em destaque

[ORACLE] Increasing the number of cores in a virtualized Oracle Database Appliance.

Hello everyone. How are you going? Today, I'll show you the process to increase the number of cores in a virtualized ODA HA X7-2. Import...