MongoDB SpiderMonkey doesn't understand UTF-8 - mongodb

If I add non-ASCII characters to MongoDB database then all db.find() fail telling "non ascii character detected".
It's problem of SpiderMonkey, I have to rebuild it with UTF-8 support.
I've tried to do it like in
http://www.mongodb.org/display/DOCS/Building+Spider+Monkey
but it doesn't work (SpiderMonkey is not installed after I've completed all steps).
I've got Ubuntu 11.04. Does anybody have instruction how to make it work there?
Working instruction how to make work MongoDB with Google V8 can also help.

I'm using MongoDB on Ubuntu Server 11.04, installed it after making fresh OS install using this instruction: http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
Everything is working fine out of the box. Is it critical for you to build MongoDB from scratch?

Using the 10gen-published packages works fine, but if you actually want to compile SpiderMonkey from source with UFT-8 support:
curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvzf js185-1.0.0.tar.gz
cd js-1.8.5/js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
export CXXFLAGS="-DJS_C_STRINGS_ARE_UTF8"
And then follow the instructions from https://developer.mozilla.org/En/SpiderMonkey/Build_Documentation
autoconf-2.13
./configure
make
make install
cp js /usr/local/bin/
This will install into /usr/local/lib, however the mongodb package looks for it in /usr/lib (where the spidermonkey package is installed). So, we link all files installed to /usr/local /lib from /usr/lib
ln -s /usr/local/lib/libmozjs185.so /usr/lib/libmozjs185.so
ln -s /usr/local/lib/libmozjs185.so.1.0 /usr/lib/libmozjs185.so.1.0
ln -s /usr/local/lib/libmozjs185.so.1.0.0 /usr/lib/libmozjs185.so.1.0.0
ln -s /usr/local/lib/libmozjs185-1.0.a /usr/lib/libmozjs185-1.0.a
Of course you could just move them into /usr/lib instead of symlinking, but I wanted to keep the utf-enabled libs away from the default location, to prevent conflicts with the default spidermonkey package. Without the libmozjs package installed, apt complains that dependencies for mongodb are not satisfied, so I've left it installed.
Keep in mind that if the spidermonkey package gets upgraded, it can overwrite the symlinks to our new libs (or the libs themselves if you've moved them to /usr/local/lib). The ideal solution would be to build your own package to solve dependency issues for good.

Related

Mac M1 Homebrew Perl Carton Net::SSLeay is loading libcrypto in an unsafe way

I'm trying to install Net::SSLeay with Carton.
The installation fails with this message
Configuring Net-SSLeay-1.90 Running Makefile.PL Do you want to run external tests?
These tests *will* *fail* if you do not have network connectivity. [n] n
*** Found LibreSSL-2.8.3 installed in /usr
*** Be sure to use the same compiler and options to compile your OpenSSL, perl, and Net::SSLeay. Mixing and matching compilers is not supported.
Checking if your kit is complete... Looks good
WARNING: /opt/homebrew/Cellar/perl/5.32.1_1/bin/perl is loading libcrypto in an unsafe way -> N/A
I've tried this with system perl, brew perl and multiple perlbrew perls.
Google came up with a temp solution to build homebrew using x86_64 architecture.
This did work for the libcrypto error, but gave me a whole different set of issues including mysql not running anymore.
Other "solutions" that I've tried are symlinking libssl & libcrypto as suggested by numerous other posts, all sadly without success.
Any ideas how to fix this or work around this without having to reinstall all brew packages as x86_64 ?
Quick Workaround
If you are looking for a quick workaround follow these steps.
Run carton bundle to create a vendor cache directory.
Go to cached tarball 'cache/authors/id/C/CH/CHRISN/' and unpack tar -xvzf Net-SSLeay-1.90.tar.gz
Edit Makefile.PL, change my $prefix = find_openssl_prefix(); to
my $prefix = '/opt/homebrew/opt/openssl#1.1'; ** adjust to your openssl location.
Save and create new tarball tar -czvf Net-SSLeay-1.90.tar.gz Net-SSLeay-1.90
Run carton install --cached to use the altered version
Hope this helps anyone in search of workaround
You can solve this in two steps:
upgrade ExtUtils::MakeMaker to at least version 7.58 (e.g. cpanm ExtUtils::MakeMaker)
install openssl via macports (sudo port install openssl) or homebrew (brew install --cask openssl)
After the Monterey update this broke again also on the x86_64 architecture, but just symlinking your latest openssl (where ever it is, depending how you have installed it) seemed to fix this. Example:
$ export OPENSSL_PREFIX=[find your openssl installation]
$ sudo ln -s $OPENSSL_PREFIX/lib/libssl.dylib /usr/local/lib/
$ sudo ln -s $OPENSSL_PREFIX/lib/libcrypto.dylib /usr/local/lib/
Better workaround:
I entered export OPENSSL_PREFIX=/opt/homebrew/opt/openssl#1.1 in my shell and then ran cpan. I checked the code in Makefile.PL and the first thing the function find_openssl_prefix does is to check the OPENSSL_PREFIX environment variable. If it is set, then it the function will return its contents.
Add the variable to your .profile, .cshrc, .bashrc, .zshrc, or whatever rc file your shell uses and you never have to worry about it again!!

MongoDB php7 driver installation

I'm working on an Ubuntu 16 server and I can't seem to get the mongodb driver for php 7 to work. I installed it successfully on my xampp on my windows machine but Ubuntu and php7 seemingly have vast differences.
I did try to install it via pecl install mongodb and used composer to put in the dependencies but it still does not work. I'm using the same php file from my windows Xampp and when I access the page it throws a 500 status code.
Could someone provide a definitive walkthrough on how to install this driver and maybe also how to revert any changes I made using composer and pecl?
Cool even I tried with pecl but didn't work as expected. It work with pecl7 Also, I received this warning along with error, WARNING: "pecl/mongo" is deprecated in favor of "channel:///mongodb" pecl/mongo requires PHP (version >= 5.3.0, version <= 5.99.99), installed version is 7.1.8. Also, got 500 Internal server error.
Before that MongoDB php7 driver, I needed the memcache and getting phphize error that I solved using this repo. Then finally I use this low level PHP driver for MongoDB.
$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule sync && git submodule update --init
$ /usr/bin/phpize
$ ./configure
$ make all -j 5
$ sudo make install
You can confirm from the output that mongodb.so driver is installed.
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
extension=mongodb.so
Then only step remaining is make it available in your respective path. You can check your extensions_dir in php.ini with the following command,
$ php -i | grep extension_dir
extension_dir => /usr/lib64/php/7.0/modules => /usr/lib64/php/7.0/modules
And, I can verify that mongodb.so is present into the above directory. Then reload the composer and you are good to go ! Hope this helps as it work for me.

Setting up Mesos on CentOS

I tried to install the latest release tarball of Mesos on CentOS 6.4 with no luck. It ended up in all sorts of failures in trying to find jvm & jni bindings. Is there any instructions on how to install Mesos on RHEL or CentOS ?
I couldn't find any instructions around so I thought I would troubleshoot all through my way and thought of documenting it here so it can save your time.
First things first, load your CentOS box with essential build tools to get started
$ sudo yum groupinstall "Development tools"
Get Java and python dependencies installed
$ sudo yum install java-1.6.0-openjdk.x86_64 java-1.6.0-openjdk-devel.x86_64 python python-devel libcurl libcurl-devel
Get the latest Mesos tarball
$ wget http://mirror.nus.edu.sg/apache/mesos/0.13.0/mesos-0.13.0.tar.gz
$ tar -xzvf mesos-0.13.0.tar.gz
$ cd mesos-0.13.0
Before you can build Mesos, you need to set correct JAVA binding paths
$ export JAVA_HOME=/usr
$ export JAVA_LDFLAGS="-L/usr/lib/jvm/java-1.6.0/jre/lib/amd64/server -R/usr/lib/jvm/java-1.6.0/jre/lib/amd64/server -ljvm"
$ export JAVA_CPPFLAGS="-I/usr/lib/jvm/java-1.6.0/include -I/usr/lib/jvm/java-1.6.0/include/linux"
$ export LD_LIBRARY_PATH=/usr/lib/jvm/java-1.6.0/jre/lib/amd64/server:$LD_LIBRARY_PATH
Configure and build it
$ ./configure
$ make
After you have built Mesos, it is advisable that you build and run the tests, this will make sure that what you have installed meets all the requirements
$ make check
If the checks are successful, You are just one step away from installing it in your system installation paths
$ make install
To learn how to use Mesos , go here http://mesos.apache.org/gettingstarted/
For those who prefer installing from RPM's, here is a link to a number of different releases for different Linux flavors: http://mesosphere.io/downloads/ For example, for Centos64:
wget http://downloads.mesosphere.io/master/centos/6/mesos_0.14.2_x86_64.rpm
sudo rpm -Uvh mesos_0.14.2_x86_64.rpm
I also had to set my LD_LIBRARY_PATH, though to a slightly different value. Check yours.
Python bindings can also be downloaded from the first link above:
wget http://downloads.mesosphere.io/master/centos/6/mesos_0.14.2_x86_64.egg
sudo easy_install mesos_0.14.2_x86_64.egg

Installing Scala 2.9 nightly build

How to install Scala 2.9 nightly build on Ubuntu?
Just extract it someplace and make sure its bin subdirectory is on the PATH, as well as java.
You have to do it by hand. I usually put my builds in
/usr/share/scala
but there are other places that make sense. Anyway, I'd start off by
sudo mkdir /usr/share/scala
cd /usr/share/scala
tar zxf scala-2.9.0.r24301-b20110218020036.tgz
ln -s scala-2.9.0.r24301-b20110218020036 2.9
Now we've got Scala in place and we have a soft link to /usr/share/scala/2.9 that we can keep pointing at new builds as we unpack them.
If you have Ubuntu's out-of-date Scala installed, you'll probably want to replace or rename those commands. Ubuntu places Scala commands in /usr/local/bin/, so you need to re-point those to the right place:
sudo mv /usr/local/bin/scala /usr/local/bin/oldscala
sudo ln -s /usr/share/scala/2.9/bin/scala /usr/local/bin/scala
# same thing for scalac, fsc, scaladoc
and then you should be set. Ubuntu doesn't bother setting environment variables, and Scala works fine without it.

Why can't I install DBD::mysql so I can use it with Maatkit?

I'm trying to install Maatkit following the maatkit instructions. I can't get past having to install DBD::mysql. "Warning: prerequisite DBD::mysql 1 not found."
When I try to install DBD::mysql from cpan, I get very helpful "make had returned bad status, install seems impossible".
Perl is "v5.8.8 built for darwin-thread-multi-2level", the one that came with OS X. I also tried building from source with same result.
We need more of the error message. Most likely, you are missing the MySQL client development files. I don't know how to install these on OSX. Also see this older post on OSX 10.5.2 , in which some other failures with the mysql client libraries are found.
Possibly post this question with more parts of your error message at perlmonks.org, if stackoverflow doesn't allow for convenient pasting of your make session or rather the last 20 or 10 lines of it.
Some more Googling with site:perlmonks.org also finds this post which has some more details on things to watch out for when installing DBD::MySQL. Depending on how comfortable you feel with the installation, you might want to manually run the tests, supplying a test database and test user or even skip testing the module.
After a bit more googling, this worked for me:
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
sudo ln -s /usr/local/mysql/include /usr/local/mysql/include/mysql
sudo perl -MCPAN -e 'install Bundle::DBD::mysql'
press enter a bunch of times, then in your maatkit folder:
perl Makefile.PL
sudo make install
and you'll find the mk-* programs in /usr/local/bin/
You will want to install MySQL first. I usually use the binary packages they provide for OS X. The packages do include the headers and MySQL client libraries which DBD::MySQL requires. Once the MySQL package is installed, DBD::MySQL should install without issue.
Here is my output:
$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite DBD::mysql 1 not found.
Writing Makefile for maatkit
$ mysql --version
mysql Ver 14.12 Distrib 5.0.51b, for apple-darwin9.0.0b5 (i686) using readline 5.0
I notice that there are in effect DBD::MySQL packages in the fink repositories. For example:
ayaz#ayazs-macbook$ fink list | grep -i 'dbd-mysql'
dbd-mysql-pm586 3.0008-10 Perl5 Database Interface to MySQL
dbd-mysql-pm588 3.0008-10 Perl5 Database Interface to MySQL
Perhaps installing through fink one of those packages may help alleviate your troubles.
Also, and I cannot be certain of this, you may want to install for MySQL-5.x (if you have that version installed) the mysql15-dev and mysql15-shlibs packages. I installed those through fink thus:
$ sudo fink --use-binary-dist install mysql15-dev