基于audit开启相关服务

IT
IT
IT
400
文章
1
评论
2020年5月21日14:27:40 评论 3,457 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
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
Teambition 网盘与阿里云盘数据合并说明 CentOS

Teambition 网盘与阿里云盘数据合并说明

前言 Teambition 团队是阿里巴巴的一个创新产品团队,除了你熟悉的 Teambition App,「阿里云盘」也是我们的作品,它们都属于阿里云正在打造的新一代「云服务」。 过去几个月,我们投入...
CentOS8安装Jenkins CentOS

CentOS8安装Jenkins

简述 Jenkins 是最流行的,开源的,基于 Java 的自动化服务器,它允许你很容易的设置一个持续集成和持续发布的管道。 持续集成 (CI)是一个 DevOps 实践。当团队成员正常提交代码到版本...
使用vmware安装VMware vSphere Hypervisor7.0服务端 CentOS

使用vmware安装VMware vSphere Hypervisor7.0服务端

创建虚拟机 安装 进入安装界面 敲击回车按F11 如下提示是:安装在哪一个硬盘里,根据自己的需求进行安装即可。博主直接默认安装在第一块硬盘上,直接回车。 默认即可,敲击回车 设置一个VMware的密码...

您必须才能发表评论!