mongodb pada ArchLinux ARM

Standard

Berikut adalah tahapan untuk menginstall paket mongodb untuk ArchLinux ARM pada Raspberry Pi (ALARM Pi) dari source yang ada di skrabban/mongo-nonx86. (ada yang mau coba build dari mongodb/mongo?)

  1. Install kebutuhan paket sudo pacman -Sy base-devel boost scons python-pymongo git [3] (Yang paket boost lupa apa aja, nanti diupdate lagi.)
  2. Clone dari repo. Kemudian masuk ke dalam folder mongo-nonx86.
  3. Fix permasalahan tentang TIME_UTC dengan menjalankan script berikut [2]. Pada dasarnya script berikut akan mengganti TIME_UTC menjadi TIME_UTC_ pada seluruh file yang terdapat di dalam source code [1].
    [code language=”bash”]for i in `grep -lr TIME_UTC`; do
    sed -i s/TIME_UTC/TIME_UTC_/ $i;
    done[/code]
  4. Sedikit perubahan pada file mongo-nonx86/src/mongo/bson/util/atomic_int.h sesuaikan dengan file dibawah ini [1].
    [code language=”c”]
    // 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
    [/code]

  5. Itulah beberapa kustomisasi yang perlu dilakukan, selanjutnya mulai proses install. Kedua proses berikut akan memakan waktu berjam-jam.
    sudo scons
    
    sudo scons --prefix=/opt/mongo install
  6. Selesai, mongodb akan terinstall di /opt/mongo

Referensi:

  1. Installing MongoDB on the Raspberry Pi, Part 2
  2. Re: [mongodb] Actual package version (2.0.7) doesn’t start
  3. Raspberry Pi MongoDB Installation – The working guide!

One thought on “mongodb pada ArchLinux ARM

Leave a Reply

Your email address will not be published. Required fields are marked *