Because the shell operation MONGO more troublesome, had to try to use Perl operation Mongo,perl need to operate MongoDB must first install the appropriate driver, most people use CPAN installation, personal feel too troublesome, use Cpanm install Perl module.
Copy Code code as follows:
# CPANM MongoDB
--> Working on MongoDB
Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.1.tar.gz ... Ok
Configuring MongoDB-0.702.1 ... Ok
Building and Testing MongoDB-0.702.1 ... FAIL
! Installing MongoDB failed. See/root/.cpanm/work/1376540233.15152/build.log for details. Retry with--force to force install it.
CPANM the error, use the –force parameter
Copy Code code as follows:
# CPANM MongoDB--force
--> Working on MongoDB
Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.1.tar.gz ... Ok
Configuring MongoDB-0.702.1 ... Ok
Building and Testing MongoDB-0.702.1 ... FAIL
! Testing MongoDB-0.702.1 failed but installing it anyway.
Successfully installed MongoDB-0.702.1 (upgraded from 0.702.0)
1 Distribution Installe
Everything seems to be in good condition. Test scripts
Script content:
Copy Code code as follows:
# cat/root/testmongo.pl
#!/usr/bin/perl
Use MongoDB;
My $connection = mongodb::connection->new (host => ' localhost ', port => 27017);
Run:
Copy Code code as follows:
# perl/root/testmongo.pl
/usr/bin/perl:symbol Lookup Error:/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/mongodb/ MongoDB.so:undefined Symbol:heutf8
Google query "MongoDB.so:undefined Symbol:heutf8", only found a related article. A group of people discussed the problem. One of the solutions for this one is as follows:
Copy Code code as follows:
# wget http://search.cpan.org/CPAN/authors/id/F/FR/FRIEDO/MongoDB-0.701.4.tar.gz
# TAR-XZVF Mongodb-0.701.4.tar.gz
# CD MongoDB-0.701.4
Add the following to Perl_mongo.h:
/* Supply HeUTF8 if it ' s missing-ppport.h doesn ' t supply it, unfortunately * *
#ifndef HeUTF8
#define HEUTF8 (Heklen (HE) = Hef_svkey)? \
SvUTF8 (HEKEY_SV (HE)): \
(U32) HeKUTF8 (He))
#endif
# Perl makefile.pl
# make
# make Install
Perl script runs OK.
In fact, because of incompatible issues, for the system Rhel5/centos5 release, the last version of MongoDB's Perl drive is v0.45
The following is a reply from a foreign netizen:
The latest version to compile, test and install properly on RHEL5/CENTOS5 was v0.45 by KRISTINA. (Requires Any::moose)
https://metacpan.org/release/KRISTINA/MongoDB-0.45