软件

浏览器

https://www.microsoft.com/zh-cn/edge

升级

git 升级

  1. # 查看版本
  2. git --version
  3. # 升级 Git
  4. brew install git
  5. # 重新链接 git
  6. brew link git --overwrite
  7. # 查看版本
  8. git --version

配置修改

修改网络设置

  1. # 列出本机所有网络服务
  2. networksetup -listallnetworkservices
  3. # 设置Wi-Fi静态IP和指定DNS
  4. networksetup -setmanual "Wi-Fi" 10.0.1.37 255.255.255.0 10.0.1.1
  5. networksetup -setdnsservers "Wi-Fi" 223.5.5.5 114.114.114.114
  6. # 设置Wi-Fi自动获取IP和DNS
  7. networksetup -setdhcp "Wi-Fi"
  8. networksetup -setdnsservers Wi-Fi empty

修改 ulimit

  1. launchctl limit
  2. -----------------
  3. cpu unlimited unlimited
  4. filesize unlimited unlimited
  5. data unlimited unlimited
  6. stack 8388608 67104768
  7. core 0 unlimited
  8. rss unlimited unlimited
  9. memlock unlimited unlimited
  10. maxproc 5568 8352
  11. maxfiles 256 unlimited
  12. ------------------
  13. echo "limit maxfiles 65535 unlimited" | sudo tee -a /etc/launchd.conf
  14. # 记得重启哈
  15. Linux发行版redhat/centos配置与osx不同,如下:
  16. vim /etc/security/limits.conf
  17. # noproc进程数,nofile文件打开数
  18. # soft软限制, 在程序的进程中可自行改变.
  19. # hard硬限制, 程序不可随意改变,除非有root权限.
  20. * soft noproc 11000
  21. * hard noproc 11000
  22. * soft nofile 4100
  23. * hard nofile 4100
  24. 创建新的配置文件,配置系统打开最多文件限制(如果没有的话)
  25. sudo vim /Library/LaunchDaemons/limit.maxfiles.plist
  26. 内容如下:
  27. <?xml version="1.0" encoding="UTF-8"?>
  28. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  29. <plist version="1.0">
  30. <dict>
  31. <key>Label</key>
  32. <string>limit.maxfiles</string>
  33. <key>ProgramArguments</key>
  34. <array>
  35. <string>launchctl</string>
  36. <string>limit</string>
  37. <string>maxfiles</string>
  38. <string>655360</string>
  39. <string>655360</string>
  40. </array>
  41. <key>RunAtLoad</key>
  42. <true/>
  43. <key>ServiceIPC</key>
  44. <false/>
  45. </dict>
  46. </plist>
  47. .创建每个最大进程数限制的配置文件
  48. sudo vi /Library/LaunchDaemons/limit.maxproc.plist
  49. 内容如下:
  50. <?xml version="1.0" encoding="UTF-8"?>
  51. <!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  52. <plist version="1.0">
  53. <dict>
  54. <key>Label</key>
  55. <string>limit.maxproc</string>
  56. <key>ProgramArguments</key>
  57. <array>
  58. <string>launchctl</string>
  59. <string>limit</string>
  60. <string>maxproc</string>
  61. <string>2048</string>
  62. <string>2048</string>
  63. </array>
  64. <key>RunAtLoad</key>
  65. <true />
  66. <key>ServiceIPC</key>
  67. <false />
  68. </dict>
  69. </plist>
  70. chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
  71. chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
  72. # 打开端口后限制 vim /etc/sysctl.conf
  73. net.inet.ip.portrange.first=1024
  74. net.inet.ip.portrange.last=65535

mac实现不对电池充电

把MagSafe接口5芯中间的那个断开,就可以实现使用电源供电,但是不对电池进行充电。只适合MagSafe接口的老机型,不适合最新的USB-C机型。

打开hosts权限

sudo /bin/chmod +a ‘user:’${LOGNAME}’:allow write’ /etc/hosts

配置系统打开最多文件限制

  1. sudo vi /Library/LaunchDaemons/limit.maxfiles.plist
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  4. <plist version="1.0">
  5. <dict>
  6. <key>Label</key>
  7. <string>limit.maxfiles</string>
  8. <key>ProgramArguments</key>
  9. <array>
  10. <string>launchctl</string>
  11. <string>limit</string>
  12. <string>maxfiles</string>
  13. <string>655360</string>
  14. <string>655360</string>
  15. </array>
  16. <key>RunAtLoad</key>
  17. <true/>
  18. <key>ServiceIPC</key>
  19. <false/>
  20. </dict>
  21. </plist>
  22. chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
  23. launchctl limit
  24. 再重启保证生效

每个最大进程数限制的配置文件

  1. sudo vi /Library/LaunchDaemons/limit.maxproc.plist
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  4. <plist version="1.0">
  5. <dict>
  6. <key>Label</key>
  7. <string>limit.maxproc</string>
  8. <key>ProgramArguments</key>
  9. <array>
  10. <string>launchctl</string>
  11. <string>limit</string>
  12. <string>maxproc</string>
  13. <string>3096</string>
  14. <string>3096</string>
  15. </array>
  16. <key>RunAtLoad</key>
  17. <true />
  18. <key>ServiceIPC</key>
  19. <false />
  20. </dict>
  21. </plist>
  22. chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
  23. launchctl limit
  24. 再重启保证生效

端口限制

  1. sudo vi /etc/sysctl.conf
  2. net.inet.ip.portrange.first=1024
  3. net.inet.ip.portrange.last=65535

CPU信息查看

  1. #查看所有信息
  2. sysctl machdep.cpu
  3. #显示CPU型号
  4. sysctl -n machdep.cpu.brand_string
  5. #显示CPU核心数(物理核)
  6. sysctl -n machdep.cpu.core_count
  7. #显示线程数(逻辑核)
  8. sysctl -n machdep.cpu.thread_count

并发测试问题

mac: max user processes最大值只能是2128,处于安全考虑,8G内存最大值为2500,16g最大值可以设置5000.

xcrun: error,missing xcrun

xcode-select --install

socket: Too many open files

$ sudo sysctl -w kern.maxfiles=1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576

出现read: connection reset by peer

sysctl -a |grep somaxconn
sudo sysctl -w kern.ipc.somaxconn=2048
sysctl -w net.inet.ip.portrange.first=32768 # 增大客户端可以建立的连接数
launchctl limit maxfiles 99999 99999
ulimit -n 99999

Mac 解决brew一直卡在Updating Homebrew

# 直接关闭brew每次执行命令时的自动更新(推荐)
vim ~/.bash_profile
# 新增一行
export HOMEBREW_NO_AUTO_UPDATE=true

替换brew源

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

#替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update


# 备用地址-1
cd "$(brew --repo)"
git remote set-url origin https://git.coding.net/homebrew/homebrew.git
brew update


# 备用地址-2
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
brew update

#--------------------------------

#重置brew.git
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

#重置homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git