Ricerca nel sito web

Come installare il database RavenDB NoSQL su Ubuntu 20.04


Su questa pagina

  1. Prerequisiti
  2. Installa le dipendenze richieste
  3. Installa RavenDB
  4. Configura RavenDB
  5. Crea un file di servizio Systemd per RavenDB
  6. Accedi all'interfaccia web di RavenDB
  7. Conclusione

RavenDB è un database NoSQL orientato ai documenti gratuito e open source progettato per la piattaforma .NET/Windows. RavenDB supporta più database, sharding o partizionamento dei dati su più server. Ha la capacità di gestire centinaia o migliaia di database sulla stessa istanza. RavenDB utilizza JSON per archiviare i documenti e non richiede la dichiarazione di uno schema e consente agli sviluppatori di lavorare con i dati in modo più naturale.

In questo tutorial impareremo come installare RavenDB sul server Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Il server è configurato con una password di root.

Installa le dipendenze richieste

Prima di iniziare, dovrai installare il runtime NET Core nel tuo sistema. Innanzitutto, scarica e installa il repository dei pacchetti con il seguente comando:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb

Dovresti ottenere il seguente output:

Selecting previously unselected package packages-microsoft-prod.
(Reading database ... 91134 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-ubuntu20.04.1) ...
Setting up packages-microsoft-prod (1.0-ubuntu20.04.1) ...

Successivamente, aggiorna il repository con il seguente comando:

apt-get install apt-transport-https -y
apt-get update -y

Una volta aggiornato il repository, installa il runtime .Net Core con il seguente comando:

apt-get install aspnetcore-runtime-3.1 -y

Una volta completata l'installazione, è possibile procedere al passaggio successivo.

Installa RavenDB

Innanzitutto, scarica l'ultima versione di RavenDB eseguendo il seguente comando:

wget -O ravendb.tar.bz2 https://hibernatingrhinos.com/downloads/RavenDB%20for%20Linux%20x64/latest

Una volta completato il download, estrai il file scaricato con il seguente comando:

tar xvjf ravendb.tar.bz2

Successivamente, autorizzazione adeguata al RavenDB con il seguente comando:

chmod -R 755 ~/RavenDB

Quindi, cambia la directory in RavenDB ed esegui lo script di installazione come mostrato di seguito:

cd ~/RavenDB
./run.sh

Dovresti vedere il seguente output:

./run.sh: line 24: xdg-open: command not found
       _____                       _____  ____ 
      |  __ \                     |  __ \|  _ \ 
      | |__) |__ ___   _____ _ __ | |  | | |_) |
      |  _  // _` \ \ / / _ \ '_ \| |  | |  _ < 
      | | \ \ (_| |\ V /  __/ | | | |__| | |_) |
      |_|  \_\__,_| \_/ \___|_| |_|_____/|____/ 


      Safe by default, optimized for efficiency

 Build 50005, Version 5.0, SemVer 5.0.0, Commit a8d3f94
 PID 23883, 64 bits, 2 Cores, Phys Mem 1.941 GBytes, Arch: X64
 Source Code (git repo): https://github.com/ravendb/ravendb
 Built with love by Hibernating Rhinos and awesome contributors!
