我在Linux上部署Mongo时遇到了问题,在AWS上运行。
vim /etc/yum.repos.d/mongodb-org-3.0.repo
sudo yum install -y mongodb-org
Error: Package: mongodb-org-tools-3.0.12-1.amzn1.x86_64 (Mongodb-org-3.0)
Requires: libgcc_s.so.1(GCC_3.0)(64bit)
Error: Package: mongodb-org-mongos-3.0.12-1.amzn1.x86_64 (Mongodb-org-3.0)
Requires: /bin/bash
Error: Package: mongodb-org-server-3.0.12-1.amzn1.x86_64 (Mongodb-org-3.0)
Requires: openssl
因此我使用
下载了mongodb和untar的tar文件tar -xvzf mongodb-linux-x86_64-amazon-3.2.7.tgz
当我进入bin的目录并使用mongod或mongo命令时,它可以工作,但是尝试用作服务,它会出错。
cd mongodb-linux-x86_64-amazon-3.2.7/bin
root@ip-172-31-43-40:/mongodb-linux-x86_64-amazon-3.2.7/bin# service mongod start
mongod: unrecognized service
root@ip-172-31-43-40:/mongodb-linux-x86_64-amazon-3.2.7/bin#export PATH=$PATH:/mongodb-linux-x86_64-ubuntu1404-3.2.7/bin/
root@ip-172-31-43-40:/mongodb-linux-x86_64-ubuntu1404-3.2.7/bin# mongod
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] MongoDB starting : pid=21208 port=27017 dbpath=/data/db 64-bit host=ip-172-31-43-40
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] db version v3.2.7
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] modules: none
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] build environment:
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] distarch: x86_64
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-06-25T10:30:48.591+0000 I CONTROL [initandlisten] options: {}
2016-06-25T10:30:48.614+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-06-25T10:30:48.614+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.988+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-06-25T10:30:48.988+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2016-06-25T10:30:48.988+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-06-25T10:31:30.997+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:56229 #1 (1 connection now open)
在其他终端/控制台
root@ip-172-31-43-40:/mongodb-linux-x86_64-ubuntu1404-3.2.7/bin# mongoMongoDB shell version: 3.2.7
connecting to: test
Server has startup warnings:
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-25T10:30:48.987+0000 I CONTROL [initandlisten]
>
无法将mongod作为服务运行...因此想知道守护进程启动并持续运行所需的步骤(如服务)
答案 0 :(得分:1)
pid文件夹和文件权限似乎不能与默认守护程序一起使用。
最简单的解决方案是通过在配置文件中的行前放一个#来禁用pid文件。
vi /etc/mongod.conf
找到pidfilepath = / var / run / mongodb / mongod.pid的行并相应更改。
# pidfilepath=/var/run/mongodb/mongod.pid
有关评论内容的信息请点击此处查看。 http://docs.mongodb.org/manual/reference/configuration-options/#processManagement.pidFilePath