mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 03:42:07 +08:00
删除无关脚本
This commit is contained in:
@@ -1,86 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -x
|
|
||||||
|
|
||||||
function Install_Java(){
|
|
||||||
cd $dir
|
|
||||||
wget https://s3-gzpu.didistatic.com/pub/jdk11.tar.gz
|
|
||||||
tar -zxf $dir/jdk11.tar.gz -C /usr/local/
|
|
||||||
mv -f /usr/local/jdk-11.0.2 /usr/local/java11 >/dev/null 2>&1
|
|
||||||
echo "export JAVA_HOME=/usr/local/java11" >> ~/.bashrc
|
|
||||||
echo "export CLASSPATH=/usr/java/java11/lib" >> ~/.bashrc
|
|
||||||
echo "export PATH=\$JAVA_HOME/bin:\$PATH:\$HOME/bin" >> ~/.bashrc
|
|
||||||
source ~/.bashrc
|
|
||||||
}
|
|
||||||
|
|
||||||
function Install_Mysql(){
|
|
||||||
cd $dir
|
|
||||||
wget https://s3-gzpu.didistatic.com/pub/mysql5.7.tar.gz
|
|
||||||
rpm -qa | grep -E "mariadb|mysql" | xargs yum -y remove >/dev/null 2>&1
|
|
||||||
mv -f /var/lib/mysql/ /var/lib/mysqlbak$(date "+%s") >/dev/null 2>&1
|
|
||||||
mkdir -p $dir/mysql/ && cd $dir/mysql/
|
|
||||||
tar -zxf $dir/mysql5.7.tar.gz -C $dir/mysql/
|
|
||||||
yum -y localinstall mysql* libaio*
|
|
||||||
systemctl start mysqld
|
|
||||||
systemctl enable mysqld >/dev/null 2>&1
|
|
||||||
old_pass=`grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}' | tail -n 1`
|
|
||||||
mysql -NBe "alter user USER() identified by '$mysql_pass';" --connect-expired-password -uroot -p$old_pass
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
echo "Mysql database installation completed"
|
|
||||||
else
|
|
||||||
echo "Mysql database configuration failed. The script exits"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function Install_ElasticSearch(){
|
|
||||||
kill -9 $(ps -ef | grep elasticsearch | grep -v "grep" | awk '{print $2}') >/dev/null 2>&1
|
|
||||||
id esuser >/dev/null 2>&1
|
|
||||||
if [ "$?" != "0" ];then
|
|
||||||
useradd esuser
|
|
||||||
echo "esuser soft nofile 655350" >>/etc/security/limits.conf
|
|
||||||
echo "esuser hard nofile 655350" >>/etc/security/limits.conf
|
|
||||||
echo "vm.max_map_count = 655360" >>/etc/sysctl.conf
|
|
||||||
sysctl -p >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
mkdir -p /km_es/es_data && cd /km_es/ >/dev/null 2>&1
|
|
||||||
wget https://s3-gzpu.didistatic.com/pub/elasticsearch.tar.gz
|
|
||||||
tar -zxf elasticsearch.tar.gz -C /km_es/
|
|
||||||
chown -R esuser:esuser /km_es/
|
|
||||||
su - esuser <<-EOF
|
|
||||||
export JAVA_HOME=/usr/local/java11
|
|
||||||
sh /km_es/elasticsearch/control.sh start
|
|
||||||
EOF
|
|
||||||
sleep 5
|
|
||||||
es_status=`sh /km_es/elasticsearch/control.sh status | grep -o "started"`
|
|
||||||
if [ "$es_status" = "started" ];then
|
|
||||||
echo "elasticsearch started successfully~ "
|
|
||||||
else
|
|
||||||
echo "Elasticsearch failed to start. The script exited"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function Install_KnowStreaming(){
|
|
||||||
cd $dir
|
|
||||||
wget https://s3-gzpu.didistatic.com/pub/knowstreaming/KnowStreaming-3.0.0-beta.tar.gz
|
|
||||||
tar -zxf KnowStreaming-3.0.0-beta.tar.gz -C $dir/
|
|
||||||
mysql -uroot -p$mysql_pass -e "create database know_streaming;"
|
|
||||||
mysql -uroot -p$mysql_pass know_streaming < ./KnowStreaming/init/sql/ddl-ks-km.sql
|
|
||||||
mysql -uroot -p$mysql_pass know_streaming < ./KnowStreaming/init/sql/ddl-logi-job.sql
|
|
||||||
mysql -uroot -p$mysql_pass know_streaming < ./KnowStreaming/init/sql/ddl-logi-security.sql
|
|
||||||
mysql -uroot -p$mysql_pass know_streaming < ./KnowStreaming/init/sql/dml-ks-km.sql
|
|
||||||
mysql -uroot -p$mysql_pass know_streaming < ./KnowStreaming/init/sql/dml-logi.sql
|
|
||||||
sh ./KnowStreaming/init/template/template.sh
|
|
||||||
sed -i "s/mysql_pass/"$mysql_pass"/g" ./KnowStreaming/conf/application.yml
|
|
||||||
cd $dir/KnowStreaming/bin/ && sh startup.sh
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dir=`pwd`
|
|
||||||
mysql_pass=`date +%s |sha256sum |base64 |head -c 10 ;echo`"_Di2"
|
|
||||||
echo "$mysql_pass" > $dir/mysql.password
|
|
||||||
|
|
||||||
Install_Java
|
|
||||||
Install_Mysql
|
|
||||||
Install_ElasticSearch
|
|
||||||
Install_KnowStreaming
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 健康巡检
|
|
||||||
|
|
||||||
## 1、前言
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2、已有巡检
|
|
||||||
|
|
||||||
### 2.1、Cluster健康巡检(1个)
|
|
||||||
|
|
||||||
#### 2.1.1、集群Controller数错误
|
|
||||||
|
|
||||||
**说明**
|
|
||||||
|
|
||||||
- 集群Controller数不等于1,表明集群集群无Controller或者出现了多个Controller,该
|
|
||||||
|
|
||||||
|
|
||||||
**配置**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### 2.2、Broker健康巡检(2个)
|
|
||||||
|
|
||||||
#### 2.2.1、Broker-RequestQueueSize被打满
|
|
||||||
|
|
||||||
**说明**
|
|
||||||
|
|
||||||
- Broker的RequestQueueSize,被打满;
|
|
||||||
|
|
||||||
|
|
||||||
**配置**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.2、Broker-NetworkProcessorAvgIdle过低
|
|
||||||
|
|
||||||
**说明**
|
|
||||||
|
|
||||||
- Broker的NetworkProcessorAvgIdle指标,当前过低;
|
|
||||||
|
|
||||||
|
|
||||||
**配置**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### 2.3、Topic健康巡检(2个)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.3.1、Topic 无Leader数
|
|
||||||
|
|
||||||
**说明**
|
|
||||||
|
|
||||||
- 当前Topic的无Leader分区数超过一定值;
|
|
||||||
|
|
||||||
|
|
||||||
**配置**
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.3.1、Topic 长期处于未同步状态
|
|
||||||
|
|
||||||
**说明**
|
|
||||||
|
|
||||||
- 指定的一段时间内,Topic一直处于未同步的状态;
|
|
||||||
|
|
||||||
|
|
||||||
**配置**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### 2.4、Group健康巡检(1个)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.4.1、Group Re-Balance太频繁
|
|
||||||
|
|
||||||
**说明**
|
|
||||||
|
|
||||||
- 指定的一段时间内,Group Re-Balance的次数是否过多;
|
|
||||||
|
|
||||||
|
|
||||||
**配置**
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3、自定义增强
|
|
||||||
|
|
||||||
如何增加想要的巡检?
|
|
||||||
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 登录系统对接
|
|
||||||
|
|
||||||
### 前言
|
|
||||||
|
|
||||||
KnowStreaming 除了实现基于本地MySQL的用户登录认证方式外,还实现了基于Ldap的登录认证。
|
|
||||||
|
|
||||||
但是,登录认证系统并非仅此两种,因此本文将介绍 KnowStreaming 如何对接自有的用户登录认证系统。
|
|
||||||
|
|
||||||
下面我们正式开始介绍登录系统的对接。
|
|
||||||
|
|
||||||
### 如何对接?
|
|
||||||
|
|
||||||
- 实现Log-Common中的LoginService的三个接口即可;
|
|
||||||
|
|
||||||
```Java
|
|
||||||
// LoginService三个方法
|
|
||||||
public interface LoginService {
|
|
||||||
/**
|
|
||||||
* 验证登录信息,同时记住登录状态
|
|
||||||
*/
|
|
||||||
UserBriefVO verifyLogin(AccountLoginDTO loginDTO, HttpServletRequest request, HttpServletResponse response) throws LogiSecurityException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登出接口,清楚登录状态
|
|
||||||
*/
|
|
||||||
Result<Boolean> logout(HttpServletRequest request, HttpServletResponse response);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查是否已经登录
|
|
||||||
*/
|
|
||||||
boolean interceptorCheck(HttpServletRequest request, HttpServletResponse response,
|
|
||||||
String requestMappingValue,
|
|
||||||
List<String> whiteMappingValues) throws IOException;
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
没错,登录就是如此的简单,仅仅只需要实现上述的三个接口即可。说了半天,具体如何做呢,能不能给个例子?
|
|
||||||
|
|
||||||
|
|
||||||
### 有没有例子?
|
|
||||||
|
|
||||||
我们以Ldap对接为例,说明KnowStreaming如何对接登录认证系统。
|
|
||||||
|
|
||||||
```Java
|
|
||||||
// 继承 LoginService 接口
|
|
||||||
public class LdapLoginServiceImpl implements LoginService {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(LdapLoginServiceImpl.class);
|
|
||||||
|
|
||||||
// Ldap校验
|
|
||||||
@Autowired
|
|
||||||
private LdapAuthentication ldapAuthentication;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserBriefVO verifyLogin(AccountLoginDTO loginDTO,
|
|
||||||
HttpServletRequest request,
|
|
||||||
HttpServletResponse response) throws LogiSecurityException {
|
|
||||||
String decodePasswd = AESUtils.decrypt(loginDTO.getPw());
|
|
||||||
|
|
||||||
// 去LDAP验证账密
|
|
||||||
LdapPrincipal ldapAttrsInfo = ldapAuthentication.authenticate(loginDTO.getUserName(), decodePasswd);
|
|
||||||
if (ldapAttrsInfo == null) {
|
|
||||||
// 用户不存在,正常来说上如果有问题,上一步会直接抛出异常
|
|
||||||
throw new LogiSecurityException(ResultCode.USER_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 进行业务相关操作
|
|
||||||
|
|
||||||
// 记录登录状态,Ldap因为无法记录登录状态,因此有KnowStreaming进行记录
|
|
||||||
initLoginContext(request, response, loginDTO.getUserName(), user.getId());
|
|
||||||
return CopyBeanUtil.copy(user, UserBriefVO.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Boolean> logout(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
request.getSession().invalidate();
|
|
||||||
response.setStatus(REDIRECT_CODE);
|
|
||||||
return Result.buildSucc(Boolean.TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean interceptorCheck(HttpServletRequest request, HttpServletResponse response, String requestMappingValue, List<String> whiteMappingValues) throws IOException {
|
|
||||||
// 其他处理
|
|
||||||
|
|
||||||
// 检查是否已经登录
|
|
||||||
String userName = HttpRequestUtil.getOperator(request);
|
|
||||||
if (StringUtils.isEmpty(userName)) {
|
|
||||||
// 未登录,则进行登出
|
|
||||||
logout(request, response);
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 其他业务处理
|
|
||||||
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### 背后原理是?
|
|
||||||
|
|
||||||
- KnowStreaming 会拦截所有的接口请求;
|
|
||||||
- 拦截到请求之后,如果是登录的请求,则调用LoginService.verifyLogin();
|
|
||||||
- 拦截到请求之后,如果是登出的请求,则调用LoginService.logout();
|
|
||||||
- 拦截到请求之后,如果是其他请求,则调用LoginService.interceptorCheck();
|
|
||||||
Reference in New Issue
Block a user