Skip to main content

How to Create a Namespace in Aerospike Database

                     This post is about creating a namespace in Aerospike.



I could not find any concrete method to create a namespace like create database in MySQL and MongoDB. So I am suggesting a way to create a namespace in Aerospike Database.

Step-1: Locate config file aerospike.conf and open it in your favorite editor and make sure you have permission to modify the file. In my system the path of file /etc/aerospike/aerospike.conf (Default in Ubuntu). Here the content of the file.

# Aerospike database configuration file.

service {
 user root
 group root
 paxos-single-replica-limit 1 # Number of nodes where the replica
 pidfile /var/run/aerospike/asd.pid
 service-threads 4
 transaction-queues 4
 transaction-threads-per-queue 4
 proto-fd-max 15000
}

logging {
 # Log file must be an absolute path.
 file /var/log/aerospike/aerospike.log {
  context any info
 }
}

network {
 service {
  address any
  port 3000
 }

 heartbeat {
  mode multicast
  address 239.1.99.222
  port 9918

  # 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
 }
}

namespace test {
 replication-factor 2
 memory-size 4G
 default-ttl 30d # 30 days, use 0 to never expire/evict.

 storage-engine memory
}

namespace bar {
 replication-factor 2
 memory-size 4G
 default-ttl 30d # 30 days, use 0 to never expire/evict.

 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.
# }
}

Step-2: Find the test namespace which is by default in Aerospike. Copy the segment of test namespace

namespace test {
 replication-factor 2
 memory-size 4G
 default-ttl 30d # 30 days, use 0 to never expire/evict.

 storage-engine memory
}

and paste it after the test namespace block. Rename it to your namespace (I am renaming it to mytest). It should look like.

namespace test {
 replication-factor 2
 memory-size 4G
 default-ttl 30d # 30 days, use 0 to never expire/evict.

 storage-engine memory
}

namespace mytest {
 replication-factor 2
 memory-size 4G
 default-ttl 30d # 10 days, use 0 to never expire/evict.

 storage-engine memory
}

namespace bar {
 replication-factor 2
 memory-size 4G
 default-ttl 30d # 30 days, use 0 to never expire/evict.

 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.
# }
}

Step-3: Save the file and you just created a new namespace in Aerospike database. To check go to the aql prompt execute type the following command.
aql>show namespaces
aql>show sets
and you will see the newly created namespace.


You can also configure the namespace according to your requirement in the same config file. Like if you want the data persistence, change the storage engine from in memory to HDD or SSD. See the bar namespace configuration at the end of the config file or look aerospike website.

Comments

  1. you should do SHOW NAMESPACES. Set is different than NAMESPACES.

    ReplyDelete
    Replies
    1. We can check new namespace under ns_name column after executing show sets. But it's better to use show namespaces. Thanx! For for your valuable input.

      Delete

Post a Comment

Popular posts from this blog

Move like a Ninja on Terminal Console

If you are in IT and do a lot of stuff on terminal, this is the post for you. In the following post, we will explore various key shortcuts to jump and edit on console. Note:- Short keys may behave differnt on differnt OS systems. These keys best work with Linux sytem, For mac OS you have to enable Option key as Meta key in case of Alt . I have never checked these on windows, Please share your experinece with windows in comments. ------------------------------------------------------------------ Edit Control Move forward one char: Ctrl + f Move backward one char: Ctrl + b Move forward one word: Alt + f Move backward one word: Alt + b Move to end: Ctrl + e #Like End Move to start: Ctrl + a #Like Home Jump toggle between current location and start: Ctrl + xx Delete forward one char: Ctrl + d #Like Delete Delete backward one char: Ctrl + h #Like Backspace Delete forward one word: Alt + d Delete backward one word: Ctrl + w Delete to end: Ctrl + k Delete to start: Ctrl + u Undo: Ct...

com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server

If you are trying to connect Mongo DB Server and it insanely throwing following error. com.mongodb.MongoTimeoutException : Timed out after 1000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.1.10:27010, type=UNKNOWN, state=CONNECTING, exception={ com.mongodb.MongoSecurityException: Exception authenticating MongoCredential {mechanism=null, userName='user123', source='admin', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18 : 'Authentication failed.' on server 192.168.1.10:27010 . The full response is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." }}}] If you start looking the error content First you encounter with Timeout Exception which may mislead you. It is basically an authentication error. I...

Easiest Method to Read and Write into Files Streams in Competitive Programming

                      T his article is about easiest way to perform read and write operation from file. File handling is one of the most important aspect of programming and it becomes more important when we do competitive programming. Here are some context when you need to deal with files in comptetive programming. 1) Some specific programming contests like Google Code Jam and Facebook Hacker Cup they provide a file for input. You have to read input from that file and write answers into a file and upload on server within limited time. 2) If you are trying to code for a problem. Suppose the problem was that a square matrix is given and you have to rotate the matrix by 90 degree clock-wise. First line of input indicate the total no. of test cases and first line before matrix represents size of matrix. Then input would be like this. 3 5 10 23 43 34 21 11 13 43 30 71 10 23 43 ...