环境:
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
![](https://img.haomeiwen.com/i1899977/1c7b218d73f2bce5.png)
2、初始化Aerospike
cd aerospike
sudo ./asinstall
![](https://img.haomeiwen.com/i1899977/c2f036d36b0a1f29.png)
3、Aerospike启动、重启、停止、查看状态
service aerospike start
service aerospike restart
service aerospike stop
service aerospike status
![](https://img.haomeiwen.com/i1899977/cb013f3f873f3a65.png)
4、Aerospike配置
cd /etc/aerospike/
vim aerospike.conf
![](https://img.haomeiwen.com/i1899977/ef9e3ec71a51c87f.png)
把配置文件aerospike.conf最后的命名空间修改为你的命名空间,具体配置根据机器空间和需要而定
![](https://img.haomeiwen.com/i1899977/4ad40194dfa1d271.png)
修改好,保存退出并重启Aerospike
5、asmonitor命令
在终端下输入命令
asmonitor
![](https://img.haomeiwen.com/i1899977/c70803816c8a61af.png)
在Monitor下查看Aerospike集群信息,如节点个数、内存使用情况等:
info
![](https://img.haomeiwen.com/i1899977/8eb88ecb163bbb0b.png)
6、asadm命令
在终端下输入命令
asadm
![](https://img.haomeiwen.com/i1899977/452f2b741675405b.png)
在asadm下查看集群节点情况
i net
![](https://img.haomeiwen.com/i1899977/f08888a2d79678a9.png)
7、aql命令
在终端下输入命令
aql
![](https://img.haomeiwen.com/i1899977/1869cd5bf9351a90.png)
进入aql命令模式下就可以使用如图SQL语句中DDL和DML语句进行创建命名空间。这里的命名空间相当于数据库中的表。
查看命名空间
show namespaces;
![](https://img.haomeiwen.com/i1899977/c48faba4d2e48860.png)
查询
select * from test
如果执行select语句报错Error: (11) AEROSPIKE_ERR_CLUSTER,则是由于在该网段中已经有Aerospike启动了
![](https://img.haomeiwen.com/i1899977/ca307a33dadbe1f6.png)
因为aerospike.conf中使用了默认配置
![](https://img.haomeiwen.com/i1899977/0e78c0ed11119abe.png)
其中multicast表示在同一网段中广播,所有使用相同address和port的Aerospike会自动组合成集群。但在Aerospike集群中,如果namespace名称相同,配置不同则会报错。解决方法可以把IP地址换成其他的,如139.1.99.222。
修改好后,然后重新查询
![](https://img.haomeiwen.com/i1899977/57a3adecaebdaecc.png)
插入数据
insert into test(pk,id,name,age) values('key1','101','AAA','21');
insert into test(pk,id,name,age) values('key2','102','BBB','18');
![](https://img.haomeiwen.com/i1899977/e88f92bad676aa95.png)
当然有些列可以空着不写
insert into test(pk,id,name) values('key3','103','CCC');
![](https://img.haomeiwen.com/i1899977/35631d6439706280.png)
删除数据
delete from test where pk='key2'
![](https://img.haomeiwen.com/i1899977/78c48d0f11f62995.png)
网友评论
我的AS版本是和博主同一个版本,这是为什么呀?