Poor Man’s Proxmox Cluster

Standard

From: http://myatus.com/p/poor-mans-proxmox-cluster/


 

Networking I had written this elsewhere before, but thought I would share it on my own site as well. The idea here is to create a Proxmox VE cluster with limited resources, in particular a lack of a private network / VLAN. We address this by creating a virtual private network using a lightweight VPN provider, namely Tinc.

You could use something else, like OpenVPN or IPSEC. The former is a bit on the heavy side for the task, whilst the latter may not have all the features we need. Specifically, Tinc allows us to create an auto-meshing network, packet switching and use multicast. Multicast will be needed to create a Proxmox VE cluster, whilst the virtual switching ensures packets will eventually be routed to the right server and VM.

 

Create an additional vmbr

By default there should already be a vmbr0 bridge for Proxmox.  We will need to create – or modify – an additional vmbr, which in this example we name vmbr1.

 

Warning: on many systems, vmbr0 bridge is used to make your server accessible over the public network – so do not edit that unless absolutely required!

You also need to think of what private IP block you would like to use, and assign each Proxmox VE server an IP from within that private IP block. For example, I use the IP range 192.168.14.0/23 (which is 192.168.14.1-192.168.15.254 and a netmask of 255.255.254.0). The 192.168.15.x range I assign to the Proxmox VE servers, whereas the 192.168.14.x range I assign to containers / VMs. Using that IP range, you would change the /etc/network/interfaces file as following:

You can force the changes using:

You will need to do this on each server, taking care to select a different IP address. Keep it simple, start at 192.168.15.1, and increment the last number for each new server.

Tinc

The next step would be installing Tinc and configuring it in such a way that Proxmox VE can use multicast over that virtual private network.

So on the server, install Tinc with:

Next, create a directory where the configuration for the VPN will reside (you can have multiple configurations as such):

Next, we create a basic configuration, which tells Tinc to use a “switch” mode and what this server’s “name” is. For sake of simplicity, use the hostname for the “name” (use uname -n to determine it):

The “ConnectTo” is currently left blank, but will be important once you have setup the other servers.  More on this later.

Then we create a server-specific configuration. Note that the filename is the same as specified in “Name =” above.

Obviously you should replace the “Address” line with the actual public IP address of your server.

Now we need to create a public/private key. The private key will remain exactly that: private. The public key will be appended to the file we just created (/etc/tinc/vpn/hosts/server1), which will eventually be distributed to the other servers.

It will ask you to confirm two file locations. The default should be correct (with the last/2nd one the file as mentioned above).

Now we need an up/down script, to do some post configuration of the network when the VPN comes up (or goes away). This is a simple copy & paste, provided you have setup vmbr1 as outlined earlier:

What the above does, is add the VPN tunnel to the vmbr1 bridge. Furthermore, it allows multicast messages over vmbr1. It also sets the use of masquerading, to allow a VM on a private IP to communicate successfully with the outside world – it will use the IP address of vmbr0 to do so.

Then, you need to tell Tinc that the contents in the “vpn” sub-directory should be started whenever it starts:

You will need to do this on each server that needs to be part of the VPN. In addition, the files within the directory /etc/tinc/vpn/hosts/ needs to be distributed to all servers (so that all servers have the files from the other servers). Its simple enough to script this, if you want to go that route, but that’s beyond the scope here.

As mentioned earlier, you will need to edit the /etc/tinc/vpn/tinc.conf and provide the name of another server in the “ConnectTo” setting that was previously left blank.  Which server you chose is entirely up to you, and you could chose a different one for each server – remember that Tinc is auto-meshing, so it will connect all servers over time.

Note: without making that change to /etc/tinc/vpn/tinc.conf, Tinc will not know what to do so you will not have a working VPN as a result.

Once you have edited the configuration as outlined, (re)start Tinc using the following command:

And test your network by pinging another node on its private IP, ie:

Note I use the “-c3″ here, to limit the amount of pings. If the VPN was not configured correctly, or a firewall is interfering, you may otherwise end up with a large number of “Host or destination is unreachable” errors.

Forcing the private IP address

