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

相关文章

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.

Python 安装和配置flask, flask_cors的图文教程

《Python安装和配置flask,flask_cors的图文教程》:本文主要介绍Python安装和配置flask,flask_cors的图文教程,本文通过图文并茂的形式给大家介绍的非常详细,... 目录一.python安装:二,配置环境变量,三:检查Python安装和环境变量,四:安装flask和flas

Docker镜像修改hosts及dockerfile修改hosts文件的实现方式

《Docker镜像修改hosts及dockerfile修改hosts文件的实现方式》:本文主要介绍Docker镜像修改hosts及dockerfile修改hosts文件的实现方式,具有很好的参考价... 目录docker镜像修改hosts及dockerfile修改hosts文件准备 dockerfile 文

Win11安装PostgreSQL数据库的两种方式详细步骤

《Win11安装PostgreSQL数据库的两种方式详细步骤》PostgreSQL是备受业界青睐的关系型数据库,尤其是在地理空间和移动领域,:本文主要介绍Win11安装PostgreSQL数据库的... 目录一、exe文件安装 (推荐)下载安装包1. 选择操作系统2. 跳转到EDB(PostgreSQL 的

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

MySQL Workbench 安装教程(保姆级)

《MySQLWorkbench安装教程(保姆级)》MySQLWorkbench是一款强大的数据库设计和管理工具,本文主要介绍了MySQLWorkbench安装教程,文中通过图文介绍的非常详细,对大... 目录前言:详细步骤:一、检查安装的数据库版本二、在官网下载对应的mysql Workbench版本,要是

Docker镜像pull失败两种解决办法小结

《Docker镜像pull失败两种解决办法小结》有时候我们在拉取Docker镜像的过程中会遇到一些问题,:本文主要介绍Docker镜像pull失败两种解决办法的相关资料,文中通过代码介绍的非常详细... 目录docker 镜像 pull 失败解决办法1DrQwWCocker 镜像 pull 失败解决方法2总

如何将Tomcat容器替换为Jetty容器

《如何将Tomcat容器替换为Jetty容器》:本文主要介绍如何将Tomcat容器替换为Jetty容器问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Tomcat容器替换为Jetty容器修改Maven依赖配置文件调整(可选)重新构建和运行总结Tomcat容器替

通过Docker Compose部署MySQL的详细教程

《通过DockerCompose部署MySQL的详细教程》DockerCompose作为Docker官方的容器编排工具,为MySQL数据库部署带来了显著优势,下面小编就来为大家详细介绍一... 目录一、docker Compose 部署 mysql 的优势二、环境准备与基础配置2.1 项目目录结构2.2 基