Aerospike 安装使用

2022-06-21 00:00:00 集群 节点 测试 分区 配置

1 install
1 安装 centos 类似

wget -O aerospike.tgz 'https://www.aerospike.com/download/server/latest/artifact/ubuntu16'

tar -xvf aerospike.tgz

cd aerospike-server-communityOrEnterprise-aerospikeVersion-ubuntuVersion

mv aerospike-server-communityOrEnterprise-aerospikeVersion-ubuntuVersion aerospike

sudo ./asinstall

启动:

service aerospike start

service aerospike restart

service aerospike stop

service aerospike status

或者:

On certain Linux distributions based on systemd (currently the Red Hat EL7-based family, including Red Hat Enterprise Linux 7, CentOS 7, Fedora 15+, Debian 8+, and Ubuntu 16.04+), the Aerospike daemon and server logs are managed using the standard systemd tools, systemctl and journalctl, rather than via the Aerospike SysV init script.

2 配置

as配置文件:

/etc/aerospike/aerospike.conf

3 日志文件:

For systemd based system, the logs by default are configured to go to the console: 默认控制台 console

You can find out all available context using asinfo, via the log command.

动态调整日志级别:

It is also possible to change the logging level dynamically on the node by using asinfo. Please see log-set.

现有日志:

For finding the logs location of a running instance, you can either check the config file or run

asinfo -v logs

安装日志旋转

sudo apt-get install logrotate

配置日志文件转储,压缩,TTL,后缀等

/etc/logrotate.d/aerospike

4 存储文件

Aerospike uses a number of directories to store tools, system files, and data files. This page describes the directories in use, although they are typically managed through Aerospike tools, should you wish to manually manage these files

4.1 基准测试

https://www.aerospike.com/docs/client/java/benchmarks.html

4.2 机器购买

https://wiki.duduyixia.com/confluence/display/jishu/aerospike

当前节点数:2

节点服务器:

ip1(待填)

ip2(待填)

每个节点服务器:

8Core

内存64G

挂载1块1T的高速ssd磁盘(如果2 * 512G的ssd比一块1T的便宜,则挂载4块512G的ssd) // 1T SSD云盘

数据副本数设置:2(就算将来添加新的node,也设置为2)

数据在硬盘模式

2 run
2.1 maven依赖:

<dependency>

<groupId>com.aerospike</groupId>

<artifactId>aerospike-client</artifactId>

<version>4.1.11</version>

</dependency>

<dependency>

<groupId>com.aerospike</groupId>

<artifactId>aerospike-client-bc</artifactId>

<version>4.1.11</version>

</dependency>

2.2 demo

package com.sharedaka.venus.tool;

import com.aerospike.client.AerospikeClient;

import com.aerospike.client.Bin;

import com.aerospike.client.Key;

import com.aerospike.client.Record;

import com.aerospike.client.policy.WritePolicy;

public class AerospikeTool {

private static AerospikeClient client = new AerospikeClient("47.105.162.XXX", 3000);

public static void main(String[] args) throws InterruptedException {

// Initialize policy.

WritePolicy policy = new WritePolicy();

// 2秒 异常

// policy.expiration = 2;

// 50 millisecond timeout.

policy.setTimeout(50);

// Write single value.

Key key = new Key("test", "myset", "mykey");

Bin bin = new Bin("mybin", "myvalue");

// Write multiple values.

Bin bin1 = new Bin("name", "John");

Bin bin2 = new Bin("age", 25);

client.put(policy, key, bin);

client.put(policy, key, bin1);

client.put(policy, key, bin2);

Record record = client.get(policy, key);

System.out.println(record);

System.out.println(record.getTimeToLive());

System.out.println(record.bins);

// Set bin value to null to drop bin.

Bin bin3 = Bin.asNull("name");

client.put(policy, key, bin3);

Thread.sleep(2000);

record = client.get(policy, key);

System.out.println(record);

System.out.println(record.getTimeToLive());

System.out.println(record.bins);

}

}

参考:https://www.aerospike.com/docs/operations/plan/ssd/ssd_setup.html

3 云盘操作
首先:Initialize the drives 磁盘清零操作;

sudo dd if=/dev/zero of=/dev/<deviceID> bs=1M&

while [ 1 ] do kill -USR1 27791 sleep 60 done 输出进度

然后:确定分区个数=cpu个数




