miaoyun+Rancher+K8S学习与实践


业务协同平台在秒云上部署

<h1>一、基础服务部署</h1> <h2>1.程序说明</h2> <p>身份认证和权限管理服务,是基于微服务开发的程序,程序有:</p> <table> <thead> <tr> <th>序号</th> <th>应用名称</th> <th>服务类型</th> <th>服务端口</th> <th>容器端口</th> <th>主机端口</th> <th>应用</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>mysql57</td> <td>集群IP</td> <td>3306</td> <td>3306</td> <td>32100</td> <td></td> </tr> <tr> <td>2</td> <td>redis</td> <td>主机端口</td> <td>6379</td> <td>6379</td> <td>32101</td> <td></td> </tr> <tr> <td>3</td> <td>nacos</td> <td>主机端口</td> <td>8848</td> <td>8848</td> <td>32102</td> <td>/nacos</td> </tr> <tr> <td>4</td> <td>uias-gateway</td> <td>主机端口</td> <td>19000</td> <td>19000</td> <td>32103</td> <td></td> </tr> <tr> <td>5</td> <td>uias-authentication-service</td> <td>集群IP</td> <td>19001</td> <td>19001</td> <td>n/a</td> <td></td> </tr> <tr> <td>6</td> <td>uias-authorization-service</td> <td>集群IP</td> <td>19002</td> <td>19002</td> <td>n/a</td> <td></td> </tr> <tr> <td>7</td> <td>uias-log-service</td> <td>集群IP</td> <td>19004</td> <td>19004</td> <td>n/a</td> <td></td> </tr> <tr> <td>8</td> <td>uias-manager-service</td> <td>集群IP</td> <td>19005</td> <td>19005</td> <td>n/a</td> <td></td> </tr> <tr> <td>9</td> <td>uias-web</td> <td>主机端口</td> <td>80</td> <td>80</td> <td>32104</td> <td>/</td> </tr> <tr> <td>10</td> <td>prometheus</td> <td>9090</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>11</td> <td>mysql5.7</td> <td>集群IP</td> <td>3306</td> <td>3306</td> <td>32200</td> <td></td> </tr> <tr> <td>12</td> <td>bcpf</td> <td>主机端口</td> <td>8080</td> <td>8080</td> <td>32201</td> <td>/bcpf_front</td> </tr> </tbody> </table> <h2>2. nacos介绍和使用</h2> <h3>2.1 nacos简单介</h3> <p>Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。nacos关键特征包括:</p> <ul> <li>服务发现和服务健康监测</li> <li>动态配置服务</li> <li>动态 DNS 服务</li> <li>服务及其元数据管理 详细请参考:<a href="https://nacos.io/zh-cn/docs/what-is-nacos.html">https://nacos.io/zh-cn/docs/what-is-nacos.html</a></li> </ul> <h3>2.2 nacos使用</h3> <p>1.部署好服务并登录nacos(nacos/nacos) 2.创建命名空间:uisa 以后可能会放到public的命名空间中,这样不再需要创建命名空间。 注意: 命名空间ID(不填则自动生成):<code>此项不能采用自动生成</code></p> <h3>2.3.导入nacos配置文件</h3> <p>配置管理/配置列表,选择命名空间:uias,点‘导入配置’按钮 例如:E:\SVN_PublicPlatForm\trunk\0720200015-业务协同平台\02.受控库\060.发布区\BCPF2.0.20.0831(全)\docker_install\conf\nacos_config_uias_prod_1.0.0.zip 导入配置说明: <img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/cf8af8fd4e717d56606f22782fd9dbc5" alt="" /></p> <pre><code class="language-bash">终止导入:一在初始安装时使用此项; 跳过导入:当有新版本配置文件时,此项能保持旧配置文件内容不变,增加配置文件中新内容项。 覆盖导入:以当前导入的配置文件为准,覆盖原旧的配置文件。</code></pre> <h3>2.4.nacos服务管理</h3> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/ad003866f4ad1c0887e3164b7557f6ce" alt="" /> 服务列表:查询并显示部署成功的服务,未成功的未此显示;</p> <h3>2.5.部署应用程序配置文件说明</h3> <p>部署服务在修改配置文件时,各服务之间的相互调用可以通过采用K8S程序的服务名,秒云中可以在:</p> <pre><code class="language-bash">域视角&amp;项目视角/default/服务services列表中,找到对应的服务名,放进配置文件中。</code></pre> <p>或者:</p> <pre><code class="language-bash">域视角&amp;项目视角/default/应用applications中,选择一服务进入修改页面,“服务与访问”页面中的`服务名称`,把服务名称复制并放入到 部署服务的配置文件中。</code></pre> <h2>3.MySQL部署</h2> <p>可以部署在容器中,也可以部署在VM上,但在生产环境中,为了获取更好的数据库性能,建议数据库不在容器中运行。如果对于读性能要求不高,倒是可以一试。</p> <h3>3.1 拉取镜像配置后,环境参数如下:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>MYSQL_VERSION</td> <td>5.7.29-1debian9</td> </tr> <tr> <td>MYSQL_MAJOR</td> <td>5.7</td> </tr> <tr> <td>GOSU_VERSION</td> <td>1.7</td> </tr> <tr> <td>PATH</td> <td>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</td> </tr> </tbody> </table> <h3>3.2 环境变量中添加mysql连接信息</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>MYSQL_ROOT_PASSWORD</td> <td>310012</td> </tr> <tr> <td>MYSQL_DATABASE</td> <td>nacos_dev</td> </tr> <tr> <td>MYSQL_USER</td> <td>nacos</td> </tr> <tr> <td>MYSQL_PASSWORD</td> <td>nacos</td> </tr> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h3>3.3 容器端口从镜像拉取</h3> <h3>3.4 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/opt/xtpt-data-volumes/data_mysql/init</td> <td>/docker-entrypoint-initdb.d</td> </tr> <tr> <td>添加至configmap中</td> <td>/etc/my.cnf</td> </tr> <tr> <td>/xtpt_volumes/data_mysql/mysql</td> <td>/var/lib/mysql</td> </tr> </tbody> </table> <h3>3.5 mysql初始数据</h3> <p>/var/lib/mysql此目录初始数据来自一键部署中/opt/data/mysql/ 总文件大小约1.2G大小</p> <h3>3.6 执行数据库脚本nacos-mysql.sql</h3> <p>连接nacos_dev数据库,执行脚本nacos-mysql.sql。</p> <h2>4.redis部署</h2> <p>应用名:redis-32101 服务名:redis-32101-deploy-0-svc-0</p> <h3>4.1 拉取镜像配置后,环境参数如下:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> </tr> <tr> <td>REDIS_DOWNLOAD_SHA</td> <td>61db74eabf6801f057fd24b590232f2f337d422280fd19486eca03be87d3a82b</td> </tr> <tr> <td>REDIS_DOWNLOAD_URL</td> <td><a href="http://download.redis.io/releases/redis-5.0.7.tar.gz">http://download.redis.io/releases/redis-5.0.7.tar.gz</a></td> </tr> <tr> <td>REDIS_VERSION</td> <td>5.0.7</td> </tr> <tr> <td>GOSU_VERSION</td> <td>1.11</td> </tr> <tr> <td>PATH</td> <td>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</td> </tr> </tbody> </table> <h3>4.2 容器端口</h3> <p>从镜像拉取</p> <h3>4.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>redis.conf添加至configmap中</td> <td>/etc/redis/redis.conf</td> </tr> <tr> <td>/xtpt_volumes/redis/data</td> <td>/data</td> </tr> </tbody> </table> <h3>4.4 服务与访问</h3> <p>服务类型:主机端口 服务端口:6379------6379-----32101</p> <h2>5 nacos部署</h2> <h3>5.1 拉取镜像配置后,环境参数如下:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TIME_ZONE</td> <td>Asia/Shanghai</td> </tr> <tr> <td>TOMCAT_ACCESSLOG_ENABLED</td> <td>false</td> </tr> <tr> <td>JVM_MMS</td> <td>320m</td> </tr> <tr> <td>JVM_MS</td> <td>128m</td> </tr> <tr> <td>JVM_XMN</td> <td>1g</td> </tr> <tr> <td>JVM_XMX</td> <td>2g</td> </tr> <tr> <td>JVM_XMS</td> <td>2g</td> </tr> <tr> <td>JAVA</td> <td>/usr/lib/jvm/java-1.8.0-openjdk/bin/java</td> </tr> <tr> <td>NACOS_USER</td> <td>nacos</td> </tr> <tr> <td>JAVA_HOME</td> <td>/usr/lib/jvm/java-1.8.0-openjdk</td> </tr> <tr> <td>FUNCTION_MODE</td> <td>all</td> </tr> <tr> <td>CLUSTER_CONF</td> <td>/home/nacos/conf/cluster.conf</td> </tr> <tr> <td>CLASSPATH</td> <td>.:/home/nacos/conf:</td> </tr> <tr> <td>BASE_DIR</td> <td>/home/nacos</td> </tr> <tr> <td>PREFER_HOST_MODE</td> <td>hostname</td> </tr> <tr> <td>MODE</td> <td>standalone</td> </tr> <tr> <td>PATH</td> <td>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</td> </tr> <tr> <td>SPRING_DATASOURCE_PLATFORM</td> <td>mysql</td> </tr> </tbody> </table> <p>说明:NACOS_DEBUG的value变量值n,不符合yml格式要求,会导致K8S容器无法启动,删除此项。</p> <h3>5.2 环境变量中添加参数</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>MYSQL_SERVICE_HOST</td> <td>172.16.7.69</td> </tr> <tr> <td>MYSQL_SERVICE_DB_NAME</td> <td>nacos_dev</td> </tr> <tr> <td>MYSQL_SERVICE_PORT</td> <td>23306</td> </tr> <tr> <td>MYSQL_SERVICE_USER</td> <td>nacos</td> </tr> <tr> <td>MYSQL_SERVICE_PASSWORD</td> <td>nacos</td> </tr> </tbody> </table> <p>上述配置由于配置单机mysql版本,来源standalone-mysql.yaml,把其中MASTER删去。 说明:nacos单机机使用有使用本地数据库和mysql数据库两种模式。</p> <h3>5.3 容器端口</h3> <p>从镜像拉到</p> <h3>5.4 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs/nacos</td> <td>/home/nacos/logs</td> </tr> </tbody> </table> <h3>5.5 配置文件</h3> <p>N/A</p> <h3>5.6 服务与访问</h3> <p>服务类型:主机端口 服务端口:8848----&gt;32102 web应用:/nacos</p> <h1>二、其它服务</h1> <h2>6.prometheus部署 (暂时不用部署)</h2> <h3>6.1 拉取镜像配置后,环境参数如下:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>PATH</td> <td>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</td> </tr> </tbody> </table> <h3>6.2 容器端口</h3> <p>从镜像拉到</p> <h3>6.3 存储卷</h3> <p>N/A</p> <h3>6.4 配置文件</h3> <p>N/A</p> <h3>6.5服务与访问</h3> <p>主机端口,9090</p> <h2>7.uias-gateway部署</h2> <h3>7.1 拉取镜像配置后,环境变量中添加如下参数:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h3>7.2 容器端口</h3> <p>镜像拉取:N/A</p> <h3>7.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs</td> <td>/opt/uias-gateway/logs</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/opt/uias-gateway/config/bootstrap.yml</td> </tr> </tbody> </table> <h3>7.4 配置文件</h3> <p>添加配置bootstrap.yml</p> <h3>7.5 服务与访问</h3> <p>服务类型:主机IP 服务端口: 19000-----19000-----32103 web应用: n/a</p> <h2>8.uias-manager-service部署</h2> <h3>8.1 拉取镜像配置后,环境变量中添加如下参数:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> <tr> <td>REGISTER_HOST</td> <td>172.16.7.69</td> </tr> <tr> <td>REGISTER_PORT</td> <td>8848</td> </tr> </tbody> </table> <h3>8.2 容器端口</h3> <p>镜像拉取:N/A</p> <h3>8.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs</td> <td>/opt/uias-manager-service/logs</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/opt/uias-manager-service/config/bootstrap.yml</td> </tr> </tbody> </table> <h3>8.4 配置文件</h3> <p>添加配置bootstrap.yml</p> <h3>8.5 服务与访问</h3> <p>服务类型:集群IP 服务端口: 19005------19005 web应用:n/a</p> <h2>9.uias-log-service部署</h2> <h3>8.1 拉取镜像配置后,环境变量中添加如下参数:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h2>9.2 容器端口</h2> <p>镜像拉取:N/A</p> <h2>9.3 存储卷</h2> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs</td> <td>/opt/uias-log-service/logs</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/opt/uias-log-service/config/bootstrap.yml</td> </tr> </tbody> </table> <h3>9.4 配置文件</h3> <p>添加配置bootstrap.yml</p> <h3>9.5 服务与访问</h3> <p>服务类型:集群IP 服务端口:19004-19004 web应用:n/a</p> <h2>10.uias-authentication-service部署</h2> <h2>10.1 拉取镜像配置后,环境变量中添加如下参数:</h2> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h3>10.2 容器端口</h3> <p>镜像拉取:N/A</p> <h3>10.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs</td> <td>/opt/uias-authentication-service/logs</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/opt/uias-authentication-service/config/bootstrap.yml</td> </tr> </tbody> </table> <h3>10.4 配置文件</h3> <p>添加配置bootstrap.yml</p> <h3>10.5 服务与访问</h3> <p>服务类型:集群IP 服务端口: 19001------19001 web应用:n/a</p> <h2>11.uias-authorization-service部署</h2> <h3>11.1 拉取镜像配置后,环境变量中添加如下参数:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h3>11.2 容器端口</h3> <p>镜像拉取:N/A</p> <h3>11.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs</td> <td>/opt/uias-authorization-service/logs</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/opt/uias-authorization-service/config/bootstrap.yml</td> </tr> </tbody> </table> <h3>11.4 配置文件</h3> <p>添加配置bootstrap.yml</p> <h3>11.5 服务与访问</h3> <p>服务类型:集群IP 服务端口:19002------19002 web应用:n/a</p> <h2>12.uias-web部署</h2> <h3>12.1 拉取镜像配置后,环境变量中添加如下参数:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h3>12.2 容器端口</h3> <p>镜像拉取:N/A</p> <h3>12.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/uias-logs</td> <td>/var/log/nginx</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/etc/nginx/conf.d/default.conf</td> </tr> </tbody> </table> <p>说明:配置文件E:\SVN_PublicPlatForm\trunk\0720200015-业务协同平台\02.受控库\060.发布区\BCPF2.0.20.0831(全)\docker_install\conf\nginx.conf 需改名为:default.conf</p> <h3>12.4 配置文件</h3> <p>添加配置default.conf</p> <h3>12.5 服务与访问</h3> <p>服务类型:主机端口 服务端口:80------80------32104 web应用:/</p> <h2>13.bcpf部署</h2> <h3>13.1 拉取镜像配置后,环境变量中添加如下参数:</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>TZ</td> <td>Asia/Shanghai</td> </tr> </tbody> </table> <h3>13.2 容器端口</h3> <p>镜像拉取:N/A 配置文件端口=服务端口</p> <h3>13.3 存储卷</h3> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>/xtpt_volumes/bcpf/logs</td> <td>/home/bcpf_logs</td> </tr> <tr> <td>配置文件添加configmap中</td> <td>/opt/tomcat/webapps/bcpf_back/WEB-INF/classes/application.yml</td> </tr> </tbody> </table> <p>web应用: /bcpf_front</p> <h3>13.4 配置文件</h3> <p>添加配置文件application.yml</p> <h3>13.5 服务与访问</h3> <p>服务类型:主机端口 服务端口:8080------8080------32201 web应用:/bcpf_front</p> <h1>三、其它</h1> <h1>1.NFS文件共享服务器</h1> <p>服务端:172.16.3.14</p> <pre><code class="language-bash">[root@sxf-miaoyum-node7 xtptvol]# cat /etc/exports /data_volumes/zyzst_volumes 192.168.30.120(rw,sync,no_subtree_check,no_root_squash) /data_volumes/zyzst_volumes 192.168.30.121(rw,sync,no_subtree_check,no_root_squash) /data_volumes/zyzst_volumes 192.168.30.122(rw,sync,no_subtree_check,no_root_squash)</code></pre> <p>客户端: mount -t nfs 172.16.3.14:/data_volumes/zyzst_volumes/xtpt_volumes /xtpt_volumes -o nolock,nfsvers=3,vers=3 说明: <a href="https://www.jianshu.com/p/238b2337e855">https://www.jianshu.com/p/238b2337e855</a> 与NFS的配置有关,NFS默认是squash_all模式,但是要想使用NFS目录,将目录映射到docker容器中,必须要配置成no_root_squash模式才行,否则root用户(因为这次mysql是以root运行)无权限使用nfs的volume来映射docker容器中的目录!!!</p>

页面列表

ITEM_HTML