Compare commits

...

5 Commits

Author SHA1 Message Date
dzj 48b3d32ac6 boot version 3.2.2 2024-01-23 19:05:58 +08:00
dzj 785dc5a239 Merge branch 'main' of https://svn.youshengyun.com:3000/dingzhaojun/demo01.git into main 2024-01-16 09:49:46 +08:00
dzj 32b95ffba0 swarm 2024-01-11 17:30:45 +08:00
dzj 1acc00cd26 portainer 2024-01-11 10:30:05 +08:00
dzj e2f357e4af consul update 2024-01-08 06:48:32 +08:00
4 changed files with 125 additions and 7 deletions

61
docker swarm install.txt Normal file
View File

@ -0,0 +1,61 @@
机器节点准备:
需要一台manager机器内存和硬盘大一点多台worker机器。
1、安装alma Linux 9.3设置主机名、静态IP。
2、设置主机名。sudo hostnamectl status
sudo hostnamectl set-hostname [swarm-manager01、swarm-worker01等等]
3、设置静态IPswarm mode需要使用静态IP不能使用动态IP。
sudo vim /etc/NetworkManager/system-connections/ens160.nmconnection
...
[ipv4]
address1=92.168.31.251/24,192.168.31.1 ip自己替换
dns=114.114.114.114;
method=manual
...
nmcli c reload # 重新加载配置文件
nmcli c up ens160
4、关闭防火墙sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl disable --now firewalld
sudo firewall-cmd --state
5、关闭SELinuxsudo setenforce 0
sudo sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
sudo sestatus
6、主机系统时间同步配置
sudo yum install -y chrony
sudo vim /etc/chrony.conf
注释掉第三行原有的时间服务器地址,设置为阿里云的时间服务地址:
# pool 2.almalinux.pool.ntp.org iburst
pool ntp1.aliyun.com iburst
....
sudo systemctl enable --now chronyd
sudo chronyc -a makestep
Docker install
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 docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4、 sudo usermod -aG docker $USER
5、 newgrp docker
6、 sudo systemctl enable docker.service
7、 sudo systemctl enable containerd.service
8、 sudo systemctl start docker
9、 docker run hello-world
delete swarm
On manager机器上执行docker swarm leave --force
Create a swarm
On manager机器上
1、 docker swarm init --advertise-addr 192.168.3.188
记住输出的命令
2、 docker info
3、 docker node ls
On worker机器上
在manager机器上执行docker swarm join-token worker可以再次获取token
1、docker swarm join --token xxx【刚才输出的命令】
2、在manager机器上执行docker node ls

28
pom.xml
View File

@ -12,7 +12,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
@ -41,6 +41,17 @@
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://svn.youshengyun.com:3000/api/packages/risesoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://svn.youshengyun.com:3000/api/packages/risesoft/maven</url>
</snapshotRepository>
</distributionManagement>
<properties>
<java.version>21</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
@ -145,7 +156,8 @@
<BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
<BP_JVM_VERSION>21</BP_JVM_VERSION>
</env>
<name>svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
<name>
svn.youshengyun.com:9923/${project.artifactId}-jvm:${project.version}</name>
<publish>true</publish>
</image>
<docker>
@ -174,7 +186,8 @@
<image>eclipse-temurin:21-jre</image>
</from>
<to>
<image>svn.youshengyun.com:9923/${project.artifactId}-jib</image>
<image>
svn.youshengyun.com:9923/${project.artifactId}-jib</image>
<tags>
<tag>${project.version}</tag>
</tags>
@ -219,14 +232,17 @@
<builder>paketobuildpacks/builder-jammy-tiny</builder>
<buildpacks>
<buildpack>gcr.io/paketo-buildpacks/graalvm</buildpack>
<buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
<buildpack>
gcr.io/paketo-buildpacks/java-native-image</buildpack>
</buildpacks>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
<BP_JVM_VERSION>21</BP_JVM_VERSION>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>--enable-preview</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
--enable-preview</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
</env>
<name>svn.youshengyun.com:9923/${project.artifactId}-native:${project.version}</name>
<name>
svn.youshengyun.com:9923/${project.artifactId}-native:${project.version}</name>
<publish>true</publish>
</image>
<docker>

41
portainer-agent-stack.yml Normal file
View File

@ -0,0 +1,41 @@
version: '3.2'
services:
agent:
image: portainer/agent:2.19.4
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce:2.19.4
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9443:9443"
- "9000:9000"
- "8000:8000"
volumes:
- portainer_data:/data
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
placement:
constraints:
node.role: manager
node.hostname: swarm-manager01
networks:
agent_network:
driver: overlay
attachable: true
volumes:
portainer_data:

View File

@ -4,7 +4,7 @@
./mvnw.cmd clean spring-boot:build-image -Pnative -Dmaven.test.skip=true
#运行docker image
docker compose -f compose.yml up -d
docker compose -f compose-dev.yml up -d
docker compose -f compose-demo01-jib.yml up -d
docker compose -f compose-demo01-jvm.yml up -d