Архив рубрики: Публикации

Как установить MongoDB на Debian 9

MongoDB — бесплатная и открытая исходная NoSQL документарно-ориентированная база данных, ориентированная на платформу. Она хранит все данные в документах с использованием формата JSON (BSON), что делает данные чрезвычайно гибкими. MongoDB входит в выпуски Community и Enterprise. Издание Enterprise предоставляет дополнительные функции администрирования, аутентификации и мониторинга. Community — это бесплатная версия MongoDB с открытым исходным кодом, и мы ее установим в этой статье на Debiab 9 VPS.

Некоторые из ключевых особенностей MongoDB перечислены ниже:

  • Высокая производительность.
  • Переносимость данных
  • Может использоваться как хранилище файлов
  • Поддерживает богатый язык запросов
  • Высокая доступность
  • Возможность глубокого запроса.
  • Горизонтальная масштабируемость
  • Поддержка множественного хранения. Вы можете использовать такие двигатели, как WiredTiger Storage Engine и MMAPv1

Предпосылки

  • Debian 9 VPS — MongoDB 64bit предоставляет только пакеты для 64-разрядных сборок Debian 9.
  • SSH-доступ с привилегиями root

Как установить MongoDB на Debian 9

Войдите на сервер и обновите систему

Войдите в свой Debian 9 VPS через SSH в качестве пользователя root

ssh root@IP_Address -p Port_number

 

и прежде чем мы начнем установку MongoDB, убедитесь, что все установленные пакеты обновлены до последней доступной версии

apt update && apt update

 

Добавить официальный репозиторий MongoDB

MongoDB можно установить из официального репозитория Debian 9, но этот пакет не поддерживается командой MongoDB, и это не официальный релиз MongoDB. Итак, чтобы установить официальный пакет MongoDB, который всегда обновляется, нам нужно добавить репозиторий MongoDB на сервер. Прежде всего мы будем импортировать открытый ключ MongoDB, чтобы обеспечить согласованность и достоверность пакета. Выполните следующую команду

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

 

Вывод:

Executing: /tmp/apt-key-gpghome.BvSKWq7GUg/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

gpg: key 68818C72E52529D4: public key "MongoDB 4.0 Release Signing Key <packaging@mongodb.com>" imported

gpg: Total number processed: 1

gpg:               imported: 1

 

Следующий шаг — добавить репозиторий, создав файл ‘/etc/apt/sources.list.d/mongodb-org-4.0.list’, используя следующую команду:

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

 

После добавления репозитория обновите локальную базу данных пакетов

apt update

 

Установите MongoDB на Debian 9

Мы добавили официальный репозиторий MongoDB в наш Debian 9 VPS, поэтому мы готовы начать установку последней версии MongoDB, просто выполнив следующую команду на сервере

apt -y install mongodb-org

 

Проверьте версию MongoDB, установленную на сервере

mongo -version

 

Вывод:

MongoDB shell version v4.0.0

git version: 3b07af3d4f471ae89e8186d33bbb1d5259597d51

OpenSSL version: OpenSSL 1.1.0f  25 May 2017

allocator: tcmalloc

modules: none

build environment:

    distmod: debian92

    distarch: x86_64

    target_arch: x86_64

 

Итак, мы успешно установили MongoDB версии 4.0.0, которая на момент написания этой статьи является последней стабильной версией.

Вы также можете установить любую конкретную версию MongoDB, в которой вы нуждаетесь. Если вам нужна более старая версия MongoDB, например 3.0.12, вы можете установить ее, выполнив следующую команду.

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

 

Обратите внимание, что версия MongoDB, которую вы специфицировали и устанавливали на сервер, будет автоматически обновляться при выпуске новой версии. Чтобы претворить это, мы поставим пакет на «hold». Таким образом, пакет MongoDB не может быть установлен, обновлен или удален, пока метка удержания не будет удалена. Вы можете добиться этого, выдав следующие команды:

echo "mongodb-org hold" | sudo dpkg --set-selections

echo "mongodb-org-server hold" | sudo dpkg --set-selections

echo "mongodb-org-shell hold" | sudo dpkg --set-selections

echo "mongodb-org-mongos hold" | sudo dpkg --set-selections

echo "mongodb-org-tools hold" | sudo dpkg --set-selections

 

Как только MongoDB будет установлен, запустите службу

service mongod start

 

и убедитесь, что процесс mongod запущен

service mongod status

 

Вывод:

● mongod.service - MongoDB Database Server

   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)

   Active: active (running) since Tue 2018-07-17 11:51:26 CDT; 21s ago

     Docs: https://docs.mongodb.org/manual

 Main PID: 21205 (mongod)

   CGroup: /system.slice/mongod.service

           └─21205 /usr/bin/mongod --config /etc/mongod.conf

 

Вот и все, MongoDB успешно установлен и запущен на вашем Debian 9 VPS. Для получения дополнительной информации и инструкций по использованию MongoDB, пожалуйста, проверьте их официальную документацию: https://docs.mongodb.com/.


Вы также можете проверить наши учебные пособия о том, как установить MongoDB на Ubuntu 16.04 VPS  или CentOS VPS.

 



2018-07-20T08:28:56
Установка ПО на Debian

MikroTik Configuration with PPPoE WAN Connection

