After giving the foundation for why I started this project in part one I will now show the steps and give the code for installing MongoDB v2.1.1 on the Raspberry Pi, but first listed are some perquisites.
- SSH access to the Raspberry Pi, technically not needed but very helpful.
- A text editor that can open and search through a directory of files. I used TextWrangler.
- Some other computer to change and modify files prior to building MongoDB. I used a mac and I suggests using some other Unix like system.
- And just as a note some of commands I included a the unix command prompt other commands are just listed the command without showing the command prompt.
1. Geting MongoDB.
I used git hub for this. I would do this on the second Unix system.
git clone git://github.com/mongodb/mongo.git
2. Make sure version r2.1.1 is in the git hub repository.
cd mongo
git tag -l
3. Check out version r2.1.1.
git chekcout r2.1.1
4. Change TIME_UTC
for newer gcc and boost capability:
Open the whole mongo folder in a text editor and do a find/replace in all files under the mongo folder for reference to TIME_UTC
and replace it with TIME_UTC_
there will be just over 60 reference instances of this macro.
5. Update the inline assembly for atomic integers atomic_int.h
I have included the whole file atomic_int.h so just copy this code and paste into original atomic_int.h file replacing the original code.
Before I list the code I would like to give thanks to soywiz for posting the majority of this code on this mongodb forum http://jira.mongodb.org/browse/SERVER-1811
The file is located:
[system@root~]# mongo/src/mongo/bson/util/atomic_int.h
The code is listed at the end of the steps.
6. Zip mongo directory and scp to Rasberry Pi.
[system@root~]# scp mongo.zip root@ipaddress:~/some_upload_dir
7. Compile and install mongodb: ADVISORY: it may take over 24 hours to compile and install.
If you don't want to compile all option please visit the MongoDB website for further options.
scons all
scons --prefix=/opt/mongo install
Change the prefix options to install MongoDB in the location of your choice.
- // atomic_int.h
- // atomic wrapper for unsigned
- /* Copyright 2009 10gen Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #pragma once
- namespace mongo {
- struct AtomicUInt {
- AtomicUInt() : x(0) {}
- AtomicUInt(unsigned z) : x(z) { }
- operator unsigned() const { return x; }
- unsigned get() const { return x; }
- inline AtomicUInt operator++(); // ++prefix
- inline AtomicUInt operator++(int);// postfix++
- inline AtomicUInt operator--(); // --prefix
- inline AtomicUInt operator--(int); // postfix--
- // inline void zero();
- inline void zero() { x = 0; } // TODO: this isn't thread safe
- volatile unsigned x;
- };
- #if defined(__ARMEL__) || defined(__ARM_ARCH_5T__) || defined(__ARM_PCS) || defined(__ARM_EABI__)
- #define arm_atomic_add_inline(ptr, val) \
- ({ register unsigned int *__ptr asm("r2") = (ptr); \
- register unsigned int __result asm("r1"); \
- asm volatile ( \
- "1: @ atomic_add\n\t" \
- "ldr r0, [r2]\n\t" \
- "mov r3, #0xffff0fff\n\t" \
- "add lr, pc, #4\n\t" \
- "add r1, r0, %2\n\t" \
- "add pc, r3, #(0xffff0fc0 - 0xffff0fff)\n\t" \
- "bcc 1b" \
- : "=&r" (__result) \
- : "r" (__ptr), "rIL" (val) \
- : "r0","r3","ip","lr","cc","memory" ); \
- __result; })
- #define atomic_int_helper(ptr, val) \
- (arm_atomic_add_inline(ptr, (val)) - (val))
- inline void AtomicUInt::set(unsigned newX) { asm volatile("" ::: "memory"); x = newX; }
- AtomicUInt AtomicUInt::operator++() {
- return atomic_int_helper((unsigned *)&x, 1)+1;
- }
- AtomicUInt AtomicUInt::operator++(int) {
- return atomic_int_helper((unsigned *)&x, 1);
- }
- AtomicUInt AtomicUInt::operator--() {
- return atomic_int_helper((unsigned *)&x, -1)-1;
- }
- AtomicUInt AtomicUInt::operator--(int) {
- return atomic_int_helper((unsigned *)&x, -1);
- }
- #else
- #error "unsupported compiler or platform"
- #endif
- } // namespace mongo
Comments
Commenting is closed for this article.