1.spring boot 中出现DataBufferLimitException: Exceeded limit on max bytes to buffer :262144
出现场景(我遇到的):
- Spring WebFlux使用Post传输文件大小
- Spring Gateway中出现
- Spring Elasticsearch Reactive中出现
解决方法:
- 修改配置文件
spring:
codec:
max-in-memory-size: 100MB
##但是其实是不生效的,依然设置为262144了,官方虽然说解决了,但是我用的版本是没有解决的
- 重写org.springframework.core.codec.AbstractDataBufferDecoder
package org.springframework.core.codec;
import java.util.Map;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.MimeType;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* @Auther: whhh
* @Date: 2021/4/7 11:08
* @Description: 图片上传重写缓存区大小,解决上传图片缓存不够问题
*/
public abstract class AbstractDataBufferDecoder<T> extends AbstractDecoder<T> {
//图片上传重写缓存区大小,解决上传图片缓存不够问题
private int maxInMemorySize = 1024*1024*100;
protected AbstractDataBufferDecoder(MimeType... supportedMimeTypes) {
super(supportedMimeTypes);
}
public void setMaxInMemorySize(int byteCount) {
this.maxInMemorySize = byteCount;
}
public int getMaxInMemorySize() {
return this.maxInMemorySize;
}
public Flux<T> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return Flux.from(input).map((buffer) -> {
return this.decodeDataBuffer(buffer, elementType, mimeType, hints);
});
}
public Mono<T> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return DataBufferUtils.join(input, this.maxInMemorySize).map((buffer) -> {
return this.decodeDataBuffer(buffer, elementType, mimeType, hints);
});
}
/** @deprecated */
@Deprecated
@Nullable
protected T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return this.decode(buffer, elementType, mimeType, hints);
}
}
2. docker: Error response from daemon: driver failed programming external connectivity on endpoint
某天启动docker容器时,突然出现这个异常问题,经查阅资料,找到如下解决方案:
pkill docker #终止进程
iptables -t nat -F #清空nat表的所有链
ifconfig docker0 down #停止docker默认网桥
brctl delbr docker0 #删除网桥
systemctl restart docker #重启docker
3.CentOS虚拟机断电或强制关机,再开机出现问题:Entering emergency mode. Exit the shell to continue.
因为之前工作需要,大量使用Linux虚拟机做开发工作,因为一些问题,会出现强制关机重启,导致出现一些问题,开机会出现如下所示:
Generating "/run/initramfs/rdsosreport.txt"
Entering emergency mode.Exit the shell to continue.
Type "journalctl"to view system logs.
You might want to save "/run/initramfs/rdsosreport.txt"to a USB stick or /boot
after mounting them and attach it to a bug report.
解决方法:
执行命令: xfs_repair -v -L /dev/dm-0
执行完上述命令后,可能出现如下问题:
Welcome to emergency mode!After logging in,type "journalctl -xb"to view
system logs,"systemctl reboot"to reboot,"systemctl default"or D to
try again to boot into default mode.
Give root password for maintenance
(or type Control-D to continue):
经过排查,出现问题的原因是自动存在问题,但开机有没有挂载成功导致的。 处理方法:
1:登陆root 乱码也输入密码
2:vim /etc/fstab ,检查磁盘挂载信息
3:注释掉自己增加的内容,如果确定不在使用可以删除
4:重启OK。
4. Docker创建容器时[Warning] IPv4 forwarding is disabled. Networking will not work.
解决方案:
vim /usr/lib/sysctl.d/00-system.conf
添加代码:net.ipv4.ip_forward=1
重启network服务:systemctl restart network