Forum: VoltDB Architecture

Post: Database Replication on Local computers

Database Replication on Local computers
Nikpraskaton
Dec 13, 2012
Hy, I would like to replicate my database on my Desktop PC to my laptop.
For example, I have table Towns (from tutorial VoltDB) and i would like to replicate it on my laptop.
So i have done the following:
1.compile projet.xml to towns.jar
2.started the database and then is automatic created deployment.xml
3.exit the database
4.I have opened deployment.xml and changed te hostcount from 1 to 2
5.then I'v done:
voltdb create deployment deployment.xml \
catalog catalog.jar host myIpAddfromPC\
6.The databease won't start
Why??

Thanks
awilson
Dec 13, 2012
Let's start with your deployment.xml. Consider this one:

<?xml version="1.0"?><deployment>
    <cluster hostcount="2" sitesperhost="6" kfactor="1" />
</deployment>


That will create a 2 host cluster with 6 sites total. The k-safety of 1 will create a duplicate partition on each host, leaving you with 3 active partitions and 3 duplicates. You won't lose data if one host goes down.

Next, you command line for volt should be something like

voltdb create catalog ./yourjar.jar deployment deployment.xml host <leaderhost>


The leaderhost is necessary for the cluster to start. It can be an IP address or a host name. All the nodes in your cluster should have the same leaderhost. The leader becomes just a peer once the cluster is up, so the leader can exit and the rest of the cluster will continue to operate.

Finally, be sure that you are using NTP and that the two hosts are synced.

This may sound like a lot, but it is documented in the Using Volt Guide and it is really easier than it all sounds.

If this does not work, please send the error messages in your log files.

Thanks,
Andy
Nikpraskaton
Dec 14, 2012
The problem is that my master database (on my Desktop PC) wont start. It is waiting:
Connecting to VoltDB cluster as the leader...
This is the log file:
2012-12-13 20:28:42,309 INFO [main] COMPILER: Path to catalog towns.sql
2012-12-13 20:28:42,577 INFO [main] COMPILER: [project.xml]: Created index: SYS_IDX_SYS_PK_10017_10018 on table: TOWNS of type: BALANCED_TREE
2012-12-13 20:28:42,585 INFO [main] COMPILER: Synthesized built-in INSERT multi-partition procedure: INSERT INTO TOWNS VALUES (?, ?, ?); for TOWNS
2012-12-13 20:28:42,591 INFO [main] COMPILER: [TOWNS.insert]: Compiling Statement: INSERT INTO TOWNS VALUES (?, ?, ?);
2012-12-14 04:29:39,113 FATAL [main] HOST: Unrecognized option to VoltDB: catlog
2012-12-14 04:29:39,113 INFO [main] HOST: Usage: voltdb create [host <hostname>] [deployment <deployment.xml>] catalog <catalog.jar>
voltdb recover [host <hostname>] [deployment <deployment.xml>]
voltdb rejoin host <hostname>

2012-12-14 04:29:50,483 INFO [main] CONSOLE: Initializing VoltDB...

_ __ ____ ____ ____
| | / /___ / / /_/ __ \/ __ )
| | / / __ \/ / __/ / / / __ |
| |/ / /_/ / / /_/ /_/ / /_/ /
|___/\____/_/\__/_____/_____/

--------------------------------

