Mongodb配置

来源:互联网 发布:上海 java 培训机构 编辑:程序博客网 时间:2024/05/16 09:04
 

netstat -lanp | grep "27017"

/usr/local/mongodb/bin/mongod -dbpath=/usr/local/mongodb/data/db --fork --port 27017 --logpath=/usr/local/mongodb/log/work.log --logappend --auth

/usr/local/mongodb/bin/mongod -dbpath=/usr/local/mongodb/data/db --fork --port 27017 --logpath=/usr/local/mongodb/log/work.log --logappend --auth

 

[root@localhost shell]# vi start-mongodb.sh

MONGODIR=/usr/local/mongodb
MONGOD=$MONGODIR/bin/mongod
MONGO=$MONGODIR/bin/mongo
DBDIR=$MONGODIR/data/db
LOGPATH=$MONGODIR/log/mongodb.log

$MONGOD -dbpath=$DBDIR --fork --port 27017 --logpath=$LOGPATH --logappend --auth

 

//            根据手册,C#驱动下创建数据库及添加用户用这种方式
//string connectionString = "mongodb://admin:admin@localhost"
//// 连库语句
//MongoServer server = MongoServer.Create(connectionString);
//// 连库或创建一个数据库test
//MongoDatabase test = server.GetDatabase("test");
//// 加个用户进去
//MongoCredentials credentials = new MongoCredentials("username", "password");
//test.AddUser(credentials);

 


 using (Mongo mongo = new Mongo("mongodb://test:test@192.168.73.128:27017/test"))
 var db = mongo.GetDatabase("test");

 

MONGODIR = /usr/local/mongodb
MONGOD = $MONGODIR /bin/mongod
MONGO = $MONGODIR /bin/mongo
DBDIR = $MONGODIR /data/db
LOGPATH = $MONGODIR/log /work.log

# mongod will print its pid, so store it in out.tmp, then
# print it using awk to mongod.pid
$MONGOD --dbpath $DBDIR --fork --logpath $LOGPATH --logappend --auth

原创粉丝点击