Linux运维工程师必备

netstat

[root@localhost training]# netstat -natpul
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1091/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1369/master
tcp        0    212 172.31.11.35:22         172.31.0.251:49494      ESTABLISHED 2132/sshd: training
tcp6       0      0 :::22                   :::*                    LISTEN      1091/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1369/master
​
​
[root@localhost training]# netstat --help
usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
       netstat [-vWnNcaeol] [<Socket> ...]
       netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]
​
        -r, --route              display routing table
        -I, --interfaces=<Iface> display interface table for <Iface>
        -i, --interfaces         display interface table
        -g, --groups             display multicast group memberships
        -s, --statistics         display networking statistics (like SNMP)
        -M, --masquerade         display masqueraded connections
​
        -v, --verbose            be verbose
        -W, --wide               don't truncate IP addresses
        -n, --numeric            don't resolve names
        --numeric-hosts          don't resolve host names
        --numeric-ports          don't resolve port names
        --numeric-users          don't resolve user names
        -N, --symbolic           resolve hardware names
        -e, --extend             display other/more information
        -p, --programs           display PID/Program name for sockets
        -o, --timers             display timers
        -c, --continuous         continuous listing
​
        -l, --listening          display listening server sockets
        -a, --all                display all sockets (default: connected)
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB
        -Z, --context            display SELinux security context for sockets
​
  <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}
           {-x|--unix} --ax25 --ipx --netrom
  <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
    x25 (CCITT X.25)

1、Linux文件文件系统

Linux文件系统是已”倒挂树“ 的形式呈现的, 文件系统最顶点的位置称为根(“/”),没有windows中 的C盘、D盘之分,所有文件的描述从根开始描述 Linux操作系统的对象,只有文件和目录,一切皆为文件

2、用户的身份识别

id 命令

Linux id命令用于显示用户的ID,以及所属群组的ID。

id会显示用户以及所属群组的实际与有效ID。若两个ID相同,则仅显示实际ID。若仅指定用户名称,则显示目前用户的ID。

[root@training ~]# id
uid=0(root) gid=0(root) groups=0(root)
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

who命令

[root@training ~]# who am i
root pts/0 2021-08-29 21:54 (192.168.226.1)
[root@training ~]# who
root tty1 2021-08-29 21:59
root pts/0 2021-08-29 21:54 (192.168.226.1)
[root@training ~]# whoami
root
​
# ~ 是用户的家目录 linux 有两个家目录./root(超级管理员的家目录) 、/home/username(普通
用户的家目录)
#[root@training doc]# [用户名@主机名短名 工作目录]
[root@training doc]# id
uid=0(root) gid=0(root) groups=0(root)
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@training doc]# hostname
training.example.com
[root@training doc]# hostname -s
training
[root@training doc]# pwd
/usr/share/doc
​

pwd 打印当前的工作路径(print work directory)

[root@training doc]# pwd
/usr/share/doc
​

file 识别文件的类型

[root@training dev]# file sda
sda sda1 sda2
​

touch 创建空文件

[root@training ~]# touch myfile
[root@training ~]# ls
anaconda-ks.cfg Downloads key.txt Pictures Videos
Desktop etc.tar.bz2 Music Public
Documents initial-setup-ks.cfg myfile Templates
[root@training ~]# file myfile
myfile: empty
#touch命令 修改文件的创建时间等,并不是创建空文件,当修改一个文件时,文件不存在,自动创建一个空
文件
代表的当前目录
.. 当前目录的上一级目录
pwd 查看当前的工作目录
cd 切换工作目录
ls 查看当前目录下的组件
 -l 以长格式查看,查看扩展信息
 -a 查看包含的隐藏文件
mkdir 创建目录
 -p 连同父目录、子目录一起创建
rm 删除文件
 -r 递归删除,先删除文件再删除目录
 -f 强制删除,不发出提醒
cp 复制、重命名
 -r
mv 移动
tree 目录树
ln 链接
[root@training ~]# ln -s key.txt mykey.txt

操作步骤

切换账号

su -

密码:Asimov 存在\etc\shadow

