当前位置:   article > 正文

StreamPark集成k8s运行Flink实战_streampark配置flink集群

streampark配置flink集群

集群配置(Centos7)

node1(4vCpu,16G)node2(4vCpu,16G)node3(4vCpu,16G)
dockerdockerdocker
k8s-masterk8s-node1k8s-node2
java-8
mysql-57
maven-3.9.6(可选)
flink-1.16.3
streampark-2.1.3_2.12

Docker安装(三台机器)

  1. #卸载自带docker
  2. sudo yum remove docker*
  3. #安装工具类
  4. sudo yum install -y yum-utils
  5. #配置docker的yum地址
  6. sudo yum-config-manager \
  7. --add-repo \
  8. http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  9. #安装docker
  10. sudo yum install -y docker-ce docker-ce-cli containerd.io
  11. # 启动&开机启动docker
  12. systemctl enable docker --now
  13. # docker加速配置
  14. sudo mkdir -p /etc/docker
  15. sudo tee /etc/docker/daemon.json <<-'EOF'
  16. {
  17. "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"],
  18. "exec-opts": ["native.cgroupdriver=systemd"],
  19. "log-driver": "json-file",
  20. "log-opts": {
  21. "max-size": "100m"
  22. },
  23. "storage-driver": "overlay2"
  24. }
  25. EOF
  26. sudo systemctl daemon-reload
  27. sudo systemctl restart docker

安装完成后可以使用docker ps 查看docker运行状态

docker ps

k8s安装

基本环境配置(三台机器):

确保每个机器使用内网ip互通

  1. #设置每个机器自己的hostname
  2. hostnamectl set-hostname xxx(更换为自己的主机名)
  3. # 将 SELinux 设置为 permissive 模式(相当于将其禁用)
  4. sudo setenforce 0
  5. sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
  6. #关闭swap
  7. swapoff -a
  8. sed -ri 's/.*swap.*/#&/' /etc/fstab
  9. #允许 iptables 检查桥接流量
  10. cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
  11. br_netfilter
  12. EOF
  13. cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
  14. net.bridge.bridge-nf-call-ip6tables = 1
  15. net.bridge.bridge-nf-call-iptables = 1
  16. EOF
  17. sudo sysctl --system

安装kubelet、kubeadm、kubectl(三台机器)

  1. #配置k8s的yum源地址
  2. cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
  3. [kubernetes]
  4. name=Kubernetes
  5. baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
  6. enabled=1
  7. gpgcheck=0
  8. repo_gpgcheck=0
  9. gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
  10. http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
  11. EOF
  12. #安装 kubelet,kubeadm,kubectl
  13. sudo yum install -y kubelet-1.20.9 kubeadm-1.20.9 kubectl-1.20.9
  14. #启动kubelet
  15. sudo systemctl enable --now kubelet
  16. #所有机器配置master域名
  17. echo "<你的k8s-master主机ip> k8s-master" >> /etc/hosts
  18. #ping一下检测连通性
  19. ping k8s-master

初始化master节点(k8s-master机器)

  1. kubeadm init \
  2. --apiserver-advertise-address=<你的k8s-master主机ip> \
  3. --control-plane-endpoint=k8s-master \
  4. --image-repository registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images \
  5. --kubernetes-version v1.20.9 \
  6. --service-cidr=10.96.0.0/16 \
  7. --pod-network-cidr=192.168.0.0/16

记录打印信息并执行3-5行(k8s-master机器)

  1. Your Kubernetes control-plane has initialized successfully!
  2. To start using your cluster, you need to run the following as a regular user:
  3. mkdir -p $HOME/.kube
  4. sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  5. sudo chown $(id -u):$(id -g) $HOME/.kube/config
  6. Alternatively, if you are the root user, you can run:
  7. export KUBECONFIG=/etc/kubernetes/admin.conf
  8. You should now deploy a pod network to the cluster.
  9. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  10. https://kubernetes.io/docs/concepts/cluster-administration/addons/
  11. You can now join any number of control-plane nodes by copying certificate authorities
  12. and service account keys on each node and then running the following as root:
  13. kubeadm join k8s-master:6443 --token 3d05gm.ayjl70fgtg4egst2 \
  14. --discovery-token-ca-cert-hash sha256:a3d6e581c493d2e02ca2e4736eeb755af671a9df26095c700bc288a514800b39 \
  15. --control-plane
  16. Then you can join any number of worker nodes by running the following on each as root:
  17. kubeadm join k8s-master:6443 --token 3d05gm.ayjl70fgtg4egst2 \
  18. --discovery-token-ca-cert-hash sha256:a3d6e581c493d2e02ca2e4736eeb755af671a9df26095c700bc288a514800b39

