EPEL MongoDB will not start on EC2 Amazon AMI

2019-05-07 09:02发布

问题:

Using Amazon Linux AMI 2013.09.2 - ami-bba18dd2 (64-bit)

I want to use the mongodb provided by EPEL because it is compiled with SSL support.

[root@domU-12-31-39-02-19-B8 ec2-user]# yum install mongodb-server
Installed:
  mongodb-server.x86_64 0:2.4.6-1.el6                                           

Dependency Installed:
<snip>
Complete!

It seems like it installs with no errors.

When I start the mongod, all I get is this cryptic error.

[root@domU-12-31-39-02-19-B8 ec2-user]# mongod
mongod --help for help and startup options
mongod: symbol lookup error: mongod: undefined symbol: _ZN7pcrecpp2RE4InitEPKcPKNS_10RE_OptionsE

The only direction I see is to download the binaries directly from mongodb. Again, I would prefer the EPEL version because it contains ssl support

https://askubuntu.com/questions/180319/mongod-fails-to-start-with-error-mongod-symbol-lookup-error-mongod-undefined

Is there a way to get the EPEL version to work?

回答1:

The biggest point was that I wanted the SSL option enabled. I couldn't find any simple answers, so I hope this helps anyone else venturing down this road.

The version from EPEL with the option enabled is built with an incompatible version of pcre-devel the Amazon AMI gets from the amzn1 linux repo.

I simply rebuilt the mongodb binary from the EPEL source RPM and the resulting RPM installed and worked fine.

Had to pull down other packages to do it.

yum install rpm-build redhat-rpm-config gcc  gcc-c++ make yum install openssl-devel snappy-devel v8-devel boost-devel python-devel python-nose scons pcre-devel readline-devel libpcap-devel gperftools-devel –y

rpmbuild --rebuild mongodb-2.4.6-1.el6.src.rpm
rpmbuild --rebuild python-pymongo-2.5.2-3.el6.src.rpm 
rpmbuild --rebuild v8-3.14.5.10-3.el6.src.rpm 

The packages are posted publicly for anyone else who struggles with this and to stay consistent with the AGPL license.

It took almost 45 minutes for it to rebuild, so I put up a small repo so that I don't have to rebuild every new instance as well as some instructions if others want to use any of it.

Instructions: http://mongodb.ssl.amzn1.bauman.in

wget http://mongodb.ssl.amzn1.bauman.in/mongodb.ssl.amzn1.bauman.in.repo
sudo mv mongodb.ssl.amzn1.bauman.in.repo /etc/yum.repos.d/mongodb.ssl.amzn1.bauman.in.repo
sudo yum install mongodb-server mongodb python-pymongo python-pymongo-gridfs -y

Repo file: http://mongodb.ssl.amzn1.bauman.in/mongodb.ssl.amzn1.bauman.in.repo



回答2:

You were absolutely right in recompiling.

The error was caused by libpcre changing the signature of RE::Init() to only take a std::string, rather than a char*. This is fixed if you get a newer version of libpcrecpp, which adds the old interface for backwards compat.

If you're good at deciphering C++ symbols, this is obvious.

[ worr on setzer ] ( ~ ) % nm -D /usr/lib64/libpcrecpp.so.0 | grep Init
0000000000005700 T _ZN7pcrecpp2RE4InitEPKcPKNS_10RE_OptionsE
0000000000005670 T _ZN7pcrecpp2RE4InitERKSsPKNS_10RE_OptionsE

The only difference between the names is Ss vs c, which is indicative of the argument types. Ss means std::string and c means char*.

Hope that gives you a good answer as to why this happened.



回答3:

This answer is more than 1 year ago, but it seems same problem is still exists. Good news is mongodb.org has a pre-compiled rpm packeages for Amazon Linux. just follows instruction on MongoDB document.