Centos7.5安装部署MongosDB
作者:互联网
环境Centos7.5
服务器地址:
192.168.5.61、192.168.5.62、192.168.5.63
开始集群搭建192.168.5.61上操作:
首先创建两个目录:
[root@localhost ~]# mkdir /opt/software
[root@localhost ~]# mkdir /opt/apps
拷贝安装包到/opt/software目录下并进入到/opt/software目录并解压安装包
[root@localhost ~]# cp mongodb-linux-x86_64-4.0.2.tgz /opt/software/
[root@localhost ~]# cd /opt/software/
[root@localhost software]# tar zxf mongodb-linux-x86_64-4.0.2.tgz -C /opt/apps/
进入到/opt/apps目录下做相关链接
[root@localhost software]# cd ../apps/
[root@localhost apps]# ln -s mongodb-linux-x86_64-4.0.2 mongodb
创建数据和日志文件夹
[root@localhost apps]# cd
[root@localhost ~]# mkdir -p /data/mongodb/conf
[root@localhost ~]# mkdir -p /data/mongodb/{mongos,config,shard1,shard2,shard3}/{log,data}
配置环境变量
[root@localhost ~]# vim /etc/profile
让环境变量立即生效
[root@localhost ~]# source /etc/profile
添加配置文件
[root@localhost ~]# vim /data/mongodb/conf/config.conf
pidfilepath = /data/mongodb/config/log/mongosrv.pid
dbpath = /data/mongodb/config/data
logpath = /data/mongodb/config/log/configsrv.log
logappend = true
bind_ip = 0.0.0.0
port = 21000
fork = true
#declare this is a config db of a cluster;
configsvr = true
#副本集名称
replSet=configs
#设置最大连接数
maxConns=20000
启动192.168.5.61上的config server
[root@localhost ~]# mongod -f /data/mongodb/conf/config.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4707
child process started successfully, parent exiting
依次启动服务器的config server(上面的操作在其他服务器做同样的操作)
192.168.5.62上操作:
标签:opt,部署,mongodb,MongosDB,data,config,root,Centos7.5,localhost 来源: https://blog.csdn.net/lq_hello/article/details/117668525