五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

Linux下MongoDB的安裝和配置教程

發(fā)布日期:2022-02-02 13:24 | 文章來(lái)源:腳本之家

MongoDB安裝

選擇使用Yum安裝

1、制作 repo 文件

cat << EOF > /etc/yum.repos.d/mongodb-org-4.2.repo
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
EOF
12345678

baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.2/x86_64/安裝失敗,嘗試把地址寫死為7,安裝基于centos7的版本??梢猿晒Π惭b
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/

2、使用yum 命令安裝

yum install -y mongodb-org

3、啟動(dòng)mongodb

安裝完啟動(dòng)服務(wù)則可以使用

啟動(dòng)、停止、重啟命令如下:

service mongod start
service mongod stop
service mongod restart

4、開(kāi)放mongodb的遠(yuǎn)程連接

mongodb的配置文件是 /etc/mongod.conf

如果要開(kāi)放遠(yuǎn)程訪問(wèn)需要修改該文件的 bindIp值為: 0.0.0.0 ,否則通過(guò)其它電腦是連接不到的

vim /etc/mongod.conf

文件修改后要執(zhí)行 restart 使配置生效

service mongod restart

如果仍不能遠(yuǎn)程連接,查看防火墻狀態(tài),如果防火墻開(kāi)啟,關(guān)閉防火墻或讓防火墻放開(kāi) 27017 端口(該端口是mongodb的默認(rèn)端口,可通過(guò)配置文件修改mongodb的端口)
查看防火墻狀態(tài)

firewall-cmd --state

關(guān)閉防火墻狀態(tài)

systemctl stop firewalld.service

防火墻放開(kāi) 27017 端口

firewall-cmd --permanent --zone=public --add-port=27017/tcp
firewall-cmd --reload

測(cè)試是否可以遠(yuǎn)程連接

http://服務(wù)器ip:27017/

阿里云服務(wù)器則需要添加端口得安全組

5、創(chuàng)建用戶和密碼

1.進(jìn)入mongo shell

[root@iZ2ze1wbnx7ym2bkq1xtk5Z conf.d]# mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("73551ca3-8d61-4ce2-a5d1-c0563f9828d4") }
MongoDB server version: 4.2.8
Server has startup warnings:
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten]
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten]
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten]
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-07-01T15:24:12.665+0800 I CONTROL [initandlisten]
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

>

2.切換到admin數(shù)據(jù)庫(kù)

admin這個(gè)庫(kù)是mongodb自動(dòng)帶的,專門管理用戶和權(quán)限的,創(chuàng)建超級(jí)用戶,這個(gè)用戶可以管理所有用戶的增刪改以及權(quán)限控制

> use admin
switched to db admin

3.添加賬戶

創(chuàng)建一個(gè)超級(jí)管理員權(quán)限(擁有userAdminAnyDatabasereadWriteAnyDatabase兩個(gè)權(quán)限)的用戶。用戶名和密碼隨便寫,但是角色必須是這兩個(gè)

db.createUser( 
{ 
user: "alenghan", pwd: "123456", roles: [
{ 
role: "userAdminAnyDatabase", db: "admin" 
},
"readWriteAnyDatabase" 
] 
}
)

