How I can change the port number of my Aerospike DB?

Hi guys, is there a way to change the port configuration of my aerospike db? If so, how? Thanks.

Which port (service, fabric, heartbeat)?

Search port here: https://www.aerospike.com/docs/reference/configuration/

1 Like

Hi,

As correctly pointed, the manual is the best place. However, for heads up …

These are in section under network in Aerospike Configuration file aerospike.conf.

Like practically every DB it follows Client server architecture, listening on host and port No on that host.

By default it listens on port 3000 which I gather what you meant.

You can see it by running the following on host

 systemctl status aerospike
● aerospike.service - Aerospike Server
   Loaded: loaded (/usr/lib/systemd/system/aerospike.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/aerospike.service.d
           └─aerospike.conf
   Active: active (running) since Thu 2019-12-05 15:30:55 GMT; 5 days ago
  Process: 16197 ExecStartPre=/usr/bin/asd-systemd-helper (code=exited, status=0/SUCCESS)
 **Main PID: 16232 (asd)**
    Tasks: 156
   CGroup: /system.slice/aerospike.service
           └─16232 /usr/bin/asd --config-file /etc/aerospike/aerospike.conf --fgdaemon

 netstat -plten|grep 16232

tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      0          2548890    16232/asd
tcp        0      0 50.140.197.220:3000     0.0.0.0:*               LISTEN      0          2548889    16232/asd
tcp        0      0 0.0.0.0:3001            0.0.0.0:*               LISTEN      0          2545287    16232/asd
tcp        0      0 50.140.197.220:3002     0.0.0.0:*               LISTEN      0          2548887    16232/asd
tcp        0      0 0.0.0.0:3003            0.0.0.0:*               LISTEN      0          2545296    16232/asd
tcp6       0      0 ::1:3000                :::*                    LISTEN      0          2548891    16232/asd
tcp6       0      0 :::3001                 :::*                    LISTEN      0          2545288    16232/asd
tcp6       0      0 :::3003                 :::*                    LISTEN      0          2545297    16232/asd

So by default it runs on port 3000. But as per below you can change it

network {
        service {
                address rhes75
                port 3000
                access-address 50.140.197.220
        }

        heartbeat {

                mode mesh                   # Send heartbeats using Mesh (Unicast) protocol
                address rhes75       # (Optional) (Default: any) IP of the NIC on
                                            # which this node is listening to heartbeat
                port 3002                   # port on which this node is listening to
                                            # heartbeat
                mesh-seed-address-port rhes75 3002 # IP address for seed node in the cluster
                                                          # This IP happens to be the local node
                mesh-seed-address-port rhes76 3002 # IP address for seed node in the cluster

                # To use unicast-mesh heartbeats, remove the 3 lines above, and see
                # aerospike_mesh.conf for alternative.

                interval 150
                timeout 10
        }

        fabric {
                port 3001
        }

        info {
                port 3003
        }
}

HTH

1 Like

I think for service since my goal is to connect the python aerospike client to aerospike db server.

How I can access the network configuration?

Hi,

The network configuration part is in /etc/aerospike/features.conf file on the host that Aerospike is running on. Your admin or DBA should know that. If you are trying touse an API like Python to connect to DB, then you need to specify it in your code

  def read_aerospike_set(self):
    # Check aerospike is accessible
    try:
      c.client
    except ex.ClientError as e:
      print("Error: {0} [{1}]".format(e.msg, e.code))
      sys.exit(1)
    else:
      print("Connection successful")
      keys = []
      for k in range(1,10000):
         key = (v.namespace, v.dbSet, str(k))
         keys.append(key)

      records = c.client.get_many(keys)
      pprint.PrettyPrinter(depth=4).pprint (records)
      print("\nget everyting for one record with pk = '9'")
      (key, meta, bins)= c.client.get((v.namespace, v.dbSet, '9'))
      print (key)
      print (meta)
      print (bins)
      c.client.close()
      sys.exit(0)

where

# aerospike
write_policy = {'key': aerospike.POLICY_KEY_SEND}
policies = {'write': write_policy, 'total_timeout': 1000}
config = {
  'hosts': [(v.dbHost, v.dbPort)],
  'policies': policies
}
client = aerospike.client(config).connect(v.dbConnection, v.dbPassword)

and variables are here

# aerospike variables
dbHost = "hostname where aerospike is running"
dbPort = 3000   # this is the default port 
dbConnection = "your aerospike login"
namespace = "your namespace"
dbPassword = "xxxxx"
dbSet = "the set/table name"
dbKey = "Your aerospike primary key"

HTH

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.