{ "version": "https://jsonfeed.org/version/1", "title": "Hito的公告栏", "subtitle": "天下事有难易乎?为之,则难者亦易矣", "icon": "https://blog.jingxiyuan.cn/images/favicon.ico", "description": "hito的博客", "home_page_url": "https://blog.jingxiyuan.cn", "items": [ { "id": "https://blog.jingxiyuan.cn/2022/10/22/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88%E9%9D%92%E9%BE%99%E9%9D%A2%E6%9D%BF%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/", "url": "https://blog.jingxiyuan.cn/2022/10/22/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88%E9%9D%92%E9%BE%99%E9%9D%A2%E6%9D%BF%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/", "title": "极空间Docker版青龙面板安装与配置", "date_published": "2022-10-22T02:44:00.000Z", "content_html": "

# 介绍

\n\n

# 安装

\n\n
#青龙面板装载路径\n/ql/data/ninja\n/ql/data/db\n/ql/data/deps\n/ql/data/config\n/ql/data/repo\n/ql/data/raw\n/ql/data/jbot\n/ql/data/scripts\n/ql/data/log\n#博客装载路径(如果你不部署hexo博客可以不用配置)\n/root/.ssh  #ssh证书文件(如果你不用把hexo推送到git上可以不用配置)\n/blog      #hexo博客编译目录\n/blog/nginx_blog  #nginx上放置博客的目录(例如:/Docker/nginx/html/blog)\n
\n\n

# 配置

\n\n
名称:JD_COOKIE\n值:web京东登陆后按F12在网络tab页中的请求内查找cookie,然后复制pt_key=到pt_pin=等\n
\n\n
repo命令拉取脚本时需要拉取的文件后缀,直接写文件后缀名即可\nRepoFileExtensions="js py ts"\n钉钉(消息推送)\nexport DD_BOT_TOKEN=\nexport DD_BOT_SECRET=\n##开卡\nexport guaopencard_All="true"\nexport guaopencard_addSku_All="true"\nexport guaopencardRun_All="true"\nexport guaopencard_draw="true"\nexport JD_TRY="true"\nexport exjxbeans="true"\nexport DY_OPENALL="true"\n#抽奖\nexport opencard_draw=3\n#开启脚本依赖文件缺失修复\nexport ec_fix_dep="true" \n#开启脚本依赖文件更新\nexport ec_re_dep="true" \n#清空购物车\nexport JD_CART_REMOVE="true"\nexport JD_CART="true"\n#去掉多余的双十一红包脚本\nexport FLCODE=''\n#加购物车抽奖\nexport RUN_CAR=true\n#停用小额免密支付\nexport JD_PAY_CONTRACT=true\n
\n\n
#nodejs依赖\ncrypto-js\t\nprettytable\t\ndotenv\t\njsdom\t\ndate-fns\t\ntough-cookie\t\ntslib\t\nws@7.4.3\t\nts-md5\t\njsdom -g\t\njieba\t\nfs\t\nform-data\t\njson5\t\nglobal-agent\t\npng-js\t\n@types/node\t\nrequire\t\ntypescript\t\njs-base64\t\naxios\n#pythone依赖\nrequests\t\ncanvas\t\nping3\t\njieba\t\naiohttp\t\nPyExecJS\n#Linux依赖\nbizCode\nbizMsg\nlxml\n
\n

# 其它

\n
#配置国内源\npip config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/\npip config --global set install.trusted-host https://mirrors.aliyun.com\n\n#升级pip\npip install --upgrade pip\n\n#更新青龙\nql update\n\n#已知要安装的依赖(不安装部分脚本任务会失败)\npnpm install ds\n\n#一键安装所有依赖(基于Faker一键脚本安装的青龙\n可通过执行/ql/data/scripts下的QLDependency.sh脚本安装,如脚本已经更新则通过下面命令执行\ncurl -fsSL https://git.metauniverse-cn.com/https://raw.githubusercontent.com/shufflewzc/QLDependency/main/Shell/QLOneKeyDependency.sh | sh\n\n#一般出现这种错误:(缺依赖)\nError: Cannot find module 'xx'\n执行pnpm install xxx\n\n#一般出现这种错误:(缺文件)\nError: Cannot find module './xx'\n那就是拉库命令不完整,请检查或复制完整的拉库命\n\n#Python3依赖安装失败修复(基于Faker一键脚本安装的青龙)\ncurl -sS https://bootstrap.pypa.io/get-pip.py | python3\n
\n", "tags": [ "极空间", "服务", "技术分享", "青龙面板", "docker" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/21/Hexo-Theme-Shoka-Valine%E8%AF%84%E8%AE%BA%E9%85%8D%E7%BD%AE/", "url": "https://blog.jingxiyuan.cn/2022/10/21/Hexo-Theme-Shoka-Valine%E8%AF%84%E8%AE%BA%E9%85%8D%E7%BD%AE/", "title": "Hexo + Theme.Shoka + Valine评论配置", "date_published": "2022-10-21T03:48:00.000Z", "content_html": "\n

# LeanCloud 注册

\n
    \n
  1. LeanCloud 网站完成注册。
  2. \n
  3. 创建应用。
    \n\"\"
  4. \n
  5. 名称随便取,方案看自己选择。开发版免费但是有限制,商业版收费无限制。
    \n\"\"
  6. \n
  7. 点击配置按钮进行配置。
    \n\"\"
  8. \n
  9. 点击设置 - 应用凭证可获取 App ID 和 App Key
    \n\"\"
  10. \n
  11. 点击设置 - 安全中心根据自己的需求配置
    \n\"\"
  12. \n
\n

# 修改 Theme.Shoka 配置

\n
valine:\n  appId: 粘贴5中获取的App ID #Your_appId\n  appKey: 粘贴5中获取的App Key #Your_appkey\n  placeholder: ヽ(○´∀`)ノ♪欢迎畅所欲言 # Comment box placeholder\n  avatar: mp #默认头像设置 Gravatar style : mp, identicon, monsterid, wavatar, robohash, retro\n  pageSize: 10 # Pagination size\n  lang: zh-CN\n  visitor: true # Article reading statistic 这个要设置为false,以免与 leancloud_visitors 突冲 \n  NoRecordIP: false # Whether to record the commenter IP\n  serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)\n  powerMode: true\n  tagMeta:\n    visitor: 新朋友\n    master: 博主\n    friend: 小伙伴\n    investor: 金主粑粑\n  tagColor:\n    master: "var(--color-orange)"\n    friend: "var(--color-aqua)"\n    investor: "var(--color-pink)"\n  tagMember:\n    master:\n      # - hash of master@email.com\n      # - hash of master2@email.com\n    friend:\n      # - hash of friend@email.com\n      # - hash of friend2@email.com\n    investor:\n      # - hash of investor1@email.com\n
\n", "tags": [ "极空间", "服务", "经验分享", "博客", "Hexo", "Shoka", "Valine", "评论" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/21/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88mariadb%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/", "url": "https://blog.jingxiyuan.cn/2022/10/21/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88mariadb%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/", "title": "极空间Docker版mariadb安装与配置", "date_published": "2022-10-21T01:06:00.000Z", "content_html": "

# 介绍

\n\n

# 安装

\n\n

# 配置

\n\n
stream {\n\t\n\t#极空间-docker-mariadb\n\tupstream mariadb {\n\t\thash $remote_addr consistent;\n\t\tserver mariadb的ip:端口;\n\t}\n\n\tserver {\n\t\tlisten 监听端口;\n\n\t\tproxy_connect_timeout 30s;\n\t\tproxy_timeout 300s;\n\t\tproxy_pass mariadb;\n\t}\n    \n}\n
\n", "tags": [ "极空间", "Docker", "技术分享", "极空间", "Docker", "mariadb", "mysql" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/20/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88Wordpress%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/", "url": "https://blog.jingxiyuan.cn/2022/10/20/%E6%9E%81%E7%A9%BA%E9%97%B4Docker%E7%89%88Wordpress%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/", "title": "极空间Docker版Wordpress安装与配置", "date_published": "2022-10-20T00:56:00.000Z", "content_html": "

# 安装

\n\n

# 配置

\n\n
if((!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) || (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {\n    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];\n    $_SERVER['HTTPS'] = 'on';\n}\n
\n\n
define('WP_TEMP_DIR', ABSPATH.'wp-content/tmp');\ndefine('FS_METHOD', 'direct');\ndefine('FS_CHMOD_DIR', 0777);\ndefine('FS_CHMOD_FILE', 0777);\n
\n\n
chown('/var/www/html', 'www-data');\nchgrp('/var/www/html', 'www-data');\nchmod('/var/www/html/wp-content/plugins', 0777);\nchmod('/var/www/html/wp-content/themes', 0777);\nchmod('/var/www/html/wp-content/tmp', 0777);\n
\n\n
if($_GET['key'] != 'value') {\n\theader('Location: https://www.xxx.com/');\n}\n
\n", "tags": [ "极空间", "Docker", "技术分享", "博客", "极空间", "Wordpress" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/19/%E9%95%BF%E4%BA%86%E4%B8%80%E5%B2%81/", "url": "https://blog.jingxiyuan.cn/2022/10/19/%E9%95%BF%E4%BA%86%E4%B8%80%E5%B2%81/", "title": "又长了一岁", "date_published": "2022-10-19T00:51:00.000Z", "content_html": "

一年一次的总结时间又到了,这一年前半年平平无奇,后半年惊涛骇浪。中年危机如期而遇,人身的低谷终究还是来了。很沮丧也很无助,但还是要坚强面对。人生起起伏伏,时好时坏,终归还是会好起来的。加油!加油!加油
\n!

\n", "tags": [ "生活", "心情", "心情" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/18/%E6%90%AD%E5%BB%BAnagios%E7%9B%91%E6%8E%A7/", "url": "https://blog.jingxiyuan.cn/2022/10/18/%E6%90%AD%E5%BB%BAnagios%E7%9B%91%E6%8E%A7/", "title": "搭建nagios监控", "date_published": "2022-10-18T01:39:00.000Z", "content_html": "

# 监控端服务安装与配置

\n
    \n
  1. nagios 需要安装主程序和 nrpe(nagios 和各被监控主机都必须安装)。如需使用自研前端可通过安装 ndoutils (用于把 nagios 监控信息写入数据库) 和 mysql 实现。具体安装见官网
  2. \n
  3. nagios 默认监控命令脚本放置在 libexec 中,自定义脚本也放到此处
  4. \n
  5. etc/objects/commands.cfg 用于保存 nagios 默认监控命令
  6. \n
  7. etc/nrpe.cfg 文件中需要添加用于被监控执行命令项(各被监控主机中都需要添加)
    \n\"\"
  8. \n
  9. etc/objects/hosts 目录下配置需要被监控的主机信息
    \n\"\"
  10. \n
  11. etc/objects/servers 目录下配置需要在被监控主机上执行的监控命令(第 4 项中的命令)
    \n\"\"
  12. \n
\n

# 被监控端服务安装与配置

\n
    \n
  1. 被监控端需要安装 nrpe
  2. \n
  3. 被监控端需要把监控端的命令写入到 nrpe 的配置文件中
  4. \n
  5. 被监控端需要把命令执行脚本放入 libexec 目录中
  6. \n
  7. 被监控端自动安装脚本(可借鉴)
  8. \n
\n
1、请先修改脚本中的服务端IP。\n2、如被监控端不支持let计算命令请执行sudo dpkg-reconfigure dash命令,弹出选择窗口后选择no。\n3、需要在脚本同目录下创建CentOS、Ubuntu、sh和conf目录,目录下分别放置nrpe的tar安装包、监控脚本和nrpe配置文件。\n\n#!/bin/bash\n#服务端ip\nSERVER_IP=10.10.10.121\n#安装目录\nINSTALL_HOME=`pwd`\n#安装ubuntu版本\nINSTALL_UBUNTU()\n{\n\tsudo apt-get update\n\tsudo apt-get install -y autoconf automake gcc libc6 libmcrypt-dev make libssl-dev wget openssl\n\t\n\tcd /tmp\n\t#wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-4.0.3.tar.gz\n\tcp $INSTALL_HOME/Ubuntu/nrpe.tar.gz ./\n\ttar xzf nrpe.tar.gz\n\n\tcd /tmp/nrpe-nrpe-4.0.3/\n\tsudo ./configure --enable-command-args --with-ssl-lib=/usr/lib/x86_64-linux-gnu/\n\tsudo make all\n\n\tsudo make install-groups-users\n\n\tsudo make install\n\n\tsudo make install-config\n\n\tsudo sh -c "echo >> /etc/services"\n\tsudo sh -c "sudo echo '# Nagios services' >> /etc/services"\n\tsudo sh -c "sudo echo 'nrpe    5666/tcp' >> /etc/services"\n\t\n\t#判断系统是高版本还是低版本\n\tVERSION=`lsb_release -r --short`\n\tIS_LOW_VERSION=`echo "$VERSION < 15" | bc`\n\n\tif [ $IS_LOW_VERSION = 1 ]; then\n\t\t#低版本\n\t\tsudo make install-init\n\telse\n\t\t#高版本\n\t\tsudo make install-init\n\t\tsudo systemctl enable nrpe.service\n\tfi\n\t\n\tsudo mkdir -p /etc/ufw/applications.d\n\tsudo sh -c "echo '[NRPE]' > /etc/ufw/applications.d/nagios"\n\tsudo sh -c "echo 'title=Nagios Remote Plugin Executor' >> /etc/ufw/applications.d/nagios"\n\tsudo sh -c "echo 'description=Allows remote execution of Nagios plugins' >> /etc/ufw/applications.d/nagios"\n\tsudo sh -c "echo 'ports=5666/tcp' >> /etc/ufw/applications.d/nagios"\n\tsudo ufw allow NRPE\n\tsudo ufw reload\n\t\n\tsudo sh -c "sed -i '/^allowed_hosts=/s/$/,$SERVER_IP/' /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "sed -i 's/^dont_blame_nrpe=.*/dont_blame_nrpe=1/g' /usr/local/nagios/etc/nrpe.cfg"\n\t\n\tcd $INSTALL_HOME\n\tsudo cp ./sh/* /usr/local/nagios/libexec/\n\tsudo chmod +xr /usr/local/nagios/libexec/*\n\t\n\tsudo sh -c "echo 'command[check_ping]=/usr/local/nagios/libexec/check_ping -H 127.0.0.1 -w 3000.0,80% -c 5000.0,100% -p 5' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_mem]=/usr/local/nagios/libexec/check_mem.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_disk]=/usr/local/nagios/libexec/check_disk.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_my_service]=/usr/local/nagios/libexec/check_my_service.sh \\$ARG1\\$' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_system_info]=/usr/local/nagios/libexec/check_system_info.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tNETWORK_INDEX=1\n\tfor NETWORK_NAME in `cat /proc/net/dev | awk '{i++; if(i>2){print $1}}' | sed 's/^[\\t]*//g' | sed 's/[:]*$//g'`;do\n\t\t\tif [ $NETWORK_NAME != 'lo' ]; then\n\t\t\t\t\tsudo sh -c "echo 'command[check_network$NETWORK_INDEX]=/usr/local/nagios/libexec/check_network.sh $NETWORK_NAME' >> /usr/local/nagios/etc/nrpe.cfg"\n\t\t\t\t\tNETWORK_INDEX=`expr $NETWORK_INDEX + 1 `\n\t\t\tfi\n\tdone\n\t\n\tif [ $IS_LOW_VERSION = 1 ]; then\n\t\t#低版本\n\t\tsudo start nrpe\n\telse\n\t\t#高版本\n\t\tsudo systemctl start nrpe.service\n\tfi\n}\n\n#安装centos版本\nINSTALL_CENTOS()\n{\n\tyum install -y gcc glibc glibc-common openssl openssl-devel perl wget\n\n\tcd /tmp\n\t#wget --no-check-certificate -O nrpe.tar.gz https://github.com/NagiosEnterprises/nrpe/archive/nrpe-4.0.3.tar.gz\n\tcp $INSTALL_HOME/CentOS/nrpe.tar.gz ./\n\ttar xzf nrpe.tar.gz\n\n\tcd /tmp/nrpe-nrpe-4.0.3/\n\t./configure --enable-command-args\n\tmake all\n\n\tmake install-groups-users\n\n\tmake install\n\n\tmake install-config\n\n\techo >> /etc/services\n\techo '# Nagios services' >> /etc/services\n\techo 'nrpe    5666/tcp' >> /etc/services\n\t\n\t#判断系统是高版本还是低版本\n\tVERSION=`rpm -q centos-release|cut -d- -f3`\n\t#安装bc命令\n\tyum -y install bc\n\tIS_LOW_VERSION=`echo "$VERSION < 7" | bc`\n\n\tif [ $IS_LOW_VERSION = 1 ]; then\n\t\t#低版本\n\t\tmake install-init\n\t\t\n\t\tiptables -I INPUT -p tcp --destination-port 5666 -j ACCEPT\n\t\tservice iptables save\n\t\tip6tables -I INPUT -p tcp --destination-port 5666 -j ACCEPT\n\t\tservice ip6tables save\n\telse\n\t\t#高版本\n\t\tmake install-init\n\t\tsystemctl enable nrpe.service\n\t\t\n\t\tfirewall-cmd --zone=public --add-port=5666/tcp\n\t\tfirewall-cmd --zone=public --add-port=5666/tcp --permanent\n\tfi\n\t\n\tsudo sh -c "sed -i '/^allowed_hosts=/s/$/,$SERVER_IP/' /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "sed -i 's/^dont_blame_nrpe=.*/dont_blame_nrpe=1/g' /usr/local/nagios/etc/nrpe.cfg"\n\t\n\tcd $INSTALL_HOME\n\tsudo cp ./sh/* /usr/local/nagios/libexec/\n\tsudo chmod +xr /usr/local/nagios/libexec/*\n\t\n\tsudo sh -c "echo 'command[check_ping]=/usr/local/nagios/libexec/check_ping -H 127.0.0.1 -w 3000.0,80% -c 5000.0,100% -p 5' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_mem]=/usr/local/nagios/libexec/check_mem.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_disk]=/usr/local/nagios/libexec/check_disk.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_my_service]=/usr/local/nagios/libexec/check_my_service.sh \\$ARG1\\$' >> /usr/local/nagios/etc/nrpe.cfg"\n\tsudo sh -c "echo 'command[check_system_info]=/usr/local/nagios/libexec/check_system_info.sh' >> /usr/local/nagios/etc/nrpe.cfg"\n\tNETWORK_INDEX=1\n\tfor NETWORK_NAME in `cat /proc/net/dev | awk '{i++; if(i>2){print $1}}' | sed 's/^[\\t]*//g' | sed 's/[:]*$//g'`;do\n\t\t\tif [ $NETWORK_NAME != 'lo' ]; then\n\t\t\t\t\tsudo sh -c "echo 'command[check_network$NETWORK_INDEX]=/usr/local/nagios/libexec/check_network.sh $NETWORK_NAME' >> /usr/local/nagios/etc/nrpe.cfg"\n\t\t\t\t\tNETWORK_INDEX=`expr $NETWORK_INDEX + 1 `\n\t\t\tfi\n\tdone\n\t\n\tif [ $IS_LOW_VERSION = 1 ]; then\n\t\t#低版本\n\t\tif [ $(echo "$VERSION < 6" | bc) -eq 1 ]; then\n\t\t\tservice nrpe start\n\t\telse\n\t\t\tstart nrpe\n\t\tfi\n\telse\n\t\t#高版本\n\t\tsystemctl start nrpe.service\n\tfi\n}\n\n#安装其它版本\nINSTALL_OTHER()\n{\n\techo "Not supported at the moment."\n}\n\n#根据不同系统安装不同版本\nINSTALL()\n{\n\tif grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then\n\t\tDISTRO='CentOS'\n        PM='yum'\n\t\tINSTALL_CENTOS\n    elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then\n        DISTRO='RHEL'\n        PM='yum'\n\t\tINSTALL_OTHER\n    elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then\n        DISTRO='Aliyun'\n        PM='yum'\n\t\tINSTALL_OTHER\n    elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then\n        DISTRO='Fedora'\n        PM='yum'\n\t\tINSTALL_OTHER\n    elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then\n        DISTRO='Debian'\n        PM='apt'\n\t\tINSTALL_OTHER\n    elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then\n        DISTRO='Ubuntu'\n        PM='apt'\n\t\tINSTALL_UBUNTU\n    elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then\n        DISTRO='Raspbian'\n        PM='apt'\n\t\tINSTALL_OTHER\n    else\n        echo "unknow linux."\n        exit 1\n    fi\n    echo $DISTRO\n}\n\nINSTALL\n\nexit 0\n
\n

# 常见问题

\n
    \n
  1. 监控日志未写入 mysql(可能是 ndoutils 服务不正常导致)。采用以下脚本命令解决
  2. \n
\n
#!/bin/bash\nsudo rm -f /usr/local/nagios/var/ndo2db.pid\nsudo rm -f /usr/local/nagios/var/ndo.sock\nsudo systemctl restart ndo2db.service\nsudo systemctl status ndo2db.service\n
\n", "tags": [ "Linux", "服务", "经验分享", "nagios", "服务监控" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/17/redis%E4%B8%BB%E4%BB%8E%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%E8%AE%B0%E5%BD%95/", "url": "https://blog.jingxiyuan.cn/2022/10/17/redis%E4%B8%BB%E4%BB%8E%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%E8%AE%B0%E5%BD%95/", "title": "redis主从基础配置", "date_published": "2022-10-17T06:07:00.000Z", "content_html": "

# 主服务

\n
    \n
  1. 基础配置
  2. \n
\n
port 6379\nrequirepass 123456(密码,建议不设置)\nvm-enabled no (虚拟内存,内存够的情况下可以不使用)\nmaxmemory 1GB(告诉Redis当使用了多少物理内存后就开始拒绝后续的写入)\nbind 127.0.0.1 (注释掉,否则不能外部连接)\nrdbchecksum no(持久化数据检查)\nlist-max-ziplist-size 1024(ziplist的最大容量,正数为自己指定的大小。负数-1到-5为对应的值4到64Kb)\nlist-compress-depth 20(quicklist的两端多少个node不压缩,0为全部不压缩)\n
\n
sysctl vm.overcommit_memory=1 (立即生效)\n修改/etc/sysctl.conf添加vm.overcommit_memory=1(表示内核允许分配所有的物理内存,而不管当前的内存状态如何。Redis的RDB持久化实现是folk一个子进程,然后让子进程将内存镜像dump到RDB文件中。理论上来说是需要跟父进程一样的内存空间,但是由于linux很早就支持的copy-on-write技术,所以实际上并不需要这么多的物理内存的。)\n
\n
    \n
  1. 禁用透明大页(影响性能)
  2. \n
\n
需要sudo su 切换到root身份(sudo 没用)\necho never > /sys/kernel/mm/transparent_hugepage/enabled\n修改/etc/init.d/redis-server,加入/bin/echo never > /sys/kernel/mm/transparent_hugepage/enabled\n
\n
    \n
  1. 修复 TCP 警告
  2. \n
\n
sysctl net.core.somaxconn=1024(立即生效)\n修改/etc/sysctl.conf添加net.core.somaxconn=1024\n
\n
    \n
  1. 客户端缓冲区限制
  2. \n
\n
客户端的输出缓冲区的限制,因为某种原因客户端从服务器读取数据的速度不够快,可用于强制断开连接(一个常见的原因是一个发布 / 订阅客户端消费消息的速度无法赶上生产它们的速度)。\n可以三种不同客户端的方式进行设置:\nnormal ->  正常客户端\nslave  -> slave 和 MONITOR 客户端\npubsub ->  至少订阅了一个 pubsub channel 或 pattern 的客户端\n语法 :\nclient-output-buffer-limit <class><hard limit> <soft limit> <soft seconds>\n一旦达到硬限制客户端会立即断开,或者达到软限制并保持达成的指定秒数(连续)。\n例如,如果硬限制为 32 兆字节和软限制为 16 兆字节 /10 秒,客户端将会立即断开。如果输出缓冲区的大小达到 32 兆字节,客户端达到 16 兆字节和连续超过了限制 10 秒,也将断开连接。默认 normal 客户端不做限制,因为他们在一个请求后未要求时(以推的方式)不接收数据,\n只有异步客户端可能会出现请求数据的速度比它可以读取的速度快的场景。\n把硬限制和软限制都设置为 0 来禁用该特性\nclient-output-buffer-limit normal 0 0 0\nclient-output-buffer-limit slave 5gb 512mb 60\nclient-output-buffer-limit pubsub 32mb 8mb 60\n
\n
    \n
  1. 持久化配置
  2. \n
\n
---关闭RDB持久化---\nsave ""\n默认配置如下:\nsave 900 1 #900秒内有1次更新就持久化\nsave 300 10 #300秒内有10次更新就持久化\nsave 60 10000 #60秒内有10000次更新就持久化\n---关闭RDB持久化---\n主从同步支持两种策略,即disk和socket方式。\n新的slave端和重连的salve端不允许去继续同步进程,这被称之为“完全同步”。\n一个RDB文件从master端传到slave端,分为两种情况:\n1、支持disk:master端将RDB file写到disk,稍后再传送到slave端;\n2、无磁盘diskless:master端直接将RDB file传到slave socket,不需要与disk进行交互。无磁盘diskless方式适合磁盘读写速度慢但网络带宽非常高的环境。\nrepl-diskless-sync no 默认不使用diskless同步方式\nrepl-diskless-sync-delay 30 无磁盘diskless方式在进行数据传递之前会有一个时间的延迟,以便slave端能够进行到待传送的目标队列中,这个时间默认是5秒\nrepl-ping-slave-period 60 slave端向server端发送pings的时间区间设置,默认为10秒\nrepl-timeout 3600 设置超时时间\nrepl-disable-tcp-nodelay no 是否启用TCP_NODELAY,如果启用则会使用少量的TCP包和带宽去进行数据传输到slave端,当然速度会比较慢;如果不启用则传输速度比较快,但是会占用比较多的带宽。\nrepl-backlog-size 1mb 设置backlog的大小,backlog是一个缓冲区,在slave端失连时存放要同步到slave的数据,因此当一个slave要重连时,经常是不需要完全同步的,执行局部同步就足够了。\nbacklog设置的越大,slave可以失连的时间就越长。\nrepl-backlog-ttl 3600 如果一段时间后没有slave连接到master,则backlog size的内存将会被释放。如果值为0则表示永远不释放这部份内存。\nslave-priority 100 slave端的优先级设置,值是一个整数,数字越小表示优先级越高。当master故障时将会按照优先级来选择slave端进行恢复,如果值设置为0,则表示该slave永远不会被选择。\nmin-slaves-to-write 3\nmin-slaves-max-lag 10 设置当一个master端的可用slave少于N个,延迟时间大于M秒时,不接收写操作。\n
\n

# 从服务

\n
基本配置同主服务一致\nslaveof 127.0.0.1 6379(主redis的ip和端口)\nmasterauth 123456 (主redis的密码)\n可以通过slaveof no one命令将Slaver升级为Maste\nbgsave (持久化命令,在redis-cli中执行,默认创建dump.rdb文件,路径为 /var/lib/redis/dump.rdb。可通过find / -name dump.rd查找)\n
\n

# 相关命令

\n
看状态\nsudo /etc/init.d/redis-server status\n看端口\nnetstat -nlt|grep 6379\n外部连接\nsudo vim /etc/redis/redis.conf把protected-mode改为no,把bind ip注释掉\n重启\nsudo server redis-server restart\n查看内存\nfree -m\n批量删除指定key\nredis-cli -n 6 scan 0 match *2020-06-12 count 10000| xargs redis-cli -n 6 del\n大量删除key后快速释放被占用的内存\nmemory purge\n
\n

# 问题解决

\n
写入问题\nredis-cli config set stop-writes-on-bgsave-error no\nsudo vim /etc/redis/redis.conf把stop-writes-on-bgsave-error改为no\n修改系统 sudo vim /etc/sysctl.conf加入vm.overcommit_memory=1\nsudo sysctl vm.overcommit_memory=1\n
\n", "tags": [ "Linux", "服务", "经验分享", "redis" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/14/nginx%E5%85%81%E8%AE%B8%E8%B7%A8%E5%9F%9F%E8%8E%B7%E5%8F%96cookies%E6%96%B9%E6%B3%95/", "url": "https://blog.jingxiyuan.cn/2022/10/14/nginx%E5%85%81%E8%AE%B8%E8%B7%A8%E5%9F%9F%E8%8E%B7%E5%8F%96cookies%E6%96%B9%E6%B3%95/", "title": "nginx允许跨域获取cookie的方法", "date_published": "2022-10-14T09:13:00.000Z", "content_html": "

# 使用场景

\n

  在 A 域名的页面向 B 域名提交数据时需要代入 B 域名的 cookie,否则 B 域名会跳转到登陆页面。解决方式需要使用到 nginx 反向代理,配置如下:

\n
server {\n\tlisten port ssl http2;\n\tserver_name xxx.com;\n\tssl_certificate_key /xxx.key;\n\tssl_certificate /xxx.pem;\n\tproxy_cookie_path ~(.*) "$1; SameSite=None; secure; httponly";\n\n\tlocation / {\n\t\t#允许镶套的方式(可以同域镶套、指定域名镶套或者所有域名镶套)\n\t\tadd_header X-Frame-Options ALLOWALL; #允许被所有域名镶套\n\t\tproxy_pass http://xxx;\n\t}\n}\n
\n", "tags": [ "Linux", "服务", "经验分享", "nginx", "iframe", "cookie" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/12/%E4%BD%BF%E7%94%A8picgo%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87%E5%88%B0chevereto/", "url": "https://blog.jingxiyuan.cn/2022/10/12/%E4%BD%BF%E7%94%A8picgo%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87%E5%88%B0chevereto/", "title": "使用PicGo上传图片到chevereto", "date_published": "2022-10-12T06:40:00.000Z", "content_html": "

# 简介

\n

PicGo 是一款开源的图床管理工具,十分流行。

\n

PicGo 官方指南:PicGo | PicGo

\n

# 配置

\n
    \n
  1. \n

    安装插件(需要先安装 NodeJS)
    \n\"\"

    \n
  2. \n
  3. \n

    图床配置  
    \nurl 后缀必须用红线圈中的部分,key 在 chevereto 登陆后 api 配置中查找
    \n\"\"

    \n
  4. \n
\n", "tags": [ "Windows", "工具", "经验分享", "PicGo", "chevereto" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/11/svn%E5%BA%93%E8%BD%ACgit%E5%BA%93/", "url": "https://blog.jingxiyuan.cn/2022/10/11/svn%E5%BA%93%E8%BD%ACgit%E5%BA%93/", "title": "svn库转git库", "date_published": "2022-10-11T02:40:00.000Z", "content_html": "

# 前期准备

\n

  首先安装好 svn 和 git 工具。

\n

# svn 转 git

\n

1、 到 svn 项目目录右键选中 gitbash 打开窗口,执行获取用户并映射成 git 样式账号命令如下:
\n svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > users.txt

\n

  然后会在目录下生成文件 users.txt 样式如:zhansan = 张三 zhansan@xxx.com

\n

2、新建个文件夹,将生成的 users.txt 放入新建的文件夹,然后在新建的文件夹中右键选中 gitbash 弹出窗口后执行下面命令(https://svn_project_url/ 为 svn 库的 url),拉取 svn 代码到本地新建文件夹中。
\n git svn clone https://svn_project_url/ --no-metadata --no-minimize-url --authors-file=users.txt

\n\n

# 推送项目到 git 库

\n

1、在 gitbash 窗口 cd 到 git 项目文件夹中执行以下命令把 git 仓库地址加入到 remote 中(https://git_project_url/ 为 git 库的 url)。
\n git remote add origin https://git_project_url/

\n

2、push 项目到 git 库中。
\n git push origin master

\n", "tags": [ "工具", "经验分享", "svn", "git" ] }, { "id": "https://blog.jingxiyuan.cn/2022/10/06/Nginx%E9%85%8D%E7%BD%AEiframe%E8%AE%BF%E9%97%AE/", "url": "https://blog.jingxiyuan.cn/2022/10/06/Nginx%E9%85%8D%E7%BD%AEiframe%E8%AE%BF%E9%97%AE/", "title": "Nginx配置iframe访问", "date_published": "2022-10-06T15:46:00.000Z", "content_html": "

# X-Frame-Options 响应头配置详解

\n

  X-Frame-Options HTTP 响应头是用来给浏览器指示允许一个页面可否在,或者 中展现的标记。网站可以使用此功能,来确保自己网站的内容没有被嵌套到别人的网站中去,也从而避免了点击劫持 (clickjacking) 的攻击。
\nX-Frame-Options 三个参数:

\n

1、 DENY

\n

  表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许。

\n

2、SAMEORIGIN

\n

  表示该页面可以在相同域名页面的 frame 中展示。

\n

3、ALLOW-FROM uri

\n

  表示该页面可以在指定来源的 frame 中展示。

\n

4、ALLOWALL

\n

  表示该页面可以在任何来源的 frame 中展示。

\n

  换一句话说,如果设置为 DENY,不光在别人的网站 frame 嵌入时会无法加载,在同域名页面中同样会无法加载。另一方面,如果设置为 SAMEORIGIN,那么页面就可以在同域名页面的 frame 中嵌套。正常情况下我们通常使用 SAMEORIGIN 参数。

\n

# Apache 配置

\n

  需要把下面这行添加到'site' 的配置中

\n

   Header always append X-Frame-Options SAMEORIGIN

\n

# Nginx 配置

\n

  需要添加到 ‘http’, ‘server’ 或者 ‘location’ 的配置项中,个人来讲喜欢配置在‘server’ 中

\n

  正常情况下都是使用 SAMEORIGIN 参数,允许同域嵌套
\n   add_header X-Frame-Options SAMEORIGIN;

\n

  允许单个域名 iframe 嵌套
\n   add_header X-Frame-Options ALLOW-FROM http://xxx.com/;

\n

  允许多个域名 iframe 嵌套,注意这里是用逗号分隔
\n   add_header X-Frame-Options "ALLOW-FROM http://xxx.com/,https://xxx.com/";

\n

  允许任何域名 iframe 嵌套
\n   add_header X-Frame-Options ALLOWALL;

\n

# Tomcat 配置

\n

  在‘conf/web.xml’填加以下配置

\n
<filter>
        <filter-name>httpHeaderSecurity</filter-name>
        <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
        <init-param>
            <param-name>antiClickJackingOption</param-name>
            <param-value>SAMEORIGIN</param-value>
        </init-param>
        <async-supported>true</async-supported>
    </filter>
<filter-mapping>
        <filter-name>httpHeaderSecurity</filter-name>
        <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

# IIS 配置

\n

  添加下面的配置到 ‘Web.config’文件中

\n
<system.webServer>
  <httpProtocol>
    <customHeaders>
      <add name=\"X-Frame-Options\" value=\"SAMEORIGIN\" />
    </customHeaders>
  </httpProtocol>
</system.webServer>
", "tags": [ "Linux", "服务", "经验分享", "nginx", "iframe" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/28/%E6%B7%B1%E6%B7%B1%E7%9A%84%E6%8C%AB%E8%B4%A5%E5%92%8C%E6%97%A0%E5%8A%A9%E6%84%9F/", "url": "https://blog.jingxiyuan.cn/2022/09/28/%E6%B7%B1%E6%B7%B1%E7%9A%84%E6%8C%AB%E8%B4%A5%E5%92%8C%E6%97%A0%E5%8A%A9%E6%84%9F/", "title": "深深的挫败和无助感", "date_published": "2022-09-28T08:02:00.000Z", "content_html": "

  一个月都过去了,工作还没有着落!

\n", "tags": [ "生活", "心情", "郁闷", "心情" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/27/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E9%85%8D%E7%BD%AE/", "url": "https://blog.jingxiyuan.cn/2022/09/27/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E9%85%8D%E7%BD%AE/", "title": "nginx负载均衡配置", "date_published": "2022-09-27T06:45:00.000Z", "content_html": "

# nginx 负载均衡配置

\n
    \n
  1. 轮询(默认)
  2. \n
\n

  每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器 down 掉,能自动剔除。

\n
upstream my_server {\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n
\n
    \n
  1. weight 权重策略
  2. \n
\n

  weight 代表权重,默认为 1,权重越高被分配的客户端越多,指定轮询几率。weight 和访问比率成正比,用于后端服务器性能不均的情况。

\n
upstream my_server {\n\tserver 192.168.0.2:8080 weight=1;\n\tserver 192.168.0.3:8080 weight=2;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n
\n
    \n
  1. ip_hash
  2. \n
\n

  每个请求按访问 ip 的 hash 结果分配,这样每个访客固定访问一个后端服务器,可以解决 session 的问题。

\n
upstream my_server {\n\tip_hash;\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n
\n
    \n
  1. fair (第三方)
  2. \n
\n

  按后端服务器的响应时间来分配请求,响应时间短的优先分配。

\n
upstream my_server {\n\tserver 192.168.0.2:8080;\n\tserver 192.168.0.3:8080;\n\tfair;\n}\n\nserver {\n\tlisten 80;\n\tserver_name 192.168.0.1;\n\n\t# Path to the root of your installation\n\tlocation / {\n\t\tproxy_pass http://my_server;\n\t}\n\t\n}\n
\n
    \n
  1. 动静分离
  2. \n
\n

  把静态的资源,比如图片,css,js 等先加载到 Nginx 的服务器里。

\n", "tags": [ "Linux", "服务", "经验分享", "nginx", "负载均衡" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/26/%E8%A7%A3%E5%86%B3Hexo-Shoka%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90%E6%97%A0%E6%B3%95%E6%92%AD%E6%94%BE%E7%9A%84%E9%97%AE%E9%A2%98/", "url": "https://blog.jingxiyuan.cn/2022/09/26/%E8%A7%A3%E5%86%B3Hexo-Shoka%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90%E6%97%A0%E6%B3%95%E6%92%AD%E6%94%BE%E7%9A%84%E9%97%AE%E9%A2%98/", "title": "解决Hexo+Shoka背景音乐无法播放的问题", "date_published": "2022-09-26T11:30:00.000Z", "content_html": "

  今天突然发现博客的音乐无法播放了。经过一顿查找,发现是因为 https://api.i-meto.com/meting/api 调用出错了。shoka 主题应该是通过这个网站提取音乐地址、图片等信息。通过断点发现网易播放列表还是能正常获取的,只是列表中的具体音乐、图片无法获取了。于是自己用获取的列表信息组装出正确的 url 问题基本解决。只针对网易播放列表,图片只能使用一张固定的。

\n

  解决方法如下:

\n

    到 themes\\shoka\\source\\js_app 目录下打开 player.js 文件,在最底部 init (config) 下加入 vendorJs ('fancybox');,然后找到 56 行用下面的代码替换即可。

\n
fetch: function(source) {
      var list = []
      return new Promise(function(resolve, reject) {
        source.forEach(function(raw) {
          var meta = utils.parse(raw)
          if(meta[0]) {
            var skey = JSON.stringify(meta)
            var playlist = store.get(skey)
            if(playlist) {
\t\t\t  // 自己修改 - start
\t\t\t  var audioInfos = JSON.parse(playlist);
\t\t\t  var neteaseStartUrl = \"https://music.163.com/song/media/outer/url?id=\";
\t\t\t  if (meta[0] == \"netease\" && audioInfos && audioInfos.length>0 && !audioInfos[0].url.startsWith(neteaseStartUrl)) {// 如果是网易音乐就自己构建 url
\t\t\t\t  jQuery.ajax({
\t\t\t\t\t  url: audioInfos[0].url,
\t\t\t\t\t  type: 'get',
\t\t\t\t\t  async: false,
\t\t\t\t\t  timeout: 5000,
\t\t\t\t\t  complete : function(XMLHttpRequest, status){
\t\t\t\t\t\t  if (XMLHttpRequest.status != 200) {
\t\t\t\t\t\t\t  audioInfos.forEach(function(audioInfo) {
\t\t\t\t\t\t\t\t  var id = audioInfo.url.substring(audioInfo.url.indexOf(\"id=\")+3, audioInfo.url.indexOf(\"&auth=\"));
\t\t\t\t\t\t\t\t  audioInfo.url = neteaseStartUrl + id;
\t\t\t\t\t\t\t\t  audioInfo.pic = \"https://p3.music.126.net/Vji3PQJAZ2C7gS_6X51NFQ==/109951164723650033.jpg?param=200y200\";
\t\t\t\t\t\t\t  })
\t\t\t\t\t\t  }
\t\t\t\t\t\t  list.push.apply(list, audioInfos);
\t\t\t\t\t\t  resolve(list);
\t\t\t\t\t  }
\t\t\t\t  });
\t\t\t  } else {
\t\t\t\t  list.push.apply(list, audioInfos);
\t\t\t\t  resolve(list);
\t\t\t  }
\t\t\t  // 自己修改 - end
            } else {
              fetch('https://api.i-meto.com/meting/api?server='+meta[0]+'&type='+meta[1]+'&id='+meta[2]+'&r='+ Math.random())
                .then(function(response) {
                  return response.json()
                }).then(function(json) {
                  store.set(skey, JSON.stringify(json))
                  list.push.apply(list, json);
                  resolve(list);
                }).catch(function(ex) {})
            }
          } else {
            list.push(raw);
            resolve(list);
          }
        })
      })
    }
", "tags": [ "Linux", "服务", "技术分享", "博客", "Hexo", "Shoka", "背景音乐" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/23/%E8%A7%A3%E5%86%B3%E5%9F%9F%E5%90%8Dip%E5%8F%98%E5%8A%A8%E5%90%8E%E9%9C%80%E8%A6%81%E9%87%8D%E5%90%AFnginx%E7%9A%84%E9%97%AE%E9%A2%98/", "url": "https://blog.jingxiyuan.cn/2022/09/23/%E8%A7%A3%E5%86%B3%E5%9F%9F%E5%90%8Dip%E5%8F%98%E5%8A%A8%E5%90%8E%E9%9C%80%E8%A6%81%E9%87%8D%E5%90%AFnginx%E7%9A%84%E9%97%AE%E9%A2%98/", "title": "解决域名ip变动后需要重启nginx的问题", "date_published": "2022-09-23T08:17:00.000Z", "content_html": "

  今天突然发现自己的网站不能访问了。经过一顿排查,发现是家里的外网 ip 变动后 nginx 解析的域名 ip 还是旧 ip 导致的。手动重启 nginx 后恢复正常。但这不是长久之计,如果每次 ip 变动都需要重启一次 nginx,想想都头大。于是查询资料后获得了解决办法,方法如下:

\n
location / {\t\n\tresolver 114.114.114.114 valid=60s; #自定义缓存有效时间间隔对变量中的域名进行解析\n\n\tset $my_server "https://ip:port";\n\n\tproxy_pass $my_server;\n}\n
\n", "tags": [ "Linux", "服务", "经验分享", "nginx" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/22/protobuf%E7%94%9F%E6%88%90js%E6%96%87%E4%BB%B6/", "url": "https://blog.jingxiyuan.cn/2022/09/22/protobuf%E7%94%9F%E6%88%90js%E6%96%87%E4%BB%B6/", "title": "protobuf生成js文件", "date_published": "2022-09-22T02:30:00.000Z", "content_html": "

# 下载工具

\n

protoc-3.19.5-win64.zip

\n

# 生成 js 文件

\n
    \n
  1. \n

    把 xxx.proto 文件拷贝到解压的 protoc-3.19.5-win64\\bin 目录下

    \n
  2. \n
  3. \n

    cmd 到相同的 bin 目录下

    \n
  4. \n
  5. \n

    执行 protoc.exe --js_out=import_style=commonjs,binary:. ./xxx.proto 命令,就会在 bin 目录下生成 xxx_pb.js 文件

    \n
  6. \n
\n", "tags": [ "工具", "经验分享", "protobuf", "js" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/21/%E8%AE%B0%E4%B8%80%E6%AC%A1netty-socket-io%E6%9C%8D%E5%8A%A1%E7%AB%AF%E8%BF%9E%E6%8E%A5%E4%B8%8D%E4%B8%8A%E7%9A%84%E9%97%AE%E9%A2%98/", "url": "https://blog.jingxiyuan.cn/2022/09/21/%E8%AE%B0%E4%B8%80%E6%AC%A1netty-socket-io%E6%9C%8D%E5%8A%A1%E7%AB%AF%E8%BF%9E%E6%8E%A5%E4%B8%8D%E4%B8%8A%E7%9A%84%E9%97%AE%E9%A2%98/", "title": "记一次netty-socketio服务端连接不上的问题", "date_published": "2022-09-21T01:46:00.000Z", "content_html": "

  今天前端开发跟我反馈用 vue 的 socketio 连接不上后台服务,连接无反应无任何报错。所以不清楚是前端代码问题还是后台服务的问题。由于框架为另一同事搭建,我只负责处理后端业务逻辑部分,所以第一时间我也不清楚具体的原因。于是我找了个第三方的 socket 工具尝试连接,果然有问题。但是只是提示连接不上,无明显错误原因。到后台查看发现有提示 Unknown transport for request 错误,最后通过调试发现 netty-socketio 的库中 AuthorizeHandler 类有段处理 transport 的代码只能接受大写的 WEBSOCKET 或者 POLLING,于是我在工具中按要求填上结果还是不行。然后我在网上搜索也未发现有相关问题,只发现有网友提示需要用 socketio 的库,不要自己写 socket 连接。于是我找了 socket.io.js 来连接,结果还是一样。经过大量调试改代码,最后突发奇想,有没有可能跟 netty-socketio 的版本有关系,于是我把版本从 1.7.20 升级到 1.7.21,结果就奇迹般的好了。

\n
# 总结:就好像大力出奇迹,实在找不到原因的时候不妨升级一下版本,说不定问题就解决了呢!O (∩_∩) O
\n", "tags": [ "生活", "心得体会", "踩坑", "netty", "socketIO" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/", "url": "https://blog.jingxiyuan.cn/2022/09/17/Hexo-Theme-Shoka-algolia%E6%90%9C%E7%B4%A2%E8%B8%A9%E5%9D%91/", "title": "Hexo + Theme.Shoka + algolia搜索踩坑", "date_published": "2022-09-17T15:12:00.000Z", "content_html": "

# Hexo + Theme.Shoka 安装

\n

  安装介绍

\n

# algolia 注册

\n
    \n
  1. \n

    algolia 不支持国内邮箱注册,而 google 和 github 由于国内被墙也没法使用。所以只能先注册 netlify 然后通过 netlify 注册 algolia。

    \n
  2. \n
  3. \n

    登录 algolia 后创建一个 index,名字随意记住既可。

    \n

    \"2022-09-17-23-32-20.png\"

    \n
  4. \n
  5. \n

    点击右上角红点,弹出窗口点 settings 按钮。

    \n

    \"2022-09-17-23-35-04.png\"

    \n
  6. \n
  7. \n

    点击 API KEYS,获取 appId 和 adminApiKey 填入 hexo 的_config.yml 中 apiKey 暂时不填。

    \n
  8. \n
\n
algolia:\n  appId: #Your appId\n  apiKey: #Your apiKey\n  adminApiKey: #Your adminApiKey\n  chunkSize: 5000\n  indexName: blog #"shoka"\n  fields:\n    - title #必须配置\n    - path #必须配置\n    - categories #推荐配置\n    - content:strip:truncate,0,2000\n    - gallery\n    - photos\n    - tags\n
\n
    \n
  1. \n

    点击 All Api Keys - New Api key 创建一个 api key,Indices 选先前让记住的 index,ACL 选下面图片中的选项。

    \n

    \"2022-09-17-23-47-50.png\"

    \n
  2. \n
  3. \n

    把第 5 步中新建的 api key 填入到第 4 步中的配置中,到此已经完成了百分之九十,只需要重新编译发布即可。不过编译步骤多了一步,在 hexo g 后需要再执行 hexo algolia,至此搜索功能就大功告成了。

    \n
  4. \n
\n", "tags": [ "Linux", "服务", "经验分享", "博客", "Hexo", "Shoka", "algolia", "踩坑", "搜索" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/16/%E6%9E%81%E7%A9%BA%E9%97%B4chevereto%E5%9B%BE%E5%BA%8Adocker%E7%89%88%E5%AE%89%E8%A3%85/", "url": "https://blog.jingxiyuan.cn/2022/09/16/%E6%9E%81%E7%A9%BA%E9%97%B4chevereto%E5%9B%BE%E5%BA%8Adocker%E7%89%88%E5%AE%89%E8%A3%85/", "title": "极空间chevereto图床docker版安装", "date_published": "2022-09-16T00:04:00.000Z", "content_html": "

# 安装准备

\n
    \n
  1. \n

    需要先安装好 mysql 数据库

    \n
  2. \n
  3. \n

    选择版本,1.5 版以前支持中文,之后被维护的团队删除只支持英文

    \n
  4. \n
  5. \n

    本文介绍使用的是 linuxserver_chevereto 的镜像

    \n
  6. \n
  7. \n

    需要预先创建好给 chevereto 使用的库、账户、密码

    \n
  8. \n
\n\n

# 容器配置

\n
    \n
  1. \n

    映射路径(不要放在高速盘,否则会有权限问题)
    \n\"6150d69d9a170d96e66ca69420f8c4e8.png\"

    \n
  2. \n
  3. \n

    端口
    \n\"08eafb3b30a7eb9b0c0be26ea7a1502a.png\"

    \n
  4. \n
  5. \n

    环境(puid 和 pgid 使用 1000,不要使用 0,否则会报错)
    \n\"01567ca9f31f87f832276be35cc4554b.png\"

    \n
  6. \n
\n

# 初始化配置

\n
    \n
  1. \n

    使用 http:// 极空间 ip:81 (端口号使用上面配置的,我配置的是 81) 进行 web 访问(数据库配置)
    \n\"0.png\"

    \n
  2. \n
  3. \n

    管理员配置(注意 website 配置选择个人,除非需要提供给其它人注册)
    \n\"1.png\"
    \n\"2.png\"

    \n
  4. \n
  5. \n

    默认上传大小是 2M,可通过修改 php.ini 配置提升(路径 /etc/php7/php.ini 查找 upload_max_filesize 和 post_max_size 进行修改)。之后用管理员登录通过页面 http://xxx/dashboard/settings/image-upload 修改。
    \n upload_max_filesize=200M
    \n post_max_size=200M
    \n max_execution_time=300
    \n memory_limit=1024M

    \n
  6. \n
\n

# 安装完成

\n
    \n
  1. 作为图片管理和链接分享服务完全够用。图片链接 url 支持的也很全面。
    \n\"2022-09-16-14-52-29.png\"
    \n\"2022-09-16-14-54-58.png\"
    \n\"2022-09-16-14-56-13.png\"
  2. \n
\n", "tags": [ "极空间", "Docker", "技术分享", "极空间", "chevereto", "docker", "图床", "图片上传" ] }, { "id": "https://blog.jingxiyuan.cn/2022/09/14/Hexo%E5%AE%89%E8%A3%85%E6%91%B8%E7%B4%A2/", "url": "https://blog.jingxiyuan.cn/2022/09/14/Hexo%E5%AE%89%E8%A3%85%E6%91%B8%E7%B4%A2/", "title": "Hexo安装摸索", "date_published": "2022-09-14T04:23:00.000Z", "content_html": "

# hexo 博客安装

\n
    \n
  1. \n

    安装 nodejs

    \n
  2. \n
  3. \n

    安装 git

    \n
  4. \n
  5. \n

    安装 hexo(windows 需进入 git bash)

    \n

    npm install -g hexo-cli

    \n
  6. \n
  7. \n

    初始化博客目录

    \n

    hexo init blog

    \n
  8. \n
  9. \n

    进入博客目录

    \n

    cd blog

    \n
  10. \n
  11. \n

    初始化 hexo 到博客目录

    \n

    npm install

    \n
  12. \n
\n

# shoka 主题安装

\n
    \n
  1. \n

    下载主题

    \n

    git clone https://github.com/amehime/hexo-theme-shoka.git ./themes/shoka

    \n
  2. \n
  3. \n

    卸载 hexo-renderer-marked 以及别的 markdown 文件渲染器

    \n

    npm un hexo-renderer-marked --save

    \n
  4. \n
  5. \n

    安装(md 文件渲染器,压缩 css/js/html)

    \n

    npm i hexo-renderer-multi-markdown-it --save

    \n
  6. \n
  7. \n

    安装(给生成的 css 文件们添加浏览器前缀)

    \n

    npm i hexo-autoprefixer --save

    \n
  8. \n
  9. \n

    安装(站内搜索功能)

    \n

    npm i hexo-algoliasearch --save

    \n
  10. \n
  11. \n

    安装(文章或站点字数及阅读时间统计)

    \n

    npm i hexo-symbols-count-time --save

    \n
  12. \n
  13. \n

    安装(生成 Feed 文件)

    \n

    npm i hexo-feed --save

    \n
  14. \n
\n

# Hexo 部分常用命令

\n\n

# 安装 hexo-admin(编写博客插件)

\n\n
admin:\nusername: username\npassword_hash: xxxxxx\nsecret: 'my super secret phrase' #用单引号包裹\ndeployCommand: 'hexo_publish.sh' #windows用hexo_publish.bat,linux用hexo_publish.sh\n
\n

# hexo_publish.sh

\n
#!/bin/bash\n\nhexo clean\nhexo g\nhexo d\n
\n

# hexo_publish.bat

\n
@echo off\ncd D:\\blog\nd:\n@cmd /c "hexo clean&& hexo g&&hexo d&&echo success"\n
\n", "tags": [ "Linux", "服务", "经验分享", "博客", "Hexo", "Hexo-admin" ] } ] }