编辑
2023-07-28
运维
00

内网穿透

1. 服务端配置

需要拥有一台带有公网IP的云服务器进行内网穿透的服务端

shell
wget https://github.com/fatedier/frp/releases/download/v0.43.0/frp_0.43.0_linux_amd64.tar.gz tar -zxvf frp_0.43.0_linux_amd64.tar.gz #解压 rm -f frpc frpc_full.ini frpc.ini #删除客户端 [common] bind_port = **** #服务端口 vhost_http_port = **** #http端口 max_pool_count = 5 authentication_timeout = 900 dashboard_port = **** #管理页面端口 dashboard_user = admin dashboard_pwd = ****** #密码 subdomain_host = wuwuwwi.cn #域名 [ssh] listen_port = **** #对应客户端ssh映射端口 auth_token = **** #客户端token [nasweb] listen_port = 6001
编辑
2023-07-28
运维
00

gunicorn

需要安装gunicorn gevent **注意!**这个模块虽然在win上可以使用pip进行安装,但是在win上是无法使用的,在linux环境下才可以使用!

Docker打包发布

使用Vscode自动生成Dockerfile

Dockerfile
# For more information, please refer to https://aka.ms/vscode-docker-python FROM python:3.8-slim EXPOSE 5002 # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1 # 复制模块安装文件到目录中 COPY requirements.txt . #换清华源 RUN python -m pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple #设置工作目录 WORKDIR /app #复制所有文件到工作目录 COPY . /app # Creates a non-root user with an explicit UID and adds permission to access the /app folder # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app USER appuser # During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug # 使用gunicorn启动项目在5002上 CMD ["gunicorn", "--bind", "0.0.0.0:5002", "wanAlert:app"]
编辑
2023-07-28
单片机杂谈
00

为什么需要中断?

循环中检查设备状态有可能因为未能及时捕捉信号导致丢失,所以需要使用中断的方式来

编辑
2023-07-28
运维
00

背景

这边需要用集群的方式部署一下JumpServer,因为堡垒机是为了对接所有服务器和交换机的,相对比较重要 所以这边使用的NFS就部署一下高可用环境。在这过程中踩了不少坑,网上的资料好像大多都是红帽的,这次想用Ubuntu的玩一下。 环境为Ubuntu2004

NFS

没什么好说的

bash
#安装 NFS apt-get install nfs-kernel-server -y #创建共享目录 mkdir -p /opt/nfsdata #编辑配置文件 vim /etc/exports # 加一行 # /opt/nfsdata 192.168.0.*(rw,sync,no_subtree_check,all_squash,anonuid=0,anongid=0) # 高版本NFS要加no_subtree_check参数 这个参数表示不检查父目录权限,或者subtree_check检查父目录权限 # 打开共享 exportfs -a # 启动 NFS服务 systemctl start nfs-server.service
编辑
2023-07-28
运维
00
bash
FROM ubuntu:20.04 #设置非交互 不然会卡tzdata ENV DEBIAN_FRONTEND noninteractive ENV TZ=Asia/Shanghai LANG=C.UTF-8 #换阿里云源以及安装runner依赖 RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list && apt update \ && apt install -y openssh-server gettext texinfo bison autoconf wget patch texinfo dos2unix simg2img libssl-dev u-boot-tools gperf ctags git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig openssl libssl-dev python2.7 #开启root登录 RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config #设置root密码 RUN echo "root:passwd" | chpasswd #开启ssh RUN service ssh restart #设置工作目录 WORKDIR /data/docker-data