1.環境檢查
[root@xag220 vhosts]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@xag220 vhosts]# java -version;
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
[root@xag220 logs]# hostname -I
10.0.30.220
2.下载Sentinel控制台安装包
[root@xag220 logs]# cd /usr/local/src
[root@xag220 src]# pwd
/usr/local/src
wget https://github.com/alibaba/Sentinel/releases/download/1.8.2/sentinel-dashboard-1.8.2.jar --no-check-certificate
3.jar包做成服务
mkdir -p /usr/local/sentinel/{bin,logs}
[root@xag220 src]# mv sentinel-dashboard-1.8.2.jar /usr/local/sentinel/
vim /usr/local/sentinel/bin/startup.sh
------------------------------
#!/bin/bash
nohup /u01/java/jdk1.8.0_181/bin/java -Dserver.port=8088 -Dcsp.sentinel.dashboard.server=localhost:8088 -Dproject.name=sentinel-dashboard -jar /usr/local/sentinel/sentinel-dashboard-1.8.2.jar > /usr/local/sentinel/logs/sentinel.log 2>&1 &
echo $! > /var/run/sentinel.pid
-------------------------------
vim /usr/local/sentinel/bin/shutdown.sh
-------------------------------
#!/bin/sh
kill -9 `cat /var/run/sentinel.pid`
-------------------------------
脚本文件赋予权限
chmod u+x /usr/local/sentinel/bin/startup.sh
chmod u+x /usr/local/sentinel/bin/shutdown.sh
vim /usr/lib/systemd/system/sentinel.service
[Unit]
Description=service for sentinel
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment="JAVA_HOME=/u01/java/jdk1.8.0_181"
ExecStart=/usr/local/sentinel/bin/startup.sh
ExecStop=/usr/local/sentinel/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
设置开机自启动
systemctl enable sentinel.service
启动sentinel服务
systemctl start sentinel.service
停止开机自启动
systemctl disable sentinel.service
查看服务当前状态
systemctl status sentinel.service
重新启动服务
systemctl restart sentinel.service
查看所有已启动的服务
systemctl list-units --type=service
浏览器登陆:http://10.0.30.220:8088
默认用户名和密码都是sentinel,对于用户登录的相关配置可以在启动命令中增加下面的参数来进行配置:
-Dsentinel.dashboard.auth.username=sentinel: 用于指定控制台的登录用户名为 sentinel;
-Dsentinel.dashboard.auth.password=123456: 用于指定控制台的登录密码为 123456;如果省略这两个参数,
默认用户和密码均为 sentinel
-Dserver.servlet.session.timeout=7200: 用于指定 Spring Boot 服务端 session 的过期时间,
如 7200 表示 7200 秒;60m 表示 60 分钟,默认为 30 分钟
网友评论