Linux installation consul

installation:

1、[root@localhost ~]# yum install -y unzip
2、[root@localhost ~]# yuminstall -y wget
3、[root@localhost ~]# wget https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip 
4、[root@localhost ~]# ll
5、[root@localhost ~]# unzip consul_0.7.5_linux_amd64.zip

start up:

  • Non-persistent start:./consul agent -dev -ui -node=consul-dev -client=10.224.162.189
  • Persistence start:./consul agent -server -ui -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -advertise=0.0.0.0 -bind=0.0.0.0 -client=10.224.162.189

consul agent output resolution:

[root@localhost local]# ./consul agent -server -ui -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -
BootstrapExpect is set to 1; this is the same as Bootstrap mode.
bootstrap = true: do not enable unless necessary
==> Starting Consul agent...
==> Consul agent running!
           Version: 'v1.5.0'
           Node ID: '98644a39-417f-3609-c789-bd059f201d9d'
         Node name: 'agent-one'
        Datacenter: 'dc1' (Segment: '<all>')
            Server: true (Bootstrap: true)
       Client Addr: [10.224.162.189] (HTTP: 8500, HTTPS: -1, gRPC: -1, DNS: 8600)
      Cluster Addr: 10.224.162.189 (LAN: 8301, WAN: 8302)
           Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false

==> Log data will now stream in as it occurs:
...
  • Node Name: This is the only name of the agent. By default, this is the host name of the machine, but you can use the -nodelogo to customize.
  • Data Center: This is the configuration of the agent to run the data center. Each node must be set to report to the other data center. -datacenterFlag may be set for the data center. For single DC configuration, the broker will default to "dc1".
  • Server: This indicates that the proxy is a server or client mode. Server: false (bootstrap: false) , it represents not running in server mode, in fact, -devis the development of server mode.
  • Client Address: This is the address for the proxy client interface. This includes HTTP and DNS port interface. By default, it only bind to the localhost.
  • Cluster Address: This is the address and port for communication between the set of cluster Consul agent. Not all cluster Consul agent must use the same port, but the address must be available to all other nodes access.
  • -dev: This mode can not be used in a production environment, because it would not persist any state in this mode, the startup mode just to start fast and convenient single-nodeconsul

Configuration:

  • -data-dir: Data storage directory specified agent status, this is all agent must be especially important for server, because they have to cluster status persistence.

  • -config-dir: The configuration file directory, the directory must consul.dfile contents are json format data, which is loaded with all .json the end of the file will be.

  • -config-file: Explicitly specify which configuration file to load.

  • -dev: Development server mode, although the server mode, but not for production environments, because there will be no lasting operation that will not have any data written to disk

  • -server: Definition of agent running in server mode, each cluster has at least one server, recommended that each cluster server not more than five

  • -node: Specifies the node name in the cluster, the cluster name must be unique (this is the default host name of the machine),直接采用机器的IP

  • -client: Consul binding on which client address, which provides HTTP, DNS, RPC and other services, the default is 127.0.0.1

-advertise:通知展现地址用来改变我们给集群中的其他节点展现的地址,一般情况下-bind地址就是展现地址
-bootstrap:用来控制一个server是否在bootstrap模式,在一个datacenter中只能有一个server处于bootstrap模式,当一个server处于bootstrap模式时,可以自己选举为raft leader。
-bootstrap-expect:在一个datacenter中期望提供的server节点数目,当该值提供的时候,consul一直等到达到指定sever数目的时候才会引导整个集群,该标记不能和bootstrap公用
-bind:该地址用来在集群内部的通讯,集群内的所有节点到地址都必须是可达的,默认是0.0.0.0
-dc:该标记控制agent允许的datacenter的名称,默认是dc1
-encrypt:指定secret key,使consul在通讯时进行加密,key可以通过consul keygen生成,同一个集群中的节点必须使用相同的key
-join:加入一个已经启动的agent的ip地址,可以多次指定多个agent的地址。如果consul不能加入任何指定的地址中,则agent会启动失败,默认agent启动时不会加入任何节点。
-retry-join:和join类似,但是允许你在第一次失败后进行尝试。
-retry-interval:两次join之间的时间间隔,默认是30s
-retry-max:尝试重复join的次数,默认是0,也就是无限次尝试
-log-level:consul agent启动后显示的日志信息级别。默认是info,可选:trace、debug、info、warn、err。
-protocol:consul使用的协议版本
-rejoin:使consul忽略先前的离开,在再次启动后仍旧尝试加入集群中。
-syslog:开启系统日志功能,只在linux/osx上生效
-pid-file:提供一个路径来存放pid文件,可以使用该文件进行SIGINT/SIGHUP(关闭/更新)agent

References && Cluster Setup:

https://www.jianshu.com/p/1d36a6277c3b

consul basis

  • Service Discovery : consul clients can provide a service, such as api or mysql, some other clients can use to find a consul's designated service provider. By DNS or HTTP application depends on the service can be easily found.
  • Health Check: Consul client can provide any number of health check, assign a service (example: the webserver returned a status code 200 OK) or using the local node (example: memory usage is greater than 90%). This information is used by the operator to monitor cluster health, and is used to avoid service discovery component to send traffic to unhealthy hosts.
  • key / value storage: Applications can use key consul level / value storage according to their needs. Such as dynamic configuration, function tag, coordination, leadership elections, a simple HTTP API to make it easier to use.
  • Multi-data center: cosul support multiple data center out of the box. This means that users do not need to worry about the need to build additional abstraction layer allows business expansion to multiple regions.

Reproduced in: https: //www.jianshu.com/p/b42b0b29ef9c

Guess you like

Origin blog.csdn.net/weixin_33860528/article/details/91066886