首页 > 其他分享 >step-by-step之-install-docker版本opengauss1-0-1主备机群

step-by-step之-install-docker版本opengauss1-0-1主备机群

时间:2024-03-18 16:13:38浏览次数:15  
标签:opengauss1 -- step location install node1 docker opengauss op

step by step 之:install docker 版本 opengauss1.0.1 主备机群

实验环境说明:OS:2 颗 8 核心 8GB 内存。

1.流程:

先安装 docker 软件,下载 Docker 镜像,在创建启动主备容器数据库,进入数据库,进行主备切换试验。

2.安装 docker 软件

[root@node1 ~]#
yum -y install docker

#检查 docker 的版本:

docker -v
Docker version 1.13.1, build 64e9980/1.13.1

3.启动 docker 服务

# 查看docker是否启动:
systemctl status docker
   docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
   Docs: http://docs.docker.com
[root@node1 ~]#
#启动Docker
systemctl start docker

检查启动是否正常:

[root@node1 ~]# systemctl status docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-10-15 09:01:06 CST; 5s ago
     Docs: http://docs.docker.com
 Main PID: 11215 (dockerd-current)
    Tasks: 30
   CGroup: /system.slice/docker.service
           ├─11215 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/do...
           └─11225 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libco...

Oct 15 09:01:05 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:05.0...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.0...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.1...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.1...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.1...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.2...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.2...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.2...
Oct 15 09:01:06 node1.localdomain dockerd-current[11215]: time="2020-10-15T09:01:06.2...
Oct 15 09:01:06 node1.localdomain systemd[1]: Started Docker Application Container ...e.
Hint: Some lines were ellipsized, use -l to show in full.
[root@node1 ~]#

对 docker 进行简单设置

systemctl enable docker #开机启动docker
systemctl status docker #查看docker状态

