优化openGauss官方容器源码(一)

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
简介: 优化openGauss官方容器源码

一、 下载源码

[root@node3 ~]# git clone https://gitee.com/opengauss/openGauss-server.git
Cloning into 'openGauss-server'...
remote: Enumerating objects: 67538, done.
remote: Counting objects: 100% (21733/21733), done.
remote: Compressing objects: 100% (7802/7802), done.
remote: Total 67538 (delta 15955), reused 17513 (delta 13814), pack-reused 45805
Receiving objects: 100% (67538/67538), 203.25 MiB | 9.94 MiB/s, done.
Resolving deltas: 100% (47623/47623), done.

二、原容器镜像制作

1. 下载介质

[root@node3 dockerfiles]# cd 3.0.0/
[root@node3 3.0.0]# ls
dockerfile_amd  dockerfile_arm  entrypoint.sh  gosu-amd64  gosu-arm64  openEuler_aarch64.repo  sha256_file_amd64  sha256_file_arm64
[root@node3 3.0.0]# wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/x86/openGauss-3.0.0-CentOS-64bit.tar.bz2

2. 安装docker

  • yum
[root@node3 dockerfiles]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@node3 dockerfiles]# yum install docker-ce docker-ce-cli containerd.io -y
  • 国内加速
[root@node3 dockerfiles]# cat /etc/docker/daemon.json
{
    "registry-mirrors":[
        "https://9cpn8tt6.mirror.aliyuncs.com",
        "https://registry.docker-cn.com"
    ]
}
[root@node3 dockerfiles]# systemctl restart docker

3. buildDockerImage.sh

[root@node3 dockerfiles]# sh buildDockerImage.sh -v 3.0.0
Checking Docker version.
Checking if required packages are present and valid...
openGauss-3.0.0-CentOS-64bit.tar.bz2: OK
==========================
DOCKER info:
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  scan: Docker Scan (Docker Inc., v0.17.0)
Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.18
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.62GiB
 Name: node3
 ID: RPLL:AKDC:SMRS:XLID:E2UB:Y6WU:HAUI:FX66:IKXO:TNZD:SRNY:TDDL
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
==========================
Building image 'opengauss:3.0.0' ...
Sending build context to Docker daemon  101.2MB
Step 1/14 : FROM centos:7.6.1810
7.6.1810: Pulling from library/centos
ac9208207ada: Downloading [======>                                            ]  9.104MB/75.16MB
^C
[root@node3 dockerfiles]# vi /etc/docker/daemon.json
[root@node3 dockerfiles]# systemctl restart docker
[root@node3 dockerfiles]# cat /etc/docker/daemon.json
{
    "registry-mirrors":[
        "https://9cpn8tt6.mirror.aliyuncs.com",
        "https://registry.docker-cn.com"
    ]
}
[root@node3 dockerfiles]# systemctl restart docker
[root@node3 dockerfiles]# sh buildDockerImage.sh -v 3.0.0
Checking Docker version.
Checking if required packages are present and valid...
openGauss-3.0.0-CentOS-64bit.tar.bz2: OK
==========================
DOCKER info:
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  scan: Docker Scan (Docker Inc., v0.17.0)
Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.18
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.62GiB
 Name: node3
 ID: RPLL:AKDC:SMRS:XLID:E2UB:Y6WU:HAUI:FX66:IKXO:TNZD:SRNY:TDDL
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://9cpn8tt6.mirror.aliyuncs.com/
  https://registry.docker-cn.com/
 Live Restore Enabled: false
==========================
Building image 'opengauss:3.0.0' ...
Sending build context to Docker daemon  101.2MB
Step 1/14 : FROM centos:7.6.1810
7.6.1810: Pulling from library/centos
ac9208207ada: Pull complete
Digest: sha256:62d9e1c2daa91166139b51577fe4f4f6b4cc41a3a2c7fc36bd895e2a17a3e4e6
Status: Downloaded newer image for centos:7.6.1810
 ---> f1cb7c7d58b7
Step 2/14 : COPY openGauss-3.0.0-CentOS-64bit.tar.bz2 .
 ---> 1d0cbd868984
Step 3/14 : COPY gosu-amd64 /usr/local/bin/gosu
 ---> 928758582360
Step 4/14 : ENV LANG en_US.utf8
 ---> Running in 9aa647847dd5
Removing intermediate container 9aa647847dd5
 ---> e221f4ad7757
