我是航空钉的新手。 我已经使用Docker部署了Aerospike。 下面是我用来部署Aerospike服务器的命令。
docker run -d --name aerospike1 -p 3000:3000 aerospike/aerospike-server
docker ps输出:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1376791119a2 aerospike/aerospike-server "/entrypoint.sh asd" 13 minutes ago Up 13 minutes 0.0.0.0:3000->3000/tcp, 3001-3003/tcp aerospike1
但是,在连接时出现连接错误。
错误:
错误-8:无法连接到主机:localhost 3000错误-8:A 连接尝试失败,因为连接方未正确 一段时间后响应,或建立的连接失败 因为连接的主机无法响应
下面是我的代码
// Establish connection the server
AerospikeClient client = new AerospikeClient("localhost",3000);
// Create key
Key key = new Key("test", "credits", "123425");
//Key key = new Key("test", "foo", "123");
// Create Bins
Bin bin1 = new Bin("name", "Sam");
Bin bin2 = new Bin("age", 25);
Bin bin3 = new Bin("gender", "Male");
Bin bin4 = new Bin("department", "Engineering");
// Write record
client.Put(null, key, bin1, bin2, bin3, bin4);
// Read record
Record record = client.Get(null, key);
string s = record.GetGeoJSON("");
// Close connection
client.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}