Build etcd cluster, Python ETCD interface

Source: Internet
Author: User
Tags etcd

node1:192.168.133.140

node2:192.168.133.141

node3:192.168.133.142

1. Install the NTP service:

Yum Install NTP

Start the NTP service

Systenctl start NTP

Installing ETCD

Yum Install-y etcd-3.2.5-1.el7.x86_64

Configure ETCD

Editing a configuration file

Vim/etc/etcd/etcd.conf

The contents of the amendment are as follows:

# [member]etcd_name=master1       #本机的主机名ETCD_DATA_DIR = "/var/lib/etcd/ Default.etcd "     #etcd的数据存储路径 #etcd_wal_dir=" "#ETCD_SNAPSHOT_COUNT =" 10000 "#ETCD_HEARTBEAT_ Interval= "+" #ETCD_ELECTION_TIMEOUT = "etcd_listen_peer_urls="      "http://0.0.0.0:2380" #监听其他etcd实例的地址ETCD_LISTEN_CLIENT_URLS = "http://0.0.0.0:2379,http://0.0.0.0:4001"    #监听etcd客户端的地址 #etcd_ max_snapshots= "5" #ETCD_MAX_WALS = "5" #ETCD_CORS = "##[cluster]etcd_initial_advertise_peer_urls="/HTTP/ 192.168.133.140:2380 "    #通知其他etcd实例地址 # if you use different etcd_name   (e.g. test),  set etcd_initial_cluster value for this name, i.e.   "test=http://..." etcd_initial_cluster= "master1=http://192.168.133.140:2380,master2=http:// 192.168.133.141:2380,master3=http://192.168.133.142:2380 "    #初始化集群内节点地址ETCD_INITIAL_CLUSTER_ State= "New"       #  initializes the cluster state, new represents the new etcd_initial_cluster_token= "Etcd-cluster"        #   Initialize cluster tokenetcd_advertise_client_urls= "http://192.168.133.140:2379,http://192.168.133.140:4001"     #  definition client  Broadcast port, here must fill in the corresponding host  ip, cannot fill  0.0.0.0, otherwise  etcd client  can not get  etcd cluster  host   #ETCD_DISCOVERY = "#ETCD_DISCOVERY_SRV =" "#ETCD_DISCOVERY_FALLBACK =" Proxy "#ETCD_DISCOVERY_PROXY =" "#ETCD_STRICT_RECONFIG_CHECK =" false "etcd_auto_compaction_retention=" 1 "     #内部调优 #etcd_enable_v2= "true"

Postil: The remaining two hosts only need to modify the red ones, and the rest will be just like me.

Start the ETCD cluster and set the boot up

Systemctl start Etcd && systemctl enable ETCD

Python Tuning Etcd interface

Installing the ETCD3 module

Pip Install ETCD3
Import etcd3# save data to ETCD client = etcd3.client (host= ' 192.168.133.140 ') #连接etcdr = client.put (' aaa ', ' qweqwe ') #往etcd中存键值b = Client.get (' aaa ') #查看etcd中的键值vents_iterator, Cancel = Client.watch (' aaa ') #监 Listen to whether the AAA key in the ETCD has changed, print (event). Value

Build etcd cluster, Python ETCD interface

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.