安装Calico网络插件(注意版本问题:使用v3.20)(k8s-master机器)

  1. curl https://docs.projectcalico.org/v3.20/manifests/calico.yaml -O
  2. kubectl apply -f calico.yaml
  3. #检测安装情况(都在runing状态再向下进行)
  4. kubectl get pod -A

加入worker节点(复制打印信息中的内容)(k8s-worker机器)

  1. kubeadm join k8s-master:6443 --token 3d05gm.ayjl70fgtg4egst2 \
  2. --discovery-token-ca-cert-hash sha256:a3d6e581c493d2e02ca2e4736eeb755af671a9df26095c700bc288a514800b39

检测节点运行情况(k8s-master机器)

  1. #都在readly状态证明安装完成
  2. kubectl get node 

java安装

上传jdk-8u401-linux-x64.tar.gz到/opt/software目录下

  1. #解压
  2. tar -zxvf jdk-8u401-linux-x64.tar.gz -C /opt/module
  3. #创建环境变量
  4. vim /etc/profile.d/myenv.sh
  5. #设置JAVA_HOME
  6. #JAVA_HOME
  7. export JAVA_HOME=/opt/module/jdk1.8.0_401
  8. export PATH=${JAVA_HOME}/bin:$PATH
  9. #刷新生效
  10. source /etc/profile.d/myenv.sh
  11. #检验
  12. java -version

mysql安装

  1. #检查是否安装过MySQL
  2. rpm -qa | grep mysql
  3. #检查是否存在 mariadb 数据库(内置的MySQL数据库),有则强制删除
  4. rpm -qa | grep mariadb
  5. #强制删除
  6. rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
  7. #强制删除
  8. rpm -e --nodeps mariadb-5.5.68-1.el7.x86_64
  9. #下载mysql源
  10. curl -O https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
  11. #安装MySQL源
  12. yum localinstall mysql57-community-release-el7-11.noarch.rpm
  13. #安装密钥
  14. rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
  15. #安装mysql
  16. yum install mysql-community-server
  17. #启动mysql
  18. systemctl start mysqld
  19. #获取默认密码
  20. grep 'temporary password' /var/log/mysqld.log
  21. #登录mysql
  22. mysql -uroot -p显示的默认密码
  23. #修改密码策略
  24. set global validate_password_policy=0;
  25. set global validate_password_length=1;
  26. #修改密码
  27. ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
  28. #授予root用户远程访问权限,并刷新权限使生效(可选)
  29. grant all privileges on *.* to 'root' @'%' identified by '新密码';

maven安装(用于依赖项下载,可选)

  1. #下载安装包
  2. curl -O https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
  3. #解压
  4. tar -zxvf apache-maven-3.9.6-bin.tar.gz -C /opt/module

flink安装

  1. #下载安装包
  2. curl -O https://archive.apache.org/dist/flink/flink-1.16.3/flink-1.16.3-bin-scala_2.12.tgz
  3. #解压
  4. tar -zxvf flink-1.16.3-bin-scala_2.12.tgz -C /opt/module

Streampark安装

官网手册:安装部署 | Apache StreamPark (incubating)

上传apache-streampark_2.12-2.1.3-incubating-bin.tar.gz到/opt/software目录下

  1. #解压
  2. tar -zxvf apache-streampark_2.12-2.1.3-incubating-bin.tar.gz -C /opt/module
  3. #初始化表结构、登录mysql
  4. source streampark安装位置/script/schema/mysql-schema.sql
  5. source streampark安装位置/script/data/mysql-data.sql
  6. #修改连接信息,进入到 conf 下,修改 conf/application.yml,找到 spring 这一项,找到 profiles.active 的配置,修改成mysql即可
  7. spring:
  8. profiles.active: mysql #[h2,pgsql,mysql]
  9. #修改 config/application-mysql.yml
  10. spring:
  11. datasource:
  12. username: root
  13. password: 你的密码如果是纯数字需要加单引号'000000'
  14. 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/859894
    推荐阅读
    相关标签
cppcmd=keepalive&