基于audit开启相关服务

IT
IT
IT
335
文章
1
评论
2020年5月21日14:27:40 评论 1,194 3540字阅读11分48秒

基于docker端口映射

[root@1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos7.2_audit latest b56e5ebef779 5 minutes ago 2.252 GB
ngjywbyg latest cc95b9673325 49 minutes ago 2.018 GB
gjywbyg latest 63274623c5f1 51 minutes ago 2.018 GB
centos7.4 latest 196e0ce0c9fb 4 days ago 196.6 MB
centos7.2 latest 3c9d8944d9b2 5 days ago 194.6 MB
[root@1 ~]# docker run -itd -p 80:8080 centos7.2_audit bash
efbb1518b2db207e729c949c436f5f46a52a9283414c9831a4d9ce7e20d48119
[root@1 ~]# ss -tnlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port 
LISTEN 0 128 *:22 *:* users:(("sshd",pid=982,fd=3))
LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=1416,fd=13))
LISTEN 0 128 :::80 :::* users:(("docker-proxy-cu",pid=22258,fd=4))
LISTEN 0 100 ::1:25 :::* users:(("master",pid=1416,fd=14))
[root@1 ~]#

简述

-p 可以指定端口映射,本例中将容器的8080端口映射为本地的80端口

进入容器

[root@1 ~]# docker run -itd -p 80:8080 centos7.2_audit bash
efbb1518b2db207e729c949c436f5f46a52a9283414c9831a4d9ce7e20d48119

[root@1 ~]# docker exec -it efbb1518b bash
[root@efbb1518b2db /]#

开启服务

启动mysql

[root@efbb1518b2db /]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/efbb1518b2db.err'.
. SUCCESS!

启动应用服务

[root@efbb1518b2db /]# cd /home/cafintech/App/audit/
[root@efbb1518b2db audit]# ll
total 8
drwxr-xr-x 2 root root 65 Sep 19 04:55 bin
drwxr-xr-x 2 root root 35 Sep 19 04:55 conf
drwxr-xr-x 2 root root 4096 Sep 19 04:55 lib
[root@efbb1518b2db audit]# ./bin/start.sh

查看端口

root@2d36536af243 cafintech]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 
tcp6 0 0 :::3306 :::* LISTEN - 
tcp6 0 0 :::8080 :::* LISTEN 194/java 
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 27753 - /tmp/mysql.sock

给mysql设置帐号权限

设置密码

[root@2d36536af243 cafintech]# mysqladmin -uroot password '123456'
Warning: Using a password on the command line interface can be insecure.

根据docker镜像主机设置登录权限

[root@2d36536af243 cafintech]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

修改审计连接数据库地址

[root@2d36536af243 conf]# pwd
/home/cafintech/App/audit/conf
[root@2d36536af243 conf]# vi application.properties 

spring.application.name=audit
server.port=8080

#\u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.18.0.2:3306/internal_tmp?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
spring.datasource.username=root
spring.datasource.password=123456

重启服务

[root@2d36536af243 conf]# cd ..
[root@2d36536af243 audit]# ll
total 8
drwxr-xr-x 2 root root 65 Sep 19 07:37 bin
drwxr-xr-x 2 root root 35 Sep 19 07:47 conf
drwxr-xr-x 2 root root 4096 Sep 19 04:55 lib
[root@2d36536af243 audit]# ./bin/reStart.sh 
stop process 194 succeed.
process 314 is start ok.

[root@2d36536af243 audit]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 
tcp6 0 0 :::3306 :::* LISTEN - 
tcp6 0 0 :::8080 :::* LISTEN 314/java 
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 27753 - /tmp/mysql.sock

web页面访问测试

用你自己的宿主机进行浏览即可

http://172.17.6.253/login

基于audit开启相关服务

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年5月21日14:27:40
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
Eureka同步到nacos Nacos

Eureka同步到nacos

官方介绍文档地址 https://nacos.io/zh-cn/docs/nacos-sync.html 官方安装文档地址 https://nacos.io/zh-cn/docs/nacos-sync...
Eureka指定应用的instanceId为IP CentOS

Eureka指定应用的instanceId为IP

痛点 现在所有的应用指定的是服务器默认机器名称,对查看是哪一个服务IP或者单节点自动剔除服务不友好。 像如上图所示,想知道是哪一个节点,还得点开才能获取IP。 改造 全部改成自动获取服务器IP为ins...
阿里云网盘 CentOS

阿里云网盘

申请内测地址 https://survey.aliyun.com/apps/zhiliao/_o6XQjioM 官网地址 https://www.teambition.com/products/pan...
GitLab或Jenkins集成构建工具 CentOS

GitLab或Jenkins集成构建工具

集成构建工具 构建工具是用来将代码编译打包成制品的工具。例如前端项目我们一般使用npm进行打包,后端java项目我们一般使用maven、gradle进行打包。构建工具很多很多,但是集成到gitlab中...