In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
By default, the Docker container needs to communicate across hosts. Both host nodes need to be in the same network segment. As long as the hosts of the two Docker containers can communicate with each other and the container uses net network mode, the implementation mode is changed to bridge mode communication.
In addition, we can also create an overlay network for different hosts to communicate across nodes by using third-party tools, which will be implemented using Flanneld
Install etcd
Create a cat / etc/etcd/etcd.conf file
# [member] ETCD_NAME=infra1 ETCD_DATA_DIR= "/ var/lib/etcd" ETCD_LISTEN_PEER_URLS= "http://192.168.2.150:2380" ETCD_LISTEN_CLIENT_URLS=" http://192.168.2.150:2379" # [cluster] ETCD_INITIAL_ADVERTISE_PEER_URLS= "http://192.168.2.150:2380" ETCD_INITIAL_CLUSTER_TOKEN=" etcd-cluster "ETCD_ADVERTISE_CLIENT_URLS=" http://192.168.2.150:2379"
Create / etc/systemd/system/etcd.service file
[Unit] Description=Etcd ServerAfter=network.targetAfter=network-online.targetWants=network-online.targetDocumentation= https://github.com/coreos[Service]Type=notifyWorkingDirectory=/var/lib/etcd/EnvironmentFile=-/etc/etcd/etcd.confExecStart=/usr/local/bin/etcd\-- name ${ETCD_NAME}\-- initial-advertise-peer-urls ${ETCD_INITIAL_ADVERTISE_PEER_URLS}\-- listen-peer-urls ${ETCD_LISTEN_PEER_URLS}\-listen-client-urls ${ETCD_LISTEN_CLIENT_URLS} Http://127.0.0.1:2379\-- advertise-client-urls ${ETCD_ADVERTISE_CLIENT_URLS}\-- initial-cluster-token ${ETCD_INITIAL_CLUSTER_TOKEN}\-- initial-cluster infra1= http://192.168.2.150:2380,infra2=http://192.168.2.151:2380\-- initial-cluster-state new\-data-dir=$ {ETCD_DATA_DIR} Restart=on-failureRestartSec=5LimitNOFILE=65536 [Install] WantedBy=multi-user.target
Start systemctl start etcd
Create a directory in etcd: etcdctl-- endpoints= http://192.168.2.150:2379,http://192.168.5.151:2379
Mkdir / kube-centos/network
Create a config node and write network configuration information:
Etcdctl-- endpoints= http://172.20.0.113:2379,http://172.20.0.114:2379 mk / kube-centos/network/config'{"Network": "192.167.0.0 vxlan 16", "SubnetLen": 24, "Backend": {"Type": "vxlan"}'
Flanneld
Create / etc/sysconfig/flanneld file
# Flanneld configuration options # etcd url location. Point this to the server where etcd runsFLANNEL_ETCD_ENDPOINTS= "http://127.0.0.1:2379"# etcd config key. This is the configuration key that flannel queries# For address range assignment# FLANNEL_ETCD_PREFIX= "/ kube-centos/network" FLANNEL_ETCD_PREFIX= "/ coreos.com/network" # Any additional options that you want to passFLANNEL_OPTIONS= "- iface=eth0"
Create / usr/lib/systemd/system/flanneld.service file
[Unit] Description=Flanneld overlay address etcd agentAfter=network.targetAfter=network-online.targetWants=network-online.targetAfter=etcd.serviceBefore= docker.service [service] Type=notifyEnvironmentFile=/etc/sysconfig/flanneldEnvironmentFile=-/etc/sysconfig/docker-network#ExecStart=/usr/bin/flanneld-start $FLANNEL_OPTIONSExecStart=/usr/bin/flanneld-start-etcd-endpoints= http://192.168.2.150:2379,http://192.168.2.151:2379-iface=ens33#ExecStart=/usr/bin/flanneld-start-etcd-endpoints= http://192.168.2.150:2379, Http://192.168.2.151:2379-etcd- prefix=/kube-centos/networkExecStartPost=/usr/libexec/flannel/mk-docker-opts.sh-k DOCKER_NETWORK_OPTIONS-d / run/flannel/dockerRestart=on-failure [Install] WantedBy=multi-user.targetRequiredBy=docker.service
Start systemctl start flanneld
The / run/flannel/subnet.env file is produced after flannled starts.
Modify the configuration of docker startup parameters and add:
EnvironmentFile=/run/flannel/subnet.env--bip=$ {FLANNEL_SUBNET}-- ip-masq=$ {FLANNEL_IPMASQ}-- mtu=$ {FLANNEL_MTU}
Restart docker, and docker will assign ip to container using the IP address range configured by flanneld
Launch the container on two nodes: docker run-it-rm busybox sh
View the container IP,ping of one host node and the other host node IP
View the container IP,ping of one host node and the other host node IP
It can be connected at this time.
Note whether the iptables configuration is correct
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.