局域网内凝思上安装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

相关文章

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

Centos7安装Mongodb4

1、下载源码包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz 2、解压 放到 /usr/local/ 目录下 tar -zxvf mongodb-linux-x86_64-rhel70-4.2.1.tgzmv mongodb-linux-x86_64-rhel70-4.2.1/

如何用Docker运行Django项目

本章教程,介绍如何用Docker创建一个Django,并运行能够访问。 一、拉取镜像 这里我们使用python3.11版本的docker镜像 docker pull python:3.11 二、运行容器 这里我们将容器内部的8080端口,映射到宿主机的80端口上。 docker run -itd --name python311 -p

Centos7安装JDK1.8保姆版

工欲善其事,必先利其器。这句话同样适用于学习Java编程。在开始Java的学习旅程之前,我们必须首先配置好适合的开发环境。 通过事先准备好这些工具和配置,我们可以避免在学习过程中遇到因环境问题导致的代码异常或错误。一个稳定、高效的开发环境能够让我们更加专注于代码的学习和编写,提升学习效率,减少不必要的困扰和挫折感。因此,在学习Java之初,投入一些时间和精力来配置好开发环境是非常值得的。这将为我

安装nodejs环境

本文介绍了如何通过nvm(NodeVersionManager)安装和管理Node.js及npm的不同版本,包括下载安装脚本、检查版本并安装特定版本的方法。 1、安装nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 2、查看nvm版本 nvm --version 3、安装

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

SWAP作物生长模型安装教程、数据制备、敏感性分析、气候变化影响、R模型敏感性分析与贝叶斯优化、Fortran源代码分析、气候数据降尺度与变化影响分析

查看原文>>>全流程SWAP农业模型数据制备、敏感性分析及气候变化影响实践技术应用 SWAP模型是由荷兰瓦赫宁根大学开发的先进农作物模型,它综合考虑了土壤-水分-大气以及植被间的相互作用;是一种描述作物生长过程的一种机理性作物生长模型。它不但运用Richard方程,使其能够精确的模拟土壤中水分的运动,而且耦合了WOFOST作物模型使作物的生长描述更为科学。 本文让更多的科研人员和农业工作者

K8S(Kubernetes)开源的容器编排平台安装步骤详解

K8S(Kubernetes)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序。以下是K8S容器编排平台的安装步骤、使用方式及特点的概述: 安装步骤: 安装Docker:K8S需要基于Docker来运行容器化应用程序。首先要在所有节点上安装Docker引擎。 安装Kubernetes Master:在集群中选择一台主机作为Master节点,安装K8S的控制平面组件,如AP

Spring框架5 - 容器的扩展功能 (ApplicationContext)

private static ApplicationContext applicationContext;static {applicationContext = new ClassPathXmlApplicationContext("bean.xml");} BeanFactory的功能扩展类ApplicationContext进行深度的分析。ApplicationConext与 BeanF