天天看點

搭建個人Leanote雲筆記本

一.連接配接ECS伺服器

二.安裝MongoDB

MongoDB是一個基于分布式檔案存儲的高性能資料庫,介于關系資料庫和非關系資料庫之間,它支援的資料結構非常松散是類似于json和bson格式,是以可以存儲比較複雜的資料類型。Mongo最大的特點是它支援的查詢語言非常強大,其文法有點類似于面向對象的查詢語言,幾乎可以實作類似關系資料庫單表查詢的絕大部分功能,而且還支援對資料建立索引。

Leanote雲筆記使用MongoDB作為後端資料庫,按照以下步驟按照MongoDB資料庫。

1.配置MongoDB的yum源

vim /etc/yum.repos.d/mongodb-org-4.0.repo

添加以下内容:

[mongodb-org-4.0]

name=MongoDB Repository

baseurl=

https://repo.mongodb.org/yum/redhat/

$releasever/mongodb-org/4.0/x86_64/

gpgcheck=0

enabled=1

gpgkey=

https://www.mongodb.org/static/pgp/server-4.0.asc

這裡可以修改 gpgcheck=0, 省去gpg驗證

[root@localhost ~]# yum makecache

2.安裝MongoDB

安裝指令:

yum -y install mongodb-org

安裝完成後

檢視mongo安裝位置 :

whereis mongod

檢視修改配置檔案 :

vim /etc/mongod.conf

3.啟動MongoDB

啟動mongodb :

systemctl start mongod.service

停止mongodb :

systemctl stop mongod.service

查到mongodb的狀态:

systemctl status mongod.service

4.外網通路需要關閉防火牆:

關閉firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall開機啟動

5.啟動Mongo shell

指令:

mongo

檢視資料庫:

show dbs

6.設定mongodb遠端通路:

編輯mongod.conf注釋bindIp,并重新開機mongodb.(這句配置代表隻能本機使用,是以需注釋) 或者 設定為 0.0.0.0

重新開機mongodb使修改生效:

systemctl restart mongod.service

到這裡就可以正常使用mongodb了

上一篇: day005