+---------------------------------------------------------------+
Using GC in server concurrent mode retaining memory from the OS.
Could not start browser: System.ComponentModel.Win32Exception (2): No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName, String arguments)
   at Raven.Server.Utils.Cli.BrowserHelper.OpenStudioInBrowser(String url, Action`1 onError) in C:\Builds\RavenDB-Stable-5.0\50005\src\Raven.Server\Utils\Cli\BrowserHelper.cs:line 26
Server available on: http://127.0.0.1:43241
Server started, listening to requests...
TIP: type 'help' to list the available commands.
Running non-interactive.

A questo punto, RavenDB è avviato e in ascolto sulla porta 43241. Ora premi CTRL + C per uscire.

Configura RavenDB

Per impostazione predefinita, RavenDB è accessibile solo dal localhost. Quindi dovrai configurarlo per accedere dall'host remoto.

Puoi configurarlo modificando il file settings.json:

nano ~/RavenDB/Server/settings.json

Aggiungi/Modifica le seguenti righe:

{
    "ServerUrl": "http://your-server-ip:8080",
    "Setup.Mode": "Initial",
    "DataDir": "RavenData",
    "Security.UnsecuredAccessAllowed": "PrivateNetwork"

}

Salva e chiudi il file quando hai finito.

Crea un file di servizio Systemd per RavenDB

Successivamente, dovrai creare un file di servizio systemd per gestire RavenDB. Puoi crearlo con il seguente comando:

nano /etc/systemd/system/ravendb.service

Aggiungi le seguenti righe:

[Unit]
Description=RavenDB v4.0
After=network.target

[Service]
LimitCORE=infinity
LimitNOFILE=65536
LimitRSS=infinity
LimitAS=infinity
User=root
Restart=on-failure
Type=simple
ExecStart=/root/RavenDB/run.sh

[Install]
WantedBy=multi-user.target

Salva e chiudi il file. Quindi, ricarica il demone systemd con il seguente comando:

systemctl daemon-reload

Quindi, avvia RavenDB e abilitalo per l'avvio al riavvio del sistema con il seguente comando:

systemctl start ravendb
systemctl enable ravendb

Ora puoi controllare lo stato di RavenDB con il seguente comando:

systemctl status ravendb

Dovresti ottenere il seguente output:

? ravendb.service - RavenDB v4.0
     Loaded: loaded (/etc/systemd/system/ravendb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-08-01 11:25:12 UTC; 7min ago
   Main PID: 30833 (run.sh)
      Tasks: 32 (limit: 2353)
     Memory: 157.0M
     CGroup: /system.slice/ravendb.service
             ??30833 /bin/bash /root/RavenDB/run.sh
             ??30871 ./Raven.Server --browser

Aug 01 11:30:19 ubunt4 run.sh[30871]: Starting shut down...
Aug 01 11:30:21 ubunt4 run.sh[30871]: Shutdown completed
Aug 01 11:30:21 ubunt4 run.sh[30871]: Restarting Server...
Aug 01 11:30:21 ubunt4 run.sh[30871]: Using GC in server concurrent mode retaining memory from the OS.
Aug 01 11:30:21 ubunt4 run.sh[30871]: Server available on: http://69.87.218.19:8080
Aug 01 11:30:21 ubunt4 run.sh[30871]: Tcp listening on 69.87.218.19:38888
Aug 01 11:30:21 ubunt4 run.sh[30871]: Server started, listening to requests...
Aug 01 11:30:21 ubunt4 run.sh[30871]: TIP: type 'help' to list the available commands.
Aug 01 11:30:21 ubunt4 run.sh[30871]: ravendb> End of standard input detected, switching to server mode...
Aug 01 11:30:21 ubunt4 run.sh[30871]: Running non-interactive.

A questo punto, RavenDB è avviato e in ascolto sulla porta 8080.

Accedi all'interfaccia web di RavenDB

Ora, apri il tuo browser web e digita l'URL http://your-server-ip:8080. Dovresti vedere la seguente schermata:

Fare clic sul pulsante Accetta per accettare il contratto di licenza. Dovresti vedere la seguente schermata:

Qui ci sono tre opzioni per configurare RavenDB. Seleziona l'opzione Non protetto. Dovresti vedere la seguente schermata:

Fornire la porta HTTP, l'indirizzo IP e fare clic sul pulsante Avanti. Dovresti vedere la seguente schermata:

Fare clic sul server Riavvia per riavviare il sistema. Dopo il riavvio riuscito, verrai reindirizzato alla dashboard di RavenDB come mostrato di seguito:

Fare clic sul pulsante CREA DATABASE. Dovresti vedere la seguente schermata:

Fornisci il nome del tuo database e fai clic sul pulsante Crea. Dovresti vedere il database appena creato nella schermata seguente:

Conclusione

Congratulazioni! hai installato correttamente RavenDB su Ubuntu 20.04. Ora puoi iniziare a esplorare RavenDB per familiarizzare con esso. Non esitate a chiedermi se avete domande.