全部产品
云市场

阿里云PRA服务端迁移(k8s--docker)

更新时间:2019-09-18 15:36:33

一、以docker方式部署RPA服务端

1.拷贝资源文件

通过scp 或者其他方式把docker 目录和server 目录传输到部署服务器上的/root根目录下
(docker和server目录,请联系阿里云RPA同学获取)

  1. scp -r docker root@server_ip:/root
  2. scp -r server root@server_ip:/root

docker资源文件:

  1. ├── docker
  2. ├── docker-ce # docker离线安装包及其依赖
  3. ├── audit-2.8.4-4.el7.x86_64.rpm
  4. ├── audit-libs-2.8.4-4.el7.x86_64.rpm
  5. ├── audit-libs-python-2.8.4-4.el7.x86_64.rpm
  6. ├── checkpolicy-2.5-8.el7.x86_64.rpm
  7. ├── container-selinux-2.74-1.el7.noarch.rpm
  8. ├── docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
  9. ├── libcgroup-0.41-20.el7.x86_64.rpm
  10. ├── libselinux-2.5-14.1.el7.x86_64.rpm
  11. ├── libselinux-python-2.5-14.1.el7.x86_64.rpm
  12. ├── libselinux-utils-2.5-14.1.el7.x86_64.rpm
  13. ├── libsemanage-2.5-14.el7.x86_64.rpm
  14. ├── libsemanage-python-2.5-14.el7.x86_64.rpm
  15. ├── libsepol-2.5-10.el7.x86_64.rpm
  16. ├── libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
  17. ├── pigz-2.3.4-1.el7.x86_64.rpm
  18. ├── policycoreutils-2.5-29.el7.x86_64.rpm
  19. ├── policycoreutils-python-2.5-29.el7.x86_64.rpm
  20. ├── python-IPy-0.75-6.el7.noarch.rpm
  21. ├── selinux-policy-3.13.1-229.el7_6.6.noarch.rpm
  22. ├── selinux-policy-targeted-3.13.1-229.el7_6.6.noarch.rpm
  23. └── setools-libs-3.3.8-4.el7.x86_64.rpm
  24. └── docker-compose
  25. └── server
  26. ├── cs-docker.tar # RPA服务端镜像文件
  27. └── docker-compose.yml # docker启动脚本

默认docker是针对centos 7.4版本,如果安装的centos 是其他版本如7.3,在安装过程中缺少相应的依赖包,需要联网下载对应版本的docker-ce里面的离线安装包

2. 安装和启动docker

进入docker-ce目录,执行

  1. yum localinstall *.rpm # 如果提示选择选Y

安装完成后执行

  1. systemctl start docker

3.部署阿里云RPA

(1)将编排文件docker-compose拷贝到用户bin目录,并提权

  1. sudo cp -f ~/docker/docker-compose /usr/bin/
  2. sudo chmod +x /usr/bin/docker-compose

(2) 进入到server目录 执行

  1. cd ~/server
  2. sudo docker load -i cs-docker.tar