We need to force Proxmox VE, or more specifically Corosync, to use the private IP addresses rather than the public IP address.  This because the multicast needs to be done over our virtual private network.

The easiest, but also the “dirtiest” method is to simply change the /etc/hosts, which I will outline here.

The first step is to ensure that the /etc/hosts file is read before attempting to do a full DNS lookup:

Next edit the /etc/hosts file, by commenting out the original line, and adding our own:

Make sure that the private IP address matches the one you assigned to vmbr1 (double check with ifconfig vmbr1).

Again, this is a “dirty” method and you may want to use your own DNS server instead that resolves IPs for a local network (say, “server1.servers.localnet”).

At this stage, reboot the server to ensure the changes get picked up and everything works as expected (that is, your server comes back up online – hmm!).

Create the cluster

If you do not yet have a cluster configured, you need to create one first. So pick a particular server that you would like to consider as a “main server” and perform the following:

Where <arbitrary-name> is something of your own choosing. Keep the name short and simple, without spaces or other funny characters.

The “main server” is a loose term really, as any server within the cluster can manage other servers. But use it as a consistent starting point for adding other servers to the cluster.

You can check if things are working correctly with:

In particular, you’d want to make sure that the “Node addresses:” portion is the private IP address as on vmbr1.

Adding servers to the cluster

Adding a server (node) to the cluster will need a little preparation. Specifically, because we use private IP addresses for the cluster, we need to force other nodes to do the same when trying to contact another node. In other words, if server1 wants to contact server2, it should use the 192.x range instead of the public IP address.

So, based on the above example, on server1 we need to add a line to the /etc/hosts like this:

Note the double “>>” brackets. If you use a single “>” one, you overwrite the entire file with just that line. You’ve been warned.

And on server2, we need to make sure server1 can be contacted using its private IP as well, so on that server, we perform:

All of this can be made much fancier with your own DNS server and bindings, but again, this is beyond the scope and goes on the assumption you don’t mind doing this for the 2, 5 or 10 servers or so you may have. If you have a few hundred, then I wouldn’t expect you to be looking at a “Poor Man’s” setup.

On the server that you will be adding to the cluster, make sure that you can successfully ping that private IP address of the “main server”.

If tested OK, then still on that server (thus the one that isn’t yet part of the cluster), type:

Where “server1″ is the “main server” (the one on which you first created the cluster). It will ask you for the root password for SSH for server1, and then does its thing with configuration.

Note: If you have disabled password-based root logins using SSH, you may have to temporarily enable it. Using SSH keys would be a preferred method over passwords.

After this has been done, the node should automatically on your web-based GUI and can be verified from the CLI using:

If the nodes show up in the “pvecm nodes” command and GUI, then you have successfully created the cluster.

Note: A note about a 2-node cluster and quorum can be found here.

Containers and VMs

You can now create containers and VMs that can be migrated between the nodes.

You can either assign the private IP address directly (venet, only on OpenVZ containers) or as a network device (veth) attached to vmbr1.

The private IP address should be within the range of your specified netmask on vmbr1. So going by the above example of using 192.168.14.0/23, that’s anything between 192.168.14.1 and 192.168.15.254. Make sure the IP isn’t already used by another VM or a node (see initial notes, re 192.168.14.x for VMs).

If you fire up the VM, its private IP address should be ping-able from any server, and from within the container / VM, you can ping any private as well as public IP address (the latter thanks to masquerading configured with the tinc-up script). If this is not the case, the network configuration was not done correctly.

Final notes

You should now have at least one container / VM with a private IP address. Its good and well if this VM doesn’t need to be accessed from the outside world, but if you want to give it such access, you will need to use NAT on the server. This will instruct the node that incoming traffic on a particular port will need to be forwarded to a particular VM.

For example, TCP port 25 on 123.4.5.6 is forwarded to VM on IP 192.168.14.1:

Note that this is just a simple guide to help you get started. More importantly, it doesn’t include any basic security measures such as a firewall (there are other articles about a firewall for Proxmox on this site [here and here], which I will update when I can).

 

1,507 total views, no views today

Restore CMD at School

Standard