注:``db.createUser()`的具體使用方法:鏈接地址

創(chuàng)建完成就可以使用命令鏈接

mongo --port 27017 -u "alenghan" --authenticationDatabase "admin" -p 123456

4.修改mongo.conf文件

停止mongodb服務(wù)(service mongod stop),修改配置文件(/etc/mongod.conf

# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog: #系統(tǒng)日志
destination: file #日志輸出目的地
logAppend: true # 如果為true,當(dāng)mongod/mongos重啟后,將在現(xiàn)有日志的尾部繼續(xù)添加日志。否則,將會(huì)備份當(dāng)前日志文件,然后創(chuàng)建一個(gè)新的日志文件;默認(rèn)為false。
path: /var/log/mongodb/mongod.log #日志路徑

# Where and how to store data.
storage:
dbPath: /var/lib/mongo # mongod進(jìn)程存儲(chǔ)數(shù)據(jù)目錄,此配置僅對(duì)mongod進(jìn)程有效
journal:
enabled: true #是否開(kāi)啟journal日志持久存儲(chǔ),journal日志用來(lái)數(shù)據(jù)恢復(fù),是mongod最基礎(chǔ)的特性,通常用于故障恢復(fù)。64位系統(tǒng)默認(rèn)為true,32位默認(rèn)為false,建議開(kāi)啟,僅對(duì)mongod進(jìn)程有效。
# engine: #存儲(chǔ)引擎類型,mongodb 3.0之后支持“mmapv1”、“wiredTiger”兩種引擎,默認(rèn)值為“mmapv1”;官方宣稱wiredTiger引擎更加優(yōu)秀。
# wiredTiger: #對(duì)wiredTiger引擎配置生效

# how the process runs
processManagement:
fork: true # fork and run in background 運(yùn)行在后臺(tái)
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile PID文件路徑
timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
port: 27017 #端口
bindIp: 127.0.0.1
# Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting. 綁定外網(wǎng)op 多個(gè)用逗號(hào)分隔,如果開(kāi)放全部外網(wǎng)訪問(wèn), 輸入0.0.0.0
# maxIncomingConnections: 65536 #進(jìn)程允許的最大連接數(shù) 默認(rèn)值為65536
# wireObjectCheck: true #當(dāng)客戶端寫入數(shù)據(jù)時(shí) 檢測(cè)數(shù)據(jù)的有效性(BSON) 默認(rèn)值為true

#security: #安全有關(guān)的配置
#authorization: enabled #disabled或者enabled,僅對(duì)mongod有效;表示是否開(kāi)啟用戶訪問(wèn)控制(Access Control),即客戶端可以通過(guò)用戶名和密碼認(rèn)證的方式訪問(wèn)系統(tǒng)的數(shù)據(jù),默認(rèn)為“disabled”,即客戶端不需要密碼即可訪問(wèn)數(shù)據(jù)庫(kù)數(shù)據(jù)。(限定客戶端與mongod、mongos的認(rèn)證)
#javascriptEnabled: true #true或者false,默認(rèn)為true,僅對(duì)mongod有效;表示是否關(guān)閉server端的javascript功能,就是是否允許mongod上執(zhí)行javascript腳本,如果為false,那么mapreduce、group命令等將無(wú)法使用,因?yàn)樗鼈冃枰趍ongod上執(zhí)行javascript腳本方法。如果你的應(yīng)用中沒(méi)有mapreduce等操作的需求,為了安全起見(jiàn),可以關(guān)閉javascript。

#operationProfiling: #性能分析器
#slowOpThresholdMs: 100 #數(shù)據(jù)庫(kù)profiler判定一個(gè)操作是“慢查詢”的時(shí)間閥值,單位毫秒;
#mode: off #數(shù)據(jù)庫(kù)profiler級(jí)別,操作的性能信息將會(huì)被寫入日志文件中,
# 可選值:1)off:關(guān)閉profiling
# 2)slowOp:on,只包含慢操作日志
# 3)all:on,記錄所有操作
# 數(shù)據(jù)庫(kù)profiling會(huì)影響性能,建議只在性能調(diào)試階段開(kāi)啟。此參數(shù)僅對(duì)mongod有效。

#replication: #主從復(fù)制 主備模式 這個(gè)是大點(diǎn),需要單獨(dú)講
#oplogSizeMB:10240 #replication操作日志的最大尺寸,單位:MB。

#sharding: #sharding架構(gòu) 集群中使用,暫時(shí)沒(méi)有接觸

總結(jié)

到此這篇關(guān)于Linux下MongoDB的安裝和配置的文章就介紹到這了,更多相關(guān)Linux下MongoDB的安裝和配置內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

香港服務(wù)器租用

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開(kāi)通

自選配置、實(shí)時(shí)開(kāi)通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問(wèn)服務(wù)

1對(duì)1客戶咨詢顧問(wèn)

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部