2012-12-14 04:29:50,501 INFO [main] CONSOLE: Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
2012-12-14 04:29:50,510 INFO [main] NETWORK: Default network thread count: 2
2012-12-14 04:29:50,547 INFO [main] HOST: Beginning inter-node communication on port 3021.
2012-12-14 04:29:50,547 INFO [main] HOST: Attempting to bind to leader ip /192.168.2.102:3021
2012-12-14 04:29:50,551 INFO [main] CONSOLE: Connecting to VoltDB cluster as the leader...
2012-12-14 04:29:50,585 INFO [main] ZK-SERVER: binding to port /127.0.0.1:2181
2012-12-14 04:29:50,597 INFO [main] ZK-SERVER: Created server with tickTime 3000 minSessionTimeout 6000 maxSessionTimeout 60000
2012-12-14 04:29:50,646 INFO [main] ZK-SERVER: Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=2000 watcher=org.voltcore.zk.ZKUtil$1@69d6065
2012-12-14 04:29:50,653 INFO [main-SendThread()] ZK-CLIENT: Opening socket connection to server /127.0.0.1:2181
2012-12-14 04:29:50,657 INFO [NIOServerCxn.Factory:/127.0.0.1:2181] ZK-SERVER: Accepted socket connection from /127.0.0.1:52385
2012-12-14 04:29:50,658 INFO [main-SendThread(localhost:2181)] ZK-CLIENT: Socket connection established to localhost/127.0.0.1:2181, initiating session
2012-12-14 04:29:50,661 INFO [NIOServerCxn.Factory:/127.0.0.1:2181] ZK-SERVER: Client attempting to establish new session at /127.0.0.1:52385
2012-12-14 04:29:50,679 INFO [main-SendThread(localhost:2181)] ZK-CLIENT: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x1232839462800000, negotiated timeout = 6000
2012-12-14 04:29:50,680 INFO [ZooKeeperServer] ZK-SERVER: Established session 0x1232839462800000 with negotiated timeout 6000 for client /127.0.0.1:52385
2012-12-14 04:29:50,729 INFO [Socket Joiner] HOST: Attempting to bind to internal ip 0.0.0.0/0.0.0.0:3021
2012-12-14 04:29:50,768 INFO [main] HOST: URL of deployment info: deployment.xml
2012-12-14 04:29:50,983 INFO [main] HOST: Cluster has 2 hosts with leader hostname: "192.168.2.102". 6 sites per host. K = 1.
2012-12-14 04:29:50,983 INFO [main] HOST: The entire cluster has 2 copies of each of the 6 logical partitions.
2012-12-14 04:29:50,983 INFO [main] HOST: Detection of network partitions in the cluster is not enabled.
2012-12-14 04:29:50,984 INFO [main] HOST: Creating voltdbroot directory: /home/voltdb/voltdb-2.8.1/doc/tutorials/ProbaReplication/voltdbroot
2012-12-14 04:29:50,984 INFO [main] HOST: Using "/home/voltdb/voltdb-2.8.1/doc/tutorials/ProbaReplication/voltdbroot" for voltdbroot directory.
2012-12-14 04:29:50,984 INFO [main] HOST: Creating snapshot directory: /home/voltdb/voltdb-2.8.1/doc/tutorials/ProbaReplication/voltdbroot/snapshots
2012-12-14 04:29:50,984 INFO [main] HOST: Creating export overflow directory: /home/voltdb/voltdb-2.8.1/doc/tutorials/ProbaReplication/voltdbroot/export_overflow
2012-12-14 04:29:51,257 INFO [main] HOST: hsql loaded
awilson
Dec 14, 2012
The problem is that my master database (on my Desktop PC) wont start. It is waiting:
Connecting to VoltDB cluster as the leader...

2012-12-14 04:29:39,113 FATAL [main] HOST: Unrecognized option to VoltDB: catlog
2012-12-14 04:29:39,113 INFO [main] HOST: Usage: voltdb create [host <hostname>] [deployment <deployment.xml>] catalog <catalog.jar>
voltdb recover [host <hostname>] [deployment <deployment.xml>]
voltdb rejoin host <hostname>


Hi,

This could be simple. It looks like the catalog parameter has a typo. To be sure, please send us more of the log and the command line you are using to start volt.

Also, be sure that volt is able to start on both nodes. You may have a port conflict on the other node.

Thanks,
Andy
Nikpraskaton
Dec 14, 2012
Do I have to start voltdb on PC and laptop?
My commands on PC are this:
voltcompiler ./ project.xml towns.jar (I have done this only on my PC. Do i have to do this on my laptop?)
And when i do this command:
voltdb create deployment deployment.xml catalog towns.jar host 192.168.2.102
it wont start:
Connecting to VoltDB cluster as the leader...

Thanks
awilson
Dec 14, 2012
Hi,

I'm getting a little confused so I'd like to write to you what I'm interpreting from your messages:

1. You have two machines, a laptop and a desktop.
2. Both machines are running Linux or OSX.
3. You have compiled your catalog with voltcompiler on the laptop and then copied it to the PC.
4. You then ran "voltdb create deployment deployment.xml catalog towns.jar host 192.168.2.102" on both the laptop and the desktop
5. The ip address for your laptop is 192.168.2.102 and your desktop is able to ping it.
6. You have NTP running and one of the machines is acting as the ntp server so that the cluster can synchronize.
7. You are planning to run a client application and it is going to run on some other machine.

Volt will not start until all the nodes in the cluster connect to the leader specified by the host command line parameter.

