gaojinguan 发表于 2018-10-27 07:56:30

rhel6上install mongodb

  下载:mongodb-linux-x86_64-3.2.6.tgz
  请去mongodb的官方网站下载,本地址不提供下载。
  上传mongodb-linux-x86_64-3.2.6.tgz到/usr/local目录下
tar xvfz mongodb-linux-x86_64-3.2.6.tgz  
mv mongodb-linux-x86_64-3.2.6 mongodb
  
chown -R mongo:dbmon mongodb
  安装完成,mongodb的安装就是解压过程。
  下面是启动:
  cd mongodb
  bin/mongod --dbpath=/data/mongodb/
  指定数据文件所在目录,默认是/data/db。如果执行此启动命令的session关掉,则mongodb也一起关掉。如果让它后台运行则要加参数fork,如果指定fork,则要指定logpath参数。
  可以编辑一个参数文件,启动时指定参数文件启动。在参数文件中指定相关参数。
  先创建配置文件、数据文件、日志文件的路径
cd /usr/local/mongodb  
mkdir data
  
mkdir etc
  
mkdir logs
  
cd etc
  
touch mongodb.cnf
  
journal=true
  
bind_ip=xxx.xxx.xxx.xxx
  
port=27017
  
httpinterface=true
  
rest=true
  
storageEngine=mmapv1
  
dbpath=/usr/local/mongodb/data
  
fork=true
  
logpath=/usr/local/mongodb/logs/mongodb.log
  
profile=1
  
slowms=1
  
replSet=xbfax
  指定参数文件启动
cd /usr/local/mongodb  
bin/mongod -f /usr/local/mongodb/etc/mongodb.cnf
  客户端连接:
bin/mongo xxx.xxx.xxx.xxx:27017  
MongoDB shell version: 3.2.6
  
connecting to: xxx.xxx.xxx.xxx:27017/test
  
Welcome to the MongoDB shell.
  
For interactive help, type "help".
  
For more comprehensive documentation, see
  
      http://docs.mongodb.org/
  
Questions? Try the support group
  
      http://groups.google.com/group/mongodb-user
  或是在windows上使用图形化工具:MongoVUE
  关于MongoVUE请自行google
  下面是相关参数的一些解释:
  journal 启用日志选项,MongoDB的数据操作将会写入到journal文件夹的文件里,默认为true
  bind_ip 绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默认本地所有IP
  port 指定服务端口号,默认端口27017
  httpinterface http接口
  rest 开启rest API
  storageEngine 启动引擎
  dbpath 数据文件存放路径
  fork 以守护进程的方式运行MongoDB,创建服务器进程
  logpath 指定MongoDB日志文件,注意是指定文件不是目录
  profile 档案参数 0=off 1=slow, 2=all
  slowms value of slow for profile and console log
  replSet 设置副本集名称


页: [1]
查看完整版本: rhel6上install mongodb