目录
5、Param 'serviceName' is illegal
8、An unexpected connection driver error occured
3.linux centos8安装docker一系列问题解决
1.Failed to convert Message content
springcloud
1、snakeyaml
java.lang.NoSuchMethodError: org.yaml.snakeyaml.representer.Representer: method <init>()V not found
版本问题
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.26</version>
</dependency>
2、optionalArgs
Field optionalArgs in org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$Refresh
引入依赖(版本根据需要指定,version部分省略)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
3、 hostname
java.lang.IllegalStateException: Request URI does not contain a valid hostname
微服务名称不合法(不能识别下划线的服务名称)或者不是注册中心所使用的名称
User user = restTemplate.getForObject("http://EUREKA-USER/user/1", User.class);
4、StatusRuntimeException
这个问题主要是nacos版本与spring-cloudalibaba版本对应问题
com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE
<spring-cloud-alibaba>2021.0.1.0</spring-cloud-alibaba> 对应1.X版本 nacos
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.0.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
5、Param 'serviceName' is illegal
java.lang.IllegalArgumentException: Param 'serviceName' is illegal, serviceName is blank
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
6、could not be found
A component required a bean of type 'com.openapi.xxx' that could not be found
一般是引入的bean未被spring容器管理到,则需要将对应包的扫描路径进行配置,一般配置对应的注解中添加basePackages
其中很容易忽视的基础:工程规范问题
比如mybatis
// mybatis
@MapperScan(basePackages={"com.admin.mapper"})
// feign
@EnableFeignClients(clients = {xxx.class}) //方式1
//@EnableFeignClients(basePackages = {"com.openapi.xxx"}) //方式2
7、Failed to declare queue
org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException:Failed to declare queue
添加rabbitmq的工作队列
8、An unexpected connection driver error occured
大概问题为没有为当前用户授权:一个是Virtual Hos 另外一个是 Topic permissions
新增一下配置到管理台:http://ip:15672/
elasticsearch
1.elasticsearch默认用户密码重置
默认用户elastic
基于docker方式,不是docker直接执行命令;会得到新的密码
【/usr/share/elasticsearch/bin/elasticsearch-reset-password】
[root@localhost indices]# docker exec -it es /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y
Password for the [elastic] user successfully reset.
New value: 3AWmqC-E-K1nOd-9*GhF
2. cosign: 未找到命令
参考地址1(链接失效):使用 Sigstore 签名的 Elastic Stack 容器镜像!_Elastic 中国社区官方博客的博客-CSDN博客
参考地址: https://docs.sigstore.dev/system_config/installation/
[root@localhost tmp]# wget https://artifacts.elastic.co/cosign.pub
[root@localhost tmp]# curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64"
[root@localhost tmp]# mv cosign-linux-amd64 /usr/local/bin/cosign
[root@localhost tmp]# chmod +x /usr/local/bin/cosign
[root@localhost tmp]# cosign verify --key cosign.pub docker.elastic.co/kibana/kibana:8.9.1
[root@localhost tmp]# curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 95.9M 100 95.9M 0 0 8192k 0 0:00:11 0:00:11 --:--:-- 9437k
[root@localhost tmp]# mv cosign-linux-amd64 /usr/local/bin/cosign
[root@localhost tmp]# chmod +x /usr/local/bin/cosign
[root@localhost tmp]# cosign verify --key cosign.pub docker.elastic.co/kibana/kibana:8.9.1
Verification for docker.elastic.co/kibana/kibana:8.9.1 --
The following checks were performed on each of these signatures:
- The cosign claims were validated
- Existence of the claims in the transparency log was verified offline
- The signatures were verified against the specified public key
[{"critical":{"identity":{"docker-reference":"docker.elastic.co/kibana/kibana"},"image":{"docker-manifest-digest":"sha256:8a973aefa3268cd92dbdc18f071bc6d4ece968fb39db41b7664b02e718007be7"},"type":"cosign container image signature"},"optional":{"Bundle":{"SignedEntryTimestamp":"MEUCIQD9J00J8MqSX9iRZbv5Hjr/XwlhsFRFaozhxbJwuYzWlgIgOYkYTpJBD+FXqyOcRheY480H4U1RiLIfVisyH94TLvg=","Payload":{"body":"eyJhcGlWZXJzaW9uIjoiMC4wLjEiLCJraW5kIjoiaGFzaGVkcmVrb3JkIiwic3BlYyI6eyJkYXRhIjp7Imhhc2giOnsiYWxnb3JpdGhtIjoic2hhMjU2IiwidmFsdWUiOiI0NjZmMzg0NDA4MDcyNDYwYjcwMzg1MWM1NjVlZGIzZjIxMWVhYTJkNjQ5N2QyNjdhM2U3NDU4ZDI1OWJiNGNiIn19LCJzaWduYXR1cmUiOnsiY29udGVudCI6Ik1FUUNJSDBQM3JZcThnZTVjYjFVUkxMQVA5R1RBVWduQmU1Mk1yTUpxck1Jd2dXekFpQTRWMWMyVFBXMnU3ek1iNTVOVTRIckc5STJqNUYrZVNGZlNFZmhrcDlUNWc9PSIsInB1YmxpY0tleSI6eyJjb250ZW50IjoiTFMwdExTMUNSVWRKVGlCUVZVSk1TVU1nUzBWWkxTMHRMUzBLVFVacmQwVjNXVWhMYjFwSmVtb3dRMEZSV1VsTGIxcEplbW93UkVGUlkwUlJaMEZGY1ZaMlRtUlJkR1JrZEdWdGRtWmpWV1V5VGpCbloxZ3ZjSFJxYVFwRlZYRjRlakp3UkZVM1ZWYzFiVE53WkcxSU1UTnJUVXR3ZURselJqUjJWVFZLVDJVM1ZYSXJSazVJVERkaFlXaE1hbWRIWXpBNGRXUkJQVDBLTFMwdExTMUZUa1FnVUZWQ1RFbERJRXRGV1MwdExTMHRDZz09In19fX0=","integratedTime":1692265232,"logIndex":31628155,"logID":"c0d23d6ad406973f9559f3ba2d1ca01f84147d8ffc5b8445c224f98b9591801d"}},"tag":"8.9.1"}}]
3.elasticsearch 8.9 &kibana问题
docker安装方式
1. Could not find the file /usr/share/elasticsearch/config/certs/http_ca.crt in container
2. Unable to create an enrollment token. Elasticsearch node HTTP layer SSL configuration is not configured with a keystore
首先必须安装官网提供方式安装:Install Elasticsearch with Docker | Elasticsearch Guide [8.9] | Elastic
如果跳过了:cosign verify --key cosign.pub docker.elastic.co/elasticsearch/elasticsearch:8.9.1
安装就会出现很多问题,建议看上面先安装:cosign
如果已经安装,先卸载掉并清理所有es&kibana相关挂载的数据卷,再安装官网步骤安装
[root@localhost tmp]# docker volume ls
DRIVER VOLUME NAME
local es-config
local es-data
local es-plugins
local html
local kibana-config
[root@localhost tmp]# docker volume rm es-config
es-config
[root@localhost tmp]# docker volume rm es-data
es-data
[root@localhost tmp]# docker volume rm es-plugins
es-plugins
[root@localhost tmp]# docker volume rm kibana-config
kibana-config
[root@localhost tmp]# docker volume ls
[root@localhost tmp]# docker pull docker.elastic.co/elasticsearch/elasticsearch:8.9.1
[root@localhost tmp]# wget https://artifacts.elastic.co/cosign.pub
[root@localhost tmp]# cosign verify --key cosign.pub docker.elastic.co/elasticsearch/elasticsearch:8.9.1
[root@localhost tmp]# docker network create es-net
[root@localhost tmp]#
docker run -d --name es01 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.type=single-node" -v es-data:/usr/share/elasticsearch/data -v es-config:/usr/share/elasticsearch/config -v es-plugins:/usr/share/elasticsearch/plugins --privileged --network es-net -p 9200:9200 -p 9300:9300 docker.elastic.co/elasticsearch/elasticsearch:8.9.1
重置默认用户密码,记下控制台的密码内容
[root@localhost tmp]# docker exec -it es /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
[root@localhost tmp]# docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
[root@localhost tmp]# curl --cacert http_ca.crt -u elastic https://localhost:9200
[root@localhost tmp]# docker run --name kb01 --net es-net -p 5601:5601 -v kibana-config:/usr/share/kibana/config -e ELASTICSEARCH_HOSTS:http://192.168.23.11:9200 -d docker.elastic.co/kibana/kibana:8.9.1
[root@localhost tmp]# docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node
[root@localhost ~]# docker logs -f kb01
控制台输出日志样子
i Kibana has not been configured.
Go to http://0.0.0.0:5601/?code=167452 to get started.
Your verification code is: 167 452
kibana控制台界面
最后使用elastic 和密码: 登录
集合
list与数组互转
1.List转数组
方式1:String[] array = list.toArray(new String[list.size()]);
方式2:String[] array = list.stream().toArray(String[]::new);
2.数组转List
方式1:Collections.addAll(list, array);
方式2:List<String> list1 = Arrays.asList(array);
方式3:List<String> collect = Arrays.stream(array).collect(Collectors.toList());
lamda方式排序
// 安装某个字段分组 常用JSON结构:{"key":[],"key2":[]}
Map<String, List<WordCheck>> collect = checkList.stream().collect(Collectors.groupingBy(f -> f.getWord_name()));
//排序
List<WordCheck> d_post_code = collect.get("d_post_code").stream().sorted(Comparator.comparing(WordCheck::getWord_order)).collect(Collectors.toList());
Docker
1、删除为none的镜像
【Error response from daemon: conflict: unable to delete 5a695b65d145 (must be forced) - image is being used by stopped container cd07b936e0fb】
[root@localhost /]# docker images
[root@localhost /]# docker rmi -f image_id
[root@localhost /]# docker rmi -f 9a3244537312
Deleted: sha256:9a3244537312288e435c00cc0d4d4cb8ebcd9ff630af4e2ea6454959e831364c
Deleted: sha256:79395207ed09b2835585c063a77c133d235c59d55c2ca0c85e719cdb30f35ec1
2、already in use by container
The container name "/rabbitmq" is already in use by container
删除占用的即可
[root@localhost ~]# docker ps -a
[root@localhost ~]# docker rm 5c1fb19d3999
附rabbitmq启动
[root@localhost ~]# docker run \
-v $(pwd)/data/rabbitmq:/var/lib/rabbitmq \
-p 5672:5672 -p 15672:15672 --name rabbitmq -d \
-e RABBITMQ_DEFAULT_USER=root \
-e RABBITMQ_DEFAULT_PASS=hadoop \
-e RABBITMQ_DEFAULT_VHOST=demo \
rabbitmq:3.8-management
正常安装步骤
参考docker官网文档【Install Docker Engine on CentOS | Docker Documentation】
公共镜像参考地址【Docker】
步骤1:sudo yum install -y yum-utils
步骤2:sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
步骤3:sudo yum install --allowerasing docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
有问题参考下面文章【3.linux centos8安装docker一系列问题解决】
主要解决:1.网络问题 2.yum安装包 3.安装依赖问题
windows与虚拟机(centos)
1、Device/Credential Guard
=====解决VM 与 Device/Credential Guard 不兼容====
Windows Powershell (管理员)(Windows键+X)
bcdedit /set hypervisorlaunchtype off
=====解决VM 与 Device/Credential Guard 不兼容====
2.没有东西提供 module(perl:5.26)
安装一下
[root@localhost ~]# yum module enable perl:5.26
[root@localhost ~]# sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
模块依赖问题:
问题 1: 冲突的请求
- 没有东西提供 module(perl:5.26)(模块 perl-DBD-SQLite:1.58:8030020200716174729:3a70019f.x86_64 需要它)
问题 2: 冲突的请求
- 没有东西提供 module(perl:5.26)(模块 perl-DBI:1.641:8030020200716150652:1e4bbb35.x86_64 需要它)
3.linux centos8安装docker一系列问题解决
如:
问题 1: 安装的软件包的问题 podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64
- 软件包 podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64 需要 runc >= 1.0.0-57,但没有提供者可以被安装
- 软件包 containerd.io-1.6.22-3.1.el8.x86_64 与 runc(由 runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64 提供)冲突
- 软件包 containerd.io-1.6.22-3.1.el8.x86_64 取代了 runc(由 runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64 提供)
如:
未提供依赖perl-DBD-SQLite、perl-DBI
如:
未知的名称或服务【域名解析问题】
下载元数据失败【AppStream 缓存失败,忽略这个 repo 等】
1.1 检查网络
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (157.148.69.74) 56(84) bytes of data.
64 bytes from 157.148.69.74 (157.148.69.74): icmp_seq=1 ttl=128 time=11.4 ms
64 bytes from 157.148.69.74 (157.148.69.74): icmp_seq=2 ttl=128 time=11.0 ms
1.2 域名解析 打开并添加域名解析地址 i进行编辑 --> esc退出--> shft+: 进行底行模式 -->wq -->回车保存
[root@localhost ~]# vim /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 114.114.114.114
[root@localhost ~]# service network restart关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
禁用防火墙
[root@localhost ~]# systemctl disable firewalld.service
参考文章地址:https://wenku.csdn.net/answer/7219741ce81111edbcb5fa163eeb3507
[root@localhost ~]# vim /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
[root@localhost ~]# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
[root@localhost ~]# dnf update dnf rpm -y
[root@localhost ~]# yum module enable perl:5.26
[root@localhost ~]# yum install -y podman修改三个文件
cd /etc/yum.repos.d-rw-r--r--. 1 root root 719 9月 14 2021 CentOS-Linux-AppStream.repo
-rw-r--r--. 1 root root 704 9月 14 2021 CentOS-Linux-BaseOS.repo
-rw-r--r--. 1 root root 704 9月 14 2021 CentOS-Linux-Extras.repo
CentOS-Linux-AppStream.repo
#========CentOS-Linux-AppStream.repo内容========
#[AppStream]
#name=CentOS-$releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
##baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial[AppStream]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#========CentOS-Linux-AppStream.repo========
CentOS-Linux-BaseOS.repo
#========2021 CentOS-Linux-BaseOS.repo========
#[BaseOS]
#name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
##baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial[BaseOS]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#========2021 CentOS-Linux-BaseOS.repo========
CentOS-Linux-Extras.repo
#========CentOS-Linux-Extras.repo========#[extras]
#name=CentOS Linux $releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
##baseurl=http://mirror.centos.org/$contentdir/$releasever/extras/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#========CentOS-Linux-Extras.repo========
刷新
[root@localhost ~]# dnf clean all
[root@localhost ~]# dnf makecache重启服务器
[root@localhost ~]# reboot
4.未知的名称或服务
[root@localhost ~]# vim /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 114.114.114.114
[root@localhost ~]# nmcli c reload更新rpm包管理器
[root@localhost ~]# dnf update dnf rpm -y
5、bash: shasum: 未找到命令
[root@localhost apps]# shasum -a 512 -c elasticsearch-8.8.2-linux-x86_64.tar.gz.sha512
bash: shasum: 未找到命令...
[root@localhost apps]# sudo yum install -y perl-Digest-SHA-1:6.02-1.el8.x86_64
[root@localhost apps]# sudo yum install -y perl-Digest-SHA
或者由默认选项处理yes
[root@localhost apps]# shasum -a 512 -c elasticsearch-8.8.2-linux-x86_64.tar.gz.sha512
bash: shasum: 未找到命令...
安装软件包“perl-Digest-SHA”以提供命令“shasum”? [N/y] y
* 正在队列中等待...
* 装入软件包列表...
下列软件包必须安装:
perl-Digest-SHA-1:6.02-1.el8.x86_64 Perl extension for SHA-1/224/256/384/512
继续更改? [N/y] y
* 正在队列中等待...
* 正在等待认证...
* 正在队列中等待...
* 正在下载软件包...
* 正在请求数据...
* 正在测试更改...
* 正在安装软件包...
elasticsearch-8.8.2-linux-x86_64.tar.gz: OK
如果以上不行,检查防火墙,DNS解析问题
github
1、github访问不了
!!!纯属网络限制问题,有时开放了有时不行,可以的话找个vpn软件,付费解决一下(纯属开发学习使用推荐,具体软件名称可自行搜索)
MQ
rabbitmq
1.Failed to convert Message content
消息发送和消息接收部分可能有问题,消息发送时指定一下contentType
例如发送字符串内容 :.setContentType("application/text")
@RequestMapping("sendDelayedQueueMsg")
public Object sendDelayedQueueMsg(@RequestParam(value = "exchangeName") String exchangeName, @RequestParam(value = "routingKey") String routingKey, @RequestParam(value = "msg") String msg) {
log.info("sendMsg:{},{}", exchangeName, msg);
Message message = MessageBuilder.withBody(msg.getBytes(StandardCharsets.UTF_8))
.setDeliveryMode(MessageDeliveryMode.PERSISTENT)
.setHeader("x-delay", 5000)
.setContentType("application/text")
.build();
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(exchangeName,routingKey,message,correlationData);
return "ok";
}
接收
@RabbitListener(bindings = {
@QueueBinding(
value = @Queue(name = "delay.queue", durable = "true"),
exchange = @Exchange(name = "delay.exchange", delayed = "true"),
key = "delay"
)
})
public void listenDelayedQueue(String message) throws Exception {
log.info("listenDelayedQueue:{}", message);
}