局域网内凝思上安装docker的mqtt容器

2023-12-13 10:52

本文主要是介绍局域网内凝思上安装docker的mqtt容器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

局域网内凝思上安装docker的mqtt容器

一:描述

       外地出差,有两个局域网的凝思系统的服务器需要安装mqtt服务,要求支持匿名登录。因为是局域网无法联网。因此,需要实现在局域网实现凝思上安装docker的mqtt容器。

二:案例分析和解决
2.1 安装docker服务

       考虑到凝思无法直接找到下载源,世界使用centos的docker的二进制包:   

    

       对应的是debian8

       先离线下载 https://download.docker.com/linux/static/stable/x86_64/ ,  Index of linux/static/stable/x86_64/ ,

       将docker-20.10.7.tgz文件或者最高版本上传到centos7-linux系统上,用ftp工具上传即可解压

[root@localhost java]# tar -zxvf docker-20.10.7.tgz

将解压出来的docker文件复制到 /usr/bin/ 目录下

[root@localhost java]# cp docker/* /usr/bin/

进入/etc/systemd/system/目录,并创建docker.service文件

[root@localhost java]# cd /etc/systemd/system/

[root@localhost system]# touch docker.service

打开docker.service文件,将以下内容复制

[root@localhost system]# vi docker.service

       Description=Docker Application Container Engine

       Documentation=https://docs.docker.com

       After=network-online.target firewalld.service

       Wants=network-online.target

       [Service]

       Type=notify

       # the default is not to use systemd for cgroups because the delegate issues still

       # exists and systemd currently does not support the cgroup feature set required

       # for containers run by docker

       ExecStart=/usr/bin/dockerd  --graph=/home/dockerbase/docker

       ExecReload=/bin/kill -s HUP $MAINPID

       # Having non-zero Limit*s causes performance problems due to accounting overhead

       # in the kernel. We recommend using cgroups to do container-local accounting.

       LimitNOFILE=infinity

       LimitNPROC=infinity

       LimitCORE=infinity

       # Uncomment TasksMax if your systemd version supports it.

       # Only systemd 226 and above support this version.

       #TasksMax=infinity

       TimeoutStartSec=0

       # set delegate yes so that systemd does not reset the cgroups of docker containers

       Delegate=yes

       # kill only the docker process, not all processes in the cgroup

       KillMode=process

       # restart the docker process if it exits prematurely

       Restart=on-failure

       StartLimitBurst=3

       StartLimitInterval=60s

        

       [Install]

       WantedBy=multi-user.target

给docker.service文件添加执行权限

[root@localhost system]# chmod 777 /etc/systemd/system/docker.service

重新加载配置文件(每次有修改docker.service文件时都要重新加载下)

[root@localhost system]# systemctl daemon-reload

启动

[root@localhost system]# systemctl start docker

设置开机启动

[root@localhost system]# systemctl enable docker.service

查看docker状态

[root@localhost system]# systemctl status docker

2.2 安装mosquitto容器

       服务器属于局域网【异地出差办公】,无法链接公网,因此使用代理来实现。

       类似结构:局域网服务器----(网线直连) ---笔记本----(wifi)----公网

       笔记本和服务器接入同一个局域网或者直连,笔记本接公网wifi,然后启动此CCProxy

     

修改

root@linx:/home/cc# cat /etc/systemd/system/docker.service.d/proxy.conf

[Service]

Environment="HTTP_PROXY=http://192.168.1.7:808/"

Environment="HTTPS_PROXY=http://192.168.1.7:808/"

Environment="NO_PROXY=localhost,127.0.0.1,.example.com"

# 拉取镜像

docker pull eclipse-mosquitto:2.0.14

# 建立目录

mkdir -p /TeaR-APP/install/mosquitto/1/config

mkdir -p /TeaR-APP/install/mosquitto/1/data

mkdir -p /TeaR-APP/install/mosquitto/1/log

# 为目录授权

chmod -R 755  /TeaR-APP/install/mosquitto/1

chmod -R 777 /TeaR-APP/install/mosquitto/1/log #日志目录要最大权限

新建文件

touch /TeaR-APP/install/mosquitto/1/config/pwfile.conf

# 启动脚本

docker run -it --name=mosquitto --privileged  -p 1883:1883 -p 9001:9001 -v /TeaR-APP/install/mosquitto/1/config:/mosquitto/config  -v /TeaR-APP/install/mosquitto/1/data:/mosquitto/data -v /TeaR-APP/install/mosquitto/1/log:/mosquitto/log -d  eclipse-mosquitto:2.0.14

