运用后台+配置文件方式启动。
条件
1下载mongodb-linux-x86_64-rhel62-3.6.3.tar 2 3官网https://www.mongodb.com/download-center?jmp=nav#community 4 5依赖openssl-1.0.1e-57.el6.x86_64.rpm
安装
1下载后是这个格式的包包 2mongodb-linux-x86_64-rhel62-3.6.3.tgz
第一次解压
gzip -d mongodb-linux-x86_64-rhel62-3.6.3.tgz
第二次解压
tar -xvf mongodb-linux-x86_64-rhel62-3.6.3.tar
重命名
mv mongodb-linux-x86_64-rhel62-3.6.3 mongodb
步骤+
1mv mongodb /usr/local 2 3cd /usr/local/mongodb/ 4 5mkdir -p data logs 6 7vim mongodb.conf
mongodb.conf
1dbpath=/usr/local/mongodb/data 2port=27017 3logpath=/usr/local/mongodb/logs/mongodb.log 4logappend=true 5fork=true
1.数据库目录
2.端口
3.日志路径文件
4.日志追加末尾
5.后台子进程运行
启动
1cd /usr/local/mongodb/bin 2 3./mongod -f ../mongodb.conf
报错
1./mongod: /usr/lib64/libssl.so.10: no version information available (required by ./mongod) 2./mongod: /usr/lib64/libcrypto.so.10: no version information available (required by ./mongod) 3./mongod: /usr/lib64/libcrypto.so.10: no version information available (required by ./mongod) 4./mongod: relocation error: ./mongod: symbol TLSv1_2_server_method, version libssl.so.10 not defined in file libssl.so.10 with link time reference
解决
问题出在openssl, 经过检验, 发现openssl版本过低, 没办法, 提升版本吧!
验证一下, 发现
1[root@localhost bin]# rpm -qa|grep openssl 2openssl-1.0.0-27.el6.i686 3openssl-1.0.0-27.el6.x86_64
一起干掉
1[root@localhost bin]# rpm -e openssl-1.0.0-27.el6.x86_64 openssl-1.0.0-27.el6.i686 2error: Failed dependencies: 3 libcrypto.so.10()(64bit) is needed by (installed) gnome-vfs2-2.24.2-6.el6.x86_64 4 libcrypto.so.10()(64bit) is needed by (installed) libssh2-1.4.2-1.el6.x86_64 5 libcrypto.so.10()(64bit) is needed by (installed) mysql-libs-5.1.66-2.el6_3.x86_64 6 libcrypto.so.10()(64bit) is needed by (installed) fipscheck-1.2.0-7.el6.x86_64 7 libcrypto.so.10()(64bit) is needed by (installed) python-2.6.6-36.el6.x86_64 8 libcrypto.so.10()(64bit) is needed by (installed) m2crypto-0.20.2-9.el6.x86_64 9 libcrypto.so.10()(64bit) is needed by (installed) pyOpenSSL-0.10-2.el6.x86_64 10 libcrypto.so.10()(64bit) is needed by (installed) openssh-5.3p1-84.1.el6.x86_64 11 libcrypto.so.10()(64bit) is needed by (installed) cyrus-sasl-2.1.23-13.el6_3.1.x86_64 12 libcrypto.so.10()(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64 13 libcrypto.so.10()(64bit) is needed by (installed) openssh-server-5.3p1-84.1.el6.x86_64 14 libssl.so.10()(64bit) is needed by (installed) gnome-vfs2-2.24.2-6.el6.x86_64 15 libssl.so.10()(64bit) is needed by (installed) libssh2-1.4.2-1.el6.x86_64 16 libssl.so.10()(64bit) is needed by (installed) mysql-libs-5.1.66-2.el6_3.x86_64 17 libssl.so.10()(64bit) is needed by (installed) python-2.6.6-36.el6.x86_64 18 libssl.so.10()(64bit) is needed by (installed) m2crypto-0.20.2-9.el6.x86_64 19 libssl.so.10()(64bit) is needed by (installed) python-rhsm-1.1.8-1.el6.x86_64 20 libssl.so.10()(64bit) is needed by (installed) pyOpenSSL-0.10-2.el6.x86_64 21 libssl.so.10()(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64 22 openssl is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
完蛋...(好像没辙)
没事, 继续来, 终极大招
rpm -e openssl-1.0.0-27.el6.i686 openssl-1.0.0-27.el6.x86_64 --nodeps
再查一下
rpm -qa | grep openssl
没有了。
安装新版的openssl, 我这里用的新版是:openssl-1.0.1e-57.el6.x86_64.rpm
1[root@localhost test]# rpm -ivh openssl-1.0.1e-57.el6.x86_64.rpm 2warning: openssl-1.0.1e-57.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY 3error: Failed dependencies: 4 make is needed by openssl-1.0.1e-57.el6.x86_64
没办法,强行安装
1[root@localhost test]# rpm -ivh openssl-1.0.1e-57.el6.x86_64.rpm --nodeps 2warning: openssl-1.0.1e-57.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY 3Preparing... ########################################### [100%] 4 1:openssl ########################################### [100%] 5[root@localhost test]# rpm -qa | grep openssl 6openssl-1.0.1e-57.el6.x86_64
再启动, 启动成功!!
验证
1查进程 2[root@localhost bin]# ps aux | grep mongo 3root 2044 12.2 4.8 1058116 56024 ? Sl 01:08 0:00 ./mongod -f ../mongodb.conf 4root 2072 0.0 0.0 6372 688 pts/0 S+ 01:08 0:00 grep mongo 5 6 7查端口 8[root@localhost bin]# netstat -tlnp | grep mongod 9tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 2044/./mongod 10 11 12客户端验证 13[root@localhost bin]# ./mongo 14MongoDB shell version v3.6.3 15connecting to: mongodb://127.0.0.1:27017 16MongoDB server version: 3.6.3 17Welcome to the MongoDB shell. 18For interactive help, type "help". 19For more comprehensive documentation, see 20 http://docs.mongodb.org/ 21Questions? Try the support group 22 http://groups.google.com/group/mongodb-user 23Server has startup warnings: 242018-03-06T01:08:44.032+0800 I STORAGE [initandlisten] 252018-03-06T01:08:44.032+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 262018-03-06T01:08:44.032+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 272018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] 282018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 292018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 302018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 312018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] 322018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 332018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server. 342018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 352018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 362018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 372018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 382018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] 392018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] 402018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 412018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 422018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] 432018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 442018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 452018-03-06T01:08:44.941+0800 I CONTROL [initandlisten] 46> use test; 47switched to db test 48> exit 49bye
成功!