在VMware虚拟机上部署polardb

免密登录到我们的虚拟机之后,要在虚拟机上部署polardb数据库,首先第一步要先克隆源码:

为了进SSH协议进行传输源码需要先进行下面的步骤:

将宿主机上的私钥文件复制到虚拟机上

复制代码
scp "C:\Users\waitw\.ssh\id_rsa" anne@192.168.198.132:/home/anne/.ssh/

权限设置:

复制代码
chmod 600 ~/.ssh/id_rsa

然后用SSH来传输polardb的源码。

复制代码
git clone -b POLARDB_15_STABLE git@github.com:ApsaraDB/PolarDB-for-PostgreSQL.git

更新包索引

复制代码
sudo apt update

更新所需要的包

复制代码
sudo apt install apt-transport-https ca-certificates curl software-properties-common

创建目录

复制代码
sudo mkdir -p /etc/apt/trusted.gpg.d/

添加Docker官方的gpg密钥

复制代码
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg

添加docker仓库

复制代码
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

再次更新包索引

复制代码
sudo apt update

安装docker ce

复制代码
sudo apt install docker-ce

验证docker是否安装成功:

复制代码
sudo docker run hello-world

需要能连接到docker hub的网

接着我们拉取polardb的镜像:

复制代码
sudo docker pull polardb/polardb_pg_devel:ubuntu24.04

进入开发机器的源码目录

复制代码
 cd PolarDB-for-PostgreSQL/

此时我们已经在开发机器的源码目录中。从开发镜像上创建一个容器,将当前目录作为一个 volume 挂载到容器中,这样可以:

  • 在容器内的环境中编译源码

  • 在容器外(开发机器上)使用编辑器来查看或修改代码

    docker run -it
    -v $PWD:/home/postgres/polardb_pg
    --shm-size=512m --cap-add=SYS_PTRACE --privileged=true
    --name polardb_pg_devel
    polardb/polardb_pg_devel:ubuntu24.04
    bash

查找所有容器:

复制代码
sudo docker ps -a

启动容器并进入其shell

复制代码
sudo docker start d71e06b59566
sudo docker exec -it d71e06b59566 bash

进入容器后,为容器内用户获取源码目录的权限,然后编译部署 PolarDB-PG 实例。

复制代码
# 获取权限并编译部署
cd polardb_pg
sudo chmod -R a+wr ./
sudo chown -R postgres:postgres ./
./build.sh

# 验证
psql -c 'SELECT version();'
                                   version
----------------------------------------------------------------------
 PostgreSQL 15.x (PolarDB 15.x.x.x build xxxxxxxx) on {your_platform}
(1 row)

启动postgreSQL

复制代码
sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl start -D /home/anne/tmp_polardb_pg_15_base/data
相关推荐
jiayou641 天前
KingbaseES 表级与列级加密完全指南
数据库·后端
GBASE2 天前
G术时刻 |GBase 8s数据库事务并发控制之封锁技术介绍(下)
数据库
xiezhr2 天前
逛GitHub发现了一款免费的带AI功能的数据库管理工具
数据库·ai编程·dba
吃糖的小孩3 天前
给 QQ AI 机器人设计“可控记忆”:会话摘要、手动长期记忆与角色卡边界
数据库
笃行3504 天前
金仓数据库数据安全双防线:静态存储加密与传输加密实战
数据库
笃行3504 天前
金仓数据库物理备份实战:sys_rman 全流程演练与误覆盖抢救
数据库
笃行3504 天前
金仓数据库逻辑备份实战:从全库导出到 Schema 替换的完整闭环
数据库
SelectDB5 天前
阶跃星辰基于 SelectDB 构建 PB 级 Agent 可观测平台
大数据·数据库·aigc
这个DBA有点耶5 天前
GROUP BY优化全解:如何写出既不丢数据又飞快的分组查询
数据库·mysql·架构