配置账号密码

vim  /TeaR-APP/install/mosquitto/1/config/mosquitto.conf

配置文件添加以下配置

# 关闭匿名模式

allow_anonymous true

# 指定密码文件

password_file /mosquitto/config/pwfile.conf

# 写入以下内容

persistence true

persistence_location /mosquitto/data

log_dest file /mosquitto/log/mosquitto.log

listener 1883

9、生成密码

docker exec -it 06e57924bf31 sh

# 使用mosquitto_passwd命令创建用户,第一个test是用户名,第二个test2020是密码

mosquitto_passwd -b /mosquitto/config/pwfile.conf  tgy  test123456

mosquitto_passwd -b /mosquitto/config/pwfile.conf  admin  aithu0508

  

2.4 利用镜像安装另外的服务器

       安装镜像后导出,并安装到其他离线服务器【只能优盘,无法联网】。

       到上一个服务器上,保存镜像出服务器指定目录,注意非容器id

#docker save 58900513926f > /home/cc/eclipse-mosquitto.tar

加载镜像到docker:

#docker load < /home/cc/eclipse-mosquitto.tar

注意: 加载成功后REPOSITORY和TAG显示none,需要我们修改标签。

3.修改镜像标签

可以使用命令:

docker tag [image id] [name]:[版本]

例如:

docker tag 999b74b01d97 eclipse-mosquitto:2.0.14

这篇关于局域网内凝思上安装docker的mqtt容器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/488205

相关文章

使用Docker构建Python Flask程序的详细教程

《使用Docker构建PythonFlask程序的详细教程》在当今的软件开发领域,容器化技术正变得越来越流行,而Docker无疑是其中的佼佼者,本文我们就来聊聊如何使用Docker构建一个简单的Py... 目录引言一、准备工作二、创建 Flask 应用程序三、创建 dockerfile四、构建 Docker

SpringBoot+Docker+Graylog 如何让错误自动报警

《SpringBoot+Docker+Graylog如何让错误自动报警》SpringBoot默认使用SLF4J与Logback,支持多日志级别和配置方式,可输出到控制台、文件及远程服务器,集成ELK... 目录01 Spring Boot 默认日志框架解析02 Spring Boot 日志级别详解03 Sp

Spring IoC 容器的使用详解(最新整理)

《SpringIoC容器的使用详解(最新整理)》文章介绍了Spring框架中的应用分层思想与IoC容器原理,通过分层解耦业务逻辑、数据访问等模块,IoC容器利用@Component注解管理Bean... 目录1. 应用分层2. IoC 的介绍3. IoC 容器的使用3.1. bean 的存储3.2. 方法注

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

java实现docker镜像上传到harbor仓库的方式

《java实现docker镜像上传到harbor仓库的方式》:本文主要介绍java实现docker镜像上传到harbor仓库的方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 前 言2. 编写工具类2.1 引入依赖包2.2 使用当前服务器的docker环境推送镜像2.2

Java MQTT实战应用

《JavaMQTT实战应用》本文详解MQTT协议,涵盖其发布/订阅机制、低功耗高效特性、三种服务质量等级(QoS0/1/2),以及客户端、代理、主题的核心概念,最后提供Linux部署教程、Sprin... 目录一、MQTT协议二、MQTT优点三、三种服务质量等级四、客户端、代理、主题1. 客户端(Clien

c++中的set容器介绍及操作大全

《c++中的set容器介绍及操作大全》:本文主要介绍c++中的set容器介绍及操作大全,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录​​一、核心特性​​️ ​​二、基本操作​​​​1. 初始化与赋值​​​​2. 增删查操作​​​​3. 遍历方

如何在Spring Boot项目中集成MQTT协议

《如何在SpringBoot项目中集成MQTT协议》本文介绍在SpringBoot中集成MQTT的步骤,包括安装Broker、添加EclipsePaho依赖、配置连接参数、实现消息发布订阅、测试接口... 目录1. 准备工作2. 引入依赖3. 配置MQTT连接4. 创建MQTT配置类5. 实现消息发布与订阅

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

MySQL MCP 服务器安装配置最佳实践

《MySQLMCP服务器安装配置最佳实践》本文介绍MySQLMCP服务器的安装配置方法,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下... 目录mysql MCP 服务器安装配置指南简介功能特点安装方法数据库配置使用MCP Inspector进行调试开发指