(3) 查看导入的docker镜像

  1. [root@rpa ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-mysql V3.3.11 b3cd3de42e96 2 weeks ago 372MB
  4. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-assets V3.3.11 34fae7fe864b 2 weeks ago 113MB
  5. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-robot V3.3.11 5b3d3e4faac2 2 weeks ago 667MB
  6. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-web V3.3.11 07176746202e 2 weeks ago 672MB
  7. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-file V3.3.11 45d5e6cf95b0 2 weeks ago 664MB
  8. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-entry-nginx V3.3.11 ac52a2af52f1 3 weeks ago 157MB
  9. registry.cn-hangzhou.aliyuncs.com/codestore/rpa-redis V3.3.11 3ecb7a463946 3 weeks ago 107MB

(4)修改docker-compose.yml文件
先登陆登陆k8s的 master 节点,查看 mysqlredis 配置文件 values.yaml ,找到数据库的密码, 然后将写到 docker-compose.yml 文件的对应位置

  1. # Default values for rpa-mysql.
  2. # This is a YAML-formatted file.
  3. # Declare variables to be passed into your templates.
  4. replicaCount: 1
  5. image:
  6. repository: work_ip:3443/library/rpa-mysql
  7. tag: V3.3.8
  8. pullPolicy: IfNotPresent
  9. service:
  10. name: rpa-mysql
  11. type: NodePort
  12. externalPort: 3306
  13. internalPort: 3306
  14. env:
  15. TZ: "Asia/Shanghai"
  16. MYSQL_ROOT_PASSWORD: "密码"
  17. MYSQL_PASSWORD: "密码"
  18. persistence:
  19. enabled: enable
  20. nfsServer: work_ip
  21. nfsPath: "/rpadata/data/mysql"
  22. accessMode: ReadWriteOnce
  23. size: 8Gi
  1. # Default values for rpa-redis.
  2. # This is a YAML-formatted file.
  3. # Declare variables to be passed into your templates.
  4. replicaCount: 1
  5. image:
  6. repository: work_ip:3443/library/rpa-redis
  7. tag: V3.3.8
  8. pullPolicy: IfNotPresent
  9. service:
  10. name: rpa-redis
  11. type: ClusterIP
  12. externalPort: 6379
  13. internalPort: 6379
  14. env:
  15. TZ: "Asia/Shanghai"
  16. REDIS_PASSWORD: "密码"
  17. persistence:
  18. enabled: enable
  19. pv:
  20. - name: redis
  21. nfsServer: work_ip
  22. nfsPath: "/rpadata/data/redis"
  23. accessMode: ReadWriteMany
  24. size: 10Gi
  25. - name: redis-log
  26. nfsServer: work_ip
  27. nfsPath: "/rpadata/log/redis"
  28. accessMode: ReadWriteMany
  29. size: 10Gi
  1. version: '3.2'
  2. services:
  3. # rpa-mysql
  4. rpa-mysql:
  5. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-mysql:Vx.x.x"
  6. volumes:
  7. - "/rpadata/data/mysql:/var/lib/mysql"
  8. ports:
  9. - "3306:3306"
  10. environment:
  11. - TZ=Asia/Shanghai
  12. - MYSQL_PASSWORD=密码
  13. - MYSQL_ROOT_PASSWORD=密码
  14. # rpa-redis
  15. rpa-redis:
  16. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-redis:Vx.x.x"
  17. volumes:
  18. - "/rpadata/data/redis:/data"
  19. - "/rpadata/log/redis:/var/log/redis"
  20. environment:
  21. - TZ=Asia/Shanghai
  22. - REDIS_PASSWORD=密码
  23. # rpa-assets
  24. rpa-assets:
  25. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-assets:Vx.x.x"
  26. ports:
  27. - "7000:7000"
  28. environment:
  29. - TZ=Asia/Shanghai
  30. # rpa-file
  31. rpa-file:
  32. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-file:Vx.x.x"
  33. volumes:
  34. - "/rpadata/file/file:/data/file"
  35. environment:
  36. - TZ=Asia/Shanghai
  37. - MYSQL_PASSWORD=密码
  38. - REDIS_PASSWORD=密码
  39. depends_on:
  40. - rpa-mysql
  41. - rpa-redis
  42. # rpa-web
  43. rpa-web:
  44. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-web:Vx.x.x"
  45. ports:
  46. - "7001:7001"
  47. volumes:
  48. - "/rpadata/web/file:/data/file"
  49. environment:
  50. - TZ=Asia/Shanghai
  51. - MYSQL_PASSWORD=密码
  52. - REDIS_PASSWORD=密码
  53. depends_on:
  54. - rpa-file
  55. # rpa-robot
  56. rpa-robot:
  57. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-robot:Vx.x.x"
  58. ports:
  59. - "7002:7002"
  60. volumes:
  61. - "/rpadata/robot/file:/data/file"
  62. environment:
  63. - TZ=Asia/Shanghai
  64. - MYSQL_PASSWORD=密码
  65. - REDIS_PASSWORD=密码
  66. depends_on:
  67. - rpa-web
  68. # rpa-entry-nginx
  69. rpa-entry-nginx:
  70. image: "xxxx.xxxx.aliyuncs.com/xxxx/xxx-nginx:Vx.x.x"
  71. ports:
  72. - "80:80"
  73. - "443:443"
  74. environment:
  75. - SERVER_RESOLVER_IP=127.0.0.11
  76. - SERVER_HOST=rpa.aliyun.net
  77. - CLUSTER_HOST=
  78. depends_on:
  79. - rpa-file

(5)启动docker镜像

  1. sudo docker-compose -f docker-compose.yml up -d

二.拷贝k8s方式部署的RPA服务端数据

1、打包RPA服务端的所有数据

RPA服务端的所有数据都保存在 work 节点的 /rpadata/ 目录下,备份整个/rpadata/目录即可。

  1. [root@linux ~]# tar -czvf ~/rpadata.tar.gz ./rpadata/ # 备份数据到home目录下

2、将打包好的RPA服务端数据拷贝到新的服务器上

  1. scp ~/rpadata.tar.gz root@server_ip:/root # 将数据拷贝到新的服务器root目录下

3、将备份的文件解压到/rpadata/目录下

  1. [root@linux ~]# cd /
  2. [root@linux ~]# tar -xzvf ~/rpadata.tar.gz

三、启动阿里云RPA服务

(1)启动docker镜像

  1. sudo docker-compose -f docker-compose.yml up -d

(2)设置docker-compose开机启动

  1. vim /etc/rc.d/rc.local # 编辑启动脚本,在末尾添加一行,加入下面的脚本
  2. systemctl start docker
  3. /usr/bin/docker-compose -f /root/server/docker-compose.yml up -d # 注意修改成自己的docker-compose.yml文件位置
  4. sudo chmod +x /etc/rc.d/rc.local

四、查看结果

在服务器上执行,需要把IP改成自己的服务器IP

  1. [root@rpa ~]# curl -H "Host:rpa.aliyun.net" http://106.15.137.252/login # 注意把ip换成自己服务器的IP
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8" />
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  7. <script type="text/javascript" async="" src="/react-dom.js"></script>
  8. <script type="text/javascript" async="" src="/polyfill.min.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/index.css?v=201812051008">
  10. <link rel="shortcut icon" href="/images/ico/favicon.ico">
  11. <title>阿里云RPA控制台</title>
  12. <!--[if lt IE 9]>
  13. <script>location.href = "//www.taobao.com/markets/tbhome/ali-page-updater"; </script>
  14. <![endif]-->
  15. </head>
  16. <body>
  17. <div id="ice_container"></div>
  18. <script type="text/javascript" src="/rsa/jquery-3.3.1.min.js"></script>
  19. <script type="text/javascript" src="/webuploader/webuploader.min.js"></script>
  20. <script type="text/javascript" charset="utf-8" src="/rsa/RSA.js"></script>
  21. <script type="text/javascript" charset="utf-8" src="/rsa/BigInt.js"></script>
  22. <script type="text/javascript" charset="utf-8" src="/rsa/Barrett.js"></script>
  23. <script type="text/javascript" charset="utf-8" src="/index.js?v=201812051008" id="ice-script"></script>
  24. </body>
  25. </html>

查看日志

  1. sudo docker-compose -f docker-compose.yml logs -f