[training@localhost ~]$ su -
Password:
Last login: Tue Jun  1 09:57:18 CST 2021 from 172.31.0.254 on pts/0
Last failed login: Fri Oct  8 10:17:31 CST 2021 on pts/0
There were 4 failed login attempts since the last successful login.
[root@localhost ~]#
[root@localhost ~]# exit
logout
[training@localhost ~]$ sudo cat /etc/shadow
root:$6$9lUpHvqexIUdy1jS$pelOYpU0orbgpA8XmNEslHaptnpMJNW5wfUXwOLGZOKhX7CsPLUuDc5DCgUf2yzTGmAWH6B8lInFyI7WgoOgE0::0:99999:7:::
bin:*:18353:0:99999:7:::
daemon:*:18353:0:99999:7:::
adm:*:18353:0:99999:7:::
lp:*:18353:0:99999:7:::
sync:*:18353:0:99999:7:::
shutdown:*:18353:0:99999:7:::
halt:*:18353:0:99999:7:::
mail:*:18353:0:99999:7:::
operator:*:18353:0:99999:7:::
games:*:18353:0:99999:7:::
ftp:*:18353:0:99999:7:::
nobody:*:18353:0:99999:7:::
systemd-network:!!:18770::::::
dbus:!!:18770::::::
polkitd:!!:18770::::::
sshd:!!:18770::::::
postfix:!!:18770::::::
training:$6$OQi1w2YjjVS/Bhv.$.VYxXgOsZBGtDp9JOh8YuU3S82D2wuQ9vVD6Ge.sOaJ8iysPLziL36TzsqRKW2XJ2Twd5j0fsjmAYJmi4.vuf1::0:99999:7:::
kafka:!!:18779:0:99999:7:::
[training@localhost ~]$ id
uid=1000(training) gid=1000(training) groups=1000(training),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[training@localhost ~]$ passwd training
passwd: Only root can specify a user name.
[training@localhost ~]$ su
Password:
[root@localhost training]# passwd training
Changing password for user training.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
Sorry, passwords do not match.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.

不要从training用户切换到root又切换到training,要用exit

用户、组管理

useradd创建用户

– -G 附属组

– -g 主组

– -u 指定用户ID

groupadd 创建组

– groupadd group1

相关文件

– /etc/passwd

– /etc/shadow

– /etc/group

权限管理

drwxr-xr-x.  3 root root     54 May 24 00:58 udev
​
-    rw-   ---   ---
类型  拥有人 拥有组  其他人
​
操作符  + - = 
     u=rw-  g=r-- o=---
     o-r  u+w
# u owner 
# g group
# o other
# a all
#运算符号 + - =  
​
授权方式
– chmod u=rw,g+w,o=x fileobject
– chmod 644 fileobject
chmod o-r,u+w file
​
改变所属组和拥有人
– chown user fileobject
– chown user:group fileobject
– chgrp group1 fileobjec
​
类型:
d 目录
l 链接文件,快捷方式
- 普通文件
b 设备文件
c 字符设备
​
      

Linux如何获取帮助

1、whatis

[root@training ~]# whatis mdadm
mdadm (8) - manage MD devices aka Linux Software RAID

常用的用法

[root@training ~]# cp --help
Usage: cp [OPTION]... [-T] SOURCE DEST
or: cp [OPTION]... SOURCE... DIRECTORY
or: cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
​

2、man page

# man command
[root@training ~]# man cp
# 使用上下键浏览
#q退出
#/keywork 搜索, n在关键字之间向后下一个, N在关键字之间向前下一个
#pageup pagedown
manpage章节
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g.
man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
[root@training ~]# man fstab
[root@training ~]# whatis mdadm
mdadm (8) - manage MD devices aka Linux Software RAID
[root@training ~]# man 8 mdadm
​

3、info文档

[root@training ~]# info ls
#和man page info文档不受到格式限制,像写书一样,man page 需要受到格式的限制
​

4、软件文档

[root@training ~]# cd /usr/share/doc/
[root@training doc]# pwd
/usr/share/doc
[root@training doc]# ls
[root@training ~]# cd /usr/share/doc/
[root@training doc]# cd zip/
[root@training zip]# ls
algorith.txt CHANGES README README.CR TODO WHATSNEW WHERE
[root@training zip]# cat algorith.txt
[root@training tigervnc]# yum install vsftpd -y
[root@training tigervnc]# cd /usr/share/doc/vsftpd/
[root@training vsftpd]# pwd
/usr/share/doc/vsftpd
[root@training vsftpd]# ls
AUDIT Changelog FAQ README SECURITY TODO
BENCHMARKS COPYING INSTALL README.security SIZE TUNING
BUGS EXAMPLE LICENSE REWARD SPEED vsftpd.xinetd
[root@training vsftpd]# cd EXAMPLE/