后执行分区:

新增机器云盘SSD 1T 分8个分区步骤:

sudo fdisk /dev/vdb

p 查看

n --> e 默认 默认 新建逻辑分区一个 1T

n--> +128G

n--> +128G

n--> +128G

n--> +128G

n--> +128G

n--> +128G

n--> +128G

4 注意社区版本限制
一个节点多2个NameSpace,一个device只能属于一个NS 社区版各种限制 :https://www.aerospike.com/docs/guide/limitations.html



扩容时,加服务器,加namespae




5 基准测试


基准测试 https://www.aerospike.com/docs/client/java/benchmarks.html

测试源码:https://github.com/aerospike/aerospike-client-java/tree/master/benchmarks

1 环境准备

wget -O aerospike-tools.tgz 'https://www.aerospike.com/download/tools/latest/artifact/el8'

tar -xvf aerospike-tools.tgz

sudo ./asinstall

yum list installed | grep aerospike-tools

sudo yum install python27 //安装py

yum install java-1.8.0-openjdk //安装jdk

2 测试结果

Example 1

Connect to localhost:3000 using test namespace.
Read 10% and write 90% of the time using 20 concurrent threads.
Use 100000000 integer keys (starting at "1") and 50 character string values.
Benchmark synchronous methods.
asbenchmark -h 127.0.0.1 -p 3000 -n test -k 100000000 -S 1 -o S:50 -w RU,10 -z 20





6 线上配置注意事项

# Aerospike database configuration file for use with systemd.

service {

paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.

proto-fd-max 15000

}

logging {

file /root/logs/aerospike/aerospike.log {

context any warning # 注意 warning 非 warn级别

}

}

network {

service {

address 172.31.146.51

port 3000

# add current node address here

access-address 172.31.146.51 3002 # 本实例的集群节点接口

}

heartbeat {

mode mesh

# current node

address 172.31.146.51

port 3002

# all cluster node

mesh-seed-address-port 172.31.146.51 3002 # 本实例的集群节点接口

mesh-seed-address-port 172.31.146.52 3002 # 其他实例的集群节点接口

interval 150

timeout 10

}

fabric {

address 172.31.146.51 # Intra-cluster communication port (migrates, replication, etc).

port 3001

}

info {

address 172.31.146.51 # Plain text telnet management port.

port 3003

}

}

namespace test {

replication-factor 2

memory-size 4G # test测试域名 内存测试完,使用记得修改回去4G

storage-engine memory

}

namespace algo {

replication-factor 2

memory-size 48G

storage-engine device { # Configure the storage-engine to use persistence

device /dev/vdb5 # 注意磁盘分区 cpu个数=分区数

device /dev/vdb6

device /dev/vdb7

device /dev/vdb8

device /dev/vdb9

device /dev/vdb10

device /dev/vdb11

device /dev/vdb12 # raw device. Maximum size is 2 TiB

write-block-size 128K # adjust block size to make it efficient for SSDs.

}

}

#namespace bar {

# replication-factor 2

# memory-size 4G

# storage-engine memory

# To use file storage backing, comment out the line above and use the

# following lines instead.

# storage-engine device {

# file /opt/aerospike/data/bar.dat

# filesize 16G

# data-in-memory true # Store data in memory in addition to file.

# }

#}

7 日志配置
1 认知

systemd and non-systemd

https://cloud.tencent.com/developer/article/1516125

2.0 级别

Severity

Meaning

critical

Critical error messages

warning

Warning messages

info

Informational messages

debug

Debugging information

detail

Verbose debugging information

2 配置 asinfo 查看系统配置

/etc/logrotate.d/aerospike

/root/logs/aerospike/aerospike.log { daily rotate 90 dateext compress olddir /var/log/aerospike/ sharedscripts postrotate /bin/kill -HUP `pidof asd` endscript }




3 测试

Force run a logrotate to test

sudo logrotate -f -v /etc/logrotate.d/aerospike

4注意事项






8 监控
1 amc 下载

wget -O amc.rpm https://www.aerospike.com/download/amc/4.0.27/artifact/el6

wget -O amc.deb https://www.aerospike.com/download/amc/4.0.27/artifact/ubuntu12

2 安装centos

sudo dpkg -i amc.deb

sudo /etc/init.d/amc start || stop || restart || status

或者使用sysmtd

sudo systemctl start amc

