0
点赞
收藏
分享

微信扫一扫

Kylin系统微服务consul安装

什么是Consul?

Consul是一个用golang开发的分布式高可用服务治理与与服务配置的工具,它有以下功能:

服务发现:Consul客户端可以提供服务,其他客户端可以使用服务名称通过DNS以及http等协议来发现服务,有助于提高服务的可扩展性。

健康检查:Consul的客户端可以通过多种方式来检查某个服务或当前节点是否处于健康状态,比如查看一个服务是否可以返回200 OK,或者是查看client当前部署的机器的内存使用是否在80%以下。

key/value存储:Consul客户端可以使用http api来存储、修改、删除一些k/v键值对。

1.下载consul安装源

官网地址:https://www.consul.io/downloads

2.解压安装包

先把压缩包上传到Kylin系统里

Kylin系统微服务consul安装_启动脚本

使用终端执行命令 unzip consul_1.9.0_linux_amd64.zip

Kylin系统微服务consul安装_bash_02

解压出的文件是一个可以执行的文件 consul

3.查看consul版本 确定是否可用

[root@localhost 桌面]# ./consul --version

Kylin系统微服务consul安装_客户端_03

4.将可执行程序设置成全局变量

(1)拷贝文件到/usr/local/bin下

[root@localhost 桌面]# cp consul /usr/local/bin/
授权:
[root@localhost bin]# chmod -R 777 consul

Kylin系统微服务consul安装_客户端_04

(2)配置环境变量

#编辑~/.bashrc

[root@localhost bin]# vi ~/.bashrc

Kylin系统微服务consul安装_bash_05

Kylin系统微服务consul安装_启动脚本_06

#新增下面代码

export CONSUL_HOME=/usr/local/bin/consul

export PATH=$PATH:CONSUL_HOME

Kylin系统微服务consul安装_bash_07

#重新加载~/.bashrc

[root@localhost bin]# source ~/.bashrc

Kylin系统微服务consul安装_bash_08

#测试是否能使用,输出版本及为正常

[root@localhost bin]# consul --version

 

Kylin系统微服务consul安装_客户端_09

 5.启动服务

[root@localhost bin]# consul agent -dev -ui -client=0.0.0.0

 

Kylin系统微服务consul安装_启动脚本_10

6.设置启动脚本

(1)添加脚本,找一个自己脚本存放的位置

#新增启动脚本 consul_start.sh

[root@localhost bin]# vi consul_start.sh

#输入

nohup consul agent -dev -ui -client=0.0.0.0 >/tmp/consul.log &

echo 'consul start success'

#保存并退出

Kylin系统微服务consul安装_bash_11

(2)设置脚本执行权限

chmod +x consul_start.sh

 

Kylin系统微服务consul安装_客户端_12

 (3)运行脚本

./consul_start.sh

 

Kylin系统微服务consul安装_bash_13

7.浏览器访问

http://127.0.0.1:8500/

 

Kylin系统微服务consul安装_客户端_14

Kylin系统微服务consul安装_客户端_15



举报

相关推荐

0 条评论