Thanks
Nikpraskaton
Dec 14, 2012
1.Yes
2.Both machines are running VMware (include Ubuntu) player witch I downloaded from VoltDb site.
3.I compiled my catalog on my desktop
4.Then i ran "voltdb create deployment deployment.xml catalog towns.jar host 192.168.2.102" on the desktop
5.Now i saw that my laptop and my desktop have same ip address (192.168.2.102) which is strange.
awilson
Dec 14, 2012
Hi,

3. VoltDB community edition does not distribute the catalog across nodes. if you haven't done so, please copy the catalog to both servers.
5. Yeah, you need distinct ip addresses for each host. Then decide which one is going to be the leader and use that ip address to execute volt, just as you did with this command line "voltdb create deployment deployment.xml catalog towns.jar host 192.168.2.102"

Thanks,
Andy
Nikpraskaton
Dec 18, 2012
Hi,
I don't know why, but i can't make database replication.
I'm running the Community Edition, i think that i have read that only in Enterprise edition can run database replication.
True or false?
Thanks
awilson
Dec 18, 2012
Hi,
I don't know why, but i can't make database replication.
I'm running the Community Edition, i think that i have read that only in Enterprise edition can run database replication.
True or false?
Thanks

Hi,

There is disaster recovery and then there is just starting a cluster. You are just starting a cluster, which is available in the community edition.

The error you have shown me so far is that both your laptop and pc have the same ip address. In other words, if you run ifconfig, on both systems, do they both say that their ip address is 192.168.2.102? If so, then you have two machines with the same ip and that is a problem unrelated to volt. Could you run ifconfig on both machines and paste the results into the forum?

Thanks
Nikpraskaton
Dec 18, 2012
I have change the ip addresses. PC have 2.103 and laptop have 2.102. So ip's are not the problem.
awilson
Dec 18, 2012
I have change the ip addresses. PC have 2.103 and laptop have 2.102. So ip's are not the problem.


Can you ssh into 2.102 and then from 2.102, ssh into 2.103? This will verify that the two machines can reach each other.

Assuming that the above works, what happens when you run your command line on 2.103? I assume that this is the command line you are using?

voltdb create deployment deployment.xml catalog towns.jar host 192.168.2.102


It should say that it is attempting to connect to 2.102. You can then start 2.102 using the same command line and the two servers should connect and become a cluster. Again, this depends on whether the ssh test I suggested works and the machines are able to communicate with each other.
Nikpraskaton
Dec 18, 2012
I can ping from my PC virtual machine (192.168.2.103) to my laptop virtual machine (192.168.2.102). That is working.
My deployment.xml looks like this:
<deployment>
<cluster hostcount="2" sitesperhost="1" kfactor="1" />
<httpd enabled="true">
<jsonapi enabled="true" />
</httpd>
</deployment>
When i enter this on my PC virtual machine:
voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.102
i get this:
Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
Connecting to the VoltDB cluster leader /192.168.2.102:3021
WARN: Joining primary failed: Connection refused retrying..
When i enter this on my PC virtual machine:
voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.103
The database wont start:
Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
Connecting to VoltDB cluster as the leader...
I dons't understand why the database won't start when i set hostcount = 2

My target is:
From Visual Studio and C# where I created client app that my data go to both pc and laptop database. Which are the same.
awilson
Dec 18, 2012
I can ping from my PC virtual machine (192.168.2.103) to my laptop virtual machine (192.168.2.102). That is working.
My deployment.xml looks like this:
<deployment>
<cluster hostcount="2" sitesperhost="1" kfactor="1" />
<httpd enabled="true">
<jsonapi enabled="true" />
</httpd>
</deployment>
When i enter this on my PC virtual machine:
voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.102
i get this:
Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
Connecting to the VoltDB cluster leader /192.168.2.102:3021
WARN: Joining primary failed: Connection refused retrying..
When i enter this on my PC virtual machine:
voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.103
The database wont start:
Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
Connecting to VoltDB cluster as the leader...
I dons't understand why the database won't start when i set hostcount = 2

My target is:
From Visual Studio and C# where I created client app that my data go to both pc and laptop database. Which are the same.


I'm probably misreading this but it looks like you are running two command lines:
1: voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.102
2: voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.103

Is this true? I apologize if this seems like I'm going round and round on the same issue. All the nodes in your cluster should the same command line.

Consequently, just run
voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.102
on both your laptop and pc.

Thanks,
Andy
Nikpraskaton
Dec 18, 2012
The problem is that database won't start whit that deployent.xml file.
I'v done the following:
1.On my laptop (which address is 192.168.2.102) voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.102
2.On my PC (which address is 192.168.2.103) voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.102