[root@node1 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@node1 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://docs.docker.com
[root@node1 ~]#

4.搜索 opengauss 镜像

# docker search opengauss
[root@node1 ~]# docker search opengauss
INDEX       NAME                                    DESCRIPTION                                   STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/enmotech/opengauss            openGauss latest images created by Enmotech   6
docker.io   docker.io/aff123/opengauss              aff学习opengauss                                0
docker.io   docker.io/blueapple/opengauss           opengauss 1.0.0 CentOS 7.8.2003               0
docker.io   docker.io/fibird/opengauss                                                            0
docker.io   docker.io/gaobo1997/opengauss_compile   OpenGauss Compile Environment                 0
docker.io   docker.io/travelliu/opengauss                                                         0

5.拉取 oceanbase docker 镜像

#docker pull enmotech/opengauss:1.0.1
 docker pull enmotech/opengauss:1.0.1
Trying to pull repository docker.io/enmotech/opengauss ...
1.0.1: Pulling from docker.io/enmotech/opengauss
ac9208207ada: Pull complete
2bedb2e83de5: Pull complete
db7ef826320f: Pull complete
2e41de1b5de7: Pull complete
d528682a66c4: Pull complete
88163b222086: Pull complete
7ea9446096be: Pull complete
2a10ad7221b8: Pull complete
Digest: sha256:d1aa6c3b5062a03b6f8ec3f7bae8a388e027df443a2c992c60e8e909ac91101b
Status: Downloaded newer image for docker.io/enmotech/opengauss:1.0.1

6.查看镜像

# docker images
#[root@node1 ~]# docker images
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
docker.io/enmotech/opengauss   1.0.1               80711c4eb80a        5 weeks ago         485 MB
[root@node1 ~]#

7.检查 docker 是否启动

# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
#

没有启动,启动数据库容器。

8.启动数据库容器(这里我们使用 enmotech/opengauss:latest 的镜像)

创建主节点:

[root@node1 ~]# docker run --name op_master --network myNetwork --ip ***.***.***.*** --privileged=true --hostname op_master --detach --env GS_PORT=6432 --env OG_SUBNET=***.***.***.***/16 --env GS_PASSWORD=Enmotech@2020 --env NODE_NAME=op_master --env REPL_CONN_INFO="replconninfo1 = 'localhost=***.***.***.*** localport=6439 localservice=6432 remotehost=***.***.***.*** remoteport=6439 remoteservice=6432 '\n" --cpuset-cpus="1,3" enmotech/opengauss:1.0.1 -M primary
775afac757803a51f9e40886a00e8c3014301cd328823e716ec1c1fe39e4f85d
[root@node1 ~]#

创建备节点:

docker run --name op_slave_one \
--network myNetwork --ip ***.***.***.*** --privileged=true \
--hostname op_slave_one --detach \
--env GS_PORT=6432 \
--env OG_SUBNET=***.***.***.***/16 \
--env GS_PASSWORD=Enmotech@2020 \
--env NODE_NAME=op_slave_one \
--env REPL_CONN_INFO="replconninfo1 = 'localhost=***.***.***.*** localport=6439 localservice=6432 remotehost=***.***.***.*** remoteport=6439 remoteservice=6432 '\n" \
--cpuset-cpus="2,4" \
enmotech/opengauss:1.0.1 -M standby
b1562b7253a6746c1093e6412c6c8f768b93a4ec3c6941ed3c7a38cc2da10782
[root@node1 ~]#

9.进入容器,

在另一个窗口检查容器 ID:

[root@node1 ~]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS               NAMES
794d54eaa87c        enmotech/opengauss:latest   "entrypoint.sh gau..."   3 minutes ago       Up 3 minutes        5432/tcp            opengauss
[root@node1 ~]#
[root@node1 ~]# docker ps -a
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS                      PORTS               NAMES
b1562b7253a6        enmotech/opengauss:1.0.1   "entrypoint.sh -M ..."   7 minutes ago       Exited (1) 6 minutes ago                        op_slave_one
775afac75780        enmotech/opengauss:1.0.1   "entrypoint.sh -M ..."   15 minutes ago      Exited (0) 11 minutes ago                       op_master
[root@node1 ~]#

启动已经停止的 Docker:

[root@node1 ~]# docker start op_master
op_master

[root@node1 ~]# docker start op_slave_one
op_slave_one

进入容器

在使用 -d 参数时,容器启动后会进入后台。此时想要进入容器,可以通过以下指令进入:

docker attach
docker exec:推荐大家使用 docker exec 命令,因为此退出容器终端,不会导致容器的停止。
[root@node1 ~]#  docker exec -it  op_master  bash
[root@op_master /]#

10.查询主备角色状态

主库状态:

[root@op_master /]# su - omm
[omm@op_master ~]$ gs_ctl query -D /var/lib/opengauss/data/
[2020-11-13 06:29:40.733][121][][gs_ctl]: gs_ctl query ,datadir is -D "/var/lib/opengauss/data"
 HA state:
     local_role                     : Primary
     static_connections             : 1
     db_state                       : Normal
     detail_information             : Normal

 Senders info:
     sender_pid                     : 103
     local_role                     : Primary
     peer_role                      : Standby
     peer_state                     : Normal
     state                          : Streaming
     sender_sent_location           : 0/3000130
     sender_write_location          : 0/3000130
     sender_flush_location          : 0/3000130
     sender_replay_location         : 0/3000130
     receiver_received_location     : 0/3000130
     receiver_write_location        : 0/3000130
     receiver_flush_location        : 0/3000130
     receiver_replay_location       : 0/3000130
     sync_percent                   : 100%
     sync_state                     : Sync
     sync_priority                  : 1
     sync_most_available            : On
     channel                        : ***.***.***.***:6439-->***.***.***.***:52798

 Receiver info:
No information
[omm@op_master ~]$

备库状态:

进入备库

[root@node1 ~]# docker exec -it op_slave_one bash
[root@op_slave_one /]# su - omm
[omm@op_slave_one ~]$  gs_ctl query -D /var/lib/opengauss/data/
[2020-11-13 06:31:07.922][324][][gs_ctl]: gs_ctl query ,datadir is -D "/var/lib/opengauss/data"
 HA state:
     local_role                     : Standby
     static_connections             : 1
     db_state                       : Normal
     detail_information             : Normal

 Senders info:
No information
 Receiver info:
     receiver_pid                   : 291
     local_role                     : Standby
     peer_role                      : Primary
     peer_state                     : Normal
     state                          : Normal
     sender_sent_location           : 0/3000238
     sender_write_location          : 0/3000238
     sender_flush_location          : 0/3000238
     sender_replay_location         : 0/3000238
     receiver_received_location     : 0/3000238
     receiver_write_location        : 0/3000238
     receiver_flush_location        : 0/3000238
     receiver_replay_location       : 0/3000238
     sync_percent                   : 100%
     channel                        : ***.***.***.***:52798<--***.***.***.***:6439

[omm@op_slave_one ~]$

说明:先启动主库,在启动备库

11.主备读写及切换测试

主库 op_master 写测试

[omm@op_master ~]$ gsql -p6432
gsql ((openGauss 1.0.1 build e9da9fb9) compiled at 2020-10-01 20:21:42 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=# create table t(id json);
CREATE TABLE
omm=# insert into t values('{"name":"Mr.D"}');
INSERT 0 1

备库 op_slave_one 读测试

[omm@op_slave_one ~]$ gsql -p6432
gsql ((openGauss 1.0.1 build e9da9fb9) compiled at 2020-10-01 20:21:42 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=# select * from t;
       id
-----------------
 {"name":"Mr.D"}
(1 row)

omm=# delete from t;
ERROR:  cannot execute DELETE in a read-only transaction

切换测试:将 op_slave_one 切换为主库,op_master 切换为备库

op_slave_one 执行 switchover

[omm@op_slave_one ~]$ gs_ctl switchover -D /var/lib/opengauss/data/
[2020-10-20 13:57:02.877][504][][gs_ctl]: gs_ctl switchover ,datadir is -D "/var/lib/opengauss/data"
[2020-10-20 13:57:02.877][504][][gs_ctl]: switchover term (1)
[2020-10-20 13:57:02.888][504][][gs_ctl]: waiting for server to switchover.........
[2020-10-20 13:57:08.920][504][][gs_ctl]: done
[2020-10-20 13:57:08.920][504][][gs_ctl]: switchover completed (/var/lib/opengauss/data)

op_slave_one 查询状态

[omm@op_slave_one ~]$ gs_ctl query -D /var/lib/opengauss/data/
[2020-10-20 13:58:13.340][555][][gs_ctl]: gs_ctl query ,datadir is -D "/var/lib/opengauss/data"
 HA state:
     local_role                     : Primary
     static_connections             : 1
     db_state                       : Normal
     detail_information             : Normal

 Senders info:
     sender_pid                     : 523
     local_role                     : Primary
     peer_role                      : Standby
     peer_state                     : Normal
     state                          : Streaming
     sender_sent_location           : 0/5004A10
     sender_write_location          : 0/5004A10
     sender_flush_location          : 0/5004A10
     sender_replay_location         : 0/5004A10
     receiver_received_location     : 0/5004A10
     receiver_write_location        : 0/5004A10
     receiver_flush_location        : 0/5004A10
     receiver_replay_location       : 0/5004A10
     sync_percent                   : 100%
     sync_state                     : Sync
     sync_priority                  : 1
     sync_most_available            : On
     channel                        : ***.***.***.***:6439-->***.***.***.***:39314

 Receiver info:
No information

op_master 查询状态

[omm@op_master ~]$ gs_ctl query -D /var/lib/opengauss/data/
[2020-10-20 13:58:42.827][743][][gs_ctl]: gs_ctl query ,datadir is -D "/var/lib/opengauss/data"
 HA state:
     local_role                     : Standby
     static_connections             : 1
     db_state                       : Normal
     detail_information             : Normal

 Senders info:
No information
 Receiver info:
     receiver_pid                   : 739
     local_role                     : Standby
     peer_role                      : Primary
     peer_state                     : Normal
     state                          : Normal
     sender_sent_location           : 0/5004A10
     sender_write_location          : 0/5004A10
     sender_flush_location          : 0/5004A10
     sender_replay_location         : 0/5004A10
     receiver_received_location     : 0/5004A10
     receiver_write_location        : 0/5004A10
     receiver_flush_location        : 0/5004A10
     receiver_replay_location       : 0/5004A10
     sync_percent                   : 100%
     channel                        : ***.***.***.***:39314<--***.***.***.***:6439

可以看到 op_master 变为备库,op_slave_one 变为主库,切换成功。

数据读写验证

主库 op_slave_one 做写入验证

[omm@op_slave_one ~]$ gsql -p6432
gsql ((openGauss 1.0.1 build e9da9fb9) compiled at 2020-10-01 20:21:42 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=# select * from t;
       id
-----------------
 {"name":"Mr.D"}
(1 row)

omm=# insert into t values('{"name":"insert from op_slave_one "}');
INSERT 0 1

备库 op_master 做读取验证

[omm@op_master ~]$ gsql -p6432
gsql ((openGauss 1.0.1 build e9da9fb9) compiled at 2020-10-01 20:21:42 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

omm=# select * from t;
                  id
--------------------------------------
 {"name":"Mr.D"}
 {"name":"insert from op_slave_one "}
(2 rows)

omm=# delete from t;
ERROR:  cannot execute DELETE in a read-only transaction

修改 docker ip:

https://www.cnblogs.com/zhangyongli2011/p/12981754.html

gsql -d enmotech -U enmotech -W'Enm0t3ch' -h ... -p 8888

DOcker cpu 设置说明:

https://www.cnblogs.com/sharesdk/p/10110946.html

openGauss docker 的说明:

https://hub.docker.com/r/enmotech/opengauss

Docker 的基本操作:

https://www.runoob.com/docker/docker-container-usage.html

标签:opengauss1,--,step,location,install,node1,docker,opengauss,op
From: https://www.cnblogs.com/renxyz/p/18080628

相关文章

  • 在win10下用pyinstaller打包scrapy项目生成exe文件
    这个玩意的使用方法很简单,但是有很多坑,特别是项目稍微大一点,import引用的很多的时候,那就是打包要人命了,基本不会正常。注意有时候还需要执行pipinstall pywin32之后再进行打包。1、打包完之后,无法导入模块。譬如:你用 pyinstaller-Fentrypoint.py【只生成一个entrypoi......
  • nvm 安装node npm install -g cnpm
     "node-sass":"^4.14.1",需要安装v14.9.0https://nodejs.org/dist/v14.9.0/node-v14.9.0-x86.msi参考https://www.cnblogs.com/biehongli/p/12756256.html node-vnpm-v  npminstall-gcnpm--registry=https://registry.npm.taobao.org出现若下提示Wind......
  • 安装install.package("devtools")时报错 提示systemfonts,textshaping, ragg, gert依赖
    devtools可用conda,R的install.packages()以及wget等方式安装,这里我采用install.packages()安装,碰到systemfonts,textshaping,ragg,gert几个依赖包的安装错误。install.package("devtools")错误形式与解决,参考:https://www.cnblogs.com/shuaihe/p/17823059.html1.systemfonts解......
  • PyInstaller:将你的Python代码打包成独立应用程序,让你的创意无限释放!
    https://www.bilibili.com/read/cv24488127/ 简介PyInstaller是一个用于将Python应用程序打包为独立可执行文件的工具。它可以将Python脚本转换为可以在目标机器上独立运行的可执行文件,无需事先安装Python解释器或其他依赖项。PyInstaller支持多个平台,包括Windows、Mac和Linux......
  • pytorch使用pytorch_wavelets包错误:ValueError: step must be greater than zero 错误
    错误描述在使用pytorch_wavelets包的DWT1DInverse时,发现报错信息如下:Traceback(mostrecentcalllast):File"/work/GDN/test/test_DWT.py",line24,inx_=idwt((YL,YH))File"/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py",line550......
  • 【rust】《处理报错Cannot find a libtorch install, you can either:》
    在学习rust的tch-rs框架的时候,引入依赖并运行小demo的时候报错了;错误信息如下:报错信息Cannotfindalibtorchinstall,youcaneither:-InstalllibtorchmanuallyandsettheLIBTORCHenvironmentvariabletoappropriatepath.-Useasystemwideinstallin/us......
  • PyInstaller does not include a pre-compiled bootloader for your platform.
    用PyInstaller打包python程序时,收到下面错误:User140343INFO:BuildingPKGbecausePKG-00.tocisnonexistent140344INFO:BuildingPKG(CArchive)mainwindow.pkg215759INFO:BuildingPKG(CArchive)mainwindow.pkgcompletedsuccessfully.215891INFO:Bootloa......
  • PyInstaller does not include a pre-compiled bootloader for your platform.
    用PyInstaller打包python程序时,收到下面错误:User140343INFO:BuildingPKGbecausePKG-00.tocisnonexistent140344INFO:BuildingPKG(CArchive)mainwindow.pkg215759INFO:BuildingPKG(CArchive)mainwindow.pkgcompletedsuccessfully.215891INFO:Bootloa......
  • CentOS7系统虚拟环境下pip install uwsgi遇到错误
    遇到的错误为ERROR:Couldnotbuildwheelsforuwsgi,whichisrequiredtoinstallpyproject.toml-basedprojects尝试了n种办法,按照网上的攻略甚至是ChatGPT的说法安装了一堆的环境依赖,都解决不了。最后看到有人在装其他组件遇到类似的问题,思路是要装的版本相对于所安装的......
  • install Homebrew and gradle
    homebrew: /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" gradle: brewinstallgradle          配置环境:https://www.youtube.com/watch?v=hYCf8HhpaSM(startfrom2:17,这个视频记载了这个......