前一篇博文中主要說了下,lxc容器在Linux上的簡單管理,回顧請參考https://www.cnblogs.com/qiuhom-1874/p/12901493.html;今天我們來介紹下lxc的影像管理工具LXC WEB Panel;
專案下載地址:https://github.com/lxc-webpanel/LXC-Web-Panel.git;
1、安裝python-flask
[root@lxc ~]# yum install python-flask Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00 (2/2): epel/x86_64/primary_db | 6.8 MB 00:00:01 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package python-flask.noarch 1:0.10.1-5.el7_7 will be installed --> Processing Dependency: python-werkzeug for package: 1:python-flask-0.10.1-5.el7_7.noarch --> Processing Dependency: python-jinja2 for package: 1:python-flask-0.10.1-5.el7_7.noarch --> Processing Dependency: python-itsdangerous for package: 1:python-flask-0.10.1-5.el7_7.noarch --> Running transaction check ---> Package python-itsdangerous.noarch 0:0.23-2.el7 will be installed ---> Package python-jinja2.noarch 0:2.7.2-4.el7 will be installed --> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-4.el7.noarch --> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-4.el7.noarch ---> Package python-werkzeug.noarch 0:0.9.1-2.el7 will be installed --> Running transaction check ---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed ---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: python-flask noarch 1:0.10.1-5.el7_7 extras 205 k Installing for dependencies: python-babel noarch 0.9.6-8.el7 base 1.4 M python-itsdangerous noarch 0.23-2.el7 extras 24 k python-jinja2 noarch 2.7.2-4.el7 base 519 k python-markupsafe x86_64 0.11-10.el7 base 25 k python-werkzeug noarch 0.9.1-2.el7 extras 562 k Transaction Summary ========================================================================================== Install 1 Package (+5 Dependent packages) Total download size: 2.7 M Installed size: 12 M Is this ok [y/d/N]: y Downloading packages: (1/6): python-flask-0.10.1-5.el7_7.noarch.rpm | 205 kB 00:00:00 (2/6): python-itsdangerous-0.23-2.el7.noarch.rpm | 24 kB 00:00:00 (3/6): python-babel-0.9.6-8.el7.noarch.rpm | 1.4 MB 00:00:00 (4/6): python-markupsafe-0.11-10.el7.x86_64.rpm | 25 kB 00:00:00 (5/6): python-jinja2-2.7.2-4.el7.noarch.rpm | 519 kB 00:00:00 (6/6): python-werkzeug-0.9.1-2.el7.noarch.rpm | 562 kB 00:00:00 ------------------------------------------------------------------------------------------ Total 3.0 MB/s | 2.7 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-werkzeug-0.9.1-2.el7.noarch 1/6 Installing : python-itsdangerous-0.23-2.el7.noarch 2/6 Installing : python-babel-0.9.6-8.el7.noarch 3/6 Installing : python-markupsafe-0.11-10.el7.x86_64 4/6 Installing : python-jinja2-2.7.2-4.el7.noarch 5/6 Installing : 1:python-flask-0.10.1-5.el7_7.noarch 6/6 Verifying : python-markupsafe-0.11-10.el7.x86_64 1/6 Verifying : python-babel-0.9.6-8.el7.noarch 2/6 Verifying : python-itsdangerous-0.23-2.el7.noarch 3/6 Verifying : python-jinja2-2.7.2-4.el7.noarch 4/6 Verifying : 1:python-flask-0.10.1-5.el7_7.noarch 5/6 Verifying : python-werkzeug-0.9.1-2.el7.noarch 6/6 Installed: python-flask.noarch 1:0.10.1-5.el7_7 Dependency Installed: python-babel.noarch 0:0.9.6-8.el7 python-itsdangerous.noarch 0:0.23-2.el7 python-jinja2.noarch 0:2.7.2-4.el7 python-markupsafe.x86_64 0:0.11-10.el7 python-werkzeug.noarch 0:0.9.1-2.el7 Complete! [root@lxc ~]#
提示:LXC WEB Panel是用flask框架研發,所以依賴python-flask這個包,當然也可以用pip去下載這個也是可以的
pip安裝flask,首先要安裝python-pip
[root@docker_node1 ~]# yum install python-pip Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package python2-pip.noarch 0:8.1.2-12.el7 will be installed --> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-12.el7.noarch --> Running transaction check ---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed --> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch --> Running transaction check ---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed --> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch --> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch --> Running transaction check ---> Package python-backports.x86_64 0:1.0-8.el7 will be installed ---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================== Package Arch Version Repository Size ======================================================================================== Installing: python2-pip noarch 8.1.2-12.el7 epel 1.7 M Installing for dependencies: python-backports x86_64 1.0-8.el7 base 5.8 k python-backports-ssl_match_hostname noarch 3.5.0.1-1.el7 base 13 k python-ipaddress noarch 1.0.16-2.el7 base 34 k python-setuptools noarch 0.9.8-7.el7 base 397 k Transaction Summary ======================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 2.1 M Installed size: 9.4 M Is this ok [y/d/N]: y Downloading packages: (1/5): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 00:00:00 (2/5): python-ipaddress-1.0.16-2.el7.noarch.rpm | 34 kB 00:00:00 (3/5): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch. | 13 kB 00:00:00 (4/5): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 00:00:00 (5/5): python2-pip-8.1.2-12.el7.noarch.rpm | 1.7 MB 00:00:00 ---------------------------------------------------------------------------------------- Total 2.3 MB/s | 2.1 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-backports-1.0-8.el7.x86_64 1/5 Installing : python-ipaddress-1.0.16-2.el7.noarch 2/5 Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/5 Installing : python-setuptools-0.9.8-7.el7.noarch 4/5 Installing : python2-pip-8.1.2-12.el7.noarch 5/5 Verifying : python-ipaddress-1.0.16-2.el7.noarch 1/5 Verifying : python-setuptools-0.9.8-7.el7.noarch 2/5 Verifying : python2-pip-8.1.2-12.el7.noarch 3/5 Verifying : python-backports-1.0-8.el7.x86_64 4/5 Verifying : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 5/5 Installed: python2-pip.noarch 0:8.1.2-12.el7 Dependency Installed: python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-ipaddress.noarch 0:1.0.16-2.el7 python-setuptools.noarch 0:0.9.8-7.el7 Complete! [root@docker_node1 ~]# pip -V pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7) [root@docker_node1 ~]#
提示:預設yum安裝的pip預設是python2.7的pip版本是8.1.2,我們使用pip安裝flask會提示我們pip版本低,如果你不想看到提示我們版本pip版本過低可以選擇pip install --upgrade pip命令對pip進行版本更新
安裝flask
[root@docker_node1 ~]# pip install flask Collecting flask Downloading https://files.pythonhosted.org/packages/f2/28/2a03252dfb9ebf377f40fba6a7841b47083260bf8bd8e737b0c6952df83f/Flask-1.1.2-py2.py3-none-any.whl (94kB) 100% |████████████████████████████████| 102kB 11kB/s Collecting Jinja2>=2.10.1 (from flask) Downloading https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl (125kB) 100% |████████████████████████████████| 133kB 10kB/s Collecting itsdangerous>=0.24 (from flask) Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl Collecting click>=5.1 (from flask) Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB) 100% |████████████████████████████████| 92kB 10kB/s Collecting Werkzeug>=0.15 (from flask) Downloading https://files.pythonhosted.org/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298kB) 100% |████████████████████████████████| 307kB 9.8kB/s Collecting MarkupSafe>=0.23 (from Jinja2>=2.10.1->flask) Downloading https://files.pythonhosted.org/packages/fb/40/f3adb7cf24a8012813c5edb20329eb22d5d8e2a0ecf73d21d6b85865da11/MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl Installing collected packages: MarkupSafe, Jinja2, itsdangerous, click, Werkzeug, flask Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 flask-1.1.2 itsdangerous-1.1.0 You are using pip version 8.1.2, however version 20.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@docker_node1 ~]# pip list|grep "Flask" Flask (1.1.2) You are using pip version 8.1.2, however version 20.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@docker_node1 ~]#
提示:可以看到flask已經安裝,版本是1.1.2
2、安裝debootstrap
[root@docker_node1 ~]# yum install -y debootstrap Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package debootstrap.noarch 0:1.0.109-2.el7 will be installed --> Processing Dependency: dpkg for package: debootstrap-1.0.109-2.el7.noarch --> Running transaction check ---> Package dpkg.x86_64 0:1.18.25-9.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================== Package Arch Version Repository Size ======================================================================================== Installing: debootstrap noarch 1.0.109-2.el7 epel 84 k Installing for dependencies: dpkg x86_64 1.18.25-9.el7 epel 1.3 M Transaction Summary ======================================================================================== Install 1 Package (+1 Dependent package) Total download size: 1.4 M Installed size: 6.2 M Downloading packages: (1/2): debootstrap-1.0.109-2.el7.noarch.rpm | 84 kB 00:00:00 (2/2): dpkg-1.18.25-9.el7.x86_64.rpm | 1.3 MB 00:00:00 ---------------------------------------------------------------------------------------- Total 2.6 MB/s | 1.4 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : dpkg-1.18.25-9.el7.x86_64 1/2 Installing : debootstrap-1.0.109-2.el7.noarch 2/2 Verifying : debootstrap-1.0.109-2.el7.noarch 1/2 Verifying : dpkg-1.18.25-9.el7.x86_64 2/2 Installed: debootstrap.noarch 0:1.0.109-2.el7 Dependency Installed: dpkg.x86_64 0:1.18.25-9.el7 Complete! [root@docker_node1 ~]#
提示:在建立ubuntu容器時,需要依賴debootstrap;
3、安裝LXC元件
請參考https://www.cnblogs.com/qiuhom-1874/p/12901493.html;如果你的主機已經安裝這一步可以跳過
4、克隆LXC WEB Panel專案到本地
[root@docker_node1 ~]# git clone https://github.com/lxc-webpanel/LXC-Web-Panel.git Cloning into 'LXC-Web-Panel'... remote: Enumerating objects: 243, done. remote: Total 243 (delta 0), reused 0 (delta 0), pack-reused 243 Receiving objects: 100% (243/243), 198.33 KiB | 205.00 KiB/s, done. Resolving deltas: 100% (108/108), done. [root@docker_node1 ~]# ls LXC-Web-Panel [root@docker_node1 ~]# cd LXC-Web-Panel/ [root@docker_node1 LXC-Web-Panel]#
5、啟動LXC WEB Panel
提示:成功啟動LXC WEB Panel後,會像上圖一樣,提示我們訪問本機的5000埠;
到此LXC WEB Panel就搭建好了,接下來我們就可以訪問5000埠,登入LXC WEB Panel來管理我們的LXC容器了;
提示:預設使用者名稱和密碼是admin
提示:登入LXC WEB Panel後,在沒有容器的情況下會提示我們建立容器,這裡需要注意的是,如果你的主機上沒有虛擬的網橋,要建立網橋,在新建容器,否則新建的容器無法啟動;
新建網橋請參考https://www.cnblogs.com/qiuhom-1874/p/12901493.html;本人用圖形介面去建立網路會報錯,不知道哪裡的原因;只好手動去Linux shell終端上建立好了;
建立好網橋後,再來啟動剛才建立好的容器,就可以正常啟動了
提示:可以看到我們建立了網橋後就可以正常啟動容器了;如果你主機上有其他網橋也是可以的,我們可以編輯u1,把你主機上有的網橋和型別對應起來,給定一個ip地址,然後啟動就沒有問題;如下所示
提示:link其他網路需要注意型別,上面docker0橋同virbr0都是虛擬網橋,所以型別是veth;這裡還需要注意,如果型別填錯了,會導致服務不可用,解決辦法是刪除/var/lib/lxc/對應容器的名的目錄,然後重新啟動 LXC WEB Penal;以上就是 LXC的影像管理LXC WEB Penal的簡單管理,更多的管理可以自己搭建一個玩玩;