sudo systemctl stop amc

sudo systemctl restart amc

sudo systemctl status amc

3 配置文件备份

sudo cp /etc/amc/amc.conf /etc/amc/amc.conf.bac

4 配置集群

[amc.clusters]

[amc.clusters.clusterone] # unused

host = "172.31.146.51"

port = 3000

show_in_ui = true # optional (needed to be visible in MultiCluster view)

[amc.clusters.clustertwo] # unused

host = "172.131.146.52"

port = 3000

show_in_ui = true

alias = "clustertwo"

5 部署DNS等 访问

http://aerospike.duduyixia.com/

5 监视对于任何关键任务部署都是必不可少的。 它可以减少对硬件故障,网络问题和软件错误的操作响应时间。多种监控品类 如下


9 配置模板


1 172.16.208.120 节点配置

# Aerospike database configuration file for use with systemd.

# 172.16.208.120 local ip

service {

paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.

proto-fd-max 15000

}

logging {

file /root/logs/aerospike/aerospike.log {

context any warning

}

}

network {

service {

address 172.16.208.120

port 3000

# add current node address here

access-address 172.16.208.120 3002

}

heartbeat {

mode mesh

# current node

address 172.16.208.120

port 3002

# all cluster node

mesh-seed-address-port 172.16.208.120 3002

mesh-seed-address-port 172.16.208.121 3002

interval 150

timeout 10

}

fabric {

address 172.16.208.120

port 3001

}

info {

address 172.16.208.120

port 3003

}

}

namespace algo2 {

replication-factor 2

memory-size 30G

storage-engine device { # Configure the storage-engine to use persistence

device /dev/vdb5

device /dev/vdb6

device /dev/vdb7

device /dev/vdb8 # raw device. Maximum size is 2 TiB

write-block-size 1M # adjust block size to make it efficient for SSDs.

}

}

namespace algo {

replication-factor 2

memory-size 30G

storage-engine device { # Configure the storage-engine to use persistence

device /dev/vdb1

device /dev/vdb2

device /dev/vdb3

device /dev/vdb4 # raw device. Maximum size is 2 TiB

write-block-size 1M # adjust block size to make it efficient for SSDs.

}

}

#namespace bar {

# replication-factor 2

# memory-size 4G

# storage-engine memory

# To use file storage backing, comment out the line above and use the

# following lines instead.

# storage-engine device {

# file /opt/aerospike/data/bar.dat

# filesize 16G

# data-in-memory true # Store data in memory in addition to file.

# }

#}

2 172.16.208.121 节点配置

# Aerospike database configuration file for use with systemd.

# 172.16.208.121 local ip

service {

paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.

proto-fd-max 15000

}

logging {

file /root/logs/aerospike/aerospike.log {

context any warning

}

}

network {

service {

address 172.16.208.121

port 3000

# add current node address here

access-address 172.16.208.121 3002

}

heartbeat {

mode mesh

# current node

address 172.16.208.121

port 3002

# all cluster node

mesh-seed-address-port 172.16.208.120 3002

mesh-seed-address-port 172.16.208.121 3002

interval 150

timeout 10

}

fabric {

address 172.16.208.121

port 3001

}

info {

address 172.16.208.121

port 3003

}

}

namespace algo2 {

replication-factor 2

memory-size 30G

storage-engine device { # Configure the storage-engine to use persistence

device /dev/vdb5

device /dev/vdb6

device /dev/vdb7

device /dev/vdb8 # raw device. Maximum size is 2 TiB

write-block-size 1M # adjust block size to make it efficient for SSDs.

}

}

namespace algo {

replication-factor 2

memory-size 30G

storage-engine device { # Configure the storage-engine to use persistence

device /dev/vdb1

device /dev/vdb2

device /dev/vdb3

device /dev/vdb4 # raw device. Maximum size is 2 TiB

write-block-size 1M # adjust block size to make it efficient for SSDs.

}

}

#namespace bar {

# replication-factor 2

# memory-size 4G

# storage-engine memory

# To use file storage backing, comment out the line above and use the

# following lines instead.

# storage-engine device {

# file /opt/aerospike/data/bar.dat

# filesize 16G

# data-in-memory true # Store data in memory in addition to file.

# }

#}
————————————————
版权声明:本文为CSDN博主「平静不绝望」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qfzhangwei/article/details/119815059

相关文章