apache flink + Paimon 快速搭建指南
Apache Paimon是一种湖格式,可以使用Flink和Spark构建实时湖屋架构,用于流式和批处理操作。Paimon创新性地将lake格式和LSM(日志结构合并树)结构相结合,将实时流式更新引入lake架构。
Paimon提供以下核心功能:
*实时更新:
*主键表支持写入大规模更新,具有很高的更新性能,通常通过Flink Streaming。
*支持定义合并引擎,以您喜欢的方式更新记录。重复数据删除以保留最后一行、部分更新、聚合记录或第一行,由您决定。
*支持定义变更日志生成器,为合并引擎生成正确完整的变更日志更新,简化您的流式分析。
*海量附加数据处理:
*附加表(无主键)提供大规模批处理和流处理能力。自动小文件合并。
*支持数据压缩和z顺序排序,以优化文件布局,使用minmax等索引提供基于数据跳过的快速查询。
*数据湖功能:
*可扩展元数据:支持存储Petabyte大规模数据集和存储大量分区。
*支持ACID事务、时间旅行和模式演化。
the environment includes:
- minio
- pamion
- flink
Centos 更换 tencent 的yum源
备份系统旧配置文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
获取对应版本的CentOS-Base.repo 到/etc/yum.repos.d/目录
各版本源配置列表
CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
CentOS8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo
更新缓存
yum clean all
yum makecache
Centos 安装Java环境(flink使用)
wget --no-check-certificate https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz
mkdir /usr/local/java/
tar -zxvf jdk-8u202-linux-x64.tar.gz -C /usr/local/java
echo "export JAVA_HOME=/usr/local/java/jdk1.8.0_202" >> /etc/profile
echo "export JRE_HOME=${JAVA_HOME}/jre" >> /etc/profile
echo "export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" >> /etc/profile
echo "export PATH=${JAVA_HOME}/bin:$PATH" >> /etc/profile
source /etc/profile
ln -s /usr/local/java/jdk1.8.0_202/bin/java /usr/bin/java
java -version
install Minio
使用以下命令下载安装最新版本的稳定 MinIO二进制包, 并设置 $PATH
:
wget https://dl.minio.org.cn/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
设置minio linux服务
sudo tee /etc/systemd/system/minio.service <<-'EOF'
[Unit]
Description=Minio Service
[Service]
Environment="MINIO_ROOT_USER=admin"
Environment="MINIO_ROOT_PASSWORD=password"
ExecStart=/usr/local/bin/minio server /mnt/minio --console-address ":9001"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
StandardOutput=/mnt/minio/logs/minio.log
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
启动 minio linux服务
systemctl start minio
systemctl enable minio
手动 创建Buckets warehouse ,设置Access Policy: Public
install flink & paimon
download jdk filnk 1.18.1
wget https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.18.1/flink-1.18.1-bin-scala_2.12.tgz
tar zxvf flink-1.18.1-bin-scala_2.12.tgz -C /opt/
download dll ,copy to flink-1.18.1/lib folder
wget https://repo1.maven.org/maven2/org/apache/paimon/paimon-s3/0.8.0/paimon-s3-0.8.0.jar
wget https://repo1.maven.org/maven2/org/apache/paimon/paimon-flink-1.18/0.8.0/paimon-flink-1.18-0.8.0.jar
wget https://repo1.maven.org/maven2/org/apache/flink/flink-connector-jdbc/3.1.2-1.18/flink-connector-jdbc-3.1.2-1.18.jar
wget https://repo1.maven.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.8.3-10.0/flink-shaded-hadoop-2-uber-2.8.3-10.0.jar
wget https://repo1.maven.org/maven2/org/apache/flink/flink-s3-fs-hadoop/1.18.0/flink-s3-fs-hadoop-1.18.0.jar
cp ./*.jar /opt/flink-1.18.1/lib/
start flink
cd /opt/flink-1.18.1/
bash ./bin/start-cluster.sh
flink 创建pamion表
bash flink 客户端:
cd /opt/flink-1.18.1/
./bin/sql-client.sh embedded
创建 Iceberg Catalog 和表
```sql
-- if you're trying out Paimon in a distributed environment,
-- the warehouse path should be set to a shared file system, S3 minio
CREATE CATALOG my_catalog WITH (
'type' = 'paimon',
'warehouse' = 's3://warehouse/wh',
's3.endpoint'='http://192.168.116.130:9000',
's3.access-key' = 'admin',
's3.secret-key' = 'password',
's3.region' = 'us-east-1'
);
USE CATALOG my_catalog;
-- create a word count table
CREATE TABLE word_count (
word STRING PRIMARY KEY NOT ENFORCED,
cnt BIGINT
);
创建完表,可以登录 minio:9001地址进行查看数据文件;
插入数据
USE CATALOG my_catalog;
-- insert data into word count table
insert into word_count values ('hello',2);
后面, 根据你的业务创建 flink job任务,进行数据写入;