Friday, 7 June 2013

Creating a VPS - page six

To set up a VPS from the debian-6.0-amd64-minimal template, located in /var/lib/vz/template/cache, from a root terminal run:
vzctl create 61 --ostemplate debian-6.0-amd64-minimal --config basic

The number 61 must be a unique ID. Each virtual machine must have its own unique ID, or name. I use the last part of the virtual machine's IP address, to make easy to figure out its IP address.

To set a hostname and IP address for the vps, run;
vzctl set 61 --hostname myvps.com --save
 vzctl set 61 --ipadd 192.168.1.61 --save


If you want the vps started on boot up of your host server, run;
vzctl set 61 --onboot yes --save

To set the number of sockets to say 120 run;
vzctl set 61 --numothersock 120 --save

 To assign nameservers to the vps run:
vzctl set 61 --nameserver 8.8.8.8 --nameserver 8.8.4.4 --save

[8.8.8.8 and 8.8.4.4 are Google Public DNS servers]
[208.67.222.222 and 208.67.220.220 are OpenDNS DNS servers]

To set a root password for the vps, run;
vzctl exec 61 passwd

If you don't want to use the vzctl set commands, you can also edit the vps's configuration file directly. It is stored in the /etc/vz/conf directory. The configuration file of the vps is same as the vps id. In this instance it's; /etc/vz/conf/61.conf.

To start the vps, run;
vzctl start 61

You can connect to the vps via SSH (e.g. with PuTTY), or by running;
vzctl enter 61

To leave the vps's console, enter;
exit

To stop the vps run;
vzctl stop 61

To restart the vps run;
vzctl restart 61

To delete a vps from the host server's hard drive (the vps must be stopped first), run;
vzctl destroy 61

To get a list of your vps's and their statuses run;
vzlist -a

To find out about the resources allocated to a vps run;
vzctl exec 61 cat /proc/user_beancountersexit


In the resulting output the failcnt column is very important. It should contain only zeros. If it doesn't, this means that the vps needs more resources than are currently allocated to it. To raise allocated resources, open the vps's configuration file in /etc/vz/conf, raise the appropriate resource, then restart the vps.

8 comments:

  1. Excellent post, I am awaiting your upcoming VPS and webmaster related stuff.



    Also visit my homepage :: UK VPS

    ReplyDelete
    Replies
    1. I am glad you liked it an found it informative.
      I checked out your page [UK VPS] and found it interesting and useful. I always change the ssh port. That alone cuts down break in attempts by 80~90%. I'll try ssh keys as you suggest.

      Check out an earlier post of mine about server hardening. It is still relevant.
      http://linuxserverhardening.blogspot.ca/

      Delete
  2. This information is invaluable. Where can I find out more?


    Also visit my page; cheap UK VPS

    ReplyDelete
  3. See page nine, [references] for more information:
    http://openvzondeb.blogspot.ca/2013/06/references-page-nine.html

    Also please note, this is for Debian 6, it may not work on Not Work on Debian 7.

    ReplyDelete
  4. Hey There. I found your blog using msn. This
    is a very well written article. I'll make sure to bookmark
    it and come back to read more of your useful info. Thanks for the post.
    I'll definitely comeback.

    Look at my webpage :: best car seat covers

    ReplyDelete
    Replies
    1. I am glad you found this posting useful.

      Delete
  5. I have been getting too many idiot comments from Anonymous Users so sorry, from now on only users with Google Accounts can comment.

    ReplyDelete
  6. Thanks for your wonderful post and great information. I am very happy to read your post. Moreover, If you want to take server hosting services then Onlive Server is the best option. our Dubai VPS Server one of the best hosting options. Apart from that, your blog is awesome.
    Thank You...

    ReplyDelete