PageSourceSearch

https://www.seagm.tech/assets/js/7bd2fc12.0c9fe873.js

js seagm.tech collected 2026-10-04 19:09:45 UTC 38,857 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkmy_seagm_tech_site=self.webpackChunkmy_seagm_tech_site||[]).push([[3202],{7945:(l,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>t,default:()=>o,frontMatter:()=>r,metadata:()=>e,toc:()=>d});const e=JSON.parse('{"id":"tech/MySQL/mac-mysql-too-many","title":"Too many open files","description":"1 \u9519\u8bef\u8be6\u60c5","source":"@site/docs/tech/MySQL/mac-mysql-too-many.md","sourceDirName":"tech/MySQL","slug":"/tech/MySQL/mac-mysql-too-many","permalink":"/docs/tech/MySQL/mac-mysql-too-many","draft":false,"unlisted":false,"editUrl":"https://gitea.seagm.tech/jihong/my-seagm-tech-site/src/branch/main/docs/tech/MySQL/mac-mysql-too-many.md","tags":[{"inline":true,"label":"MySQL","permalink":"/docs/tags/my-sql"},{"inline":true,"label":"Errcode","permalink":"/docs/tags/errcode"}],"version":"current","frontMatter":{"title":"Too many open files","tags":["MySQL","Errcode"]},"sidebar":"techSidebar","previous":{"title":"Mac Mariadb|Mysql8 \u5b89\u88c5|\u914d\u7f6e|\u5907\u4efd|\u8fd8\u539f","permalink":"/docs/tech/MySQL/mac-homebrew-insstall-mariadb"},"next":{"title":"Mariadb \u670d\u52a1\u5668\u914d\u7f6e","permalink":"/docs/tech/MySQL/mariadb-config"}}');var i=s(4848),c=s(8453);const r={title:"Too many open files",tags:["MySQL","Errcode"]},t="MySQL Errcode: 24 Too many open files",a={},d=[{value:"1 \u9519\u8bef\u8be6\u60c5",id:"1-\u9519\u8bef\u8be6\u60c5",level:2},{value:"2 \u6392\u67e5\u95ee\u9898",id:"2-\u6392\u67e5\u95ee\u9898",level:2},{value:"\u53ef\u80fd\u7684\u539f\u56e0",id:"\u53ef\u80fd\u7684\u539f\u56e0",level:3},{value:"\u6392\u67e5\u6b65\u9aa4",id:"\u6392\u67e5\u6b65\u9aa4",level:3},{value:"3 \u89e3\u51b3\u529e\u6cd5",id:"3-\u89e3\u51b3\u529e\u6cd5",level:2},{value:"1 \u901a\u8fc7launchctl\u4fee\u590d",id:"1-\u901a\u8fc7launchctl\u4fee\u590d",level:3},{value:"2 \u901a\u8fc7\u6dfb\u52a0plist\u6587\u4ef6\u4fee\u590d\uff08\u63a8\u8350\uff09",id:"2-\u901a\u8fc7\u6dfb\u52a0plist\u6587\u4ef6\u4fee\u590d\u63a8\u8350",level:3},{value:"4 \u53c2\u80031",id:"4-\u53c2\u80031",level:2},{value:"launchctl",id:"launchctl",level:3},{value:"<strong>\u4ecb\u7ecd</strong>",id:"\u4ecb\u7ecd",level:4},{value:"<strong>launchctl  \u67e5\u770b\uff5c\u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236</strong>
1",id:"launchctl--\u67e5\u770b\u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236",level:4},{value:"<strong>\u901a\u8fc7\u5199\u5165plist\u6587\u4ef6 \u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236</strong>",id:"\u901a\u8fc7\u5199\u5165plist\u6587\u4ef6-\u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236",level:4},{value:"sysctl",id:"sysctl",level:3},{value:"ulimit",id:"ulimit",level:3},{value:"\u533a\u522b\u8054\u7cfb",id:"\u533a\u522b\u8054\u7cfb",level:3},{value:"5 \u53c2\u80032",id:"5-\u53c2\u80032",level:2},{value:"launchctl \u53c2\u8003",id:"launchctl-\u53c2\u8003",level:3},{value:"\u5e38\u7528\u547d\u4ee4",id:"\u5e38\u7528\u547d\u4ee4",level:4},{value:"\u6267\u884c\u5b9a\u65f6\u811a\u672c|\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u6b65\u9aa4",id:"\u6267\u884c\u5b9a\u65f6\u811a\u672c\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u6b65\u9aa4",level:4},{value:"ulimit | sysctl | lauchctl \u533a\u522b",id:"ulimit--sysctl--lauchctl-\u533a\u522b",level:3},{value:"\u4e09\u8005\u4ecb\u7ecd",id:"\u4e09\u8005\u4ecb\u7ecd",level:4},{value:"\u8bf4\u660e",id:"\u8bf4\u660e",level:4},{value:"ulimit",id:"ulimit-1",level:3}];function h(l){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,c.R)(),...l.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"mysql-errcode-24-too-many-open-files",children:"MySQL Errcode: 24 Too many open files"})}),"\n",(0,i.jsx)(n.h2,{id:"1-\u9519\u8bef\u8be6\u60c5",children:"1 \u9519\u8bef\u8be6\u60c5"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"MySQL said: Out of resources when opening file '/var/folders/84/b3ghw9z51kg8xlrykdwrvqpw0000gn/T/#sqla0c_e_11f.MAI' (Errcode: 24 \"Too many open files\")\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://gitbook-media.oss-ap-southeast-1.aliyuncs.com/pics/image-20201015172853944.png",alt:"image-20201015172853944"})}),"\n",(0,i.jsx)(n.h2,{id:"2-\u6392\u67e5\u95ee\u9898",children:"2 \u6392\u67e5\u95ee\u9898"}),"\n",(0,i.jsx)(n.h3,{id:"\u53ef\u80fd\u7684\u539f\u56e0",children:"\u53ef\u80fd\u7684\u539f\u56e0"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"mysql\u8fdb\u7a0b\u6253\u5f00\u7684\u6587\u4ef6\u6570\u91cf \u8d85\u8fc7\u4e86\u7cfb\u7edf\u5141\u8bb8\u7684\u6700\u5927\u6570\u91cf"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u6392\u67e5\u6b65\u9aa4",children:"\u6392\u67e5\u6b65\u9aa4"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u68c0\u67e5mac \u7cfb\u7edf\u6587\u4ef6\u6570\u91cf\u9650\u5236"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"#\u67e5\u770b\u7cfb\u7edf\u53e5\u67c4\u914d\u7f6e \u547d\u4ee4\uff1a\n$ launchctl limit\n#\u6267\u884c\u7684\u7ed3\u679c\uff1a\nz***jh@z***jhdeMBP ~ % launchctl limit\n\tcpu         unlimited      unlimited      \n\tfilesize    unlimited      unlimited      \n\tdata        unlimited      unlimited      \n\tstack       8388608        67104768       \n\tcore        0              unlimited      \n\trss         unlimited      unlimited      \n\tmemlock     unlimited      unlimited      \n\tmaxproc     2784           4176           \n\tmaxfiles    256            unlimited   # soft-limit:256 | hard-limit:unlimited\n\t\n#\u6216\u8005\u7528\u547d\u4ee4\uff1a\n$ ulimit -a\n#\u6267\u884c\u7684\u7ed3\u679c\uff1a\nz***jh@z***jhdeMBP ~ % ulimit -a\n-t: cpu time (seconds)              unlimited\n-f: file size (blocks)              unlimited\n-d: data seg size (kbytes)          unlimited\n-s: stack size (kbytes)             8192\n-c: core file size (blocks)         0\n-v: address space (kbytes)          unlimited\n-l: locked-in-memory size (kbytes)  unlimited\n-u: processes                       2784\n-n: file descriptors                256\n\n# \u67e5\u770b\u5f53\u524d\u5185\u6838\u548c\u8fdb\u7a0b\u80fd\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236\n$ sysctl -a | grep files\nz***jh@z***jhdeMBP ~ % sysctl -a |grep files\nkern.maxfiles: 49152\t\t\t\t\t\t# \u7cfb\u7edf\u7ea7\u7684\u9650\u5236\nkern.maxfilesperproc: 24576\t\t\t# \u5185\u6838\u7ea7\u7684\u9650\nkern.num_files: 6188\n\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u67e5\u7
170b\u5f53\u524dmysql\u8fdb\u7a0b\u5df2\u7528\u7684\u6587\u4ef6\u53e5\u67c4"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"/docs/tech/commands/linux-lsof-cmd",children:"lsof\u4f7f\u7528\u4ecb\u7ecd"})}),"\n",(0,i.jsx)(n.li,{children:"\u67e5\u770b\u6253\u5f00\u6587\u4ef6\u6570\u91cf"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"#\u5229\u7528lsof\u67e5\u770b\uff1a\nlsof -c mysql\n#\u6267\u884c\u7ed3\u679c \u53ef\u4ee5\u770b\u51fa\u6253\u5f00\u4e86\u5f88\u591a\u6587\u4ef6 \u8bf4\u660e\u662f\u6587\u4ef6\u6570\u8d85\u51fa\u4e86256 \u6240\u4ee5\u62a5\u9519\nz***jh@z***jhdeMBP ~ % lsof -c mysql\nCOMMAND   PID   USER   FD    TYPE             DEVICE   SIZE/OFF                NODE NAME\nmysqld   2572 z***jh  cwd     DIR                1,7       1152             2319917 /usr/local/var/mysql\nmysqld   2572 z***jh  txt     REG                1,7   15747544            23743982 /usr/local/Cellar/[email protected]/10.3.23/bin/mysqld\nmysqld   2572 z***jh  txt     REG                1,7     490556            22873844 /usr/local/Cellar/[email protected]/1.1.1g/lib/libssl.1.1.dylib\nmysqld   2572 z***jh  txt     REG                1,7    2262368            22873850 /usr/local/Cellar/[email protected]/1.1.1g/lib/libcrypto.1.1.dylib\nmysqld   2572 z***jh  txt     REG                1,7      24576            33942989 /usr/local/var/mysql/tc.log\nmysqld   2572 z***jh  txt     REG                1,7      28512            33930114 /Library/Preferences/Logging/.plist-cache.Ire7fQDK\nmysqld   2572 z***jh  txt     REG                1,7    1568368 1152921500312826105 /usr/lib/dyld\nmysqld   2572 z***jh    0r    CHR                3,2        0t0                 310 /dev/null\nmysqld   2572 z***jh    1w    REG                1,7      46425            25857787 /usr/local/var/mysql/z***jhdeMBP.RT-AX88U.err\nmysqld   2572 z***jh    2w    REG                1,7      46425            25857787 /usr/local/var/mysql/z***jhdeMBP.RT-AX88U.err\nmysqld   2572 z***jh    3u    REG                1,7         52             2319921 /usr/local/var/mysql/aria_log_control\nmysqld   2572 z***jh    4r    DIR                1,7       1152             2319917 /usr/local/var/mysql\nmysqld   2572 z***jh    5u    REG                1,7      32768             2320101 /usr/local/var/mysql/aria_log.00000001\nmysqld   2572 z***jh    6u    REG                1,7  817889280             2319918 /usr/local/var/mysql/ibdata1\nmysqld   2572 z***jh    7u    REG                1,7          0            33942984 /private/var/folders/84/b3ghw9z51kg8xlrykdwrvqpw0000gn/T/ibmCUk7P\nmysqld   2572 z***jh    8u    REG                1,7          0            33942985 /private/var/folders/84/b3ghw9z51kg8xlrykdwrvqpw0000gn/T/ibJ9Durq\nmysqld   2572 z***jh    9u    REG                1,7          0            33942986 /private/var/folders/84/b3ghw9z51kg8xlrykdwrvqpw0000gn/T/ibrNIlka\nmysqld   2572 z***jh   10u    REG                1,7   50331648             2320927 /usr/local/var/mysql/ib_logfile0\nmysqld   2572 z***jh   11u    REG                1,7   50331648             2320928 /usr/local/var/mysql/ib_logfile1\nmysqld   2572 z***jh   12u    REG                1,7   12582912            33942988 /usr/local/var/mysql/ibtmp1\nmysqld   2572 z***jh   13u    REG                1,7          0            33942987 /private/var/folders/84/b3ghw9z51kg8xlrykdwrvqpw0000gn/T/ibBuLfH8\nmysqld   2572 z***jh   14u    REG                1,7     180224             2320130 /usr/local/var/mysql/mysql/innodb_table_stats.ibd\nmysqld   2572 z***jh   15u    REG                1,7      24576            33942989 /usr/local/var/mysql/tc.log\nmysqld   2572 z***jh   16u    REG                1,7   37748736            33908957 /usr/local/var/mysql/sdb/transferto_orders.ibd\nmysqld   2572 z***jh   17u   unix 0xaa2db352875e520b        0t0                     /tmp/mysql.sock\nmysqld   2572 z***jh   18u    REG                1,7      98304            19054104 /usr/local/var/mysql/spin@002dcopy/alarms.ibd\nmysqld   2572 z***jh   19u    REG                1,7 2646605824            33908961 /usr/local/var/mysql/sdb/user_account_logs.ibd\nmysqld   2572 z***jh   20u    REG                1,7  113246208            33909660 /usr/local/var/mysql/sdb/user_address_details.ibd\nmysqld   2572 z***jh   21u    REG                1,7 1908408320            33909679 /usr/local/var/mysql/sdb/user_credits_account_logs.ibd\nmysqld   2572 z***jh   22u  systm 0xaa2db352a9d9aafb        0t0                     [ctl com.apple.netsrc id 7 unit 41]\nmysqld   2572 z***jh   23u    REG                1,7   54525952            33909994 /usr/local/var/mysql/sdb/user_credits_account_reports.ibd\nmysqld   2572 z***jh   24u    REG                1,7  310378496            33910006 /usr/local/var/mysql/sdb/user_credits_accounts.ibd\nmysqld   2572 z***jh   25u    REG                1,7      98304            33910068 /usr/local/var/mysql/sdb/user_departments.ibd\nmysqld   2572 z***jh   26u    REG                1,7   14680064            33910070 /usr/local/var/mysql/sdb/user_discounts.ibd\nmysqld   2572 z***jh   27u    REG                1,7   15728640            33910072 /u
1sr/local/var/mysql/sdb/user_favorites.ibd\nmysqld   2572 z***jh   28u    REG                1,7     131072            33910075 /usr/local/var/mysql/sdb/user_groups.ibd\nmysqld   2572 z***jh   29u    REG                1,7     393216            33910077 /usr/local/var/mysql/sdb/user_pay_limits.ibd\nmysqld   2572 z***jh   30u    REG                1,7      98304            33910082 /usr/local/var/mysql/sdb/user_phone_infos.ibd\nmysqld   2572 z***jh   31u    REG                1,7  968884224            33910084 /usr/local/var/mysql/sdb/user_point_logs.ibd\nmysqld   2572 z***jh   32u    REG                1,7 1493172224            33910307 /usr/local/var/mysql/sdb/user_verifications.ibd\nmysqld   2572 z***jh   33u    REG                1,7 2113929216            33910684 /usr/local/var/mysql/sdb/users.ibd\nmysqld   2572 z***jh   34u    REG                1,7     114688            33911079 /usr/local/var/mysql/sdb/voucher_items.ibd\n\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u51famysql\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u6570\u91cf\u5f88\u591a\uff0c\u5e94\u8be5\u662f\u8d85\u51fa\u4e86\u6700\u5927256\u7684\u9650\u5236 \u6240\u4ee5\u62a5\u9519"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"3-\u89e3\u51b3\u529e\u6cd5",children:"3 \u89e3\u51b3\u529e\u6cd5"}),"\n",(0,i.jsx)(n.h3,{id:"1-\u901a\u8fc7launchctl\u4fee\u590d",children:"1 \u901a\u8fc7launchctl\u4fee\u590d"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-mysql",children:"# Usage: launchctl limit \\[<limit-name> \\[<both-limits> | <soft-limit> <hard-limit>\\]\n# \u67e5\u770b\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236\nlaunchctl limit maxfiles\nmaxfiles    256            unlimited \n\n# \u4fee\u6539\u8f6f\u9650\u5236\u4e3a512 \u7cfb\u7edf\u91cd\u542f\u5931\u6548\nsudo launchctl limit maxfiles 512 unlimited\n\n# \u53ef\u5c06launchctl\u5b50\u547d\u4ee4\u5199\u5165/etc/launchd.conf\u4e2d\n# \u5728launchd\u542f\u52a8\u65f6 \u4f1a\u6267\u884c\u8be5\u6587\u4ef6\u4e2d\u7684\u547d\u4ee4\nlimit maxfiles 512 unlimited\n"})}),"\n",(0,i.jsx)(n.h3,{id:"2-\u901a\u8fc7\u6dfb\u52a0plist\u6587\u4ef6\u4fee\u590d\u63a8\u8350",children:"2 \u901a\u8fc7\u6dfb\u52a0plist\u6587\u4ef6\u4fee\u590d\uff08\u63a8\u8350\uff09"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u65b0\u5efa\u6587\u4ef6"})," Library/LaunchDaemons/limit.maxfiles.plist \u6587\u4ef6\uff0c\u5199\u5165"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",children:' <?xml version="1.0" encoding="UTF-8"?>  \n <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"  \n         "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n <plist version="1.0">  \n   <dict>\n     <key>Label</key>\n     <string>limit.maxfiles</string>\n     <key>ProgramArguments</key>\n     <array>\n       <string>launchctl</string>\n       <string>limit</string>\n       <string>maxfiles</string>\n       <string>64000</string>\n       <string>524288</string>\n     </array>\n     <key>RunAtLoad</key>\n     <true/>\n     <key>ServiceIPC</key>\n     <false/>\n   </dict>\n </plist>\n'})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u4fee\u6539\u6587\u4ef6\u6743\u9650"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:" sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist\n sudo chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u52a0\u8f7d plist \u6587\u4ef6"})}),"\n",(0,i.jsx)(n.p,{children:"(\u6216\u91cd\u542f\u7cfb\u7edf\u540e\u751f\u6548 launchd \u5728\u542f\u52a8\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u8be5\u76ee\u5f55\u7684 plist)"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:" sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u786e\u8ba4\u66f4\u6539\u540e\u7684\u9650\u5236"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" launchctl limit maxfiles\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"4-\u53c2\u80031",children:"4 \u53c2\u80031"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.a,{href:"https://www.dazhuanlan.com/2019/11/06/5dc2d14ecf
163e/?__cf_chl_jschl_tk__=fdccd67719bf0d4de170b86f90fad159c58ab315-1602757392-0-AZeSZKfcbTplIkZP49WrsMkQcokyx5iMq1YbM0MMwbF1A122ujh-kz6N8oePi6LaNCJPzztdgk6moS1DN0gewDk3qzjMSoiMEuEU8StXHkmy6VpgQI0D_546BessNK7dR3b58A98GI6bgLxHL7FY9q9WG8uku-cwv7rR1HAZdOZySh3aujbAmHnXQ9nJ8WWPvzz7cVqNpHX4nrQySil5KjAVMMkwDZU8J-g-F2WcuNMox0weH6f8461dZ7gb3INRQFAtUwwIzS7spolI39DqcQWSONLejQw501mJZJp_0AKYaftyQcZLTwqn6BW59jOQXQ",children:"Mac OS X\u4e0b\u7684\u8d44\u6e90\u9650\u5236\u548c\u4fee\u6539"})}),"\n",(0,i.jsx)(n.p,{children:"\u5728 Mac OS X \u4e0b\uff0c\u6709\u5982\u4e0b\u4e09\u4e2a\u547d\u4ee4\u4e0e\u7cfb\u7edf\u8d44\u6e90\u6709\u5173\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"launchctl",children:"launchctl"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.h4,{id:"\u4ecb\u7ecd",children:(0,i.jsx)(n.strong,{children:"\u4ecb\u7ecd"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"launchctl \u7ba1\u7406 OS X \u7684\u542f\u52a8\u811a\u672c\uff0c\u63a7\u5236\u542f\u52a8\u8ba1\u7b97\u673a\u65f6\u9700\u8981\u5f00\u542f\u7684\u670d\u52a1 (\u901a\u8fc7\u540e\u53f0\u8fdb\u7a0b launchd)\u3002\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u5b9a\u65f6\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u7684\u811a\u672c\uff0c\u7c7b\u4f3c Linux cron\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u5f00\u673a\u65f6\u81ea\u52a8\u542f\u52a8 Apache \u670d\u52a1\u5668\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u5173\u4e8e launchctl \u7684 plist \u683c\u5f0f\u548c\u7528\u6cd5\u53c2\u8003:"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/launchctl.1.html",children:"launchctl man page"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html",children:"launchd plist man page"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"http://paul.annesley.cc/2012/09/mac-os-x-launchd-is-cool/",children:"mac-os-x-launchd-is-cool"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html",children:"creating launchd jobs"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u7b80\u5355\u6765\u8bf4\uff0cplist \u6587\u4ef6\u7528\u7c7b\u4f3c XML \u683c\u5f0f\u5b9a\u4e49\u4e86\u4e00\u4e2a\u547d\u4ee4 (\u53ca\u542f\u52a8\u53c2\u6570) \u548c\u8be5\u547d\u4ee4\u7684\u6267\u884c\u65b9\u5f0f(\u5b9a\u65f6\u6267\u884c\uff0c\u7cfb\u7edf\u542f\u52a8\u6267\u884c\uff0c\u7528\u6237\u767b\u5f55\u6267\u884c\u7b49)\u3002\u6211\u4eec\u8fd9\u91cc\u4e0d\u7740\u91cd\u8ba8\u8bba\uff0c\u6211\u4eec\u5173\u5fc3 launchctl \u4e2d\u5982\u4f55\u67e5\u770b / \u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236\u3002"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.h4,{id:"launchctl--\u67e5\u7
170b\u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236",children:(0,i.jsx)(n.strong,{children:"launchctl  \u67e5\u770b\uff5c\u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"# Usage: launchctl limit \\[<limit-name> \\[<both-limits> | <soft-limit> <hard-limit>\\]\n# \u67e5\u770b\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236\nlaunchctl limit maxfiles\nmaxfiles    256            unlimited \n\n# \u4fee\u6539\u8f6f\u9650\u5236\u4e3a512 \u7cfb\u7edf\u91cd\u542f\u5931\u6548\nsudo launchctl limit maxfiles 512 unlimited\n\n# \u53ef\u5c06launchctl\u5b50\u547d\u4ee4\u5199\u5165/etc/launchd.conf\u4e2d\n# \u5728launchd\u542f\u52a8\u65f6 \u4f1a\u6267\u884c\u8be5\u6587\u4ef6\u4e2d\u7684\u547d\u4ee4\nlimit maxfiles 512 unlimited\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.h4,{id:"\u901a\u8fc7\u5199\u5165plist\u6587\u4ef6-\u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236",children:(0,i.jsx)(n.strong,{children:"\u901a\u8fc7\u5199\u5165plist\u6587\u4ef6 \u66f4\u6539\u7cfb\u7edf\u8d44\u6e90\u9650\u5236"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u901a\u8fc7\u5c06\u66f4\u6539\u547d\u4ee4\u5199\u5165 plist \u6587\u4ef6\uff0c\u5e76\u5728\u542f\u52a8\u65f6\u6267\u884c\uff0c\u4e5f\u53ef\u6c38\u4e45\u66f4\u6539\u8d44\u6e90\u9650\u5236\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u65b0\u5efa\u6587\u4ef6"})," Library/LaunchDaemons/limit.maxfiles.plist \u6587\u4ef6\uff0c\u5199\u5165"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",children:' <?xml version="1.0" encoding="UTF-8"?>  \n <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"  \n         "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n <plist version="1.0">  \n   <dict>\n     <key>Label</key>\n     <string>limit.maxfiles</string>\n     <key>ProgramArguments</key>\n     <array>\n       <string>launchctl</string>\n       <string>limit</string>\n       <string>maxfiles</string>\n       <string>64000</string>\n       <string>524288</string>\n     </array>\n     <key>RunAtLoad</key>\n     <true/>\n     <key>ServiceIPC</key>\n     <false/>\n   </dict>\n </plist>\n'})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u4fee\u6539\u6587\u4ef6\u6743\u9650"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:" sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist\n sudo chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u52a0\u8f7d plist \u6587\u4ef6"})}),"\n",(0,i.jsx)(n.p,{children:"(\u6216\u91cd\u542f\u7cfb\u7edf\u540e\u751f\u6548 launchd \u5728\u542f\u52a8\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u8be5\u76ee\u5f55\u7684 plist)"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:" sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u786e\u8ba4\u66f4\u6539\u540e\u7684\u9650\u5236"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:" launchctl limit maxfiles\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"sysctl",children:"sysctl"}),"\n",(0,i.jsx)(n.p,{children:"\u5927\u591a\u6570\u7c7b Unix \u7cfb\u7edf\u90fd\u901a\u8fc7 (Linux/*BSD/OS X) \u90fd\u63d0\u4f9b\u8be5\u547d\u4ee4\u6765\u66f4\u6539\u8d44\u6e90\u9650\u5236\u548c\u5185\u6838\u914d\u7f6e\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"# \u67e5\u770b\u5f53\u524d\u5185\u6838\u548c\u8fdb\u7a0b\u80fd\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236\n$ sysctl -A | grep kern.maxfiles\nkern.maxfiles: 12288             # \u7cfb\u7edf\u7ea7\u7684\u9650\u5236\nkern.maxfilesperproc: 10240    # \u5185\u6838\u7ea7\u7684\u9650\u5236\n\n# \u901a\u8fc7sysctl\u547d\u4ee4\u70ed\u66f4\u6539 \u7cfb\u7edf\u91cd\u542f\u540e\u5931\u6548\n$ sysctl -w kern.maxfilesperproc=20480\n\n# \u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u6c38\u4e45\u66f4\u6539 \u91cd\u542f\u751f\u6548\n# \u5728/etc/sysctl.conf\u4e2d\u5199\u5165\nkern.maxfiles=20480 kern.maxfilesperproc=24576\n"})}),"\n",(0,i.jsx)(n.h3,{id:"ulimit",children:"ulimit"}),"\n",(0,i.jsx)(n.p,{children:"ulimit \u662f shell \u7684\u5185\u7f6e\u547d\u4ee4\uff0c\u7528\u4e8e\u67e5\u7
170b / \u66f4\u6539\u5f53\u524d shell \u53ca\u5176\u521b\u5efa\u7684\u5b50\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\u3002\u4f7f\u7528\u6bd4\u8f83\u7b80\u5355\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"\\# \u67e5\u770b\u5f53\u524dshell(\u53ca\u5176\u5b50\u8fdb\u7a0b)\u7684\u6240\u6709\u9650\u5236\nulimit -a\n# \u6539\u53d8\u8fdb\u7a0b\u80fd\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u8f6f\u9650\u5236 \u5f53shell\u5173\u95ed\u540e\u5931\u6548\n# \u5c06\u5176\u5199\u5165\u5bf9\u5e94shell\u7684startup\u6587\u4ef6(\u5982~/.bashrc, ~/.zshrc)\uff0c\u53ef\u4fdd\u7559\u66f4\u6539\nulimit -S -n 1024\n\n\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u533a\u522b\u8054\u7cfb",children:"\u533a\u522b\u8054\u7cfb"}),"\n",(0,i.jsx)(n.p,{children:"\u8fd9\u4e09\u4e2a\u547d\u4ee4\u7684\u5173\u7cfb\u5728 Mac OS X \u5404\u7248\u672c\u4e2d\u5c24\u5176\u6df7\u4e71\uff0c\u5148\u8bf4\u8bf4\u672c\u4eba\u7684\u4e00\u4e9b\u8bd5\u9a8c (Mac OS X 10.10.3)\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728\u9ed8\u8ba4\u914d\u7f6e\u4e0b (\u4e0d\u914d\u7f6e plist \u548c sysctl.conf)\uff0claunchctl \u7684 maxfiles \u9ed8\u8ba4\u503c\u4e3a (256, unlimited)\uff0csysctl \u7684 maxfiles \u9ed8\u8ba4\u503c\u4e3a (12288, 10240)\uff0c\u800c ulimit -n \u5f97\u5230\u7684\u503c\u4e3a 4864\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5f53\u4e0d\u5b9a\u4e49 plist \u800c\u5b9a\u4e49 sysctl.conf\uff0c\u90a3\u4e48\u91cd\u542f\u540e launchctl \u548c ulimit \u770b\u5230\u7684\u4e0a\u9650\u4ecd\u4e3a\u9ed8\u8ba4\u503c\uff0csysctl \u770b\u5230\u7684\u4e0a\u9650\u4e0e sysctl.conf \u5b9a\u4e49\u7684\u4e00\u81f4\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u5f53\u540c\u65f6\u5728",(0,i.jsx)(n.code,{children:"/etc/sysctl.conf"}),"\u548c",(0,i.jsx)(n.code,{children:"/Library/LaunchDaemons/limit.maxfiles.plist"}),"\u4e2d\u5b9a\u4e49 maxfiles \u65f6\uff0cplist \u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u4f1a\u8986\u76d6 sysctl.conf \u4e2d\u7684\u914d\u7f6e\u3002\u5982\u679c\u901a\u8fc7\u7cfb\u7edf\u91cd\u542f\u5e94\u7528 plist\uff0c\u4e09\u4e2a\u547d\u4ee4\u770b\u5230\u7684\u4e0a\u9650\u5747\u4e3a plist \u914d\u7f6e\u3002\u5982\u679c\u901a\u8fc7 launchctl load \u52a0\u8f7d plist\uff0c\u5219\u4f1a\u540c\u6b65\u5f71\u54cd sysctl \u770b\u5230\u7684\u4e0a\u9650\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd shell \u4e0b\u7684 ulimit \u4e0a\u9650\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u901a\u8fc7 launchctl \u914d\u7f6e\u7684\u8f6f\u4e0a\u9650\u548c\u786c\u4e0a\u9650\u5206\u522b\u4e3a S \u548c H(\u975e unlimited)\uff0c\u90a3\u4e48\u901a\u8fc7 launchctl \u5e94\u7528\u914d\u7f6e\u540e\u6700\u7ec8\u5f97\u5230\u8f6f\u4e0a\u9650\u548c\u786c\u4e0a\u9650\u90fd\u4e3a S\u3002\u5982\u679c\u8bbe\u5b9a\u7684\u4e0a\u9650\u4e3a S \u548c unlimited\uff0c\u5b9e\u9645\u4e0a\u5e94\u7528\u7684\u53c2\u6570\u4e3a S \u548c 10240(sysctl \u4e2d kern.maxfilesperproc \u9ed8\u8ba4\u503c)\uff0c\u5f53 S > 10240 \u65f6\uff0c\u4f1a\u8bbe\u7f6e\u5931\u8d25\uff0cS < 10240 \u65f6\uff0c\u4f1a\u5f97\u5230 (S, 10240)"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"ulimit -H -n 1000"})," \u964d\u4f4e\u786c\u4e0a\u9650\u65e0\u9700 Root \u6743\u9650\uff0c\u5347\u9ad8\u5219\u9700\u8981"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u8d81\u7740\u5934\u5927\uff0c\u8fd8\u53ef\u4ee5\u770b\u770b\u8fd9\u51e0\u7bc7\u6587\u7ae0:"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://superuser.com/questions/827984/open-files-limit-does-not-work-as-before-in-osx-yosemite",children:"open files limit does not work as before in osx yosemite"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"http://krypted.com/mac-os-x/maximum-files-in-mac-os-x/",children:"maximum files in mac os x"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://unix.stackexchange.com/questions/108174/how-to-persist-ulimit-settings-in-osx-mavericks",children:"how to persist ulimit settings in osx mavericks"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://docs.basho.com/riak/kv/2.2.0/using/performance/open-files-limit/#mac-os-x",children:"open files limit in max os x"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://superuser.com/questions/302754/increase-the-maximum-number-of-open-file-descriptors-in-snow-leopard",children:"increase the maximum number of open file descriptors in snow leopard"})}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u7f51\u4e0a\u5bf9 Mac OS X \u5404\u7248\u672c\u7684\u89e3\u51b3\u65b9\u6848\u5404\u4e0d\u76f8\u540c\uff0c\u5e76\u4e14\u5bf9\u8fd9\u4e09\u4e2a\u547d\u4ee4 (\u7279\u522b\u662f launchctl \u548c sysctl) \u5728\u8d44\u6e90\u9650\u5236\u4e0a\u7684\u8054\u7cfb\u4e0e\u533a\u522b\u4e5f\u6ca1\u6709\u6e05\u6670\u7684\u89e3\u91ca\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u6309\u7167\u6211\u7684\u7406\u89e3\u548c\u6298\u817e\u51fa\u6765\u7684\u7ecf\u9a8c\uff1a"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"ulimit \u53ea\u5f71\u54cd\u5f53\u524d Shell \u4e0b\u7684\u8fdb\u7a0b\uff0c\u5e76\u4e14\u53d7\u9650\u4e8e kern.maxfilesperproc"}),"\n",(0,i.jsx)(n.li,{children:"\u5982\u679c\u914d\u7f6e\u4e86 plist\uff0c\u90a3\u4e48\u91cd\u542f\u540e\uff0culimit \u548c sysctl \u5747\u4f1a\u7ee7\u627f plist \u4e2d\u7684\u503c"}),"\n",(0,i.jsx)(n.li,{children:"\u70ed\u4fee\u6539 sysctl \u4e0a\u9650\u503c\u4e0d\u4f1a\u5f71\u54cd launchctl\uff0c\u800c\u53cd\u4e4b\uff0claunchctl \u4f1a\u5f71\u54cd sysctl \u4e0a\u9650\u503c"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u7efc\u4e0a\uff0c\u5728 Mac OS X 10.10(\u62
111\u7684\u7248\u672c\uff0c\u6ca1\u8bd5\u8fc7\u4e4b\u524d\u7684) \u4e4b\u540e\uff0c\u4f7f\u7528 plist \u662f\u6700\u5408\u7406\u7684\u65b9\u6848 (\u4f46 launchctl \u8c8c\u4f3c\u53ea\u80fd\u8bbe\u5b9a\u4e00\u6837\u7684\u8f6f\u9650\u5236\u548c\u786c\u9650\u5236\uff0c\u5982\u679c\u5c06\u786c\u9650\u5236\u8bbe\u4e3a ulimited\uff0c\u5219\u4f1a\u4f7f\u7528 kern.maxfilesperproc \u503c)\u3002\u5728\u7cfb\u7edf\u91cd\u542f\u540e\uff0ckern.maxfilesperproc \u548c ulimit -n \u90fd\u4f1a\u7ee7\u627f plist maxfiles \u7684\u503c\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"5-\u53c2\u80032",children:"5 \u53c2\u80032"}),"\n",(0,i.jsx)(n.h3,{id:"launchctl-\u53c2\u8003",children:"launchctl \u53c2\u8003"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"launchctl \u7ba1\u7406 MacOS \u7684\u542f\u52a8\u811a\u672c\uff0c\u63a7\u5236\u542f\u52a8\u8ba1\u7b97\u673a\u65f6\u9700\u8981\u5f00\u542f\u7684\u670d\u52a1\u3002\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u5b9a\u65f6\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u7684\u811a\u672c\uff0c\u5c31\u50cfLinux cron\u4e00\u6837\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.h4,{id:"\u5e38\u7528\u547d\u4ee4",children:"\u5e38\u7528\u547d\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"# 1.\u663e\u793a\u5f53\u524d\u7684\u542f\u52a8\u811a\u672c\nlaunchctl list\n\n# 2.\u5f00\u673a\u65f6\u81ea\u52a8\u542f\u52a8Apache\u670d\u52a1\u5668\nsudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist\n\n# 3.\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u5e76\u7acb\u5373\u542f\u52a8\u6539\u670d\u52a1\nlaunchctl load -w   **.pist \n\n# 4. \u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u4f46\u4e0d\u7acb\u5373\u542f\u52a8\u670d\u52a1 \nlaunchctl load **.pist \n\n# 5. \u505c\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u542f\u52a8\u811a\u672c\nsudo launchctl unload [path/to/script]\n\n# 6. \u518d\u52a0\u4e0a-w\u9009\u9879\u5373\u53ef\u53bb\u9664\u5f00\u673a\u542f\u52a8\nsudo launchctl unload -w [path/to/script]\n"})}),"\n",(0,i.jsx)(n.h4,{id:"\u6267\u884c\u5b9a\u65f6\u811a\u672c\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u6b65\u9aa4",children:"\u6267\u884c\u5b9a\u65f6\u811a\u672c|\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u6b65\u9aa4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"# 1.\u5199\u6267\u884c\u811a\u672c \uff08\u901a\u8fc7 brew \u5b89\u88c5\u8f6f\u4ef6 brew \u4f1a\u4e3a\u6211\u4eec\u81ea\u52a8\u751f\u6210\u3002\uff09\n# 2. \u53bb\u5bf9\u5e94\u7684\u76ee\u5f55\u4e0b\u5efa\u7acbplist\u6587\u4ef6 \n# 3. \u52a0\u8f7d\u670d\u52a1\n    # 3.1 cd \u8fdb\u5165\u6307\u5b9a plist \u6587\u4ef6\u76ee\u5f55 \n    # 3.2 \u52a0\u8f7d\u548c\u53d6\u6d88\u52a0\u8f7d\n    #\t\u52a0\u8f7d \n    launchctl load *.plist \n    #\t\u53d6\u6d88 \u52a0\u8f7d\n    launchctl unload *.plist \n    #3.3 \u67e5\u770b\u670d\u52a1\n    launchctl list \n"})}),"\n",(0,i.jsx)(n.h3,{id:"ulimit--sysctl--lauchctl-\u533a\u522b",children:"ulimit | sysctl | lauchctl \u533a\u522b"}),"\n",(0,i.jsx)(n.h4,{id:"\u4e09\u8005\u4ecb\u7ecd",children:"\u4e09\u8005\u4ecb\u7ecd"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"ulimit"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"This is a builtin command of your shell (bash/ash/zsh etc). It temporarily sets process limits for the current shell. This is not OS X specific by the way."}),"\n",(0,i.jsx)(n.li,{children:"\u8fd9\u662f\u4e00\u79cd\u5d4c\u5165shell\u7684\u547d\u4ee4\uff0c\u53ea\u80fd\u4e34\u65f6\u8bbe\u7f6e\u5f53\u524dshell\uff08\u4e5f\u5c31\u662f\u5f53\u524d\u8fdb\u7a0b\uff09\u7684\u53c2\u6570\u3002unix-like OS\u90fd\u6709\u3002"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"sysctl"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Most unix-like (Linux/*BSD/OS X) systems set global limit/kernel settings via the ",(0,i.jsx)(n.code,{children:"sysctl"}),"command/",(0,i.jsx)(n.code,{children:"/etc/sysctl.conf"})," config file. But see below for the OS X caveat."]}),"\n",(0,i.jsx)(n.li,{children:"\u5927\u90e8\u5206unix-like OS\u90fd\u91c7\u7528\u8fd9\u4e2a\u6765\u8bbe\u7f6e\u5168\u5c40\u7684\u5185\u6838\u9650\u5236\uff0csysctl\u4e3a\u547d\u4ee4\uff0c/etc/sysctl.conf\u4e3a\u914d\u7f6e\u6587\u4ef6\u3002\u4e0d\u8fc7\u8bf7\u770b\u4e0b\u9762\u7684launchctl"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"launchctl"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Seems like OS X does not honor ",(0,i.jsx)(n.code,{children:"sysctl.conf"})," on startup anymore ( ",(0,i.jsx)(n.a,{href:"https://discussions.apple.com/thread/2781309?start=0&tstart=0",children:"https://discussions.apple.com/thread/2781309?start=0&tstart=0"}),"). So on OS X, it looks like ",(0,i.jsx)(n.code,{children:"sysctl"}),"is merely usable for temporarily setting the global limits."]}),"\n",(0,i.jsx)(n.li,{children:"\u770b\u8d77\u6765OS X\u5728\u542f\u52a8\u7684\u65f6\u5019\u4e0d\u5728\u5c0a\u91cdsysctl.conf\u7684\u914d\u7f6e\uff08\u9644\u94fe\u63a5\uff09\u3002\u6240\u4ee5\u5728OS X\u4e0a\uff0csysctl\u4ec5\u4ec5\u80fd\u591f\u4e34\u65f6\u8bbe\u7f6e\u5168\u5c40\u9650\u5236\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h4,{id:"\u8bf4\u660e",children:"\u8bf4\u660e"}),"\n",(0,i.jsx)(n.h3,{id:"ulimit-1",children:"ulimit"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["ulimit","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"ulimit\u4ec5\u4f5c\u7528\u4e8e\u5f53\u524dshell\uff0c\u4e5f\u5c31\u662f\u5f53\u524d\u8fdb\u7a0b"}),"\n",(0,i.jsx)(n.li,{children:"ulimit -n \u7684\u8bbe\u7f6e\u7406\u6240\u5f53\u7136\u7684\u4e5f\u662f\u4e34\u65f6\u8bbe\u7f6e"}),"\n",(0,i.jsx)(n.li,{children:"ulimit\u4e0b\u7684open files\u624d\u662f\u771f\u6b63\u5f71\u54cd\u5f53\u524d\u8fdb\u7a0b\u6253\u5f00\u6587\u4ef6\u7684\u914d\u7f6e"}),"\n",(0,i.jsx)(n.li,{children:"\u4fee\u6539open files\u7684\u4e0a\u9650\u4e0d\u80fd\u8d85\u8fc7 kern.maxfilesperproc\u8bbe\u7f6e\uff08\u53c2\u89c1\u4e0b\u9762sysctl\u53c2\u6570\uff09"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["launchctl","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"launchctl\u4e3amacOS\u7279\u6709\u914d\u7f6e"}),"\n",(0,i.jsxs)(n.li,{children:["$ launchctl limit maxfiles","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"maxfiles  1024   10240"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"\u53ef\u5c06launchctl\u5b50\u547d\u4ee4\u5199\u5165/etc/launchd.conf\u4e2d"}),"\n",(0,i.jsx)(n.li,{children:"\u6709\u8f6f\u914d\u548c\u786c\u914d\u3002\u8f6f\u914d\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u53ef\u81ea\u7531\u63a7\u5236\uff0c\u4f46\u4e0d\u80fd\u8d85\u8fc7\u786c\u914d\uff1b\u786c\u914d\u4e3a\u53ea\u6709root\u624d\u80fd\u4fee\u6539\uff0c\u76ee\u7684\u5c31\u662f\u7ed9\u8f6f\u914d\u5212\u5b9a\u4e0a\u9650\u3002"}
1),"\n",(0,i.jsx)(n.li,{children:"\u4fee\u6539\u8be5\u9879\u914d\u7f6e\u4f1a\u76f4\u63a5\u540c\u65f6\u8bbe\u7f6esysctl\u7684 kern.maxfilesperproc\u53c2\u6570"}),"\n",(0,i.jsx)(n.li,{children:"\u70ed\u4fee\u6539sysctl\u4e0a\u9650\u503c\u4e0d\u4f1a\u5f71\u54cdlaunchctl\uff0c\u800c\u53cd\u4e4b\uff0claunchctl\u4f1a\u5f71\u54cdsysctl\u4e0a\u9650\u503c"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["sysctl","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"sysctl\u4e3a\u7cfb\u7edf\u63a7\u5236"}),"\n",(0,i.jsxs)(n.li,{children:["$ sysctl -a|grep files","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"kern.maxfiles: 10240"}),"\n",(0,i.jsx)(n.li,{children:"kern.maxfilesperproc: 512"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"\u7531\u4ee5\u4e0a\u4e24\u4e2a\u914d\u7f6e\u9879\u51b3\u5b9a\uff0c\u7b2c\u4e00\u4e2a\u4e3a\u5185\u6838\u603b\u6587\u4ef6\u4e0a\u9650\uff0c\u7b2c\u4e8c\u4e2a\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u5141\u8bb8\u7684\u4e0a\u9650"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u7cfb\u7edf\u7684\u8d44\u6e90\u662f\u6709\u9650\u7684 (\u5982 CPU\uff0c\u5185\u5b58\uff0c\u5185\u6838\u6240\u80fd\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u6570\u7b49)\uff0c\u8d44\u6e90\u9650\u5236\u5bf9\u9488\u5bf9\u8fdb\u7a0b\u80fd\u4f7f\u7528\u7684\u7cfb\u7edf\u8d44\u6e90\u8bbe\u5b9a\u4e0a\u9650\u3002\u9632\u6b62\u6076\u610f\u8fdb\u7a0b\u65e0\u9650\u5236\u5730\u5360\u7528\u7cfb\u7edf\u8d44\u6e90\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u8d44\u6e90\u9650\u5236\u5206\u4e3a\u4e24\u79cd\uff0c\u786c\u9650\u5236 (Hard Limit) \u548c\u8f6f\u9650\u5236(Soft Limit)\uff0c\u8f6f\u9650\u5236\u4f5c\u7528\u4e8e\u5b9e\u9645\u8fdb\u7a0b\u5e76\u4e14\u53ef\u4ee5\u4fee\u6539\uff0c\u4f46\u4e0d\u80fd\u8d85\u8fc7\u786c\u9650\u5236\uff0c\u786c\u9650\u5236\u53ea\u6709 Root \u6743\u9650\u624d\u80fd\u4fee\u6539\u3002"})]})}function o(l={}){const{wrapper:n}={...(0,c.R)(),...l.components};return n?(0,i.jsx)(n,{...l,children:(0,i.jsx)(h,{...l})}):h(l)}},8453:(l,n,s)=>{s.d(n,{R:()=>r,x:()=>t});var e=s(6540);const i={},c=e.createContext(i);function r(l){const n=e.useContext(c);return e.useMemo((function(){return"function"==typeof l?l(n):{...n,...l}}),[n,l])}function t(l){let n;return n=l.disableParentContext?"function"==typeof l.components?l.components(i):l.components||i:r(l.components),e.createElement(c.Provider,{value:n},l.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.