Step 5/14 : RUN set -eux;     yum install -y bzip2 bzip2-devel curl libaio&&     groupadd -g 70 omm;      useradd -u 70 -g omm -d /home/omm omm;      mkdir -p /var/lib/opengauss &&     mkdir -p /usr/local/opengauss &&     mkdir -p /var/run/opengauss  &&     mkdir /docker-entrypoint-initdb.d &&     tar -jxf openGauss-3.0.0-CentOS-64bit.tar.bz2 -C /usr/local/opengauss &&     chown -R omm:omm /var/run/opengauss && chown -R omm:omm /usr/local/opengauss && chown -R omm:omm /var/lib/opengauss &&  chown -R omm:omm /docker-entrypoint-initdb.d &&     chmod 2777 /var/run/opengauss &&     rm -rf openGauss-3.0.0-CentOS-64bit.tar.bz2 && yum clean all
 ---> Running in c24660db34d1
+ yum install -y bzip2 bzip2-devel curl libaio
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package bzip2.x86_64 0:1.0.6-13.el7 will be installed
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
---> Package curl.x86_64 0:7.29.0-51.el7 will be updated
---> Package curl.x86_64 0:7.29.0-59.el7_9.1 will be an update
--> Processing Dependency: libcurl = 7.29.0-59.el7_9.1 for package: curl-7.29.0-59.el7_9.1.x86_64
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Running transaction check
---> Package libcurl.x86_64 0:7.29.0-51.el7 will be updated
---> Package libcurl.x86_64 0:7.29.0-59.el7_9.1 will be an update
--> Processing Dependency: libssh2(x86-64) >= 1.8.0 for package: libcurl-7.29.0-59.el7_9.1.x86_64
--> Running transaction check
---> Package libssh2.x86_64 0:1.4.3-12.el7 will be updated
---> Package libssh2.x86_64 0:1.8.0-4.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package            Arch          Version                  Repository      Size
================================================================================
Installing:
 bzip2              x86_64        1.0.6-13.el7             base            52 k
 bzip2-devel        x86_64        1.0.6-13.el7             base           218 k
 libaio             x86_64        0.3.109-13.el7           base            24 k
Updating:
 curl               x86_64        7.29.0-59.el7_9.1        updates        271 k
Updating for dependencies:
 libcurl            x86_64        7.29.0-59.el7_9.1        updates        223 k
 libssh2            x86_64        1.8.0-4.el7              base            88 k
Transaction Summary
================================================================================
Install  3 Packages
Upgrade  1 Package  (+2 Dependent packages)
Total download size: 876 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/base/packages/bzip2-devel-1.0.6-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for bzip2-devel-1.0.6-13.el7.x86_64.rpm is not installed
Public key for curl-7.29.0-59.el7_9.1.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total                                              2.3 MB/s | 876 kB  00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libssh2-1.8.0-4.el7.x86_64                                   1/9
  Updating   : libcurl-7.29.0-59.el7_9.1.x86_64                             2/9
  Updating   : curl-7.29.0-59.el7_9.1.x86_64                                3/9
  Installing : libaio-0.3.109-13.el7.x86_64                                 4/9
  Installing : bzip2-1.0.6-13.el7.x86_64                                    5/9
  Installing : bzip2-devel-1.0.6-13.el7.x86_64                              6/9
  Cleanup    : curl-7.29.0-51.el7.x86_64                                    7/9
  Cleanup    : libcurl-7.29.0-51.el7.x86_64                                 8/9
  Cleanup    : libssh2-1.4.3-12.el7.x86_64                                  9/9
  Verifying  : bzip2-devel-1.0.6-13.el7.x86_64                              1/9
  Verifying  : curl-7.29.0-59.el7_9.1.x86_64                                2/9
  Verifying  : libssh2-1.8.0-4.el7.x86_64                                   3/9
  Verifying  : bzip2-1.0.6-13.el7.x86_64                                    4/9
  Verifying  : libcurl-7.29.0-59.el7_9.1.x86_64                             5/9
  Verifying  : libaio-0.3.109-13.el7.x86_64                                 6/9
  Verifying  : curl-7.29.0-51.el7.x86_64                                    7/9
  Verifying  : libssh2-1.4.3-12.el7.x86_64                                  8/9
  Verifying  : libcurl-7.29.0-51.el7.x86_64                                 9/9
Installed:
  bzip2.x86_64 0:1.0.6-13.el7           bzip2-devel.x86_64 0:1.0.6-13.el7
  libaio.x86_64 0:0.3.109-13.el7
Updated:
  curl.x86_64 0:7.29.0-59.el7_9.1
Dependency Updated:
  libcurl.x86_64 0:7.29.0-59.el7_9.1        libssh2.x86_64 0:1.8.0-4.el7
