Exceptionless in Docker on Linux 搭建及部署疑难杂症
https://github.com/exceptionless/Exceptionless
https://github.com/exceptionless/Exceptionless.UI
项目拉下来,nuget还原下,这里我是一直还原不上的,后面强了就对了(最近github一直比较慢,nuget也是慢死了)
先是用了它的docker-compose 里面东西太多了,job总是有问题,后面用源码自己建立一个dockerfile 来打包
打包UI 需要用
npx grunt build
需要安装 grunt 这里就不介绍了
通过之前的 用nginx来打包ui 就行了
通过命令推送到 Harbor
当然也需要安装elasticsearch 5.X ,容器很方便的,后面用容器即可创建es了
一起看起来都很容易
后面检查了源码发现 模式非Localhost环境下是需要用 https的
services.AddMvc(o => { o.Filters.Add(new CorsAuthorizationFilterFactory("AllowAny")); o.Filters.Add<RequireHttpsExceptLocalAttribute>(); o.Filters.Add<ApiExceptionFilter>(); o.ModelBinderProviders.Insert(0, new CustomAttributesModelBinderProvider()); o.InputFormatters.Insert(0, new RawRequestBodyFormatter()); })
public sealed class RequireHttpsExceptLocalAttribute : RequireHttpsAttribute { public RequireHttpsExceptLocalAttribute() { IgnoreLocalRequests = true; } }
[ApiController] [RequireHttpsExceptLocal] public abstract class ExceptionlessApiController : Controller { }
使用的时候需要注释一下
分别运行容器 ,这里需要注意的是es容器和exceptionless 要做对于的资料卷挂载 ,后面我统一整理到 docker-compose中
发现都是OK的。
为了实现一键搞定,整理了一个docker-compose 如下
version: "3.3" volumes: #el exceptionless_data: driver: local #es elasticsearch_data: driver: local # el使用的es elasticsearch_el_data: driver: local services: # redis 服务 redis: image: redis:5.0.3-alpine3.8 container_name: stu-exam_redis # deploy: # mode: replicated # replicas: 1 # resources: # limits: # cpus: '0.50' # memory: 256M # reservations: # cpus: '0.10' # memory: 50M # restart_policy: # condition: on-failure # delay: 5s # max_attempts: 3 command: redis-server /usr/local/etc/redis/redis.conf expose: - '6379' ports: - 6379:6379 volumes: - ./redis/data:/data - ./redis/redis.conf:/usr/local/etc/redis/redis.conf #ES 5.X master elasticsearch_master: image: elasticsearch:5.6.16 container_name: stu-exam_es_master environment: - "ES_JAVA_OPTS=-Xms1g -Xmx1g" - ES_CLUSTERNAME=elasticsearch command: elasticsearch volumes: - elasticsearch_data:/usr/share/elasticsearch/data - ./elasticsearch/node/master/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml ports: - 9200:9200 - 9300:9300 # ES node01 # elasticsearch_node01: # image: elasticsearch:5.6.16 # container_name: stu-exam_es_node01 # environment: # - bootstrap.memory_lock=true # - "ES_JAVA_OPTS=-Xms1g -Xmx1g" # - ES_CLUSTERNAME=elasticsearch # command: elasticsearch # volumes: # - elasticsearch_data/node/node01/data:/usr/share/elasticsearch/data # - ./elasticsearch/node/node01/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml # ports: # - 9200:9200 # - 9300:9300 # links: # - elasticsearch_master #el_api exceptionless_api: image: xxxx/tools/exceptionless_api:pro-1.0 container_name: stu-exam_exceptionless_api # environment: # AppMode: Production # EX_ConnectionStrings__Cache: provider=redis # EX_ConnectionStrings__Elasticsearch: server=http://192.168.0.240:9200 # EX_ConnectionStrings__MessageBus: provider=redis # EX_ConnectionStrings__Queue: provider=redis # #EX_ConnectionStrings__Metrics: provider=statsd;server=statsd; # EX_ConnectionStrings__Queue: provider=redis # EX_ConnectionStrings__Redis: server=redis,abortConnect=false # EX_ConnectionStrings__Storage: provider=folder;path=/app/storage # EX_RunJobsInProcess: 'false' links: - elasticsearch_master:es-master - redis expose: - '80' ports: - 65000:80 volumes: - exceptionless_data:/appexceptionless/storage - ./exceptionless/appsettings.Production.yml:/appexceptionless/appsettings.Production.yml depends_on: - elasticsearch_master # el_ui exceptionless_ui: image: xxx/tools/exceptionless_ui:pro-1.0 environment: AppMode: Development # EL-API 配置外部URL BaseUrl: http://192.168.0.240:65000 ports: - 5100:80 volumes: - ./exceptionless/conf.js:/usr/share/nginx/html/app.config.11aa095b02872a76.js depends_on: - exceptionless_api
通过 docker-compose up 启动全部就搞定了 当然也可以通过 docker-compose 指定的服务名称来启动(exceptionless_ui) ,服务会根据depends_on依赖关系来确定启动的先后顺序。
但是后面使用客户端添加日志,发现日志并没有记录在里面,出现了错误
解决办法:
原来是因为我们使用容器安装的包或者自己下载的es包中缺少插件,这里这个错误就需要安装 mapper-size 这个插件,安装好了,客户端就添加进去了,怎么安装就不介绍了,我们在容器内部安装好相关插件后自己在打包一个自己的es镜像就可以了
最后还有一个问题就是 当我们要从新运行 elasticsearch容器的时候,记得也要重新运行 exceptionless_api,不然当elasticsearch rm掉之后,exceptionless_api访问会出现问题 mapper相关的问题,可能是因为 exceptionless_api 再次访问会从新创建 es 分片的原因
docker run -d --name=elasticsearch_node1 \ -v /root/customdata/es/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /root/customdata/es/data:/usr/share/elasticsearch/data \ -v /root/customdata/es/plugins/:/usr/share/elasticsearch/plugins/ \ -p 9400:9200 -p 9500:9300 elasticsearch:5.6.16 ui: docker run -d --name=exceptionlessui_node1 -v /root/customdata/exceptionless_ui/app.config.js:/usr/share/nginx/html/app.config.11aa095b02872a76.js -p 40007:80 xxxx/tools/exceptionless_ui:pro-1.0 exceptionlessapi: docker run -d --name=exceptionlessapi_node1 -v /root/customdata/exceptionless_api/appsettings.Production.yml:/appexceptionless/appsettings.Production.yml \ -v /root/customdata/exceptionless_api/storage/:/appexceptionless/storage \ -p 40008:80 xxxx/tools/exceptionless_api:pro-1.0
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!
本文版权归作者和博客园共有,来源网址:http://www.cnblogs.com/liyouming欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接。