1.下载
wget https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip
[root@localhost soft]# wget https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip
--2017-07-02 19:01:02-- https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 151.101.73.183, 2a04:4e42:11::439
Connecting to releases.hashicorp.com (releases.hashicorp.com)|151.101.73.183|:443... failed: Connection timed out.
Connecting to releases.hashicorp.com (releases.hashicorp.com)|2a04:4e42:11::439|:443... failed: Network is unreachable.
[root@localhost soft]# wget https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip
--2017-07-02 19:04:23-- https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 151.101.73.183, 2a04:4e42:11::439
Connecting to releases.hashicorp.com (releases.hashicorp.com)|151.101.73.183|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8764587 (8.4M) [application/zip]
Saving to: 鈥榗onsul_0.7.5_linux_amd64.zip鈥
100%[==================================================================================================================================================================================================>] 8,764,587 59.4KB/s in 3m 31s
2017-07-02 19:07:55 (40.7 KB/s) - 鈥榗onsul_0.7.5_linux_amd64.zip鈥saved [8764587/8764587]
[root@localhost soft]# ll
2.解压
unzip consul_0.7.5_linux_amd64.zip
就会在当前目下看到consul文件
inflating: consul
[root@localhost soft]# ll
total 44540
-rwxr-xr-x. 1 root root 36003713 Feb 14 20:15 consul
-rw-r--r--. 1 root root 8764587 Mar 1 08:50 consul_0.7.5_linux_amd64.zip
3.执行以下 ./consul 出现以下信息就说明安装成功
[root@localhost soft]# ./consul
usage: consul [--version] [--help] []
Available commands are:
agent Runs a Consul agent
configtest Validate config file
event Fire a new event
exec Executes a command on Consul nodes
force-leave Forces a member of the cluster to enter the "left" state
info Provides debugging information for operators
join Tell Consul agent to join cluster
keygen Generates a new encryption key
keyring Manages gossip layer encryption keys
kv Interact with the key-value store
leave Gracefully leaves the Consul cluster and shuts down
lock Execute a command holding a lock
maint Controls node or service maintenance mode
members Lists the members of a Consul cluster
monitor Stream logs from a Consul agent
operator Provides cluster-level tools for Consul operators
reload Triggers the agent to reload configuration files
rtt Estimates network round trip time between nodes
snapshot Saves, restores and inspects snapshots of Consul server state
version Prints the Consul version
watch Watch for changes in Consul
4.启动consul
我的linux ip地址为:10.11.3.161
./consul agent -dev -ui -node=consul-dev -client=10.11.3.161
出现以下信息,说明consul已在启动
[root@localhost soft]# ./consul agent -dev -ui -node=consul-dev -client=10.11.3.161
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
Version: 'v0.7.5'
Node ID: '564da851-08d0-5ca7-732d-220ea19adae9'
Node name: 'consul-dev'
Datacenter: 'dc1'
Server: true (bootstrap: false)
Client Addr: 10.11.3.161 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)
Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
Atlas:
==> Log data will now stream in as it occurs:
2017/07/02 19:14:43 [DEBUG] Using unique ID "564da851-08d0-5ca7-732d-220ea19adae9" from host as node ID
2017/07/02 19:14:43 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:127.0.0.1:8300 Address:127.0.0.1:8300}]
2017/07/02 19:14:43 [INFO] raft: Node at 127.0.0.1:8300 [Follower] entering Follower state (Leader: "")
2017/07/02 19:14:43 [INFO] serf: EventMemberJoin: consul-dev 127.0.0.1
2017/07/02 19:14:43 [INFO] consul: Adding LAN server consul-dev (Addr: tcp/127.0.0.1:8300) (DC: dc1)
2017/07/02 19:14:43 [INFO] serf: EventMemberJoin: consul-dev.dc1 127.0.0.1
2017/07/02 19:14:43 [INFO] consul: Adding WAN server consul-dev.dc1 (Addr: tcp/127.0.0.1:8300) (DC: dc1)
2017/07/02 19:14:50 [WARN] raft: Heartbeat timeout from "" reached, starting election
2017/07/02 19:14:50 [INFO] raft: Node at 127.0.0.1:8300 [Candidate] entering Candidate state in term 2
2017/07/02 19:14:50 [DEBUG] raft: Votes needed: 1
2017/07/02 19:14:50 [DEBUG] raft: Vote granted from 127.0.0.1:8300 in term 2. Tally: 1
2017/07/02 19:14:50 [INFO] raft: Election won. Tally: 1
2017/07/02 19:14:50 [INFO] raft: Node at 127.0.0.1:8300 [Leader] entering Leader state
2017/07/02 19:14:50 [INFO] consul: cluster leadership acquired
2017/07/02 19:14:50 [INFO] consul: New leader elected: consul-dev
2017/07/02 19:14:50 [DEBUG] consul: reset tombstone GC to index 3
2017/07/02 19:14:50 [INFO] consul: member 'consul-dev' joined, marking health alive
2017/07/02 19:14:51 [INFO] agent: Synced service 'consul'
2017/07/02 19:14:51 [DEBUG] agent: Node info in sync
==> Failed to check for updates: Get https://checkpoint-api.hashicorp.com/v1/check/consul?arch=amd64&os=linux&signature=&version=0.7.5: net/http: TLS handshake timeout
2017/07/02 19:16:19 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:16:19 [DEBUG] agent: Node info in sync
2017/07/02 19:18:06 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:18:06 [DEBUG] agent: Node info in sync
2017/07/02 19:19:54 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:19:54 [DEBUG] agent: Node info in sync
2017/07/02 19:21:15 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:21:15 [DEBUG] agent: Node info in sync
2017/07/02 19:22:44 [DEBUG] http: Request GET /v1/catalog/datacenters (49.937碌s) from=10.11.3.161:38143
2017/07/02 19:22:44 [DEBUG] http: Request GET /v1/catalog/datacenters (28.699碌s) from=10.11.3.161:38143
2017/07/02 19:22:44 [DEBUG] http: Request GET /v1/internal/ui/nodes?dc=dc1&token= (526.341碌s) from=10.11.3.161:38144
2017/07/02 19:22:44 [DEBUG] http: Request GET /v1/coordinate/nodes?dc=dc1&token= (99.51碌s) from=10.11.3.161:38143
2017/07/02 19:22:44 [DEBUG] http: Request GET /v1/internal/ui/services?dc=dc1&token= (92.846碌s) from=10.11.3.161:38143
2017/07/02 19:22:57 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:22:57 [DEBUG] agent: Node info in sync
2017/07/02 19:24:43 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:24:43 [DEBUG] agent: Node info in sync
2017/07/02 19:25:46 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:25:46 [DEBUG] agent: Node info in sync
2017/07/02 19:27:43 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:27:43 [DEBUG] agent: Node info in sync
2017/07/02 19:29:18 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:29:18 [DEBUG] agent: Node info in sync
2017/07/02 19:30:51 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:30:51 [DEBUG] agent: Node info in sync
2017/07/02 19:32:41 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:32:41 [DEBUG] agent: Node info in sync
2017/07/02 19:34:02 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:34:02 [DEBUG] agent: Node info in sync
2017/07/02 19:35:21 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:35:21 [DEBUG] agent: Node info in sync
2017/07/02 19:36:22 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:36:22 [DEBUG] agent: Node info in sync
2017/07/02 19:37:32 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:37:32 [DEBUG] agent: Node info in sync
2017/07/02 19:38:49 [DEBUG] agent: Service 'consul' in sync
2017/07/02 19:38:49 [DEBUG] agent: Node info in sync
然后在虚拟机浏览器中输 http://10.11.3.161:8500 就看到以下图:
然后我在本机上访问consul 发现访问不了,后发现centos的防火墙比较严,8500端口没有打开,执行以下命令即行:
[root@localhost soft]# firewall-cmd --zone=public --add-port=8500/tcp --permanent
[root@localhost soft]# systemctl stop firewalld.service
[root@localhost soft]# systemctl start firewalld.service
这样再启动consul,就可以访问了