In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to build a container java running environment through lxc". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to build a container java running environment through lxc by ubuntu13.04".
Step1: installing lxc
Sudo apt-get install lxc
Note: because installing lxc through apt-get in ubuntu will automatically install other software that lxc depends on, debootstrap,lvm2,cgroup-lite and so on.
Step2:lxc host configuration
First introduce several folders (the following files / folders will be automatically generated by default through apt-get installation)
/ etc/lxc/default.conf
If no configuration file is specified when creating a container, this default.conf is used as the configuration file for the container by default.
/ usr/share/lxc/templates/
This directory holds linux templates for various distributions supported by LXC, usually:
/ var/lib/lxc/
This directory is used to store container instances. By default, only administrators have access to and write to the files in this folder.
/ var/cache/lxc/
To create a container for the first time, you need to download a mini version of the container system, which will take a long time. After it is created, the cache will be created under this directory, and the cache will be created again without having to download it online. For my needs, I prefer to use lxc-clone. The containers of all applications are almost the same configuration, so cloning not only saves time but also saves a lot of tedious configuration.
Step3: verify that lxc is installed
Lxc-verison
If lxc version: x.x.x is displayed, the installation is successful. Here x represents the version number, and I installed lxc version:0.9.0
Lxc-checkconfig
All options are supposed to be enable, but User namespace:missing, don't worry, it doesn't matter much. Some say it's the kernel configuration, others say it's only on ubuntu 32-bit systems. The following paragraph was written by a foreign blogger:
Step4: create the first container master
Create a container called master, using ubuntu as the template. Don't forget to add sudo here, or you will make a mistake.
Sudo lxc-create-t ubuntu-n master-t: created virtual machine template name, default is ubuntu 12.04 minimum installation version, very small-n: created virtual name, need to specify-f: specify configuration file-B: virtual machine disk system, in order to control the disk capacity limit of a single virtual machine. -- lvname: the virtual machine uses the volume name. By default, it uses the virtual machine name-- vgname: volume group name. This must exist. The default name is lxc, which can be specified separately. If you do not specify this option, a volume group named lxc already exists, otherwise, specify the volume group name-fstype: file system type, default is ext4 type-fssize: disk capacity, default is 1G, disk space occupied by a single application, generally after installation, in addition to system files, only 500m functions can be used.
It will take some time to create for the first time. After the creation is completed, you will be prompted to create it successfully. The default user name and password are ubuntu.
Sudo lxc-start-n master-dsudo lxc-console-n master
Open the master container with the daemon, then enter the console and enter the user name and password ubuntu. The directory you see now is the directory of the container, and you cannot access the directory of the host host, which is equivalent to a complete server for the user.
Exit the console [ctrl+a Q]
Step5: build a java environment in a container: jdk+tomcat
First of all, go to the official website to download the versions of jdk and tomcat and your own system. Here are jdk1.7.0_45.zip and apache-tomcat-8.0.0-RC5.tar.gz.
New folder
Mkdir / var/lib/lxc/master/rootfs/usr/local/java
Move the above two files to the java directory and extract them, and rename the tomcat folder to tomcat. Note that there may be permission problems when decompressing, use sudo chmod-R 755 filename to modify file permissions.
The next configuration is done in the container, and the command line goes to the container console.
Configure environment variables:
Sudo vim / etc/profile
Add the path of your jre, the path of tomcat, etc.
For example, mine is in / usr/local/java/jdk1.7.0_45,/usr/local/java/tomcat, where the root directory is the root directory of the container, so the environment variable is configured as follows:
Export JAVA_HOME=/usr/local/java/jdk1.7.0_45export CATALINA_HOME=/usr/local/java/tomcatexport TOMCAT_HOME=/usr/local/java/tomcatexport JRE_HOME=$ {JAVA_HOME} / jreexport CLASSPATH=.:$ {JAVA_HOME} / lib:$ {JRE_HOME} / lib:$ {CATALINA_HOME} / libexport PATH=$ {JAVA_HOME} / bin:$PATH:$ {CATALINE_HOME} / bin
Exit the save and execute the following command to take effect
Source / etc/profile
Whether the inspection is effective or not
Echo $PATH
If the output of your jdk path indicates that it is in effect
Start tomcat
Sh / usr/local/tomcat/bin/startup.sh
By the way, let's see if port 8080 is open.
Netstat-nl | grep 8080
Enter URL: http://localhost:8080
If the welcome page of tomcat appears, it is done.
At this point, I believe you have a deeper understanding of "ubuntu13.04 how to build a container java running environment through lxc". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.