赞
踩
数据库审计管理,是数据安全规范中不可或缺的一环,通过审计管理我们能够把控、追溯sql执行情况。yearning作为一款开源的数据库审计软件,是我们开发运维工作中经常打交道的一个“伙伴”。
yearning提供的核心功能就是sql查询和审计。
我们可以通过yearning来创建用户,设置权限,规定哪些用户可以查询哪个库,哪些用户可以修改哪个库,查询、修改操作需要经过那些人的审批后才能执行,执行完成的SQL修改语句可以进行回退,可以监控追溯到哪些人执行了哪些SQL。
mysql> create database yearning;
mysql> use mysql;
mysql> create user 'yearning'@'%' identified by 'Yearning@123';
mysql> grant all privielges on yearning.* to 'yearning'@'%';
mysql> flush privileges;
mkdir /opt/yearning
cd /opt/yearning
wget https://github.com/cookieY/Yearning/releases/download/v3.1.1/Yearning-v3.1.1-linux-amd64.zip
cd /opt/yearning unzip Yearning-v3.1.1-linux-amd64.zip cd Yearning vim conf.toml [Mysql] Db = "Yearning" Host = "your db ip" Port = "3306" Password = "Yearning@123" User = "yearning" [General] SecretKey = "dbcjqheupqjsuwsm" Hours = 4 [Oidc] Enable = false ClientId = "yearning" ClientSecret = "fefehelj23jlj22f3jfjdfd" Scope = "openid profile" AuthUrl = "https://keycloak.xxx.ca/auth/realms/master/protocol/openid-connect/auth" TokenUrl = "https://keycloak.xxx.ca/auth/realms/master/protocol/openid-connect/token" UserUrl = "https://keycloak.xxx.ca/auth/realms/master/protocol/openid-connect/userinfo" RedirectUrL = "http://127.0.0.1:8000/oidc/_token-login" UserNameKey = "preferred_username" RealNameKey = "name" EmailKey = "email" SessionKey = "session_state"
$ ./Yearning install
1、使用默认8000端口启动
$ ./Yearning run
2、使用指定端口启动
./Yearning run --push “you ip:you port” --port “your port”
3、放到后台运行
$ nohup ./Yearning run --push “you ip:you port” --port “your port” >> /var/log/yearning.log 2>&1 &
如无法访问,请查看防火墙是否放行8000端口
地址:http://对外ip或域名:端口 http://localhost:8000
默认账号: admin / Yearning_admin
docker run -it -d \
--name yearning \
--restart unless-stopped \
-p 8000:8000 \
-e MYSQL_ADDR=your db ip:3306 \
-e MYSQL_USER=yearning \
-e MYSQL_PASSWORD=Yearning@123 \
-e MYSQL_DB=yearning \
zhangsean/yearning:v3.1.1
apiVersion: apps/v1 kind: Deployment metadata: labels: app: yearning name: yearning namespace: tools spec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: yearning strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: app: yearning spec: containers: - args: - run - -b - 对外域名或ip:对外端口 env: - name: MYSQL_ADDR value: yearning数据库地址 - name: MYSQL_USER value: yearning - name: MYSQL_PASSWORD value: Yearning@123 - name: MYSQL_DB value: yearning image: zhangsean/yearning:v3.1.1 imagePullPolicy: IfNotPresent name: yearning resources: limits: cpu: 800m memory: 2Gi requests: cpu: 100m memory: 256Mi dnsPolicy: ClusterFirst nodeSelector: role: rools tolerations: - effect: NoExecute key: role operator: Equal value: tools
apiVersion: v1 kind: Service metadata: name: yearning-svc namespace: tools spec: ports: - name: http port: 8000 protocol: TCP targetPort: 8000 selector: app: yearning sessionAffinity: None type: ClusterIP --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: yearning-ing namespace: tools spec: rules: - host: 域名或公网IP http: paths: - backend: serviceName: yearning-svc servicePort: http path: /
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。