Linux下安装Aerospike
2016-07-06 本文已影响2595人
lynch0571
环境:
1、操作系统:CentOS release 6.8 (Final)
2、安装版本: aerospike-3.5.9.tgz
1、解压安装包并重命名
tar zxvf aerospike-3.5.9.tgz
mv aerospike-server-community-3.5.9-el6/ aerospike

2、初始化Aerospike
cd aerospike
sudo ./asinstall

3、Aerospike启动、重启、停止、查看状态
service aerospike start
service aerospike restart
service aerospike stop
service aerospike status

4、Aerospike配置
cd /etc/aerospike/
vim aerospike.conf

把配置文件aerospike.conf最后的命名空间修改为你的命名空间,具体配置根据机器空间和需要而定

修改好,保存退出并重启Aerospike
5、asmonitor命令
在终端下输入命令
asmonitor

在Monitor下查看Aerospike集群信息,如节点个数、内存使用情况等:
info

6、asadm命令
在终端下输入命令
asadm

在asadm下查看集群节点情况
i net

7、aql命令
在终端下输入命令
aql

进入aql命令模式下就可以使用如图SQL语句中DDL和DML语句进行创建命名空间。这里的命名空间相当于数据库中的表。
查看命名空间
show namespaces;

查询
select * from test
如果执行select语句报错Error: (11) AEROSPIKE_ERR_CLUSTER,则是由于在该网段中已经有Aerospike启动了

因为aerospike.conf中使用了默认配置

其中multicast表示在同一网段中广播,所有使用相同address和port的Aerospike会自动组合成集群。但在Aerospike集群中,如果namespace名称相同,配置不同则会报错。解决方法可以把IP地址换成其他的,如139.1.99.222。
修改好后,然后重新查询

插入数据
insert into test(pk,id,name,age) values('key1','101','AAA','21');
insert into test(pk,id,name,age) values('key2','102','BBB','18');

当然有些列可以空着不写
insert into test(pk,id,name) values('key3','103','CCC');

删除数据
delete from test where pk='key2'
