分类 运维 下的文章

CIDR 无类别域间路由 Classless Inter-Domain Routing

所有IP 0.0.0.0/0

A级段 192.168.1.1/8 表示192.0.0.0-192.255.255.255
对应子网掩码格式 192.168.1.1/255.0.0.0

B级段 192.168.1.1/16 表示192.168.0.0-192.168.255.255
对应子网掩码格式 192.168.1.1/255.255.0.0

C级段 192.168.1.1/24 表示192.168.1.0-192.168.1.255
对应子网掩码格式 192.168.1.1/255.255.255.0

TCPD 传输控制协议守护进程 Transmission Control Protocol daemon
配置文件为/etc/hosts.allow和/etc/hosts.deny

修改/etc/hosts.allow文件
sshd:222.77.15.:allow
all:218.24.129.110
vsftpd:all

修改/etc/hosts.deny文件
sshd:all:deny

service xinetd restart

1 vsftp基于IP段的访问控制

修改/etc/vsftpd/vsftpd.conf 需要有下面这条配置
tcp_wrappers=YES

vsftpd 所有的ip都不可以访问
echo "vsftpd:all:Deny" >> /etc/hosts.deny

只允许192.168.5.1访问
echo "vsftpd:192.168.5.1:Allow" >> /etc/hosts.allow
允许策略,可以用*号,也可以写多行
vsftpd:196.168.0.*:allow

重启vsftpd
systemctl restart vsftpd

2 vsftp基于OS本地用户和IP段的访问控制

这里我们需要用到pam模块,开始下面的配置
cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bk
cat > /etc/pam.d/vsftpd <<EOF
auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
account required pam_access.so
EOF

pam_access.so是模块,会调用到配置文件/etc/security/access.conf ,然后我们在access.conf里面配置访问控制信息,按照自己的需求添加下面的信息。
vi /etc/security/access.conf
test用户所有IP都不让访问,vagrant用户都可以访问
-:test:ALL
+:vagrant:ALL
test用户只有192.168.5.1 192.168.5.101可以访问,vagrant用户只有192.168.5.1可以访问
-:test:ALL EXCEPT 192.168.5.1 192.168.5.101
-:vagrant:ALL EXCEPT 192.168.5.1

重启vsftpd服务
systemctl restart vsftpd

一 stable diffusion简介
stable diffusion和mid journey是现今最为流行的2个A训练工具
stable diffusion开源,插件和配置项较多
mid journey非开源,操作较为简单

二 github下载源码
https://github.com/AUTOMATIC1111/stable-diffusion-webui

三 根据当前版本的readme文件进行安装
Installation and Running推荐的安装步骤为:
1 确认及更新显卡驱动
2 安装Python
3 安装git
4 下载仓库
5 运行批处理

四 安装Python
建议的版本为3.10.6
安装时勾选Add Python to PATH
安装后确认版本:python -V
版本异常检查环境变量

五 更新显卡驱动
命令行执行
nvidia-smi
确认当前为CUDA Version: 11.7

在developer.download.nvidia.cn下载对应斑斑
https://developer.download.nvidia.cn/compute/cuda/11.7.0/local_installers/cuda_11.7.0_516.01_windows.exe

在命令行确认当前版本
nvcc -V

六 运行批处理
文件夹下直接点击webui-user.bat

七 从入门到放弃
卡顿 无法安装
使用B站秋葉aaaki的整合包
https://www.bilibili.com/video/BV1iM4y1y7oA

八 问题解决
提示:No module 'xformers'. Proceeding without it
webui-user.bat”文件,添加--xformers参数
set COMMANDLINE_ARGS=--xformers

提示RuntimeError: No CUDA GPUs are available
命令行
python
import torch
torch.cuda.device_count()
torch.cuda.is_available()
发现为false

print(torch.__version__)
发现为2.0.0+cpu
cpu版本而非GPU版本

安装GPU版本Pytorch
根据官网选项生成在线安装命令
https://pytorch.org/get-started/locally/
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

执行报错
Requirement already satisfied: torch in XXX
进入所在目录
针对提示删除torch开头的文件夹
重新执行安装命令