1、换源
换国内源以加快程序包下载速度。注意系统版本:CentOS 7
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv CentOS-* bak/
[root@localhost yum.repos.d]# ls
bak epel.repo epel-testing.repo
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http:// mirrors.aliyun.com/repo/Centos-7.repo
--2023-02-27 11:06:55-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 27.221.120.196, 27.221.120. 190, 27.221.120.241, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|27.221.120.196|:80... conn ected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100%[======================================>] 2,523 --.-K/s in 0.006s
2023-02-27 11:06:55 (402 KB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523 /2523]
[root@localhost yum.repos.d]# ls
bak CentOS-Base.repo epel.repo epel-testing.repo
执行命令 yum clean all 清除缓存。
执行命令 yum makecache 生成缓存。
执行命令 yum -y update 更新 yum 源。
2、安装 dokcer
执行命令 yum -y install docker 安装 docker。
执行命令 systemctl start docker 启动 docker 服务。
执行命令 systemctl enable docker 开机启动 docker。(可选)
[root@localhost yum.repos.d]# systemctl start docker
[root@localhost yum.repos.d]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor pres et: disabled)
Active: active (running) since Mon 2023-02-27 11:12:25 CST; 5s ago
Docs: http://docs.docker.com
Main PID: 4788 (dockerd-current)
CGroup: /system.slice/docker.service
├─4788 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/lib...
└─4794 /usr/bin/docker-containerd-current -l unix:///var/run/docke...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Feb 27 11:12:25 localhost.localdomain systemd[1]: Started Docker Application ...
Feb 27 11:12:25 localhost.localdomain dockerd-current[4788]: time="2023-02-27...
Hint: Some lines were ellipsized, use -l to show in full.
docker 加速(可选)
为了 pull 镜像更快,可以配置镜像加速服务器。镜像加速地址可以百度,暂时可以用我的加速地址:https://8h88nptu.mirror.aliyuncs.com。 顺便一提:阿里云镜像获取地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors,登陆后,左侧菜单选中镜像加速器就可以看到你的专属地址了 配置镜像地址,执行命令 vi /etc/docker/daemon.json 修改配置文件,如该文件不存在,则创建。
在其中加入内容
{"registry-mirrors":["https://8h88nptu.mirror.aliyuncs.com"]}
加速地址仅供参考 依次执行命令 systemctl daemon-reload 和 systemctl restart docker 重新启动 docker。
[root@localhost yum.repos.d]# vim /etc/docker/daemon.json
[root@localhost yum.repos.d]# systemctl daemon-reload
[root@localhost yum.repos.d]# systemctl restart docker
3、拉取 openGauss 镜像并启动
执行 docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 -p 8887:5432 enmotech/opengauss:latest 拉取镜像并创建容器。
其中,opengauss 为容器名,8887:5432 为容器内部的 5432 端口映射到外部 8887 端口,默认密码为 Enmo@123。
之后执行 docker start opengauss 启动 openGauss 镜像。
通过 docker update --restart=always opengauss 来设置 openGauss 镜像随着 docker 的启动而启动
[root@localhost yum.repos.d]# docker run --name opengauss --privileged=true -d -e GS
Unable to find image 'enmotech/opengauss:latest' locally
Trying to pull repository docker.io/enmotech/opengauss ...
latest: Pulling from docker.io/enmotech/opengauss
a70d879fa598: Pull complete
c4394a92d1f8: Pull complete
10e6159c56c0: Pull complete
a3f150d5db3e: Pull complete
8729468a83ce: Pull complete
e65b8206d99c: Pull complete
573b68aebc9b: Pull complete
Digest: sha256:9d6ad2660950a6baa149f058d49a04b8200b2f2b306da030ef086fe74d3088fc
Status: Downloaded newer image for docker.io/enmotech/opengauss:latest
aba27bad02e8407e894dac1ea082280d3572c39c4754e57240ab379f8dfb5458
[root@localhost yum.repos.d]# docker stats
CONTAINER CPU % MEM USAGE / LIMIT MEM % N
aba27bad02e8 1.40% 120.8 MiB / 3.84 GiB 3.07% 1
CONTAINER CPU % MEM USAGE / LIMIT MEM % N
[root@localhost yum.repos.d]# docker ps
CONTAINER ID IMAGE COMMAND CREATED
aba27bad02e8 enmotech/opengauss:latest "entrypoint.sh gau..." About a min
[root@localhost containerd]# docker info
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 8891bca22c049cd2dcf13ba2438c0bac8d7f3343 (expected: 9df8b306d01f59d3a8
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876a
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-1160.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 2
Total Memory: 3.84 GiB
Name: localhost.localdomain
ID: 5XYK:JTRR:KLWU:JRMB:2VMQ:SR7D:GJ4I:I333:WASI:LQTU:L2OH:HLSO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)
4、数据库的设置
执行命令 docker exec -it opengauss bash 进入容器。
执行命令 su - omm 切换到 omm 账户。
执行命令 gsql 进入数据库。
[root@localhost docker]# docker exec -it opengauss bash
root@aba27bad02e8:/# su - omm
omm@aba27bad02e8:~$ gsql
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:46 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
omm=#
因为外部连接时,不允许使用初始账户 omm,所以新建一个账户。
执行语句 CREATE USER opcs WITH PASSWORD ‘opcs’;创建一个名为 testuser,密码为 opcs 的账户。
执行语句 GRANT ALL PRIVILEGES ON DATABASE omm to opcs ;给予 opcs 默认数据库 omm 权限。
执行语句 GRANT ALL PRIVILEGES ON all tables in schema public TO opcs ;给予全部表权限给 testuser。
完成设置。
omm=# CREATE USER opcs WITH PASSWORD "opcs";
ERROR: Password must be quoted
omm=# CREATE USER opcs identified by 'XXX';
ERROR: Password must contain at least 8 characters.
omm=# CREATE USER opcs identified by 'XXXX1234';
ERROR: Password must contain at least three kinds of characters.
omm=# CREATE USER opcs identified by 'OXXXXXXX';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# GRANT ALL PRIVILEGES ON DATABASE omm to opcs ;
GRANT
omm=# GRANT ALL PRIVILEGES ON all tables in schema public TO opcs ;
GRANT
omm-# \q
连接测试:
omm@aba27bad02e8:~$ gsql -U opcs -d omm
Password for user opcs:
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:46 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
omm=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+---------+-------+-------------------
omm | | UTF8 | C | C | =Tc/omm +
| | | | | omm=CTc/omm +
| | | | | opcs=CTc/omm +
| | | | | opcs=APm/omm
postgres | | UTF8 | C | C |
template0 | | UTF8 | C | C | =c/omm +
| | | | | omm=CTc/omm
template1 | | UTF8 | C | C | =c/omm +
| | | | | omm=CTc/omm
(4 rows)




