Mac + Virtualbox + CoreOS + etcd2 + fleet 기본 설정 (2)
7710 단어 CoreOSetcd2fleetVirtualBox
CoreOS 클러스터 구축 3대 구성
이 장에서는 클러스터 구성을 3대 준비하고, 1대 서버가 다운되어도 다른 멤버가 정보를 계승해, 운용 가능한 상태를 목표로 합니다.
전제
Mac + Virtualbox + CoreOS + etcd2 + fleet 기본 설정 (1)
목표로 하는 구성
discovery 채널에서 클러스터 멤버 관리
이번에는 클러스터 크기를 3대 구성으로 하므로 다음 URL에 액세스하여 토큰을 발행합니다.
※추기:클러스터 구성이 잘 가지 않고 단념. . .
discovery
curl -s discovery.etcd.io/new?size=3
https://discovery.etcd.io/<TOKEN>
TOKEN이라고 쓰여 있는 곳에는 실제로는 영숫자 혼재의 문자열이 들어옵니다.
이제 토큰을 얻었으므로 이전 섹션에서 만든 coreos를 사용하여 클러스터를 만들고 싶습니다.
※모든 네트워크 카드의 MAC 주소를 초기화는 잊지 않고
※명칭은 coreos-01/02/03라고 만들어 갑니다.
1.Virtualbox에서 복제
virtualbox를 시작하고 템플릿을 마우스 오른쪽 버튼으로 클릭하여 복제 만들기를 누릅니다.
2. 모두 클론을 선택하고 클론 작성 실행
※5분 정도 시간이 걸립니다. . .
3. MAC 주소 새로 고침
IP 주소, MAC 주소가 충돌하지 않도록 새로 고칩니다.
4. 클러스터 3 서버 시작, cloud-config.yml 만들기
복제된 서버를 모두 시작합니다.
cloud-config.yml#cloud-config
hostname: coreos-01 #hostname suffixに合わせてください
write_files:
- path: /etc/environment
permissions: 0644
content: |
COREOS_PUBLIC_IPV4=192.168.0.10 #ここは3台別別のIPを指定してください
COREOS_PRIVATE_IPV4=192.168.0.10
coreos:
update:
reboot-strategy: 'off'
etcd2:
name: coreos-01
heartbeat-interval: 1000
election-timeout: 5000
advertise-client-urls: http://192.168.0.10:2379
initial-advertise-peer-urls: http://192.168.0.10:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://0.0.0.0:2380
initial-cluster-token: etcd-cluster-1
initial-cluster: coreos-01=http://192.168.0.10:2380,coreos-02=http://192.168.0.20:2380,coreos-03=http://192.168.0.30:2380
initial-cluster-state: new
fleet:
public-ip: 192.168.0.10
metadata: "role=services,cabinet=one"
flannel:
interface: 192.168.0.10
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
- name: docker.service
command: start
- name: timezone.service
command: start
content: |
[Unit]
Description=timezone
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ln -sf ../usr/share/zoneinfo/Japan /etc/localtime
- name: 10-static.network
runtime: false
content: |
[Match]
Name=enp0s3
[Network]
Address=192.168.0.10/24 #public_ipv4にするIPを記述
DNS=8.8.8.8
DNS=8.8.4.4
ssh_authorized_keys:
- ssh-rsa ※ここに自身の鍵を設置
users:
- name: coreuser
passwd: $1$VIyj3wZe$HVVOEAc/H6a6YZGKCBWSD/
groups:
- sudo
- docker
ssh-authorized-keys:
- ssh-rsa ※ここに自身の鍵を設置
5.cloud-config.yml 쓰기
wirte_cloudconfigsudo coreos-cloudinit -from-file=./cloud-config.yml
#念のためuser_dataも上書き
sudo cp -a cloud-config.yml /var/lib/coreos-install/user_data
sudo reboot
6. 각 클러스터에서 fleetctl/etcdctl cluster-health를 실행할 수 있는가?
cluster-check
ssh [email protected]
etcdctl cluster-health
member 59d0611e956db7d1 is healthy: got healthy result from http://192.168.0.20:2379
member 6fb0d145a155e8ee is healthy: got healthy result from http://192.168.0.30:2379
member 7a0fb1a3031d4c79 is healthy: got healthy result from http://192.168.0.10:2379
유효성 검사: 클러스터를 하나씩 다운하여 클러스터를 유지할 수 있습니까?
cluster-checkssh [email protected]
fleetctl list-machines --full
MACHINE IP METADATA
87799244733442d381cc207c049e1f68 192.168.0.30 cabinet=one,role=services
#coreos-03をシャットダウン
ssh [email protected]
sudo shutdown -h now
# coreos-01にアクセスし状況確認
ssh [email protected]
etcdctl cluster-health
member 59d0611e956db7d1 is healthy: got healthy result from http://192.168.0.20:2379
failed to check the health of member 6fb0d145a155e8ee on http://192.168.0.30:2379: Get http://192.168.0.30:2379/health: dial tcp 192.168.0.30:2379: no route to host
member 6fb0d145a155e8ee is unreachable: [http://192.168.0.30:2379] are all unreachable
member 7a0fb1a3031d4c79 is healthy: got healthy result from http://192.168.0.10:2379
fleetctl list-machines --full
MACHINE IP METADATA
87799244733442d381cc207c049e1f68 192.168.0.10 cabinet=one,role=services
유효성 검사: 클러스터를 2개 다운시켜 클러스터를 유지할 수 있습니까?
cluster-check
#coreos-03を起動
ssh [email protected]
sudo shutdown -h now
ssh [email protected]
sudo shutdown -h now
ssh [email protected]
etcdctl cluster-health
failed to check the health of member 59d0611e956db7d1 on http://192.168.0.20:2379: Get http://192.168.0.20:2379/health: dial tcp 192.168.0.20:2379: no route to host
member 59d0611e956db7d1 is unreachable: [http://192.168.0.20:2379] are all unreachable
failed to check the health of member 6fb0d145a155e8ee on http://192.168.0.30:2379: Get http://192.168.0.30:2379/health: dial tcp 192.168.0.30:2379: no route to host
member 6fb0d145a155e8ee is unreachable: [http://192.168.0.30:2379] are all unreachable
member 7a0fb1a3031d4c79 is unhealthy: got unhealthy result from http://192.168.0.10:2379
cluster is unhealthy
fleetctl list-machines --full
Error retrieving list of active machines: googleapi: Error 503: fleet server unable to communicate with etcd
※3대 클러스터 구성으로 2대 소실해 버리면, 클러스터를 유지할 수 없는 모습. . .
검증 : 다시 coreos-02/03을 시작
check-clusterssh [email protected]
etcdctl cluster-health
member 59d0611e956db7d1 is healthy: got healthy result from http://192.168.0.20:2379
member 6fb0d145a155e8ee is healthy: got healthy result from http://192.168.0.30:2379
member 7a0fb1a3031d4c79 is healthy: got healthy result from http://192.168.0.10:2379
fleetctl list-machines --full
MACHINE IP METADATA
87799244733442d381cc207c049e1f68 192.168.0.10 cabinet=one,role=services
※ 문제없이 복구했습니다.
고찰
etcd2로 클러스터를 구축하는 경우는 최소 3대의 구성이 필요하고, 2대 소실하면 클러스터를 유지할 수 없는 것 같습니다.
quoram 알고리즘으로 생존이 2대 이하가 되면 정보의 유지를 할 수 없게 되어, 클러스터로서 유지할 수 없게 됩니다. 하지만 중앙 서비스가 한 대보다 여러 대에서 실행되고 단일 지점을 제거하는 것이 중요합니다.
다음은 worker 역할(proxy)의 설정입니다.
다음 항목:
Mac + Virtualbox + CoreOS + etcd2 + fleet 기본 설정(완료)
참고:
CoreOS Cluster Architectures
Configuration Flags
CoreOS를 사용하여 Docker 컨테이너 이동
Reference
이 문제에 관하여(Mac + Virtualbox + CoreOS + etcd2 + fleet 기본 설정 (2)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/xshsaku/items/a5b57fafa0b41740bd7f
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
curl -s discovery.etcd.io/new?size=3
https://discovery.etcd.io/<TOKEN>
#cloud-config
hostname: coreos-01 #hostname suffixに合わせてください
write_files:
- path: /etc/environment
permissions: 0644
content: |
COREOS_PUBLIC_IPV4=192.168.0.10 #ここは3台別別のIPを指定してください
COREOS_PRIVATE_IPV4=192.168.0.10
coreos:
update:
reboot-strategy: 'off'
etcd2:
name: coreos-01
heartbeat-interval: 1000
election-timeout: 5000
advertise-client-urls: http://192.168.0.10:2379
initial-advertise-peer-urls: http://192.168.0.10:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://0.0.0.0:2380
initial-cluster-token: etcd-cluster-1
initial-cluster: coreos-01=http://192.168.0.10:2380,coreos-02=http://192.168.0.20:2380,coreos-03=http://192.168.0.30:2380
initial-cluster-state: new
fleet:
public-ip: 192.168.0.10
metadata: "role=services,cabinet=one"
flannel:
interface: 192.168.0.10
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
- name: docker.service
command: start
- name: timezone.service
command: start
content: |
[Unit]
Description=timezone
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ln -sf ../usr/share/zoneinfo/Japan /etc/localtime
- name: 10-static.network
runtime: false
content: |
[Match]
Name=enp0s3
[Network]
Address=192.168.0.10/24 #public_ipv4にするIPを記述
DNS=8.8.8.8
DNS=8.8.4.4
ssh_authorized_keys:
- ssh-rsa ※ここに自身の鍵を設置
users:
- name: coreuser
passwd: $1$VIyj3wZe$HVVOEAc/H6a6YZGKCBWSD/
groups:
- sudo
- docker
ssh-authorized-keys:
- ssh-rsa ※ここに自身の鍵を設置
sudo coreos-cloudinit -from-file=./cloud-config.yml
#念のためuser_dataも上書き
sudo cp -a cloud-config.yml /var/lib/coreos-install/user_data
sudo reboot
ssh [email protected]
etcdctl cluster-health
member 59d0611e956db7d1 is healthy: got healthy result from http://192.168.0.20:2379
member 6fb0d145a155e8ee is healthy: got healthy result from http://192.168.0.30:2379
member 7a0fb1a3031d4c79 is healthy: got healthy result from http://192.168.0.10:2379
ssh [email protected]
fleetctl list-machines --full
MACHINE IP METADATA
87799244733442d381cc207c049e1f68 192.168.0.30 cabinet=one,role=services
#coreos-03をシャットダウン
ssh [email protected]
sudo shutdown -h now
# coreos-01にアクセスし状況確認
ssh [email protected]
etcdctl cluster-health
member 59d0611e956db7d1 is healthy: got healthy result from http://192.168.0.20:2379
failed to check the health of member 6fb0d145a155e8ee on http://192.168.0.30:2379: Get http://192.168.0.30:2379/health: dial tcp 192.168.0.30:2379: no route to host
member 6fb0d145a155e8ee is unreachable: [http://192.168.0.30:2379] are all unreachable
member 7a0fb1a3031d4c79 is healthy: got healthy result from http://192.168.0.10:2379
fleetctl list-machines --full
MACHINE IP METADATA
87799244733442d381cc207c049e1f68 192.168.0.10 cabinet=one,role=services
#coreos-03を起動
ssh [email protected]
sudo shutdown -h now
ssh [email protected]
sudo shutdown -h now
ssh [email protected]
etcdctl cluster-health
failed to check the health of member 59d0611e956db7d1 on http://192.168.0.20:2379: Get http://192.168.0.20:2379/health: dial tcp 192.168.0.20:2379: no route to host
member 59d0611e956db7d1 is unreachable: [http://192.168.0.20:2379] are all unreachable
failed to check the health of member 6fb0d145a155e8ee on http://192.168.0.30:2379: Get http://192.168.0.30:2379/health: dial tcp 192.168.0.30:2379: no route to host
member 6fb0d145a155e8ee is unreachable: [http://192.168.0.30:2379] are all unreachable
member 7a0fb1a3031d4c79 is unhealthy: got unhealthy result from http://192.168.0.10:2379
cluster is unhealthy
fleetctl list-machines --full
Error retrieving list of active machines: googleapi: Error 503: fleet server unable to communicate with etcd
ssh [email protected]
etcdctl cluster-health
member 59d0611e956db7d1 is healthy: got healthy result from http://192.168.0.20:2379
member 6fb0d145a155e8ee is healthy: got healthy result from http://192.168.0.30:2379
member 7a0fb1a3031d4c79 is healthy: got healthy result from http://192.168.0.10:2379
fleetctl list-machines --full
MACHINE IP METADATA
87799244733442d381cc207c049e1f68 192.168.0.10 cabinet=one,role=services
Reference
이 문제에 관하여(Mac + Virtualbox + CoreOS + etcd2 + fleet 기본 설정 (2)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/xshsaku/items/a5b57fafa0b41740bd7f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)