MikroTik Router is a popular routing device to any network administrator because of having a lot of network features availability. MikroTik PPPoE Client is a special feature that is used to connect any PPPoE Server. If your ISP provides PPPoE connection, MikroTik Router is able to connect that PPPoE Server using PPPoE Client. In my previous article, I discussed how to configure MikroTik Router with static WAN connection and in this article I will show how to configure MikroTik Router with WAN PPPoE Client.




Core Devices and IP Information




To configure MikroTik Router with WAN PPPoE Client, I am using a MikroTik RouterBoard 1100 AHX2 (RouterOS v6.38.1). IP information that I am using this configuration is given below.




  • PPPoE username: mikrotik_wan and Password: mikrotik123
  • LAN Gateway: 192.168.10.1/24 and
  • DNS IP: 8.8.8.8 or 8.8.4.4




This information is just for my R&D purpose. Change this information according to your network requirements.




Network Diagram




To configure MikroTik Router with WAN PPPoE Client, I am following a network diagram like below image.




MikroTik WAN PPPoE Client
MikroTik WAN PPPoE Client




In this network, MikroTik Router’s ether1 interface is connected to ISP network where PPPoE Server is enabled. So, we will create MikroTik PPPoE Client in this interface so that MikroTik Router can connect with ISP PPPoE Server and can access internet. Again, MikroTik Router’s ether2 interface is connected to a LAN switch having IP block 192.168.10.0/24. We are assigning static IP for LAN users but if we want, we can configure MikroTik PPPoE Server, MikroTik DHCP Server or MikroTik Hotspot Server on ether2 interface.  We will also configure NAT in our MikroTik Router so that LAN users are able to get internet using this private IP block.




MikroTik Configuration with WAN PPPoE Client




We will now start our MikroTik Router configuration with WAN PPPoE client according to the above network diagram. Complete MikroTik configuration with PPPoE WAN connection can be divided into four steps.




  • MikroTik PPPoE Client Configuration on WAN Interface
  • Assigning LAN Gateway
  • Assigning DNS IP and
  • NAT configuration






Step 1: MikroTik PPPoE Client Configuration on WAN Interface




If your uplink ISP provides PPPoE connection, you must configure MikroTik PPPoE Client on your WAN interface. The following steps will show how to configure PPPoE Client on MikroTik WAN interface.




  • Login to MikroTik Router using Winbox with admin privilege credential.
  • Click on PPP menu item. PPP window will appear. From Interface tab, click on PLUS SIGN (+) dropdown menu and then choose PPPoE Client. New Interface window will appear.
  • Under General tab, put your PPPoE interface name (pppoe-wan) in Name input field and then choose your WAN interface (ether1) from Interfaces dropdown menu.
  • Click on Dial Out tab and put your ISP given username (mikrotik_wan) in User input field and password (mikrotik123) in Password input field. Click on Dial On Demand checkbox and Use Peer DNS checkbox. Also ensure that Add Default Route checkbox is checked. Also uncheck all the checkboxes except pap checkbox from Allow panel.
  • Click Apply and OK button.




MikroTik PPPoE Client Configuration
MikroTik PPPoE Client Configuration




MikroTik PPPoE Client will be connected now and you can see PPPoE Client status from Status tab. You will find that a dynamic IP is added in IP > Address list and you will also find a default route is automatically added in IP > Routes list by MikroTik PPPoE client.




Step 2: Assigning LAN Gateway




After MikroTik PPPoE Client configuration, we will now assign LAN Gateway IP so that LAN user can communicate with MikroTik Router. The following steps will show how to assign LAN Gateway IP in MikroTik Router.




  • Go to IP > Addresses menu item. Address List window will appear.
  • Click on PLUS SIGN (+) and put your LAN gateway IP (192.168.10.1/24) in Address input field.
  • Choose your LAN interface (ether2) from Interface dropdown menu.
  • Click Apply and OK button.






LAN Gateway IP has been assigned. Now we will assign DNS IP in our MikroTik Router.




Step 3: Assigning DNS IP




According to our PPPoE Client configuration, DNS IP will be assigned dynamically if ISP provides DNS IP with their PPPoE Server’s user profile. However, we will assign DNS Server IP manually in our MikroTik Router because they may forget to assign DNS Server IP with their user profile. The following steps will show how to assign DNS IP in your MikroTik Router.




  • Go to IP > DNS menu item and put DNS Server IP (8.8.8.8 or 8.8.4.4) in Servers input field.
  • Click on Apply and OK button.




Assigning DNS IP has been completed. Now we will configure NATing so that LAN user can get internet through MikroTik Router.




Step 4: NAT Configuration




In the last step, we will create a NAT firewall rule to masquerade our LAN IP block. Otherwise, our LAN user cannot access internet through our MikroTik router. The following steps will show how to create the masquerade firewall rule in your MikroTik router.




  • Go to IP > Firewallmenu and click on NAT tab and then click on PLUS SIGN (+). New NAT Rule window will appear now.
  • Choose srcnatfrom Chain dropdown menu and put LAN IP block (192.168.10.0/24) in Address input field.
  • Click on Action tab and choose masqueradefrom Action dropdown menu.
  • Click Applyand OK




NAT configuration in MikroTik router has been completed as well as all our necessary steps to configure MikroTik Router with WAN PPPoE Client have been completed. Now connect your LAN users to MikroTik Router through a LAN switch. If everything is OK, your LAN users will able to get internet through MikroTik Router.




If you face any confusion to follow above steps properly, watch my video about MikroTik Router Configuration with WAN PPPoE Client. I hope it will reduce your any confusion.