LXD Container:-
LXD is a lightweight open source hypervisor, It allows you to create multiple Container on a single machine or Virtual machine also. Where you can run multiple application, services without extra cost And without modifying core server application package.
i.e. you are working in a hosting provider or Software development company, Where you need multiple version of PHP, MySQL and Apache etc.. but you don't want to modify existing installation because it can interrupt current running application. For such requirement, you can use LXD container.
LXD System requirement:
One working PC with Ubuntu 16.04 LTS
Required Software packages:
1- LXD
2- zfsutils-linux
3- bridge-utils
Step-1: Install LXD
Step-2: Install zfsutils-Linux
ZFSUtils-Linux is required to create ZFS file system to store LXD Container, for ZFS file system we can use the same partition or can use another HDD.
Use command below to Install Zfsutils-linux
Step-3: Install bridge-utils
we required this package to setup network bridge interface so that container's interface can get IP and can communicate with Public network.
Use command below to install this package.
Step-4: Create Bridge network interface.
Modify your network Interface and it should look like below.
Change your Primary network interface to Manual and bind it with bridge network.
Save and Exit from the file.
Step-5: Restart your br0 network interface
Please Note: - If you don't see reply from bridge interface, Please restart your server once.
Check your network interface and IP address status using command below.
Step-6: Complete LXD configuration -
During the LXD configuration wizard It will ask to configure bridge interface, Select No when it ask for auto and choose no to give bridge interface manually.
Configuration part has been completed successfully.
Step-7: Create your first Container using the command below.
Save file and restart ssh service.
LXD is a lightweight open source hypervisor, It allows you to create multiple Container on a single machine or Virtual machine also. Where you can run multiple application, services without extra cost And without modifying core server application package.
i.e. you are working in a hosting provider or Software development company, Where you need multiple version of PHP, MySQL and Apache etc.. but you don't want to modify existing installation because it can interrupt current running application. For such requirement, you can use LXD container.
LXD System requirement:
One working PC with 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 create ZFS file system to store LXD Container, for ZFS file system we can use the same partition or can use another HDD.
Use command below to Install Zfsutils-linux
root@Server16:~# apt install zfsutils-linux
Step-3: Install bridge-utils
we required this package to setup network bridge interface so that container's interface can get IP and can communicate with Public network.
Use command below to install this package.
root@Server16:~# apt install bridge-utils
Step-4: Create Bridge network interface.
Modify your network Interface and it should look like below.
Change your Primary network interface to Manual and bind it with bridge network.
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary 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
Step-5: Restart your br0 network interface
root@Server16:~# ifdown enp0s3 && ifup enp0s3 && ifup br0
Please Note: - If you don't see reply from bridge interface, Please restart your server once.
Check your network interface and IP address status using command 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:~#
During the LXD configuration wizard It will ask to configure bridge interface, Select No when it ask for auto and choose no to give bridge interface manually.
root@Server16:~# lxd init
Name of the storage backend to use (dir or zfs) [default=zfs]: zfs
Create a new ZFS pool (yes/no) [default=yes]? yes
Name of the new ZFS pool [default=lxd]: zfs-pool
Would you like to use an existing block device (yes/no) [default=no]? no
Size in GB of the new loop device (1GB minimum) [default=15]: 10
Would you like LXD to be available over the network (yes/no) [default=no]? no
Do you want to configure the LXD bridge (yes/no) [default=yes]? yes
Warning: Stopping lxd.service, but it can still be activated by:
lxd.socket
LXD has been successfully configured.
root@Server16:~#
Step-7: Create your first Container using the command below.
root@Server16:~# lxc launch ubuntu:xenial C1
Creating C1
Starting C1
root@Server16:~#
Your first container is ready, let's check container status using command bellow.
root@Server16:~# lxc list
+------+---------+-----------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+---------+-----------------------+------+------------+-----------+
| C1 | RUNNING | 192.168.28.121 (eth0) | | PERSISTENT | 0 |
+------+---------+-----------------------+------+------------+-----------+
root@Server16:~#
!!! Congrats, You have successfully configured LDX hypervisor !!!
**Some other useful command to work with 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 like below.# To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no # Change to no to disable tunnelled clear text passwords PasswordAuthentication yes # Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes
root@C1:~# /etc/init.d/ssh restart [ ok ] Restarting ssh (via systemctl): ssh.service.
No comments:
Post a Comment