{"id":914,"date":"2022-09-05T21:49:30","date_gmt":"2022-09-05T13:49:30","guid":{"rendered":"https:\/\/www.dd-home.top\/?p=914"},"modified":"2022-09-07T15:28:05","modified_gmt":"2022-09-07T07:28:05","slug":"centos%e4%b8%ad%e5%ae%89%e8%a3%85redis","status":"publish","type":"post","link":"https:\/\/www.dd-home.top\/?p=914","title":{"rendered":"Centos\u4e2d\u5b89\u88c5redis"},"content":{"rendered":"<p><!--more--><\/p>\n<h6>1.\u8fdb\u5165CENTOS \u7cfb\u7edf\uff0c\u521b\u5efa\u6587\u4ef6\u5939SOFT\uff0c\u540e\u671f\u7f16\u8bd1\u5b89\u88c5\u90fd\u5728\u6b64<\/h6>\n<pre><code>cd \/usr\/local\r\nmkdir soft\r\ncd soft<\/code><\/pre>\n<h6><\/h6>\n<h6>2.\u4e0b\u8f7dREDIS\uff0c\u53ef\u4ee5\u901a\u8fc7WGET\u4e0b\u8f7d\u6216\u8005\u53ef\u4ee5\u9884\u4e0b\u8f7d\u597d\uff0c\u653e\u5728SOFT\u6587\u4ef6\u5939\u4e2d(\u672a\u5b89\u88c5WGET\uff0c\u9700\u8981\u9884\u5148\u5b89\u88c5\u597d)<\/h6>\n<pre><code># \u6ca1\u6709\u5b89\u88c5wget\u65f6\u9700\u8981\u63d0\u524d\u5b89\u88c5\r\nyum install wget\r\n# \u4e0b\u8f7dredis\uff0c\u53bb\u5b98\u7f51\u590d\u5236\u6700\u65b0\u7684\u5730\u5740\uff0c\u6216\u8005\u76f4\u63a5\u4e0b\u8f7d\u597d\u4e0a\u4f20\u4e0a\u53bb\r\nwget https:\/\/download.redis.io\/releases\/redis-6.2.4.tar.gz\r\n# \u89e3\u538bredis\r\ntar -zxvf redis-6.2.4.tar.gz\r\n# \u8fdb\u5165\u5230Redis\r\ncd redis<\/code><\/pre>\n<h6>3.\u7f16\u8bd1\u5b89\u88c5\u524d\u7684\u51c6\u5907\u5de5\u4f5c\uff08\u5b89\u88c5GCC\uff0c\u5207\u6362GCC\u7248\u672c\u7b49\u7b49\uff09<\/h6>\n<pre><code># \u5b89\u88c5gcc \u5b89\u88c5\u7684\u7248\u672c\u4e3a4\r\nyum install gcc\r\n# \u5b89\u88c5\u8f6f\u4ef6\u96c6\u5408\r\nyum -y install centos-release-scl\r\n# \u5b89\u88c5gcc 9\r\nyum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils\r\n# \u5207\u6362\u7248\u672c\u4e3a9\r\n# \u4f7f\u7528scl\u521b\u5efa\u4e00\u4e2ascl\u5305\u7684bash\u4f1a\u8bdd\r\nscl enable devtoolset-9 bash\r\n# \u6c38\u4e45\u5207\u6362\u52309\r\necho \u201csource \/opt\/rh\/devtoolset-9\/enable\u201d &gt;&gt; \/etc\/profile\r\nreboot<\/code><\/pre>\n<h6>3.1CENTOS-RELEASE-SCL<\/h6>\n<p>SoftwareCollections.org \u662f\u4e3a Red Hat Enterprise Linux\uff0cFedora\uff0cCentOS \u548c Scientific Linux \u521b\u5efa\u8f6f\u4ef6\u96c6\u5408\uff08SCL\uff09\u7684\u9879\u76ee\u7684\u6240\u5728\u5730\u3002<\/p>\n<pre><code>yum install centos-release-scl -y\r\nyum list all --enablerepo='centos-sclo-rh'\r\n\r\n# \u67e5\u770bscl\u4e2dgcc\u7248\u672c\r\nyum list all --enablerepo='centos-sclo-rh'|grep gcc\r\n<\/code><\/pre>\n<h6>4.\u5b89\u88c5<\/h6>\n<pre><code># \u6e05\u7406\u7f16\u8bd1 \r\n#make clean\u4ec5\u4ec5\u662f\u6e05\u9664\u4e4b\u524d\u7f16\u8bd1\u7684\u53ef\u6267\u884c\u6587\u4ef6\u53ca\u914d\u7f6e\u6587\u4ef6\u3002\r\n#make distclean\u8981\u6e05\u9664\u6240\u6709\u751f\u6210\u7684\u6587\u4ef6\u3002\r\nmake distclean &amp;&amp; make\r\n\r\n# \u914d\u7f6e\u5b89\u88c5\u4f4d\u7f6e\r\nmake install PREFIX=\/usr\/local\/soft\/redis<\/code><\/pre>\n<h6>5.\u8bd5\u8fd0\u884c<\/h6>\n<pre><code># \u8fdb\u5165\u76ee\u5f55\r\ncd \/usr\/local\/soft\/redis\/bin\/\r\n# \u8bd5\u8fd0\u884c\r\n.\/redis-server<\/code><\/pre>\n<h6>5.1\u8bd5\u8fd0\u884c\u95ee\u9898\u5904\u7406<\/h6>\n<pre><code># \u7f16\u8f91sysctl.conf \u6587\u4ef6\r\nvi \/etc\/sysctl.conf\r\n\r\n# \u6309insert\u952e\uff0c\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\r\n# \u8f93\u5165\u4e0b\u9762\u4e24\u884c\r\nnet.core.somaxconn = 1024\r\nvm.overcommit_memory = 1\r\n# \u6309\u4e0besc\u952e\u76d8\r\n# \u8f93\u5165:wq \u56de\u8f66\uff0c\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\r\n# \u6267\u884c\u751f\u6548\r\nsysctl -p \r\n\r\n# \u7f16\u8f91\/etc\/rc.local \u6587\u4ef6\r\nvi \/etc\/rc.local\r\n\r\n# \u6309insert\u952e\uff0c\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\r\n# \u8f93\u5165\u4e0b\u9762\r\necho never &gt; \/sys\/kernel\/mm\/transparent_hugepage\/enabled\r\n\r\n# \u6309\u4e0besc\u952e\u76d8\r\n# \u8f93\u5165:wq \u56de\u8f66\uff0c\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\r\n# \u6267\u884c\u751f\u6548\r\nsource \/etc\/rc.local \r\n<\/code><\/pre>\n<h6>6.\u6dfb\u52a06379\u5230\u9632\u706b\u5899<\/h6>\n<pre><code># \u6dfb\u52a0\u9632\u706b\u5899\u7aef\u53e3\r\nfirewall-cmd --zone=public --add-port=6379\/tcp --permanent\r\n\r\n# \u91cd\u542f\u9632\u706b\u5899\r\nsystemctl restart firewalld.service<\/code><\/pre>\n<h6>7.\u914d\u7f6eREDIS\u914d\u7f6e\u6587\u4ef6<\/h6>\n<pre><code># \u5c06\u914d\u7f6e\u6587\u4ef6\u4ecesrc\u4e2d\u590d\u5236\u51fa\u6765\r\n# \u5efa\u8bae\u914d\u7f6e\u597d\uff0c\u76f4\u63a5\u4e0a\u4f20\u5230\u8fd9\u513f\r\ncp \/usr\/local\/soft\/redis-6.2.4\/redis.conf \/usr\/local\/soft\/redis\/bin\/<\/code><\/pre>\n<h6>8.\u914d\u7f6e\u5f00\u673a\u542f\u52a8<\/h6>\n<pre><code># \u521b\u5efa\u5f00\u673a\u542f\u52a8\u7684\u670d\u52a1,\u5982\u679c\u901a\u8fc7winsp\u6ce8\u610f\u683c\u5f0f\uff0c\u4f1a\u6709\u5f02\u5e38\r\nvi \/etc\/systemd\/system\/redis.service\r\n\r\n# \u6309\u4e0bInsert\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\r\n[Unit]\r\nDescription=redis-server\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\nExecStart=\/usr\/local\/soft\/redis\/bin\/redis-server \/usr\/local\/soft\/redis\/bin\/redis.conf\r\nPrivateTmp=true\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n# \u6309\u4e0bEsc\uff0c\u8f93\u5165:wq \u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\u5e76\u4fdd\u5b58\r\n# \u91cd\u65b0\u52a0\u8f7d\u670d\u52a1\u4e3a\r\nsystemctl daemon-reload\r\n# \u5f00\u542fredis\u670d\u52a1\r\nsystemctl start redis.service\r\n# \u5f00\u542fredis\u670d\u52a1\u5f00\u673a\u91cd\u542f\r\nsystemctl enable redis.service<\/code><\/pre>\n<h6>9.\u5e38\u7528\u547d\u4ee4<\/h6>\n<pre><code># \u542f\u52a8redis\u670d\u52a1\r\nsystemctl start redis.service\r\n# \u505c\u6b62redis\u670d\u52a1\r\nsystemctl stop redis.service\r\n# \u91cd\u542f\u670d\u52a1\r\nsystemctl restart redis.service\r\n# \u67e5\u770b\u670d\u52a1\u5f53\u524d\u72b6\u6001\r\nsystemctl status redis.service\r\n# \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8\r\nsystemctl enable redis.service\r\n# \u505c\u6b62\u5f00\u673a\u81ea\u542f\u52a8\r\nsystemctl disable redis.service<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[71],"class_list":["post-914","post","type-post","status-publish","format-standard","hentry","category-5","category-6","tag-redis"],"_links":{"self":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=914"}],"version-history":[{"count":2,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions"}],"predecessor-version":[{"id":924,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions\/924"}],"wp:attachment":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}