Restore Command Prompt at School

I am not responsible for what you do with this, what you do are your actions, not mine!

So your school disabled command prompt?
Well read this short and sweet tut and find out how to get it back!

First open notepad and paste this in:
[crayon]
‘Script by BYTE

Set WshShell = WScript.CreateObject(“WScript.Shell”)
With WScript.CreateObject(“WScript.Shell”)

On Error Resume Next

.RegDelete “HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools”
.RegDelete “HKCU\Software\Policies\Microsoft\Windows\System\DisableCMD”

End With

Mybox = MsgBox(jobfunc & enab & vbCR & “Congrats, you have re-enabled your Command Prompt!”, 4096, t)
[\crayon]

And click save as, cmdrestore.vbs and click Save As: All Files, and just save it to the desktop or anywhere you want.

Then, go to where you save it and double click, if it says: “Congrats, you have re-enabled your Command Prompt” then it worked succesfully.

What it basically does is delete the DisableCMDPrompt registry, which then enables you to use command prompt…so enjoy!

Byte

343 total views, no views today

USA Calling For the Extradition of Snowden

Standard

From: http://news.slashdot.org/story/13/06/10/1134226/usa-calling-for-the-extradition-of-snowden?utm_source=rss1.0mainlinkanon&utm_medium=feed

 

Taco Cowboy writes”Edward Snowden, the leaker who gave us the evidence of US government spying on its people is under threat of being extradited back to the U.S. to face prosecution. Some people in Congress, including Republican Peter King (R-NY), are calling for his extradition from Hong Kong to face trial. From the article: ‘A spokesman for the director of national intelligence, James Clapper, said Snowden’s case had been referred to the justice department and US intelligence was assessing the damage caused by the disclosures. “Any person who has a security clearance knows that he or she has an obligation to protect classified information and abide by the law,” the spokesman, Shawn Turner, said.'”

354 total views, no views today

Multiple Instances of Dropbox on Ubuntu Jaunty

Standard

I used this technique to run two dropbox daemons at the same time. I have one dropbox for data and a separate one for portable applications I use on a USB stick when I’m forced to use Windows. I run two instances of dropbox on the USB stick already, but wanted to keep a copy of the portableapps dropbox on my Ubuntu machine as well. Keeping the two dropboxen separate means I have more control over when the two data stores are updated.

Run the following command in a terminal:

This should start the dropbox installer. In the wizard, you can create a new account or link to an existing one. “.dropbox-alt” is the directory where I want the installer to download the new instance — you can choose a different location for the actual dropbox sync folder during the installation. Note that the .dropbox and .dropbox-dist folders will still be created inside the .dropbox-alt folder, so don’t panic if it looks empty.

I haven’t tried it, but I presume this method should work for as many instances as necessary.

I don’t want my second dropbox to run automatically, so I can start it up when I want it with the same command without the “-i” (which runs the installer):

HOME=$HOME/.dropbox-alt /usr/bin/dropbox start

The dropbox wiki suggests adding this line to /etc/rc.local in order to run the dropbox daemon at startup (replace “username” with the actual user):

su username -c “/home/username/.dropbox-alt/.dropbox-dist/dropboxd &”

UPDATE: I tried the previous command and it doesn’t seem to work. I’m trying this instead:

su username -c “HOME=$HOME/.dropbox-alt /usr/bin/dropbox start”

357 total views, no views today

Bash Socket Programming

Standard

From: http://hacktux.com/bash/socket


You can connect to a socket using Bash by using exec and redirecting to and from the pseudo-path /dev/tcp/<hostname>/<port> or /dev/udp/<hostname>/<port>. For instance, to connect to your localhost SSH port using TCP:

Then, use cat and echo to read or write to the socket. Here is an example read:

Notice that there is no such file as /dev/tcp or /dev/udp. Bash interprets the pseudo-path.

As another example, maybe you want to download a webpage:

Finally, let’s say you wanted to connect to an IRC server. Here is an example:

Sources

tldp.org: Advanced Bash-Scripting Guide – Chapter 29
thesmithfam.org: Bash socket programming with /dev/tcp


669 total views, no views today