Linux下Sentinel环境搭建(图文详细)

本文档详细介绍了在Linux系统中如何搭建Sentinel环境,包括Sentinel的概述和具体配置步骤,如资源准备、配置文件设置、启动脚本编写、服务自启配置以及启停命令和测试访问的说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、Sentinel 概述

  • 官方链接: https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7%BB%8D

二、Sentinel 环境配置

  • 资源装备
#上传资源jar包至Linux目录
/opt/module/alibaba/sentinel

在这里插入图片描述

  • 配置文件
#spring settings
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true

#cookie name setting
server.servlet.session.cookie.name=sentinel_dashboard_cookie

#logging settings
logging.level.org.springframework.web=INFO
logging.file=${user.home}/logs/csp/sentinel-dashboard.log
logging.pattern.file= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
#logging.pattern.console= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n

#auth settings
auth.filter.exclude-urls=/,/auth/login,/auth/logout,/registry/machine,/version
auth.filter.exclude-url-suffixes=htm,html,js,css,map,ico,ttf,woff,png
# If auth.enabled=false, Sentinel console disable login
auth.username=sentinel
auth.password=sentinel

# Inject the dashboard version. It's required to enable
# filtering in pom.xml for this resource file.
sentinel.dashboard.version=1.8.1

  • 编写脚本
#切换目录
cd /etc/rc.d/init.d

#创建脚本
vim sentinel

#脚本内容

#!/bin/bash
#
# chkconfig: 2345 10 90
# 
# description:auto_run

#程序名
RUN_NAME="sentinel-dashboard-1.8.1.jar"

#资源位置
JAVA_OPTS=/opt/module/alibaba/sentinel/sentinel-dashboard-1.8.1.jar

#日志位置
LOG_DIR=/opt/module/alibaba/sentinel/logs/csp
LOG_FILE=$LOG_DIR/sentinel-dashboard.log
LOG_OPTS=/opt/module/alibaba/sentinel/sentinel_temp.log

#开始方法
start() {
        source /etc/profile; nohup java -Xms256M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M -Dcsp.sentinel.log.dir=$LOG_DIR -Dlogging.file=$LOG_FILE -Dserver.port=9100  -Dcsp.sentinel.dashboard.server=127.0.0.1:9100 -Dproject.name=Sentinel基本控制台 -jar $JAVA_OPTS >$LOG_OPTS 2>&1 &
        echo "$RUN_NAME started success."
}

#结束方法
stop() {
        echo "stopping $RUN_NAME ..."
        kill -9 `ps -ef|grep $JAVA_OPTS|grep -v grep|grep -v stop|awk '{print $2}'`
}

case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            start
            ;;
        *)
                echo "Userage: $0 {start|stop|restart}"
                exit 1
esac

在这里插入图片描述

  • 配置自启
#刷新配置
systemctl daemon-reload

#授权为可执行文件
chmod +x sentinel 
chmod +x /opt/module/alibaba/sentinel/sentinel-dashboard-1.8.1.jar 

#添加至系统服务
chkconfig --add sentinel

#开机自启
chkconfig sentinel on

#查看服务列表
chkconfig --list

在这里插入图片描述

  • 启停命令
#启停
systemctl start|stop|restart sentinel

#查看进程
ps -ef|grep sentinel

在这里插入图片描述

  • 测试访问
#访问地址
http://您的IP:9100/

#账户密码
sentinel  sentinel

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值