爲服務器安全起見,建立用戶(用戶名:yishi):mongodb
useradd yishi
設置密碼:shell
passwd yishi
添加sudo權限:數據庫
usermod -aG wheel yishi
修改/etc/ssh/sshd_config
ubuntu
PermitRootLogin no
而後:centos
service sshd restart
$ cat id_rsa.pub >> ~/.ssh/authorized_keys $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/id_rsa # Disable password authentication forcing use of keys PasswordAuthentication no
Create/etc/yum.repos.d/mongodb-org-3.2.repo
,Content:服務器
[mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
Client only:ssh
sudo yum install -y mongodb-org-shell
export LC_ALL=C mongo
dbURI = sprintf("mongodb://%s:%s@%s:%d,%s:%d/%s?replicaSet=%s", conf.username, conf.password, conf.host1, conf.port1, conf.host2, conf.port2, conf.dbname, conf.replSetName);
openssl rand -hex 16