Sabtu, 28 Januari 2017

How To Install Lxd Container Hypervisor On Ubuntu 16.04 Lts Server

LXD Container:-
LXD is a lightweight opened upward source hypervisor, It allows yous to exercise multiple Container on a unmarried machine or Virtual machine also. Where yous tin run multiple application, services without extra toll And without modifying heart server application package. 

i.e. yous are working inwards a hosting provider or Software evolution company, Where yous demand multiple version of  PHP, MySQL too Apache etc.. but yous don't desire to modify existing installation because it tin interrupt electrical flow running application. For such requirement, yous tin exercise LXD container.

 LXD System requirement:
 One working PC amongst Ubuntu 16.04 LTS

Required Software packages:
1- LXD
2- zfsutils-linux
3- bridge-utils 


Step-1: Install LXD
root@Server16: # apt install lxd

Step-2: Install zfsutils-Linux
ZFSUtils-Linux is required to exercise ZFS file organization to shop LXD Container, for ZFS file organization nosotros tin exercise the same region or tin exercise simply about other HDD.

Use ascendance below to Install Zfsutils-linux
root@Server16: # apt install zfsutils-linux


Step-3:  Install bridge-utils
we required this packet to setup network brace interface hence that container's interface tin become IP too tin communicate amongst Public network.

Use ascendance below to install this package.
root@Server16: # apt install bridge-utils

Step-4: Create Bridge network interface.
 Modify your network Interface too it should hold off similar below.

Change your Primary network interface to Manual too bind it amongst brace network.


# This file describes the network interfaces available on your organization # too how to activate them. For to a greater extent than information, come across interfaces(5).  source /etc/network/interfaces.d/*  # The loopback network interface auto lo iface lo inet loopback  # The main network interface #auto enp0s3 iface enp0s3 inet manual # Bridge Network Interface auto br0 iface br0 inet dhcp         bridge-ports enp0s3         bridge-ifaces enp0s3 # Secondary Network Interface auto enp0s8 iface enp0s8 inet dhcp 

Save too Exit from the file.

Step-5: Restart your br0 network interface 
root@Server16: # ifdown enp0s3 && ifup enp0s3 && ifup br0

Please Note: - If yous don't come across respond from brace interface, Please restart your server once.

Check your network interface too IP address condition using ascendance below.
root@Server16: # ifconfig br0       Link encap:Ethernet  HWaddr 08:00:27:ab:3c:75           inet addr:192.168.28.120  Bcast:192.168.28.255  Mask:255.255.255.0           inet6 addr: fe80::a00:27ff:feab:3c75/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:337 errors:0 dropped:0 overruns:0 frame:0           TX packets:141 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:30299 (30.2 KB)  TX bytes:17098 (17.0 KB)  enp0s3    Link encap:Ethernet  HWaddr 08:00:27:ab:3c:75           inet6 addr: fe80::a00:27ff:feab:3c75/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:398 errors:0 dropped:0 overruns:0 frame:0           TX packets:149 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:40161 (40.1 KB)  TX bytes:17866 (17.8 KB)  enp0s8    Link encap:Ethernet  HWaddr 08:00:27:9f:86:47           inet addr:10.0.2.5  Bcast:10.0.2.255  Mask:255.255.255.0           inet6 addr: fe80::a00:27ff:fe9f:8647/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:7 errors:0 dropped:0 overruns:0 frame:0           TX packets:15 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:1988 (1.9 KB)  TX bytes:1720 (1.7 KB)  lo        Link encap:Local Loopback           inet addr:127.0.0.1  Mask:255.0.0.0           inet6 addr: ::1/128 Scope:Host           UP LOOPBACK RUNNING  MTU:65536  Metric:1           RX packets:80 errors:0 dropped:0 overruns:0 frame:0           TX packets:80 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1           RX bytes:5920 (5.9 KB)  TX bytes:5920 (5.9 KB)  root@Server16: # 

Step-6: Complete LXD configuration -
During the LXD configuration wizard  It volition inquire to configure brace interface, Select No when it inquire for auto too lead no to give brace interface manually.

root@Server16: # lxd init Name of the storage backend to exercise (dir or zfs) [default=zfs]: zfs Create a novel ZFS puddle (yes/no) [default=yes]? yes Name of the novel ZFS puddle [default=lxd]: zfs-pool Would yous similar to exercise an existing block device (yes/no) [default=no]? no Size inwards GB of the novel loop device (1GB minimum) [default=15]: 10 Would yous similar LXD to last available over the network (yes/no) [default=no]? no Do yous desire to configure the LXD brace (yes/no) [default=yes]? yes Warning: Stopping lxd.service, but it tin notwithstanding last activated by:   lxd.socket LXD has been successfully configured. root@Server16: # 

Configuration exercise has been completed successfully.


Step-7: Create your showtime Container using the command below.
root@Server16: # lxc launch ubuntu:xenial C1 Creating C1 Starting C1 root@Server16: # 
 
Your showtime container is ready, let's cheque container condition using ascendance bellow.
 
root@Server16: # lxc listing +------+---------+-----------------------+------+------------+-----------+ | NAME |  STATE  |         IPV4          | IPV6 |    TYPE    | SNAPSHOTS | +------+---------+-----------------------+------+------------+-----------+ | C1   | RUNNING | 192.168.28.121 (eth0) |      | PERSISTENT | 0         | +------+---------+-----------------------+------+------------+-----------+ root@Server16: # 


!!! Congrats, You bring successfully configured LDX hypervisor !!!


**Some other useful ascendance to operate amongst LXD**

1- Command  login to LXD container:
root@Server16: # lxc exec C1 /bin/bash root@C1: # 

2- By default you can't login to container using password from a remote PC because 
"PasswordAuthentication  no" not allowed from sshd_conf file
Let's modify this file to access via ssh from remote pc.
 
root@C1: # vi /etc/ssh/sshd_config
And modify passwordaAthentication file similar below.

# To enable empty passwords, alter to yeah (NOT RECOMMENDED) PermitEmptyPasswords no  # Change to yeah to enable challenge-response passwords (beware issues amongst # simply about PAM modules too threads) ChallengeResponseAuthentication no  # Change to no to disable tunnelled clear text passwords PasswordAuthentication yes  # Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yeah #KerberosTicketCleanup yeah  

Save file too restart ssh service.
root@C1: # /etc/init.d/ssh restart [ ok ] Restarting ssh (via systemctl): ssh.service.  










Sumber https://linuxhowtoguide.blogspot.com/