Linux 网卡特性配置 ethtool 详解 网卡Offload

网络中校验和比较

2015年10月14日

本文说明了网卡,IP层,TCP层,UDP层的校验和功能,以及异同点。

 

网卡校验和

高级的网卡(e1000e等千M网卡)的接收,发送的校验和的计算方法是CRC32。

Refs7.10. Checksums

http://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf

 

可以使用ethtool查看网卡的校验功能,rx-checksumming是接收端的校验功能,tx-checksumming是发送端的校验功能:

# ethtool -k eth0 
Offload parameters for eth0: 
rx-checksumming: on 
tx-checksumming: on 
scatter-gather: on 
tcp-segmentation-offload: on 
udp-fragmentation-offload: off 
generic-segmentation-offload: on 
generic-receive-offload: on 
large-receive-offload: off

 

IP校验和

校验和只对头部进行,不包括数据部分。

发送IP包, 计算checksum:

(1)把IP数据报的首部校验和字段设置为0。 
(2)把首部看成以16位为单位的数字组成,依次进行二进制反码求和。 
(3)把得到的结果存入校验和字段中。

 

接收IP包,验证checksum:

(1)把首部看成以16位为单位的数字组成,依次进行二进制反码求和,包括校验和字段。 
(2)检查计算出的校验和的结果是否为全1。 
(3)如果全1,校验是和正确。否则,校验和就是错误的,协议栈要抛弃这个数据包。但不生成差错报文,由上层去发现丢失的数据报并进行重传。

 

Refs

RFC 791 - Internet Protocol

 

UDP校验和

校验和即覆盖头部,也覆盖数据部分。UDP校验和是可选的,而TCP校验和是必须的。

发送包, 计算checksum:

算法和IP头部的校验和计算方法类似:二进制反码求和。但有下面两个区别:

1) 总长度如果是奇数,则自动补齐,并自动填充为0. 填充的部分不发送出去。

2)添加12个字节的伪头部。源地址(4个字节),目的地址(4个字节),0(1个字节),udp协议号(1个字节),udp头部中长度字段值(2个字节)。

如果校验和字段是0,表示不需要计算校验和。

 

接收包, 验证checksum:

验证checksum是根据udp头部中的length字段值所指向的数据长度进行校验,如果length字段值大于实际的数据长度,那么包在校验前会被丢弃。如果length字段值小于实际的数据长度,则需要裁减数据,并校验。

 

TCP校验和

校验和即覆盖头部,也覆盖数据部分。TCP校验和是必须的。也包含了12个字节的伪头部。

Linux Networking: How todisable/enable offload features, RX/TX checksum, scatter, gather and beyond

Submitted by root on Mon,03/02/2015 - 10:17

http://docs.gz.ro/node/282

 

TCP offload engine or TOE is a technology used in networkinterface cards (NIC) to offload processing of the entire TCP/IP stack to thenetwork controller. It is primarily used with high-speed network interfaces,such as gigabit Ethernet and 10 Gigabit Ethernet, where processing overhead ofthe network stack becomes significant.
The term, TOE, is often used to refer to the NIC itself, although circuit boardengineers may use it to refer only to the integrated circuit included on thecard which processes the TCP headers. TOEs are often suggested as a way toreduce the overhead associated with IP storage protocols such as iSCSI and NFS.Read more about this on wikipedia.

Linux doesn't support TOE by default because of many reasonsmentioned here.
But even if TOE is not suitable, at least for now, there are other settingsthat could improve your network (especially if you use it for iSCSI). So readon and remember: in most of the cases, these settings must be ON but you haveto test and see what is suitable for your environment. Enjoy!

Offload features


Most of these offload features are configured using the ethtool tool.In order to check which features are set, you can use the -k parameter.Also, in order to disable/enable, use -K or --offload parameteralong with the desired features.
Display: 
ethtool -kethX
Enable (recommended): ethtool -K ethX rx on tx on
Disable: ethtool -KethX rx off tx off

Example:


 

root@pluto:~# ethtool -k eth2
Features for eth2:
rx-checksumming: off
tx-checksumming: on
        tx-checksum-ipv4: off [fixed]
        tx-checksum-unneeded: off [fixed]
        tx-checksum-ip-generic: on
        tx-checksum-ipv6: off [fixed]
        tx-checksum-fcoe-crc: off [fixed]
        tx-checksum-sctp: off [fixed]
