AeroSpike基本原理及概念

说明:分两篇介绍,第一篇为基本概念介绍,第二篇为Java客户端操作。

1、什么是AeroSpike?


  Aerospike是一个分布式,可扩展的NoSQL数据库。T级别大数据高并发的结构化数据存储解决方案,读写操作达微妙级,99%的响应可在1毫秒内实现,99.9%的响应可在5毫秒内实现。
  采用混合架构,索引存储在 RAM 中,而数据存储在闪存/固态硬盘(SSD) 上,自动感知集群,可以随意增加节点线性扩容,无需分片,无需人工干预(性能与节点成正比上升),支持多语言集成;与redis相比不太会遇到性能瓶颈,客户端SQL介入对RDBMS支持友好,对玩转数据库的朋友来说,可以无缝接入。
  缺点吗?半开源状态,免费的有社区版下载,企业版是收费的,居说社区版不太稳定(本人使用感觉还很OK)。
  架构概述可参考:https://www.aerospike.com/docs/architecture/index.html

2、基本概念介绍


  大家可以自行下载world.js文件打开看一下源码,这里只拿出一行核心代码说明,registerMap里面的world.json就是我们要自定义的json(原world.js中world.json参数位置坐标是不包含中国省份的),这里我们要做的就是把中国省份地理坐标加入,因为registerMap支持的是标准的geo坐标系(不了解的可自行搜索),关于中国省份的坐标,大家可以从网上自行下载china.js,很容易找到,记得要稍微转换一下格式。
namespace 策略容器,类似RDBMS中的schema,可以设置副本数、内存大小、有效时长、存储引擎、文件存储位置。
Sets 类似RDBMS中的表。
Records 类似RDBMS中的行,行级的失效时间(TTL)。
Bin 类似RDBMS中的列,一行可以有多个bins。

AerospikeMysql
namespacedatabase
settable
bincolumn
recordrow
keypk

Aerospike支持的数据类型(v3.6+):早期的版本可能不太一样。
integers
doubles
strings
blobs
lists
maps
geoJSON
natively serialized types

3、坑爹的限制遵守


Aerospike server itemlimits
namespace名称<= 31个字符(名称空间名称中不允许使用’:‘或’;’)
命名空间中所有键的总分类数< 32 K
命名空间中的总二级索引<= 256 indices
每个键的bin< 32 K
索引名称<= 255个字符(索引名称中不允许使用’:‘或’;’)
hist-track-back86400秒(切片10秒)
复制因子=节点数是集群
命名空间的每个文件或磁盘的最大可配置大小= 2 TiB
接口数量<= 500(对于3.15之前的服务器版本,限制为50)

4、下载安装


上传文件:aerospike-server-community-3.9.1.1-el6.zip
解压:unzip aerospike-server-community-3.9.1.1-el6.zip
添加执行权限:
cd  aerospike-server-community-3.9.1.1-el6
chmod  a+x  asinstall
chmod  a+x  aerospike-tools-deps/install.sh
执行脚本安装:./asinstall
默认安装目录:/etc/aerospike

4.1、aerospike.conf 配置


  参数说明参考配置中注解 。

# 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天,设置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 # 内存和文件中同时存储.

       }
}

4.2、启动


service aerospike start –启动
service aerospike status–查看状态
service aerospike restart –重启动
service aerospike stop –关闭
说明:确保配置文件的目录是存在的,否则你可能会看到下面的异常
WARN Failed to connect to seed 127.0.0.1:3000. AEROSPIKE_ERR_CLIENT Socket write error: 111  

4.3、查看


更多可关注

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值