5、搜索引擎

百度 谷歌 技术论坛 官方网站、开源软件网站

6、技术支持

购买服务

软件包管理

rpm -qi httpd-2.4.37- 39.module_el8.4.0+778+c970deab.x86_64.rpm

rpm -ivh httpd-2.4.37- 39.module_el8.4.0+778+c970deab.x86_64.rpm

yum install --downloadonly -- downloaddir=/tmp apr-util-1.6.1- 6.el8.x86_64.rpm -y

rpm –help可以看到这里有很多的命令,是rpm需要命令,下面列出了常用命令。

RPM常用命令:

-i 安装软件包

--nodeps 不验证软件包的依赖  

-v 可视化,提供更多的详细信息的输出  

-h 显示安装进度  另外的常用的附带参数为:  

--force 强制安装,即使覆盖其他包的文件也要安装

-a 查询所有已经安装的软件包

-f 查询 文件所属于的软件包

-q 查询软件包(通常用来看下还未安装的软件包)

-l 显示软件包的文件列表

-d 显示被标注为文档的文件列表

-c 显示被标注为配置文件的文件列表

-e 卸载包

yum原理

YUM的工作原理并不复杂,每一个 RPM软件的头(header)里面都会纪录该软件的依赖关系,那么如果可以将该头的内容纪录下来并且进行分析,可以知道每个软件在安装之前需要额外安装 哪些基础软件。也就是说,在服务器上面先以分析工具将所有的RPM档案进行分析,然后将该分析纪录下来,只要在进行安装或升级时先查询该纪录的文件,就可以知道所有相关联的软件。所以YUM的基本工作流程如下: 服务器端:在服务器上面存放了所有的RPM软件包,然后以相关的功能去分析每个RPM文件的依赖性关系,将这些数据记录成文件存放在服务器的某特定目录内。 客户端:如果需要安装某个软件时,先下载服务器上面记录的依赖性关系文件(可通过WWW或FTP方式),通过对服务器端下载的纪录数据进行分析,然后取得所有相关的软件,一次全部下载下来进行安装。

