這份紀錄如何預先下載套件,並建立 Local YUM Repo 讓其他 Container 存取。
這邊會使用到 HTTPD 服務,上一份已經預先處理好了。
這份筆記內容
- 延續上一篇筆記的環境,搭配 EDB 的軟體安裝檔作建立 YUM Repo 的示範。
- 使用 YUM Download Only 功能,預先準備需要的相依 RPM
這邊的範例,也可以適用到其他東西上~
(Note:這篇在 LXC 上面並不顯然喔,需要小小 Workaround 才行~)
(Note:這篇在 LXC 上面並不顯然喔,需要小小 Workaround 才行~)
取得這邊要示範的軟體安裝檔
EnterpriseDB 的產品,以 YUM Repo 的方式發布,需要由訂閱帳戶取得相關的登入帳密,方能下載。
設置 YUM Repo Container
這邊產生一個 Container,作為 Container 可以共同存取的 YUM Repository
[user@lxc-lab ~]$ sudo ./addcontainer.sh localrepo [user@lxc-lab ~]$ sudo ./startenv.sh localrepo [user@lxc-lab ~]$ ls addcontainer.sh envlogin.sh edb_11_redhat_rhel-7-x86_64.tar.gz startenv.sh edb_dependencies_redhat_rhel-7-x86_64.tar.gz stopenv.sh [user@lxc-lab ~]$ sudo ./startenv.sh Below is the List of Available containers NAME STATE IPV4 IPV6 AUTOSTART --------------------------------------------------- container1 RUNNING 192.168.68.11 - YES container2 RUNNING 192.168.68.12 - YES localrepo RUNNING 192.168.68.13 - YES [user@lxc-lab ~]$
放置相關檔案進去
[user@lxc-lab ~]$ sudo mv edb_11_redhat_rhel-7-x86_64.tar.gz edb_dependencies_redhat_rhel-7-x86_64.tar.gz /var/lib/lxc/localrepo/rootfs/root/ [user@lxc-lab ~]$
進入 Container 環境,開始進行 Repository 設置
[root@localrepo ~]# mkdir -p /var/www/html/edb11 /var/www/html/edb_dependencies [root@localrepo ~]# tar -xvf ~/edb_11_redhat_rhel-7-x86_64.tar.gz -C /var/www/html/edb11 [root@localrepo ~]# tar -xvf ~/edb_dependencies_redhat_rhel-7-x86_64.tar.gz -C /var/www/html/edb_dependencies [root@localrepo ~]# yum install -y createrepo [root@localrepo ~]# createrepo /var/www/html/edb11/ Spawning worker 0 with 39 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@localrepo ~]# createrepo /var/www/html/edb_dependencies Spawning worker 0 with 100 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@localrepo ~]#
設置 Apache HTTPD 服務,以便讓其他 Container 存取
HTTPD 服務要在 Container 產生之前,預先安裝到裡面。前面的筆記已經有作過調整,Container 初始化完成之後,就會裝好 HTTPD 軟體了。如果沒有預先裝的話,由於 CentOS 的 Container 的運作限制,yum install httpd 會下載失敗。
在本處的環境內,基本上直接啟動 HTTPD 服務就好,依照預設值,會在 80 Port 上啟動服務,並接受所有綁在這個 VM 的 IP 的請求。如果覺得有需要,可以調整 /etc/httpd/conf/httpd.conf 裡面的 Listen 選項,可以改 Port 或指定只理會特定 IP
[root@localrepo edb11]# sudo service httpd start Redirecting to /bin/systemctl start httpd.service [root@localrepo edb11]# chkconfig httpd on Note: Forwarding request to 'systemctl enable httpd.service'. Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@localrepo edb11]# [root@localrepo edb11]# netstat -tulnap | grep httpd tcp6 0 0 :::80 :::* LISTEN 300/httpd [root@localrepo edb11]#
此時可以離開 Container,到其他 Container 裡面設定 Repository。這邊簡便起見,可以直接在 Host 準備好 Repo FIle 再複製進去需要的 Container 就好。這邊用 container1 作示範就好
[user@lxc-lab ~]$ sudo tee ~/local-edb.repo << "EOF" [local-edb11] name=Local EPAS 11 Packages for Enterprise Linux 7 - $basearch baseurl=http://192.168.68.13:80/edb11/ enabled=1 gpgcheck=0 [local-edb-dependencies] name=Local EPAS Dependency Packages for Enterprise Linux 7 - $basearch baseurl=http://192.168.68.13:80/edb_dependencies/ enabled=1 gpgcheck=0 EOF [user@lxc-lab ~]$ sudo cp ~/local-edb.repo /var/lib/lxc/container1/rootfs/etc/yum.repos.d/ [user@lxc-lab ~]$
進入 container1 就可以查看 rpeolist 有生效了
[brandon_hsu@lxc-lab ~]$ sudo ./envlogin.sh container1 Connected to tty 0 Typeto exit the console, to enter Ctrl+a itself ↲ CentOS Linux 7 (Core) Kernel 3.10.0-957.1.3.el7.x86_64 on an x86_64 container1 login: root Password: root Last login: Sun Jan 27 03:06:45 on lxc/console [root@container1 ~]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.scalabledns.com * extras: mirror.fileplanet.com * updates: repos.lax.quadranet.com local-edb-dependencies | 2.9 kB 00:00:00 local-edb11 | 2.9 kB 00:00:00 (1/2): local-edb-dependencies/primary_db | 42 kB 00:00:00 (2/2): local-edb11/primary_db | 23 kB 00:00:00 repo id repo name status base/7/x86_64 CentOS-7 - Base 10019 extras/7/x86_64 CentOS-7 - Extras 321 local-edb-dependencies Local EPAS Dependency Packages for Enterprise Linux 7 - x86_64 100 local-edb11 Local EPAS 11 Packages for Enterprise Linux 7 - x86_64 39 updates/7/x86_64 CentOS-7 - Updates 667 repolist: 11146 [root@container1 ~]#
下載相依套件
本處示範的是 EDB 11 企業版。由於 EDB 11 需要額外的 LLVM 套件,需要額外先行下載,這邊使用 YUM Download 功能
[root@container1 ~]# yum install -y yum-plugin-downloadonly ...略 [root@container1 ~]# mkdir ~/edb11-db-alldep [root@container1 ~]# yum install -y epel-release ...略 [root@container1 ~]# yum install --downloadonly --downloaddir=edb11-db-alldep/ edb-as11-server -y ...略 [root@container1 ~]#
檢視下載結果:裡面的 llvm3.9 來自 EPEL,以及來自 localrepo 的 RPM
[root@container1 ~]# ls ~/edb11-db-alldep/
boost-atomic-1.53.0-27.el7.x86_64.rpm
boost-chrono-1.53.0-27.el7.x86_64.rpm
boost-date-time-1.53.0-27.el7.x86_64.rpm
boost-filesystem-1.53.0-27.el7.x86_64.rpm
boost-regex-1.53.0-27.el7.x86_64.rpm
boost-system-1.53.0-27.el7.x86_64.rpm
boost-thread-1.53.0-27.el7.x86_64.rpm
edb-as11-pgagent-4.0.0-1.rhel7.x86_64.rpm
edb-as11-server-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-client-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-cloneschema-1.8-1.rhel7.x86_64.rpm
edb-as11-server-contrib-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-core-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-devel-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-docs-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-indexadvisor-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-libs-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-llvmjit-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-parallel-clone-1.4-1.rhel7.x86_64.rpm
edb-as11-server-pldebugger-1.1-1.rhel7.x86_64.rpm
edb-as11-server-plperl-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-plpython-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-pltcl-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-sqlprofiler-4.0-3.rhel7.x86_64.rpm
edb-as11-server-sqlprotect-11.1.7-1.rhel7.x86_64.rpm
edb-as11-server-sslutils-1.2-3.rhel7.x86_64.rpm
libicu-50.1.2-17.el7.x86_64.rpm
libicu-edb-53.1-11.rhel7.x86_64.rpm
libxslt-1.1.28-5.el7.x86_64.rpm
llvm3.9-3.9.1-7.el7.x86_64.rpm
llvm3.9-libs-3.9.1-7.el7.x86_64.rpm
make-3.82-23.el7.x86_64.rpm
openssl-1.0.2k-16.el7.x86_64.rpm
perl-5.16.3-294.el7_6.x86_64.rpm
perl-Carp-1.26-244.el7.noarch.rpm
perl-Encode-2.51-7.el7.x86_64.rpm
perl-Exporter-5.68-3.el7.noarch.rpm
perl-File-Path-2.09-2.el7.noarch.rpm
perl-File-Temp-0.23.01-3.el7.noarch.rpm
perl-Filter-1.49-3.el7.x86_64.rpm
perl-Getopt-Long-2.40-3.el7.noarch.rpm
perl-HTTP-Tiny-0.033-3.el7.noarch.rpm
perl-PathTools-3.40-5.el7.x86_64.rpm
perl-Pod-Escapes-1.04-294.el7_6.noarch.rpm
perl-Pod-Perldoc-3.20-4.el7.noarch.rpm
perl-Pod-Simple-3.28-4.el7.noarch.rpm
perl-Pod-Usage-1.63-3.el7.noarch.rpm
perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm
perl-Socket-2.010-4.el7.x86_64.rpm
perl-Storable-2.45-3.el7.x86_64.rpm
perl-Text-ParseWords-3.29-4.el7.noarch.rpm
perl-Time-HiRes-1.9725-3.el7.x86_64.rpm
perl-Time-Local-1.2300-2.el7.noarch.rpm
perl-constant-1.27-2.el7.noarch.rpm
perl-libs-5.16.3-294.el7_6.x86_64.rpm
perl-macros-5.16.3-294.el7_6.x86_64.rpm
perl-parent-0.225-244.el7.noarch.rpm
perl-podlators-2.5.1-3.el7.noarch.rpm
perl-threads-1.87-4.el7.x86_64.rpm
perl-threads-shared-1.43-6.el7.x86_64.rpm
systemd-sysv-219-62.el7_6.2.x86_64.rpm
tcl-8.5.13-8.el7.x86_64.rpm
uuid-1.6.2-26.el7.x86_64.rpm
[root@container1 ~]#
示範到此,便完成 Container 環境下 YUM Repo 設置驗證了。
相關連結
PostgreSQL/EnterpriseDB Inside Linux Containers (LXC) - Toad World Blog
沒有留言:
張貼留言