Complete!
+ groupadd -g 70 omm
+ useradd -u 70 -g omm -d /home/omm omm
+ mkdir -p /var/lib/opengauss
+ mkdir -p /usr/local/opengauss
+ mkdir -p /var/run/opengauss
+ mkdir /docker-entrypoint-initdb.d
+ tar -jxf openGauss-3.0.0-CentOS-64bit.tar.bz2 -C /usr/local/opengauss
+ chown -R omm:omm /var/run/opengauss
+ chown -R omm:omm /usr/local/opengauss
+ chown -R omm:omm /var/lib/opengauss
+ chown -R omm:omm /docker-entrypoint-initdb.d
+ chmod 2777 /var/run/opengauss
+ rm -rf openGauss-3.0.0-CentOS-64bit.tar.bz2
+ yum clean all
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
Removing intermediate container c24660db34d1
 ---> f4ae499280cf
Step 6/14 : RUN set -eux;     echo "export GAUSSHOME=/usr/local/opengauss"  >> /home/omm/.bashrc &&     echo "export PATH=\$GAUSSHOME/bin:\$PATH " >> /home/omm/.bashrc &&     echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$LD_LIBRARY_PATH" >> /home/omm/.bashrc
 ---> Running in 2476e733860c
+ echo 'export GAUSSHOME=/usr/local/opengauss'
+ echo 'export PATH=$GAUSSHOME/bin:$PATH '
+ echo 'export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH'
Removing intermediate container 2476e733860c
 ---> d3ef4604a117
Step 7/14 : ENV GOSU_VERSION 1.12
 ---> Running in f9651ff17661
Removing intermediate container f9651ff17661
 ---> 09120578b30d
Step 8/14 : RUN set -eux;      chmod +x /usr/local/bin/gosu
 ---> Running in f3e98497815c
+ chmod +x /usr/local/bin/gosu
Removing intermediate container f3e98497815c
 ---> 49ea79f289ca
Step 9/14 : ENV PGDATA /var/lib/opengauss/data
 ---> Running in 8904d7dd69f7
Removing intermediate container 8904d7dd69f7
 ---> e7bd16787dd3
Step 10/14 : COPY entrypoint.sh /usr/local/bin/
 ---> a76ddb916acd
Step 11/14 : RUN chmod 755 /usr/local/bin/entrypoint.sh;ln -s /usr/local/bin/entrypoint.sh / # backwards compat
 ---> Running in f9d0c641357b
Removing intermediate container f9d0c641357b
 ---> ddd27afee5a5
Step 12/14 : ENTRYPOINT ["entrypoint.sh"]
 ---> Running in f5b70bbdc217
Removing intermediate container f5b70bbdc217
 ---> cd3a184c91ad
Step 13/14 : EXPOSE 5432
 ---> Running in 82b77be1ebe9
Removing intermediate container 82b77be1ebe9
 ---> 1ebed742aefc
Step 14/14 : CMD ["gaussdb"]
 ---> Running in 66fc27eca766
Removing intermediate container 66fc27eca766
 ---> 18f4347e4d04
Successfully built 18f4347e4d04
Successfully tagged opengauss:3.0.0
  openGauss Docker Image  3.0.0 is ready to be extended:
    --> opengauss:3.0.0
  Build completed in 90 seconds.

4. 启动容器

  • image
[root@node3 dockerfiles]# docker image ls
REPOSITORY   TAG        IMAGE ID       CREATED          SIZE
opengauss    3.0.0      18f4347e4d04   11 seconds ago   663MB
centos       7.6.1810   f1cb7c7d58b7   3 years ago      202MB
  • run
