CentOS7 Miscellaneous Tips

This article is for personal notes only

  • Virtual memory related (when your server runs out of memory, proper use of virtual memory can make projects that could not run perfectly run)
    • Create a blank file for swap swap hard disk storage.
      dd if=/dev/zero of=/swap bs=1M count=1024
    • Use mkswap to format the file as a swap file system
      mkswap -f /swap
    • Enable the swap file
      swapon /swap just created
    • Set the swap file swap area to be automatically enabled at boot, modify /etc/fstab, and add a line
      echo “/swap swap swap defaults 0 0” >> /etc/fstab
  • Related tips:
    • 关闭swap
      swapoff /swap
      rm -rf /swap
    • Increase the usage frequency (the larger the value of 0-100, the higher the usage rate)
      echo “80” > /proc/sys/vm/swappiness
    • In the first line of the command, bs is the block size, count is the number of blocks, and the multiplication is the final virtual memory size.
  • Linux network related (usually virtual machines or servers built by themselves with the host may be used when they are first used)
    • Change onboot=no under /etc/sysconfig/network-scripts/ifcfg-e* to onboot=yes
    • Run service network restart to restart the network card
    • Run ip address to get the current ip
    • Run ping www.baidu.com to determine whether there is currently a network
  • smb file sharing (can be used to build intranet disk sharing within the company, used to share large files, the network speed of the intranet perfectly solves the problem of file transfer)

    • yum -y install samba #Install samba service
    • vi /etc/samba/smb.conf #Change the samba service configuration file
    • Give configuration file reference:
      [share]
      null passwords = yes
      comment = share
      path = /home/smb #share directory location
      public = yes
      writable = yes
      guest ok = yes
      browsable = yes
      available = yes
      security = share
    • service smb start #Start smb service
    • useradd smbtest #Add smbtest user and set password
    • smbpasswd -a smbtest #Add the smbtest user of smb and set the password
    • Instructions:
    • Under win, enter the path \ip (for example: \192.168.1.131) under the resource manager and press Enter, and then enter the smbtest account and password created before
    • Under mac, enter smb://ip in the browser (for example: smb:\192.168.1.131) to select a non-google search item, then click to open finder and enter the smbtest account and password
  • Network monitoring related (use nload to view real-time network speed)

    • yum install epel-release.noarch nload -y
    • nload
  • Internet speed limit command line

    tc qdisc del dev eth0 root
    tc qdisc add dev eth0 root handle 1: htb
    tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
    tc class add dev eth0 parent 1:1 classid 1:10 htb rate 5mbit ceil 5mbit
    tc qdisc add dev eth0 parent 1:10 sfq perturb 10
    tc filter add dev eth0 protocol ip parent 1: prio 50 u32 match ip dst 0.0.0.0/0 flowid 1:10

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325390251&siteId=291194637