scatter-gather: on
        tx-scatter-gather: on
        tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
        tx-tcp-segmentation: on
        tx-tcp-ecn-segmentation: off [fixed]
        tx-tcp6-segmentation: off [fixed]
udp-fragmentation-offload: off [fixed]
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: on
tx-vlan-offload: on [fixed]
ntuple-filters: off [fixed]
receive-hashing: off [fixed]
highdma: off [fixed]
rx-vlan-filter: on [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: on
loopback: off [fixed]
root@pluto:~# ethtool --offload eth2 rx off tx off
Actual changes:
tx-checksumming: off
        tx-checksum-ip-generic: off
scatter-gather: off
        tx-scatter-gather: off [requested on]
tcp-segmentation-offload: off
        tx-tcp-segmentation: off [requested on]
generic-segmentation-offload: off [requested on]
root@pluto:~# ethtool --offload eth2 rx on tx on
Actual changes:
rx-checksumming: on
tx-checksumming: on
        tx-checksum-ip-generic: on
scatter-gather: on
        tx-scatter-gather: on
tcp-segmentation-offload: on
        tx-tcp-segmentation: on
generic-segmentation-offload: on

TCP Segmentation Offload (TSO)


This is useful to reduce CPU overhead and it is also called Large SegmentOffload (LSO).
In order to enable/disable TCP segmentation offload, you must use ethtool commandwith tso option:
Display: 
ethtool -k ethX | grep tcp-segmentation
Enable (recommended): ethtool -K ethX tso on
Disable: ethtool -K ethX tso off

Example:


 

root@pluto:~# ethtool -K eth2 tso off
root@pluto:~# ethtool -k eth2 | grep segmentation
tcp-segmentation-offload: off
        tx-tcp-segmentation: off
        tx-tcp-ecn-segmentation: off [fixed]
        tx-tcp6-segmentation: off [fixed]
generic-segmentation-offload: on
tx-fcoe-segmentation: off [fixed]


 

root@pluto:~# ethtool -K eth2 tso on
root@pluto:~# ethtool -k eth2 | grep segmentation
tcp-segmentation-offload: on
        tx-tcp-segmentation: on
        tx-tcp-ecn-segmentation: off [fixed]
        tx-tcp6-segmentation: off [fixed]
generic-segmentation-offload: on
tx-fcoe-segmentation: off [fixed]

Scatter and Gather


Scatter and Gather (Vectored I/O) is a concept that was primarily used in harddisks and it enhances large I/O request performance, if supported by thehardware.
To manipulate this feature, you must use the same ethtool commandwith the following parameter:

Display: ethtool -kethX | grep scatter-gather
Enable (recommended): ethtool -K ethX sg on
Disable: ethtool -K ethX sg off

Example:


 

root@pluto:~# ethtool -k eth2 | grep scatter-gather
scatter-gather: on
        tx-scatter-gather: on
        tx-scatter-gather-fraglist: off [fixed]


 

root@pluto:~# ethtool -K eth2 sg off
Actual changes:
scatter-gather: off
        tx-scatter-gather: off
tcp-segmentation-offload: off
        tx-tcp-segmentation: off [requested on]
generic-segmentation-offload: off [requested on]


 

root@pluto:~# ethtool -K eth2 sg on
Actual changes:
scatter-gather: on
        tx-scatter-gather: on
tcp-segmentation-offload: on
        tx-tcp-segmentation: on
generic-segmentation-offload: on

Generic Segmentation Offload


This feature is related to TSO so it is advisable to enable them together. Itcan be done with ethtool command also:
Display: 
ethtool -k ethX | grepgeneric-segmentation-offload
Enable (recommended): ethtool -K ethX gso on
Disable: ethtool -K ethX gso off

Example:


 

root@pluto:~# ethtool -K eth2 gso off
root@pluto:~# ethtool -k eth2 | grep generic-segmentation-offload
generic-segmentation-offload: off


 

root@pluto:~# ethtool -K eth2 gso on
root@pluto:~# ethtool -k eth2 | grep generic-segmentation-offload
generic-segmentation-offload: on

UDP / TCP Checksum errors in tcpdump output


To avoid any extra search from your part, if you have offload features enabledand you see cksum incorrect in tcpdump output,without any packet errors and your network is working properly: it is nothingto worry about because the checksum is actually calculated on the networkadapter and the tcpdump is showing the checksum calculated on kernel level.Read more here if you are curious.

Linux 网卡特性配置ethtool详解

近期遇到一个自定义报文传输性能问题,解决过程中借助了ethtool这个工具,因此发掘一下与此工具相关的网卡的一些特性。

ethtool 常用命令如下,比如对eth0的操作:

ethtool eth0       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0、eth1等等

ethtool –h        //显示ethtool的命令帮助(help)

ethtool –ieth0    //查询eth0网口的相关信息

ethtool –deth0    //查询eth0网口注册性信息

ethtool –reth0    //重置eth0网口到自适应模式

ethtool –Seth0    //查询eth0网口收发包统计

ethtool –s eth0[speed 10|100|1000] [duplex half|full] [autoneg on|off]        //设置网口速率10/100/1000M、设置网口半/全双工、设置网口是否自协商

我这里主要想发掘一下ethtool -k 相关的内容,以下命令在ubuntu 14.04上亲测:

1rx-checksumming: off      

    接收侧硬件校验和计算,如能设置为on,表示网卡支持该特性,命令: ethtool -K eth0 rx-checksum on|off

2tx-checksumming:on      

    发送侧硬件校验和计算,如能设置为on,表示网卡支持该特性,命令: ethtool -K eth0 tx-checksum-ip-generic on|off

3scatter-gather:on          

    分散/聚集 (Scatter Gather) 功能,是网卡要支持TSO的必要条件之一。

4tcp-segmentation-offload: on 

    简称TSO,是一种利用网卡对TCP数据包分片,减轻CPU负荷的一种技术,有时也被叫做 LSO (Large segment offload) TSO是针对TCP的,UFO是针对UDP的。如果硬件支持 TSO功能,同时也需要硬件支持的TCP校验计算和分散/聚集 (Scatter Gather) 功能。命令: ethtool -K eth0 tso on|off

     在不支持TSO的网卡上,TCP层向IP层发送数据会考虑mss,使得TCP向下发送的数据可以包含在一个IP分组中而不会造成分片, mss是在TCP初始建立连接时由网卡MTU确定并和对端协商的,所以在一个MTU1500的网卡上,TCP向下发送的数据不会大于min(mss_local, mss_remote)-ip-tcp头。
      网卡支持TSO时,TCP层会逐渐增大mss(总是整数倍数增加),当TCP层向下发送大块数据时,仅仅计算TCP头,网卡接到到了IP层传下的大数据包后自己重新分成若干个IP数据包,添加IP头,复制TCP头并且重新计算校验和等相关数据,这样就把一部分CPU相关的处理工作转移到由网卡来处理。

5udp-fragmentation-offload: off

    简称UFO,是网卡对udp提供的类似TSO的技术。命令:ethtool -K eth0 ufo on | off

    在我的网卡上不支持这个特性,所以命令执行失败是这样的:

root@ubuntu:~#ethtool -K eth0 ufo on

Cannot changeudp-fragmentation-offload

Could not changeany device features

6generic-segmentation-offload: on

     简称GSO,它比TSO更通用,基本思想就是尽可能的推迟数据分片直至发送到网卡驱动之前,此时会检查网卡是否支持分片功能(如TSOUFO, 如果支持直接发送到网卡,如果不支持就进行分片后再发往网卡。这样大数据包只需走一次协议栈,而不是被分割成几个数据包分别走,这就提高了效率。命令: ethtool -K eth0 gso on | off

7large-receive-offload: off

  简称LRO,通过将接收到的多个TCP数据聚合成一个大的数据包,然后传递给网络协议栈处理,以减少上层协议栈处理开销,提高系统接收TCP数据包的能力。

8generic-receive-offload: on

    简称GRO,基本思想跟LRO类似,克服了LRO的一些缺点,更通用。后续的驱动都使用GRO的接口,而不是LRO

 

附:

RSS(Receive Side Scaling),是一项网卡的新特性,俗称多队列。具备多个RSS队列的网卡,可以将不同的网络流分成不同的队列,再分别将这些队列分配到多个CPU核心上进行处理,从而将负荷分散,充分利用多核CPU的能力。

 

网卡Offload

对于网络安全来说,网络传输数据包的捕获和分析是个基础工作,绿盟科技研究员在日常工作中,经常会捕获到一些大小远大于MTU值的数据包,经过分析这些大包的特性,发现和网卡的offload特性有关,本文对网卡Offload技术做简要描述。

MTU

最大传输单元,指一种通信协议的某一层上面所能通过的最大数据包大小(以字节为单位)。

在以太网通信中,MTU规定了经过网络层封装的数据包的最大长度。例如,若某个接口的MTU值为1500,则通过此接口传送的IP数据包的最大长度为1500字节。

小编注:对于普通用户来说,如果你优化过迅雷的下载速度,可能通过这篇文章《合理设置MTU,提升下载速度》,对MTU的基础知识有所了解。

IP分片

当IP层需要传送的数据包长度超过MTU值时,则IP层需要对该数据包进行分片,使每一片的长度小于或等于MTU值。在分片过程中,除了对payload进行分片外,数据包的IP首部也需要进行相应的更改:

  • 将identifier字段的值复制给每个分片;
  • 将分片数据包的Flags中的DF位置为0;
  • 除最后一个分片之外的其他分片,将MF位置为1;
  • 将Fragment Offset字段设置正确的值。  

MSS

最大分段长度,TCP数据包每次能够传输的最大数据分段长度,在TCP协议的实际实现中,MSS往往用MTU-(IPHeader Length + TCP Header Length)来代替。在TCP通信建立连接时,取两端提供的MSS的最小值作为会话的MSS值。由于TCP分段有MSS值的限制,通常情况下TCP数据包经IP层封装后的长度不会大于MTU,因此一般情况下,TCP数据包不会进行IP分片。

机制

早先TCP设计的目标是为了解决低速网络传输的不可靠性问题(拨号上网的年代),但随着互联网骨干传输速度的提升(光纤、千兆以太、万兆以太)以及用户端更可靠的访问机制的出现(ADSL等),相关的数据中心及客户端桌面环境上的TCP软件常常需要面临大量的计算需求。

当网络速度超过1Gb的时候,这些计算会耗费大量的CPU时间,有数据表明,即便使用千兆全双工网卡,TCP通信也将消耗CPU的80%的使用率(以2.4GHz奔腾4处理器为例),这样留给其他应用程序的时间就很少了,表现出来就是用户可能感觉到很慢。

小编注:当年的蠕虫病毒对CPU的影响与此近似。

为了解决性能问题,就产生了TOE技术(TCP offload engine),将TCP连接过程中的相关计算工作转移到专用硬件上(比如网卡),从而释放CPU资源。从2012年开始,这项技术开始在普通用户的网卡上应用。

随着技术的日趋成熟,目前越来越多的网卡设备开始支持offload特性,以便提升网络收发和处理的性能。本文所描述的offload特性,主要是指将原本在协议栈中进行的IP分片、TCP分段、重组、checksum校验等操作,转移到网卡硬件中进行,降低系统CPU的消耗,提高处理性能。

**TSO (tcp-segmentation-offload) **

从名字来看很直观,就是把tcp分段的过程转移到网卡中进行。当网卡支持TSO机制时,可以直接把不超过滑动窗口大小的payload下传给协议栈,即使数据长度大于MSS,也不会在TCP层进行分段,同样也不会进行IP分片,而是直接传送给网卡驱动,由网卡驱动进行tcp分段操作,并执行checksum计算和包头、帧头的生成工作。例如,

在本地主机上(10.8.55.1)发送一个超长的HTTP请求,当TSO模式关闭时,10.8.55.1抓包如下

 

当TSO模式开启时,10.8.55.1抓包如下:

 

**UFO(udp-fragmentation-offload) **

是一种专门针对udp协议的特性,主要机制就是将IP分片的过程转移到网卡中进行,用户层可以发送任意大小的udp数据包(udp数据包总长度最大不超过64k),而不需要协议栈进行任何分片操作。目前貌似没找到有支持UFO机制的网卡,主要是应用在虚拟化设备上。

**GSO(generic-segmentation-offload) **

相对于TSO和UFO,GSO机制是针对所有协议设计的,更为通用。同时,与TSO、UFO不同的是,GSO主要依靠软件的方式实现,对于网卡硬件没有过多的要求。其基本思想就是把数据分片的操作尽可能的向底层推迟直到数据发送给网卡驱动之前,并先检查网卡是否支持TSO或UFO机制,如果支持就直接把数据发送给网卡,否则的话再进行分片后发送给网卡,以此来保证最少次数的协议栈处理,提高数据传输和处理的效率。

**LRO/GRO(large-receive-offload) **

在网卡驱动层面上将接受到的多个TCP数据包聚合成一个大的数据包,然后上传给协议栈处理。这样可以减少协议栈处理的开销,提高系统接收TCP数据的能力和效率。

generic-receive-offload,基本思想和LRO类似,只是改善了LRO的一些缺点,比LRO更加通用。目前及后续的网卡都采用GRO机制,不再使用LRO机制。例如,

当本地主机(10.51.19.40)开启GRO模式时,从主机10.8.55.11向主机10.51.19.40发送一个超长请求。

10.8.55.11抓包如下:

10.51.19.40抓包如下:

 **RSS(Receive Side Scaling)**

具备多个RSS队列的网卡,可以将不同的网络流分成不同的队列,再将这些队列分配到多个CPU核心上进行处理,从而将负荷分散,充分利用多核处理器的能力,提交数据接收的能力和效率。

模式的设置

Linux

在linux系统下,可以通过ethtool查看各模式的状态并进行设置:

**查看状态 **

1.   ethtool –k 设备名

  **设置开关状态 **

  1. ethtool –K 设备名 模式名(缩写)on/off

windows

在windows系统下,可以通过设备管理器中网卡设备的属性对网卡模式进行查看和调整。以Intel 82579LM和Intel I217-LM网卡为例

  • IPv4、TCP、UDP校验和分载传输控制的是在网卡中进行checksum的计算和校验,其中Rx表示接收数据、Tx表示发送数据。
  • 大型发送分载对应的是前文中提到的TSO模式
  • 接收方调整和接收方调整队列对应的是RRS模式的启用状态以及RSS队列的个数设置。

技术给网络数据包分析带来的影响

目前常用的抓包工具大部分都是从协议栈中(如数据链路层)捕获数据包,而网卡的offload特性会将数据包的分片、重组等工作转移到协议栈以下的硬件层面进行,因此在开启TSO、GRO等机制的情况下,我们使用tcpdump、wireshark等工具抓取到的数据包往往不能真实反应链路上实际的数据帧,给网络流量特征的分析造成不利影响。

在某些情况下,例如分片攻击等攻击方式,甚至可能会因为网卡设备的offload机制处理,而规避防火墙、IDS以及人工的检查。针对这些情况,可以选择关闭网卡offload的相关选项,或者在链路的其他节点进行抓包。

  • 3
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
包含如下操作系统版本 FreeBSD Linux Solaris Windows 分别对应如下目录 MegaCLI for DOS MegaCLI for Linux MegaCLI for Solaris MegaCLI for FreeBSD MegaCLI for Windows ********************************************* LSI Corp. MegaRAID MegaCLI Release ********************************************* Release Date: 01/20/14 ======================== Supported Controllers ================== MegaRAID SAS 9270-8i MegaRAID SAS 9271-4i MegaRAID SAS 9271-8i MegaRAID SAS 9271-8iCC MegaRAID SAS 9286-8e MegaRAID SAS 9286CV-8e MegaRAID SAS 9286CV-8eCC MegaRAID SAS 9265-8i MegaRAID SAS 9285-8e MegaRAID SAS 9240-4i MegaRAID SAS 9240-8i MegaRAID SAS 9260-4i MegaRAID SAS 9260CV-4i MegaRAID SAS 9260-8i MegaRAID SAS 9260CV-8i MegaRAID SAS 9260DE-8i MegaRAID SAS 9261-8i MegaRAID SAS 9280-4i4e MegaRAID SAS 9280-8e MegaRAID SAS 9280DE-8e MegaRAID SAS 9280-24i4e MegaRAID SAS 9280-16i4e MegaRAID SAS 9260-16i MegaRAID SAS 9266-4i MegaRAID SAS 9266-8i MegaRAID SAS 9285CV-8e MegaRAID SAS 8704ELP MegaRAID SAS 8704EM2 MegaRAID SAS 8708ELP MegaRAID SAS 8708EM2 MegaRAID SAS 8880EM2 MegaRAID SAS 8888ELP MegaRAID SAS 8308ELP* MegaRAID SAS 8344ELP* MegaRAID SAS 84016E* MegaRAID SAS 8408E* MegaRAID SAS 8480E* MegaRAID SATA 300-8ELP* *These older controllers should work but have not been tested. Component: ========= SAS MegaRAID MegaCLI Release Date: 01/20/14 Version Numbers: MegaCLI =============== =========== Current Version 8.07.14 Previous Version 8.07.07 Contents: ========= This package contains MegaCLI for the following OSes: DOS FreeBSD Linux Solaris Windows Use the MegaCLI components from the folder that matches your OS. Enhancements and Bug Fixes ========================== SCGCQ00393585 (DFCT) - VD creation from MegaCli fails on Solaris Sparc 10u9 operating system. SCGCQ00413883 (DFCT) - "megacli -version -pd -a0" Segmentation Faults if PDs are missing SCGCQ00445356 (CSET) - Megacli crashes after invoking any command in SGI system with one 9280-8e and 2 quad port qlogic FC cards. SCGCQ
Mac OS X 10.15 下源码安装 mysql-8.0.20-macos10.15-x86_64 https://my.oschina.net/kinglyphp/blog/4281112 博客地址 下载mysql-8.0.20-macos10.15-x86_64.tar.gz 可以从mysql官网下载,如果比较慢, 从https://download.csdn.net/download/long4512524/12427861 中下载 解压 tar zxvf mysql-8.0.20-macos10.15-x86_64.tar.gz 移动解压后的二进制包到安装目录 sudo mv mysql-8.0.20-macos10.15-x86_64 /usr/local/mysql 在 /usr/local/mysql 目录新建 data目录文件 cd /usr/local/mysql sudo mkdir data 更改 mysql 安装目录所属用户与用户组 cd /usr/local sudo chown -R root:wheel mysql 在启动 mysql 之前,我们先需要指定my.cnf 文件 因为 mysql 5.7 版本开始 my-default.cnf 文件不会自带,需要手动创建。 cd /usr/local/mysql/support-files sudo vi my-default.cnf 在 /usr/local/mysql/support-files 目录下创建 my-default.cnf [mysqld] basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 socket = /usr/local/mysql/data/mysql.sock log-error = /usr/local/mysql/data/mysqld.log [client] socket=/usr/local/mysql/data/mysql.sock 拷贝my-default.cnf到/etc/my.cnf sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf 初始化 mysqld cd /usr/local/mysql sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 其中: basedir 是指你的mysql安装在哪儿了。 (具体需要换成你自己的路径) datadir 是指MySQL后续的数据存放在哪儿。(具体需要换成你自己的路径) 注意: 这儿执行完会生成mysql root账号的密码,后面在客户端连接时,5.7版本需要用到,自己别忘了记录下 类似这种: 其中 Wt#GeUu_q2oJ 就是root的密码。 [Note] A temporary password is generated for root@localhost: Wt#GeUu_q2oJ 启动MYSQL cd /usr/local/mysql sudo support-files/mysql.server start 如下: kingly@192 data % cd /usr/local/mysql kingly@192 mysql % sudo support-files/mysql.server start Starting MySQL . SUCCESS! 对应mysqld 启动起来接口 ps aux | grep mysqld 见到如下所示,证明mysql安装成功。 kingly@192 mysql % ps aux | grep mysqld kingly 40915 0.6 0.0 4285708 724 s000 S+ 5:47下午 0:00.00 grep --color=auto mysqld _mysql 40907 0.4 2.1 4907248 350300 s000 S 5:46下午 0:00.95 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mysqld.log --pid-file=/usr/local/mysql/data/192.168.0.103.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306 使用 之前的记住的 Wt#GeUu_q2oJ的密码,测试mysql的链接情况 /usr/local/mysql/bin/mysql -uroot -P3306 -p kingly@192 bin % /usr/local/mysql/bin/mysql -uroot -P3306 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.20 Copyright (c) 2000, 2020, 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> 修改root密码,并为 PASSWORD EXPIRE NEVER 永不过期 mysql> alter user 'root'@'localhost' identified by '12345678' PASSWORD EXPIRE NEVER; mysql> flush privileges; mysql> quit; 设置远程访问 允许root用户在任何地方进行远程登录,并具有所有库任何操作权限。 如果出现 提示”Access denied for user ‘root’@’localhost’ (using password: YES)” mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | epass | % | | epass | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 6 rows in set (0.00 sec) mysql> 发现root只有本地权限, 那么, 我们需要给root 加上 127.0.0.1,% 还有指定服务器ip访问的权限, 注意: mysql版本8.0.13,在给新用户授权时,发生了变化 如果出现, 不能直接使用 grant all privileges on *.* to root@'%' identified by '12345678'; //给mysql用户分配远程访问权限 会出现, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by "12345678"' at line 1 的错误,原因是新版本mysql版本把将创建账户和赋予权限分开了。 应该如下操作: mysql> use mysql; mysql> create user 'root'@'%' identified by 'password'; mysql> grant all privileges on *.* to 'root'@'%' with grant option; mysql> flush privileges; 如果使用 Navicat连接MySQL Server8.0版本时出现Client does not support authentication protocol requested by server; 解决办法: mysql> use mysql; mysql> alter user 'root'@'localhost' identified with mysql_native_password by '12345678'; mysql> flush privileges; 如上即可。 加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了 sudo vi ~/.bash_profile 添加 export PATH=$PATH:/usr/local/mysql//bin 使~/.bash_profile环境变量生效 source ~/.bash_profile 这个就可以在 任何地方用 mysql 命令了。 mysql -uroot -p 启动、重启与停止,状态 启动 sudo /usr/local/mysql/support-files/mysql.server start 重启 sudo /usr/local/mysql/support-files/mysql.server restart 停止 sudo /usr/local/mysql/support-files/mysql.server stop 查看状态 sudo /usr/local/mysql/support-files/mysql.server status
What this book covers Chapter 1, CMS Core Design, discusses how a content management system works, and the various ways to administrate it, followed by code which allows a page to be retrieved from a database based on the URL requested. www.it-ebooks.info Preface Chapter 2, User Management, expands on the CMS to build an administration area, with user authentication, and finish with a user management system, including forgotten password management, and captchas. Chapter 3, Page Management – Part One, discusses how pages are managed in a CMS, and will build the first half of a page management system in the administration area. Chapter 4, Page Management – Part Two, finishes off the page management system in this chapter, with code for rich-text editing, and file management. Chapter 5, Design Templates – Part One, focuses on the front-end of the site by discussing how Smarty works. We will start building a templates engine for providing cdesign to the front-end, and a simple navigation menu. Chapter 6, Design Templates – Part Two, improves on the navigation menu we started in the previous chapter by adding some jQuery to it, and will finish up the templating engine. Chapter 7, Plugins, discusses how plugins work, and we will demonstrate this by building a plugin to handle page comments. Chapter 8, Forms Plugin, improves on the plugin architecture by building a forms plugin. The improvements allow entirely new page types to be created using plugins. Chapter 9, Image Gallery Plugin, an image gallery plugin is created, showing how to manage the uploading and management of images. Chapter 10, Panels and Widgets – Part One, describes how panels and widgets work. These allow for extremely flexible templates to be created, where non-technical administrators can "design" their own page layouts. Chapter 11, Panels and Widgets – Part Two, finishes up the panels system by creating a Content Snippet widget, allowing HTML sections to be placed almost anywhere on a page, and even select what pages they appear on. Chapter 12, Building an Installer, shows how an installer can be created, using virtual machines to help test the installer.
### 回答1: Linux网卡配置命令包括: 1. ifconfig:用于配置和显示网络接口的状态,包括IP地址、子网掩码、MAC地址等。 2. ip:用于配置和显示网络接口的状态,包括IP地址、子网掩码、MAC地址等,同时还可以配置路由表、ARP表等。 3. route:用于配置和显示路由表。 4. arp:用于配置和显示ARP表。 5. ethtool:用于显示和配置以太网接口的参数,如速度、双工模式等。 6. nmcli:用于配置和管理NetworkManager,包括网络接口、连接、DNS等。 7. nmtui:用于在终端中配置和管理NetworkManager,包括网络接口、连接、DNS等。 8. ifup/ifdown:用于启用或禁用网络接口。 9. dhclient:用于获取DHCP服务器分配的IP地址。 10. resolvconf:用于配置和管理DNS解析器。 ### 回答2: Linux网卡配置命令可以通过命令行进行配置或修改。一般情况下,网卡配置文件位于/etc/network/interfaces中。下面是一些常用的网卡配置命令: 1. ifconfig命令:该命令用于显示或配置网络接口的状态。使用ifconfig命令可以查看网卡的IP地址、MAC地址、子网掩码等信息。例如,执行ifconfig命令显示网卡的状态。 2. ip命令:该命令也用于配置网络接口的状态。使用ip命令可以查看、配置、删除网络接口及其属性。例如,执行ip addr命令可以查看所有网卡的IP地址。 3. ping命令:该命令主要用于测试网络的连通性。通过ping命令可以测试网卡是否正常工作,是否能够与其他主机进行通信。例如,执行ping 192.168.1.1命令即可测试与IP地址为192.168.1.1的主机是否能够进行通信。 4. route命令:该命令用于查看和修改内核的路由表。通过route命令可以设置网关、静态路由等。例如,执行route add default gw 192.168.1.1命令可以设置默认网关。 5. ifup/ifdown命令:该命令用于启用或禁用网络接口。例如,执行ifdown eth0命令可以禁用eth0网卡。 6. dhclient/dhclient3命令:该命令用于自动获取IP地址。例如,执行dhclient eth0命令可以让eth0网卡自动获取IP地址。 以上是一些常用的Linux网卡配置命令,当然还有其他的命令和工具可以用于网络配置,需要根据具体情况选择使用。 ### 回答3: Linux 网卡配置命令是指在 Linux 操作系统中用来配置网络接口卡(NIC)的命令。对于 Linux 操作系统而言,使用命令行进行网卡配置比使用图形化界面更加直接有效,且可以灵活地配置和管理网络接口。 以下是常用的 Linux 网卡配置命令: 1. ifconfig命令:ifconfig 命令可以用来查看和配置网络接口卡的配置信息,比如 IP 地址、掩码、广播地址、MAC 地址等。例如,可以通过 ifconfig eth0 来查看 eth0 网卡的相关信息,或使用 ifconfig eth0 192.168.1.1 来配置 eth0 网卡的 IP 地址为 192.168.1.1。 2. ip命令:ip 命令是 ifconfig 命令的升级版。它不仅可以查看和配置网络接口卡的信息,还可以进行高级网络配置和管理。比如可以使用 ip link set eth0 up 和 ip link set eth0 down 命令来启用和禁用网卡。 3. ethtool命令:ethtool 命令可以用来查看和配置网卡的高级参数和硬件信息,比如速率、双工模式、接收和发送缓冲区大小等。例如,可以使用 ethtool eth0 来查看 eth0 网卡的相关信息,或使用 ethtool -s eth0 speed 100 duplex full 来配置 eth0 网卡的速率为 100Mbps,双工模式为全双工。 4. route命令:route 命令可以用来查看和配置本地路由表。它可以帮助我们进行网络路由设置和管理。例如,可以使用 route add default gw 192.168.1.1 来配置默认网关为 192.168.1.1。 5. iptables命令:iptables 命令可以用来配置 Linux 内核中的防火墙,用于管理对网络流量的筛选、转发和 NAT 等操作。 总的来说,通过学习 Linux 网卡配置命令,我们可以更加有效地操作网络接口卡,实现更精细化的网络管理。同时也可以帮助我们更好的提升网络系统的性能和安全性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值