In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use the LXC container in the Ubuntu system, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Install LXC under Ubuntu
Use the following command to install LXC's tools in user mode:
Copy the code
The code is as follows:
$sudo apt-get install lxc
Then check whether the current kernel supports LXC. If all results are "enable", the kernel supports:
Copy the code
The code is as follows:
$lxc-checkconfig
After installing the LXC tool, you can see that LXC automatically creates a bridge card (lxcbr0, which can be set in / etc/lxc/default.conf).
When you create a LXC container, its network port is automatically linked to the bridge card, and the container can communicate with the outside world.
Create a LXC container
To create a LXC container in a specified environment (such as Debian Wheezy 64-bit), you need a corresponding LXC template. Fortunately, the tools provided by LXC integrate a complete set of ready-made LXC templates, which you can find in the / usr/share/lxc/templates directory.
Copy the code
The code is as follows:
$ls / usr/share/lxc/templates
A LXC template is essentially a script that creates a container in a specified environment. When you create LXC containers, you need to use them.
For example, if you want to create a new Ubuntu container, use the following command:
Copy the code
The code is as follows:
$sudo lxc-create-n-t ubuntu
By default, this command creates a minimum Ubuntu environment with the same version number as your host, and on my side is the "lively salamander" (version number is 13.10), 64 bits.
Of course, you can also create any version you like, as long as you add a version parameter to the command. For example, create a container for Ubuntu 14.10:
Copy the code
The code is as follows:
$sudo lxc-create-n-t ubuntu-release utopic
This command will download and install the package in the specified environment and create a new container. The whole process takes a few minutes, depending on the type of container, so you may need to wait patiently.
After downloading and installing all the packages, the LXC container image is created, and you can see the default login interface. The container is placed in the / var/lib/lxc/ directory, and the container's root file system is placed in the / var/lib/lxc//rootfs directory.
The packages downloaded during the creation process are saved in the / var/cache/lxc directory, which can save a lot of download time when you want to build another same container.
Look at all the LXC containers on the host with the following command:
Copy the code
The code is as follows:
$sudo lxc-ls-fancy
NAME STATE IPV4 IPV6 AUTOSTART
-
Test-lxc STOPPED-NO
Start the container using the following command. The parameter "- d" opens the container as a background process. If this parameter is not specified, you can turn off the container runner directly on the console interface (LCTT: Ctrl+C key combination).
Copy the code
The code is as follows:
$sudo lxc-start-n-d
After opening the container, check the status:
Copy the code
The code is as follows:
$sudo lxc-ls-fancy
NAME STATE IPV4 IPV6 AUTOSTART
-
Lxc RUNNING 10.0.3.55-NO
The container state is "running" and the container IP is 10.0.3.55.
You can also see that the container's network interface (for example, vethJ06SFL here) is automatically connected to the LXC internal bridge (lxcbr0):
Copy the code
The code is as follows:
$brctl show lxcbr0
Manage LXC containers
Now that we've learned how to create and start a LXC container, let's take a look at how to play with a running container.
Step 1: open the container console:
Copy the code
The code is as follows:
$sudo lxc-console-n
Use the "Crtl+a Q" combination to exit the console.
Stop and delete the container:
Copy the code
The code is as follows:
$sudo lxc-stop-n
$sudo lxc-destroy-n
Copy the container, using the following command:
Copy the code
The code is as follows:
$sudo lxc-stop-n
$sudo lxc-clone-o-n
common problem
This section focuses on the problems you have encountered in using LXC.
The following error was encountered while creating the LXC container:
Copy the code
The code is as follows:
$sudo lxc-create-n test-lxc-t ubuntu
Lxc-create: symbol lookup error: / usr/lib/x86_64-linux-gnu/liblxc.so.1: undefined symbol: cgmanager_get_pid_cgroup_abs_sync
The reason for the error is that you are running the latest LXC, but it depends on an older version of libcgmanager, so the two are not compatible. Upgrade the libcmanager to solve the problem:
Copy the code
The code is as follows:
$sudo apt-get install libcgmanager0
On how to use the LXC container in the Ubuntu system to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.