本地demo服务器搭建计划——(二)服务中心consul安装&防火墙配置

安装consul

1、安装consul
直接yum安装,或者官网获取安装包
https://developer.hashicorp.com/consul/downloads

 sudo yum install -y yum-utils
 # 如果已经安装了yum-utils,可以跳过第一个
 sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
 sudo yum -y install consul

安装好之后直接启动

nohup consul agent -dev -client 0.0.0.0 -ui &

-dev : 以dev模式启动(单节点)
-client : 指定客户端地址,全零放通
-ui :启动ui页面,默认端口8500,需要放通防火墙访问

关闭防火墙服务

以CentOS7为例,CentOS7之前使用iptables,CentOS7使用firewalld

简单粗暴

# 查看防火墙状态
systemctl status firewalld
firewall-cmd --state
# 简单粗暴
systemctl stop firewalld
# 禁止开机自启
systemctl disable firewalld

端口放行

# 查看zone,默认启动public。firewalld命令有很多,简单列几个常用的,有兴趣自己研究不展开
firewall-cmd --list-all-zones
firewall-cmd --get-default-zone
# 查看已放行的端口
firewall-cmd --list-ports [--permanent]
--permanent 永久生效,重启后不失效
# 放行端口
firewall-cmd --add-port=8500/tcp [--permanent]
# 删除放行
firewall-cmd --remove-port=8500/tcp [--permanent]

配置端口放行后,需要重启firewalld服务

systemctl restart firewalld

添加链接描述

放行端口后就可以访问consul的控制台了

consul控制台 : http://YOUR_HOST_IP:8500
比较完整的配置参考这篇blog https://blog.51cto.com/u_15069485/2611956

启动consul集群

nohup后台启动

以server模式启动consul集群建议至少三个节点。你可以安装三个虚拟机

# -bootstrap-except 集群最少的server数量,少于这个数量报错
# -node 节点名换成呢个
# -bind 节点的地址
nohup consul agent -server -bootstrap-except 2 -data-dir=/demo/consul/data -node=node1 -bind=10.0.0.1 >/dev/null &
nohup consul agent -server -bootstrap-except 2 -data-dir=/demo/consul/data -node=node2 -bind=10.0.0.2 >/dev/null &
nohup consul agent -server -bootstrap-except 2 -data-dir=/demo/consul/data -node=node3 -bind=10.0.0.3 >/dev/null &
# 在server2 server3中将当前节点加入集群
consul join 10.0.0.1
# 查看集群成员
consul members

docker 启动

参考这篇blog https://www.cnblogs.com/woxpp/p/11849002.html
dockerhub https://hub.docker.com/_/consul

# server模式启动
$ docker run -d --net=host -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' \
consul agent -server -bind=<external ip> -retry-join=<root agent ip> -bootstrap-expect=<number of server agents>

其他

rsyslogd配置详解(服务日志) http://c.biancheng.net/view/1102.html
logrotate配置详解(日志转储)http://c.biancheng.net/view/1106.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

code tea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值