vim /etc/yum.conf
[main]
cachedir=/var/cache/yum
#cachedir:yum缓存的目录,yum在此存储下载的rpm包和数据库,一般是/var/cache/yum。
debuglevel=2
#debuglevel:除错级别,0──10,默认是2 貌似只记录安装和删除记录
logfile=/var/log/yum.log
pkgpolicy=newest
#pkgpolicy: 包的策略。一共有两个选项,newest和last,这个作用是如果你设置了多个repository,而同一软件在不同的repository中同时存 在,yum应该安装哪一个,如果是newest,则yum会安装最新的那个版本。如果是last,则yum会将服务器id以字母表排序,并选择最后的那个 服务器上的软件安装。一般都是选newest。
distroverpkg=centos-release
#指定一个软件包,yum会根据这个包判断你的发行版本,默认是redhat-release,也可以是安装的任何针对自己发行版的rpm包。
tolerant=1
#tolerent,也有1和0两个选项,表示yum是否容忍命令行发生与软件包有关的错误,比如你要安装1,2,3三个包,而其中3此前已经安装了,如果你设为1,则yum不会出现错误信息。默认是0。
exactarch=1
#exactarch,有两个选项1和0,代表是否只升级和你安装软件包cpu体系一致的包,如果设为1,则如你安装了一个i386的rpm,则yum不会用1686的包来升级。
retries=20
#retries,网络连接发生错误后的重试次数,如果设为0,则会无限重试。
obsoletes=1
gpgcheck=1
#gpgchkeck= 有1和0两个选择,分别代表是否是否进行gpg校验,如果没有这一项,默认是检查的。
reposdir=/etc/yy.rm #默认是 /etc/yum.repos.d/ 低下的 xx.repo后缀文件
#默认都会被include 进来 也就是说 /etc/yum.repos.d/xx.repo 无论配置文件有多少个 每个里面有多少个[name] 最后其实都被整合到 一个里面看就是了 重复的[name]后面的覆盖前面的
exclude=xxx
#exclude 排除某些软件在升级名单之外,可以用通配符,列表中各个项目要用空格隔开,这个对于安装了诸如美化包,中文补丁的朋友特别有用。
keepcache=[1 or 0]
#  设置 keepcache=1,yum 在成功安装软件包之后保留缓存的头文件 (headers) 和软件包。默认值为 keepcache=0 不保存
​
reposdir=[包含 .repo 文件的目录的绝对路径]
#  该选项用户指定 .repo 文件的绝对路径。.repo 文件包含软件仓库的信息 (作用与 /etc/yum.conf 文件中的 [repository] 片段相同)。
​
​
​
​
vim /etc/yum.repo.d/xx.repo
这个字段其实也可以在yum.conf里面直接配置
[serverid]
#其中serverid是用于区别各个不同的repository(仓库;贮藏室;博物馆;亲信),必须有一个独一无二的名称。 重复了 前面覆盖后面--还是反过来呢?用enabled 测试是后面覆盖前面
​
​
name=Some name for this server
#name,是对repository的描述,支持像$releasever $basearch这样的变量; name=Fedora Core $releasever - $basearch - Released Updates
​
baseurl=url://path/to/repository/
#baseurl是服务器设置中最重要的部分,只有设置正确,才能从上面获取软件。它的格式是:
baseurl=url://server1/path/to/repository/
url://server2/path/to/repository/
url://server3/path/to/repository/
#其中url支持的协议有 http:// ftp:// file://三种。baseurl后可以跟多个url,你可以自己改为速度比较快的镜像站,但baseurl只能有一个,也就是说不能像如下格式:
baseurl=url://server1/path/to/repository/
baseurl=url://server2/path/to/repository/
baseurl=url://server3/path/to/repository/
其中url指向的目录必须是这个repository header目录的上一级,它也支持$releasever $basearch这样的变量。
​
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
#上面的这一行是指定一个镜像服务器的地址列表,通常是开启的,本例中加了注释符号禁用了,我们可以试试,将$releasever和$basearch替换成自己对应的版本和架构,例如10和i386,在浏览器中打开,我们就能看到一长串镜可用的镜像服务器地址列表。
​
url之后可以加上多个选项,如gpgcheck、exclude、failovermethod等,比如:
gpgcheck=1
exclude=gaim
#其中gpgcheck,exclude的含义和[main]部分相同,但只对此服务器起作用,
failovermethod=priority
#failovermethode 有两个选项roundrobin和priority,意思分别是有多个url可供选择时,yum选择的次序,roundrobin是随机选择,如果连接失 败则使用下一个,依次循环,priority则根据url的次序从第一个开始。如果不指明,默认是roundrobin。
​
enabled=[1 or 0]
#当某个软件仓库被配置成 enabled=0 时,yum 在安装或升级软件包时不会将该仓库做为软件包提供源。使用这个选项,可以启用或禁用软件仓库。
#通过 yum 的 --enablerepo=[repo_name] 和 --disablerepo=[repo_name] 选项,或者通过 PackageKit 的"添加/删除软件"工具,也能够方便地启用和禁用指定的软件仓库
​
几个变量:
$releasever,发行版的版本,从[main]部分的distroverpkg获取,如果没有,则根据redhat-release包进行判断。
$arch,cpu体系,如i686,athlon等
$basearch,cpu的基本体系组,如i686和athlon同属i386,alpha和alphaev6同属alpha。
对yum.conf设定完成,我们就可以好好体验yum带来的方便了。

yum源(软件仓库)的配置文件

[root@localhost training]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo          docker-ce.repo  epel-testing.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo  epel.repo

yum源更换

1.首先备份/etc/yum.repos.d/CentOS-Base.repo
​
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
​
2.下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
​
Centos7:
​
wget -P /etc/yum.repos.d http://mirrors.163.com/.help/CentOS7-Base-163.repo
​
Centos6:
​
wget -P /etc/yum.repos.d http://mirrors.163.com/.help/CentOS6-Base-163.repo
​
Centos5:
​
wget -P /etc/yum.repos.d http://mirrors.163.com/.help/CentOS5-Base-163.repo
​
3.运行以下命令生成缓存
​
yum clean all
yum makecache