Laptop is trying to connect to database but it doesn's.
Connecting to VoltDB cluster as the leader...
PC is saying this:
Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
Connecting to the VoltDB cluster leader /192.168.2.102:3021
1 Notified of host 0
ERROR: Failed to establish socket mesh.
java.lang.Exception: Timed out trying to connect local ZooKeeper instance
at org.voltcore.messaging.HostMessenger.notifyOfHosts(HostMessenger.java:598)
at org.voltcore.messaging.SocketJoiner.connectToPrimary(SocketJoiner.java:531)
at org.voltcore.messaging.SocketJoiner.start(SocketJoiner.java:172)
at org.voltcore.messaging.HostMessenger.start(HostMessenger.java:241)
at org.voltdb.RealVoltDB.buildClusterMesh(RealVoltDB.java:1297)
at org.voltdb.RealVoltDB.initialize(RealVoltDB.java:366)
at org.voltdb.VoltDB.initialize(VoltDB.java:706)
at org.voltdb.VoltDB.main(VoltDB.java:690)
FATAL: Stack trace of thrown exception: java.lang.RuntimeException: java.lang.Exception: Timed out trying to connect local ZooKeeper instance
FATAL: org.voltcore.messaging.SocketJoiner.connectToPrimary(SocketJoiner.java:536)
FATAL: org.voltcore.messaging.SocketJoiner.start(SocketJoiner.java:172)
FATAL: org.voltcore.messaging.HostMessenger.start(HostMessenger.java:241)
FATAL: org.voltdb.RealVoltDB.buildClusterMesh(RealVoltDB.java:1297)
FATAL: org.voltdb.RealVoltDB.initialize(RealVoltDB.java:366)
FATAL: org.voltdb.VoltDB.initialize(VoltDB.java:706)
FATAL: org.voltdb.VoltDB.main(VoltDB.java:690)
VoltDB has encountered an unrecoverable error and is exiting.
The log may contain additional information.

This are the last lines from log file:
2012-12-18 16:43:26,501 INFO [main] CONSOLE: Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
2012-12-18 16:43:26,513 INFO [main] NETWORK: Default network thread count: 2
2012-12-18 16:43:26,536 INFO [main] HOST: Beginning inter-node communication on port 3021.
2012-12-18 16:43:26,536 INFO [main] HOST: Attempting to bind to leader ip /192.168.2.102:3021
2012-12-18 16:43:26,539 INFO [main] CONSOLE: Connecting to the VoltDB cluster leader /192.168.2.102:3021
2012-12-18 16:43:26,574 INFO [main] HOST: Leader provided address 192.168.2.102
2012-12-18 16:43:26,576 INFO [main] HOST: Heartbeat timeout to host: /192.168.2.102:3021 is 10000 milliseconds
2012-12-18 16:43:26,613 INFO [main] ZK-SERVER: binding to port /127.0.0.1:2181
2012-12-18 16:43:26,623 INFO [main] ZK-SERVER: Created server with tickTime 3000 minSessionTimeout 6000 maxSessionTimeout 60000
2012-12-18 16:43:27,411 INFO [ZooKeeperServer] AGREEMENT: Loaded ZK snapshot
2012-12-18 16:43:27,415 INFO [main] ZK-SERVER: Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=2000 watcher=org.voltcore.zk.ZKUtil$1@3313beb5
2012-12-18 16:43:27,421 INFO [main-SendThread()] ZK-CLIENT: Opening socket connection to server /127.0.0.1:2181
2012-12-18 16:43:27,423 INFO [NIOServerCxn.Factory:/127.0.0.1:2181] ZK-SERVER: Accepted socket connection from /127.0.0.1:36042
2012-12-18 16:43:27,424 INFO [main-SendThread(localhost:2181)] ZK-CLIENT: Socket connection established to localhost/127.0.0.1:2181, initiating session
2012-12-18 16:43:27,426 INFO [NIOServerCxn.Factory:/127.0.0.1:2181] ZK-SERVER: Client attempting to establish new session at /127.0.0.1:36042
2012-12-18 16:44:27,425 ERROR [main] HOST: Failed to establish socket mesh.
java.lang.Exception: Timed out trying to connect local ZooKeeper instance
at org.voltcore.messaging.HostMessenger.notifyOfHosts(HostMessenger.java:598)
at org.voltcore.messaging.SocketJoiner.connectToPrimary(SocketJoiner.java:531)
at org.voltcore.messaging.SocketJoiner.start(SocketJoiner.java:172)
at org.voltcore.messaging.HostMessenger.start(HostMessenger.java:241)
at org.voltdb.RealVoltDB.buildClusterMesh(RealVoltDB.java:1297)
at org.voltdb.RealVoltDB.initialize(RealVoltDB.java:366)
at org.voltdb.VoltDB.initialize(VoltDB.java:706)
at org.voltdb.VoltDB.main(VoltDB.java:690)
2012-12-18 16:44:27,453 FATAL [main] HOST: Stack trace of thrown exception: java.lang.RuntimeException: java.lang.Exception: Timed out trying to connect local ZooKeeper instance
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltcore.messaging.SocketJoiner.connectToPrimary(SocketJoiner.java:536)
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltcore.messaging.SocketJoiner.start(SocketJoiner.java:172)
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltcore.messaging.HostMessenger.start(HostMessenger.java:241)
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltdb.RealVoltDB.buildClusterMesh(RealVoltDB.java:1297)
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltdb.RealVoltDB.initialize(RealVoltDB.java:366)
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltdb.VoltDB.initialize(VoltDB.java:706)
2012-12-18 16:44:27,453 FATAL [main] HOST: org.voltdb.VoltDB.main(VoltDB.java:690)
awilson
Dec 18, 2012
Are you running NTP and are the nodes synchronized?

