AeroSpike基本原理及概念

說明:分兩篇介紹,第一篇為基本概念介紹,第二篇為Java客戶端操作。

1、什么是AeroSpike?


??Aerospike是一個分布式,可擴展的NoSQL數(shù)據(jù)庫。T級別大數(shù)據(jù)高并發(fā)的結(jié)構(gòu)化數(shù)據(jù)存儲解決方案,讀寫操作達(dá)微妙級,99%的響應(yīng)可在1毫秒內(nèi)實現(xiàn),99.9%的響應(yīng)可在5毫秒內(nèi)實現(xiàn)。
??采用混合架構(gòu),索引存儲在 RAM 中,而數(shù)據(jù)存儲在閃存/固態(tài)硬盤(SSD) 上,自動感知集群,可以隨意增加節(jié)點線性擴容,無需分片,無需人工干預(yù)(性能與節(jié)點成正比上升),支持多語言集成;與redis相比不太會遇到性能瓶頸,客戶端SQL介入對RDBMS支持友好,對玩轉(zhuǎn)數(shù)據(jù)庫的朋友來說,可以無縫接入。
??缺點嗎?半開源狀態(tài),免費的有社區(qū)版下載,企業(yè)版是收費的,居說社區(qū)版不太穩(wěn)定(本人使用感覺還很OK)。
??架構(gòu)概述可參考:https://www.aerospike.com/docs/architecture/index.html

2、基本概念介紹


??大家可以自行下載world.js文件打開看一下源碼,這里只拿出一行核心代碼說明,registerMap里面的world.json就是我們要自定義的json(原world.js中world.json參數(shù)位置坐標(biāo)是不包含中國省份的),這里我們要做的就是把中國省份地理坐標(biāo)加入,因為registerMap支持的是標(biāo)準(zhǔn)的geo坐標(biāo)系(不了解的可自行搜索),關(guān)于中國省份的坐標(biāo),大家可以從網(wǎng)上自行下載china.js,很容易找到,記得要稍微轉(zhuǎn)換一下格式。
? namespace 策略容器,類似RDBMS中的schema,可以設(shè)置副本數(shù)、內(nèi)存大小、有效時長、存儲引擎、文件存儲位置。
? Sets 類似RDBMS中的表。
? Records 類似RDBMS中的行,行級的失效時間(TTL)。
? Bin 類似RDBMS中的列,一行可以有多個bins。

Aerospike Mysql
namespace database
set table
bin column
record row
key pk

Aerospike支持的數(shù)據(jù)類型(v3.6+):早期的版本可能不太一樣。
? integers
? doubles
? strings
? blobs
? lists
? maps
? geoJSON
? natively serialized types

3、坑爹的限制遵守


Aerospike server item limits
namespace名稱 <= 31個字符(名稱空間名稱中不允許使用’:‘或’;’)
命名空間中所有鍵的總分類數(shù) < 32 K
命名空間中的總二級索引 <= 256 indices
每個鍵的bin < 32 K
索引名稱 <= 255個字符(索引名稱中不允許使用’:‘或’;’)
hist-track-back 86400秒(切片10秒)
復(fù)制因子 =節(jié)點數(shù)是集群
命名空間的每個文件或磁盤的最大可配置大小 = 2 TiB
接口數(shù)量 <= 500(對于3.15之前的服務(wù)器版本,限制為50)

4、下載安裝


上傳文件:aerospike-server-community-3.9.1.1-el6.zip
解壓:unzip aerospike-server-community-3.9.1.1-el6.zip
添加執(zhí)行權(quán)限:
cd  aerospike-server-community-3.9.1.1-el6
chmod  a+x  asinstall
chmod  a+x  aerospike-tools-deps/install.sh
執(zhí)行腳本安裝:./asinstall
默認(rèn)安裝目錄:/etc/aerospike

4.1、aerospike.conf 配置


??參數(shù)說明參考配置中注解 。

# Aerospike database configuration file.
service {
    user root
    group root
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
    pidfile /var/run/aerospike/asd.pid
    service-threads 4
    transaction-queues 4
    transaction-threads-per-queue 4
    proto-fd-max 15000
}
logging {
    # Log file must be an absolute path.
    file /home/plugin/logs/aerospike.log {
        context any info
    }
}
network {
    service {
        address any
        port 3000
                access-address 192.168.75.142
    }
    heartbeat {
        # To use unicast-mesh heartbeats, remove the 3 lines above, and see
        # aerospike_mesh.conf for alternative.
                mode mesh         #mesh模式配置
                port 3002
                address 192.168.75.142
               # mesh-seed-address-port vmhost 3002
        interval 150
        timeout 10
    }
    fabric {
        port 3001
    }
    info {
        port 3003
    }
}
namespace testMemory {
    replication-factor 1 #備份副本1個
    memory-size 1G
    default-ttl 30d # 有效期30天,設(shè)置0為永久有效
    storage-engine memory
}

namespace testFile {
        replication-factor 1
        memory-size 1G
        default-ttl 30d # 30 days, use 0 to never expire/evict.
        storage-engine device {
               file /home/plugin/logs/aerospike.data
               filesize 2G
               data-in-memory true # 內(nèi)存和文件中同時存儲.

       }
}

4.2、啟動


service aerospike start –啟動
service aerospike status–查看狀態(tài)
service aerospike restart –重啟動
service aerospike stop –關(guān)閉
說明:確保配置文件的目錄是存在的,否則你可能會看到下面的異常
WARN Failed to connect to seed 127.0.0.1:3000. AEROSPIKE_ERR_CLIENT Socket write error: 111  

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容