repo 文件包含软件仓库的信息 (作用与 /etc/yum.conf 文件中的 [repository] 片段相同

podman 每个进程要跑个容器

docker run -d --name web2 -p 88:80 httpd

物理机:docker

NAT :PAT端口地址转换、POOL、Static

SNAT:出互联网

DNAT:out到in

ss -ltpn |grep 80

iptables

1、iptables -L

查看filter表的iptables规则,包括所有的链。filter表包含INPUT、OUTPUT、FORWARD三个规则链。

说明:-L是--list的简写,作用是列出规则。

2、iptables -L [-t 表名]

只查看某个表的中的规则。

说明:表名一共有三个:filter,nat,mangle,如果没有指定表名,则默认查看filter表的规则列表(就相当于第一条命令)。

举例:iptables -L -t filter

#iptables -t nat -nv -L
#watch  -n 1 -d iptables -t nat -nv -L
​
[root@localhost training]# iptables -t nat -nv -L
Chain PREROUTING (policy ACCEPT 3 packets, 234 bytes)
 pkts bytes target     prot opt in     out     source               destination
  300 36748 PREROUTING_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  300 36748 PREROUTING_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  300 36748 PREROUTING_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 DOCKER     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL
​
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
​
Chain OUTPUT (policy ACCEPT 2 packets, 125 bytes)
 pkts bytes target     prot opt in     out     source               destination
  617 40401 OUTPUT_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0
    0     0 DOCKER     all  --  *      *       0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL
​
Chain POSTROUTING (policy ACCEPT 2 packets, 125 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  *      !docker0  172.17.0.0/16        0.0.0.0/0
  617 40401 POSTROUTING_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  617 40401 POSTROUTING_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  617 40401 POSTROUTING_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0
​
Chain DOCKER (2 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  docker0 *       0.0.0.0/0            0.0.0.0/0
​
Chain OUTPUT_direct (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain POSTROUTING_ZONES (1 references)
 pkts bytes target     prot opt in     out     source               destination
  617 40401 POST_public  all  --  *      ens192  0.0.0.0/0            0.0.0.0/0           [goto]
    0     0 POST_public  all  --  *      +       0.0.0.0/0            0.0.0.0/0           [goto]
​
Chain POSTROUTING_ZONES_SOURCE (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain POSTROUTING_direct (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain POST_public (2 references)
 pkts bytes target     prot opt in     out     source               destination
  617 40401 POST_public_log  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  617 40401 POST_public_deny  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  617 40401 POST_public_allow  all  --  *      *       0.0.0.0/0            0.0.0.0/0
​
Chain POST_public_allow (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain POST_public_deny (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain POST_public_log (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain PREROUTING_ZONES (1 references)
 pkts bytes target     prot opt in     out     source               destination
  300 36748 PRE_public  all  --  ens192 *       0.0.0.0/0            0.0.0.0/0           [goto]
    0     0 PRE_public  all  --  +      *       0.0.0.0/0            0.0.0.0/0           [goto]
​
Chain PREROUTING_ZONES_SOURCE (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain PREROUTING_direct (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain PRE_public (2 references)
 pkts bytes target     prot opt in     out     source               destination
  300 36748 PRE_public_log  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  300 36748 PRE_public_deny  all  --  *      *       0.0.0.0/0            0.0.0.0/0
  300 36748 PRE_public_allow  all  --  *      *       0.0.0.0/0            0.0.0.0/0
​
Chain PRE_public_allow (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain PRE_public_deny (1 references)
 pkts bytes target     prot opt in     out     source               destination
​
Chain PRE_public_log (1 references)
 pkts bytes target     prot opt in     out     source               destination

brctl

[root@localhost training]# yum provides brctl
Loaded plugins: fastestmirror, product-id, search-disabled-repos
Loading mirror speeds from cached hostfile
 * base: mirrors.njupt.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
bridge-utils-1.5-9.el7.x86_64 : Utilities for configuring the linux ethernet bridge
Repo        : base
Matched from:
Filename    : /usr/sbin/brctl
​
​
​
[root@localhost training]# yum install bridge-utils-1.5-9.el7.x86_64
Loaded plugins: fastestmirror, product-id, search-disabled-repos
Loading mirror speeds from cached hostfile
 * base: mirrors.njupt.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package bridge-utils.x86_64 0:1.5-9.el7 will be installed
--> Finished Dependency Resolution
​
Dependencies Resolved
​
======================================================================================================================================================================
 Package                                     Arch                                  Version                                  Repository                           Size
======================================================================================================================================================================
Installing:
 bridge-utils                                x86_64                                1.5-9.el7                                base                                 32 k
​
Transaction Summary
======================================================================================================================================================================
Install  1 Package
​
Total download size: 32 k
Installed size: 56 k
Is this ok [y/d/N]: y
Downloading packages:
bridge-utils-1.5-9.el7.x86_64.rpm                                                                                                              |  32 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : bridge-utils-1.5-9.el7.x86_64                                                                                                                      1/1
  Verifying  : bridge-utils-1.5-9.el7.x86_64                                                                                                                      1/1
​
Installed:
  bridge-utils.x86_64 0:1.5-9.el7
​
Complete!
[root@localhost yum.repos.d]# brctl show
bridge name     bridge id               STP enabled     interfaces
docker0         8000.024295e4398d       no              vethb38a69a
                                                        vethf2e0ce9
docker search nginx

交互式启动并进入容器中 $ docker run -i -t image_name /bin/bash

docker rm -f $(docker ps -a -q)

docker tag f8f4ffc8092c 3190217171/nginx:latest docker push 3190217171/nginx:latest

docker-php-ext-install mysqli

 0.查看网络docker network ls
 1.创建桥接网络docker network create mynetwork
 2.检查网络docker network inspect mynetwork
 3.拉取mysql5.6的docker  docker pull mysql:5.6
 4.docker images
 5.运行mysql镜像docker run -dit --name mysql -p 3306:3306 --network mynetwork \
 -e MYSQL_ROOT_PASSWORD=rootpass \
 -e MYSQL_DATABASE=mydb \
 -e MYSQL_USER=user1  \
 -e MYSQL_PASSWORD=rootpass \
 -v /webapp/mysqldata:/var/lib/mysql \
 mysql:5.6
 6.docker ps
 7.docker exec -it mysql /bin/bash
 8.mysql -u root -prootpass -h localhost
 9.show database;  exit
 10.docker pull wordpress
 11.
 #docker network connect mynetwork wordpress
 docker run --name wordpress --network mynetwork -p 8080:80 \
 -e WORDPRESS_DB_HOST=mysql \
 -e WORDPRESS_DB_USER=user1 \
 -e WORDPRESS_DB_PASSWORD=rootpass \
 -e WORDPRESS_DB_NAME=mydb \
 -e WORDPRESS_TABLE_PREFIX=table1 \
 -d wordpress
 12.打开浏览器http://172.31.11.35:8080/wp-admin/install.php

apache web http

nginx(F5) web LB 反向代理

tomcat java

​
$ systemctl start httpd 
​
$ systemctl enable httpd 
​
$systemctl enable --now httpd
​
$ firewall-cmd --list-all

查询放行的端口:

firewall-cmd --zone=public --list-ports

新增放行端口(比如8080):

firewall-cmd --zone=public --add-port=80/tcp --permanent

切记要刷新:

firewall-cmd --reload

service firewall stop

mstsc远程

DNS解析

FQDN-->IP地址 正向查找

DNS查询方式:递归、迭代

多个域名可以指向一个IP

1.cache

2.hosts

3.首选DNS

多域名 app1.x.com、app2.x.com

Apache虚拟主机

cd /etc/httpd/conf.d/
​
cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf ./
​
vim httpd-vhosts.conf
​
<VirtualHost *:80>
    DocumentRoot "var/www/web1"
    ServerName web1.example.com
    ErrorLog "/var/log/httpd/web1_error.log"
    CustomLog "/var/log/httpd/web1_access_log" common
</VirtualHost>
​
​
mkdir /var/www/log/
systemctl restart httpd
ss -ltpn |grep 80

*代表所有网卡

虚拟主机的测试

C:\Windows\System32\drivers\etc\hosts

172.31.11.35 web1.example.com web2.example.com

vim /etc/hosts

ipconfig /flushdns 
​
Windows IP 配置
​
已成功刷新 DNS 解析缓存。

mysql 单实例多库多表

Oracle单实例单库多表

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

神圣雅诗人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值