What do you get if you run ntpq -p on both machines?

The cluster will fail to initialize if they are too out of sync. See http://voltdb.com/docs/PerfGuide/ChapNtp.php.

Another thing to consider is that maybe there is something running on ports 2181 or 36042. Take a look at the results of
netstat -anf inet
. The command is for OSX and it may work on ubuntu.
Nikpraskaton
Dec 18, 2012
The NTP was not set and synchronized.
Thank you very much for your help.

But i have one question more:
From my PC (2.103) run the command:

voltdb create catalog towns.jar deployment deployment.xml host 192.168.2.103

That same command i entered on my laptop(2.102)

Does this mean that my PC ili Leader??

Because when i shut down the database service on my laptop and when i wonted to rejoin to the cluster again i have entered this:

voltdb rejoin catalog towns.jar deployment deployment.xml host 192.168.2.103

and everything worked normally.

But, when i shut down the service process on my PC when i tried to rejoin i get this error:

Build: 2.8.1 voltdb-2.8.1-0-g8f15375-local Community Edition
Connecting to VoltDB cluster as the leader...
FATAL: Stack trace of thrown exception: org.apache.zookeeper_voltpatches.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /db/topology
FATAL: org.apache.zookeeper_voltpatches.KeeperException.create(KeeperException.java:101)
FATAL: org.apache.zookeeper_voltpatches.KeeperException.create(KeeperException.java:44)
FATAL: org.apache.zookeeper_voltpatches.ZooKeeper.getData(ZooKeeper.java:938)
FATAL: org.apache.zookeeper_voltpatches.ZooKeeper.getData(ZooKeeper.java:972)
FATAL: org.voltdb.RealVoltDB.getTopology(RealVoltDB.java:977)
FATAL: org.voltdb.RealVoltDB.initialize(RealVoltDB.java:417)
FATAL: org.voltdb.VoltDB.initialize(VoltDB.java:706)
FATAL: org.voltdb.VoltDB.main(VoltDB.java:690)
VoltDB has encountered an unrecoverable error and is exiting.
The log may contain additional information.

Does this mean that when i shut down my PC which was in this case the MASTER i can't rejoin on the cluster anymore?

Thanks:)
awilson
Dec 19, 2012
What happened when you tried to rejoin to the other node?

The notion of a master is temporary. It lasts only until the cluster comes up and then the servers are peers.
Nikpraskaton
Dec 20, 2012
Every thing is ok.
When i shut down one node and when i wont to rejoin it, i have to give him the address of the node that is still alive.

awilson, thank you very much.
Nikpraskaton
Jan 12, 2013
Hy again,
can someone explaine to me what is site per host.
My example is:
1.One table
2.Two hosts (PC and laptop)

my deployment file is:
hostcount="2" siteperhost="1" kfactor="1"

I understand that if kfactor = 0 my data from table are half on PC and half on Laptop. If kfactor = 1 i have all data on PC and all data on laptop.
My question is what siteperhost = 1 means?
Another question: what if I partition my table first column?

Thanks