[root@node3 dockerfiles]# docker run --name opengauss_3.0.0 --privileged=true -d -e GS_PASSWORD=GaussDB@123 opengauss:3.0.0
77e79f91e71082fd0fff3376adb8de2dbfc4eb257ec0fd5c60d4b110c79e8d9f
[root@node3 dockerfiles]# docker logs opengauss_3.0.0 -f
                        Message: The supplied GS_PASSWORD is meet requirements.
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
fixing permissions on existing directory /var/lib/opengauss/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
Begin init undo subsystem meta.
[INIT UNDO] Init undo subsystem meta successfully.
creating template1 database in /var/lib/opengauss/data/base/1 ... The core dump path is an invalid directory
2022-10-09 01:40:26.710 [unknown] [unknown] localhost 140475676310592 0[0:0#0]  [BACKEND] WARNING:  macAddr is 578/2886795266, sysidentifier is 37923857/137466, randomNum is 593369338
ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
initialize global configure for bucketmap length ... ok
creating information schema ... ok
loading foreign-data wrapper for distfs access ... ok
loading foreign-data wrapper for hdfs access ... ok
loading foreign-data wrapper for log access ... ok
loading hstore extension ... ok
loading foreign-data wrapper for MOT access ... ok
loading security plugin ... ok
update system tables ... ok
creating snapshots catalog ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok
...
...
[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
  • gsql
[root@node3 dockerfiles]# docker exec -it opengauss_3.0.0 bash
[root@77e79f91e710 /]# su - omm
[omm@77e79f91e710 ~]$ gsql -d postgres -p5432 -r
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# select version();
                                                                       version
------------------------------------------------------------------------------------------------------------------------------------------------------
 (openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:34 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)


目录
相关文章
|
1月前
|
存储 编译器 C++
【C++篇】揭开 C++ STL list 容器的神秘面纱:从底层设计到高效应用的全景解析(附源码)
【C++篇】揭开 C++ STL list 容器的神秘面纱:从底层设计到高效应用的全景解析(附源码)
57 2
|
6月前
|
运维 Kubernetes 测试技术
容器技术:优化软件测试流程的利器
本文介绍了容器技术的概念、优势和历史发展,对比了容器与虚拟机的区别,并提及了Docker和Kubernetes等常见容器技术。容器作为轻量级虚拟化工具,提供高效、灵活的应用部署方式,广泛应用于软件开发、云计算和微服务架构。随着技术演进,容器将在边缘计算、人工智能等领域发挥更大作用,推动行业变革。
|
3月前
|
运维 Kubernetes 开发者
使用容器化技术优化你的应用:从理论到实践
【8月更文挑战第7天】容器化技术通过提供一致的运行环境、高效的部署与扩展能力以及资源优化,为现代应用的开发和运维带来了显著的便利。通过本文的介绍,你应该对如何使用Docker来优化你的应用有了初步的了解。从编写Dockerfile到构建镜像,再到运行容器和使用Docker Compose管理多容器应用,每一步都是向更高效、更可靠的应用交付迈进的坚实步伐。
|
3月前
|
存储 缓存 监控
在Linux中,如何优化虚拟机和容器的性能和资源使用?
在Linux中,如何优化虚拟机和容器的性能和资源使用?
|
3月前
|
Dragonfly Docker 容器
实时数仓Hologres容器镜像问题之优化私有化部署如何解决
容器镜像常遇问题包括:将过多组件打包至单一容器、使用systemd导致状态不一致、私有部署中传输未优化的镜像包及基础镜像频繁下发致网络拥堵。应采用轻量化基础镜像,明确镜像版本,并利用镜像层复用来优化。[了解更多](https://developer.aliyun.com/ask/666077)。 避免容器臃肿的方法是选用精简基础镜像,固定镜像版本,并通过镜像层复用来减少重复内容,实现高效部署。[查看详情](https://developer.aliyun.com/ask/666078)。
53 0
|
3月前
|
数据采集 监控 Kubernetes
Job类日志采集问题之iLogtail以减小容器发现和开始采集的延时如何优化
Job类日志采集问题之iLogtail以减小容器发现和开始采集的延时如何优化
|
5月前
|
安全 Java 大数据
Java性能优化(七)-多线程调优-并发容器的使用
Java性能优化(七)-多线程调优-并发容器的使用
59 0
|
13天前
|
Kubernetes Cloud Native Docker
云原生时代的容器化实践:Docker和Kubernetes入门
【10月更文挑战第37天】在数字化转型的浪潮中,云原生技术成为企业提升敏捷性和效率的关键。本篇文章将引导读者了解如何利用Docker进行容器化打包及部署,以及Kubernetes集群管理的基础操作,帮助初学者快速入门云原生的世界。通过实际案例分析,我们将深入探讨这些技术在现代IT架构中的应用与影响。
55 2
|
3天前
|
Kubernetes Linux 开发者
深入探索容器化技术——Docker 的实战应用
深入探索容器化技术——Docker 的实战应用
25 5
|
7天前
|
运维 Cloud Native 云计算
云原生之旅:Docker容器化实战
本文将带你走进云原生的世界,深入理解Docker技术如何改变应用部署与运维。我们将通过实际案例,展示如何利用Docker简化开发流程,提升应用的可移植性和伸缩性。文章不仅介绍基础概念,还提供操作指南和最佳实践,帮助你快速上手Docker,开启云原生的第一步。
下一篇
无影云桌面