1.先吧mongdb压缩包放到/usr/local 目录下
2.
解压命令
tar zxvf
解压三次
3.
分别在3个mongodb文件夹下创建文件夹mongodata
4.
/usr/local/mongodb1/bin/mongod --dbpath /usr/local/mongodb1/mongodata --port 27017 --replSet repl
/usr/local/mongodb2/bin/mongod --dbpath /usr/local/mongodb2/mongodata --port 27018 --replSet repl
/usr/local/mongodb3/bin/mongod --dbpath /usr/local/mongodb3/mongodata --port 27019 --replSet repl
5.创建副本集,任意启动一个mongodb之后,复制下代码
config = { _id:"repl", members:[{_id:0,host:"192.168.126.153:27017"},{_id:1,host:"192.168.126.153:27018"},
{_id:2,host:"192.168.126.153:27019",arbiterOnly:true}]}
[root@localhost ~]# cd ../
[root@localhost /]# cd usr
[root@localhost usr]# cd local
[root@localhost local]# ll
total 37440
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
drwxr-xr-x. 4 root root 4096 May 10 02:26 mongodb1
drwxr-xr-x. 4 root root 4096 May 10 02:27 mongodb2
drwxr-xr-x. 4 root root 4096 May 10 02:27 mongodb3
-rw-r--r--. 1 root root 38288414 May 10 02:24 mongodb-linux-i686-3.0.5.tgz
drwxr-xr-x.