採用yaml方式安裝mongodb

2021-08-28 23:17:28 字數 3855 閱讀 5930

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

新增如下內容:

[mongodb-org-4.0]

name=mongodb repository

baseurl=

gpgcheck=0

enabled=1

gpgkey=

cd /etc/yum.repos.d/

rm -f centos-*

yum install -y mongodb-org-4.0.3 mongodb-org-server-4.0.3 mongodb-org-shell-4.0.3 mongodb-org-mongos-4.0.3 mongodb-org-tools-4.0.3

mkdir -p /data1/mongodb/logs/

mkdir -p /data1/mongodb/shard1

mkdir -p /data1/mongodb/mongodcfg

mkdir -p /data1/mongodb/cnf/

cd /data1/mongodb/cnf/

/data1/mongodb/start_mongo_shard.sh

/data1/mongodb/stop_mongo_shard.sh

systemctl stop firewalld.service

systemctl disable firewalld.service

//乙個節點執行即可

mongo --port 27019

config=,,]}

rs.initiate(config)

mongo --port 22000

config = ,,]

} rs.initiate(config)

登陸mongos對應服務新增分片複製集,啟用資料庫和表分片

mongo --port 31000

use admin

db.runcommand();

shard.yaml

systemlog:

quiet: false

path: /data1/mongodb/logs/shard1.log

destination: file

processmanagement:

fork: true

pidfilepath: /data1/mongodb/shard1.pid

net:

bindip: 0.0.0.0

port: 27019

maxincomingconnections: 65536

wireobjectcheck: true

ipv6: false

storage:

dbpath: /data1/mongodb/shard1

engine: wiredtiger

wiredtiger:

engineconfig:

cachesizegb: 16

directoryforindexes: false

collectionconfig:

indexconfig:

prefixcompression: true

replication:

replsetname: rs01

sharding:

clusterrole: shardsvr

config.yaml

systemlog:

quiet: false

path: /data1/mongodb/logs/mongodcfg.log

destination: file

processmanagement:

fork: true

pidfilepath: /data1/mongodb/mongodcfg.pid

net:

bindip: 0.0.0.0

port: 22000

storage:

dbpath: /data1/mongodb/mongodcfg

directoryperdb: false

engine: wiredtiger

syncperiodsecs: 61

wiredtiger:

engineconfig:

cachesizegb: 16

directoryforindexes: false

collectionconfig:

indexconfig:

prefixcompression: true

sharding:

clusterrole: configsvr

replication:

replsetname: configs

mongos.yaml

systemlog:

quiet: false

path: /data1/mongodb/logs/mongods.log

destination: file

sharding:

configdb: configs/192.168.31.61:22000,192.168.31.62:22000,192.168.31.63:22000

processmanagement:

fork: true

pidfilepath: /data1/mongodb/mongos.pid

net:

bindip: 0.0.0.0

port: 31000

maxincomingconnections: 1024

wireobjectcheck: true

ipv6: false

start_mongo_shard.sh

#!/bin/sh

mongod --config=/data1/mongodb/cnf/shard.yaml

mongod --config=/data1/mongodb/cnf/config.yaml

mongos --config=/data1/mongodb/cnf/mongos.yaml

stop_mongo_shard.sh

#!/bin/sh

kill `cat /data1/mongodb/shard1.pid`

kill `cat /data1/mongodb/mongodcfg.pid`

kill `/data1/mongodb/mongos.pid`

[unit]

description=mongodb

after=network.target

[service]

type=forking

execstart=/data1/mongodb/start_mongo_shard.sh

execstop=/data1/mongodb/stop_mongo_shard.sh

privatetmp=true

[install]

wantedby=multi-user.target

開啟開機啟動

systemctl enable mongodb開機自動啟動

服務啟動

systemctl start mongodb

服務關閉

systemctl stop mongodb

如果啟動未成功使用systemctl status mongodb 檢視服務狀態

通過journalctl -xe 檢視錯誤日誌記性拍錯

採用Link方式安裝PyDev外掛程式

部落格列表 本文是採用link方式安裝pydev外掛程式,安裝過程如下。一 環境準備 jdk,安裝pydev之前要確保windows上已經安裝好jdk,要求jdk的版本在jdk 4以上 eclipse,我安裝的是myeclipse enterprise workbench 10.0 python,我...

Nginx採用yum安裝方式及安裝後的目錄

rpm ivh 至此安裝完成 啟動命令 service nginx start 停止命令 service nginx stop 重啟命令 service nginx restart config etc nginx nginx.conf 安裝目錄 config etc sysconfig nginx...

Nginx採用yum安裝方式及安裝後的目錄

第一次寫部落格就不講究格式了,純文字了吧 開始第一步先執行 rpm ivh 第二步yum info nginx 檢視當前版本可選 第三步yum install nginx 安裝 至此安裝完成 啟動命令 service nginx start 停止命令 service nginx stop 重啟命令 ...