作者归档:杨龙

Entity: line 39: parser error : Entity ‘nbsp’ not defined

在 XML 中,只有 5 个预定义的实体引用,$nbsp; 应该替换为空格~

$content = Entities::replaceAllEntities($content);

在 XML 中,有 5 个预定义的实体引用:

&lt;<小于
&gt;>大于
&amp;&和号
&apos;单引号
&quot;引号

注释:在 XML 中,只有字符 “<” 和 “&” 确实是非法的。大于号是合法的,但是用实体引用来代替它是一个好习惯。

innodb_large_prefix

查看表结构,发现token这个字段类型是varchar(4000),默认情况下innodb下创建的索引最大长度是767字节,大概原因我们就知道了,由于字段长度过长,导致创建索引的长度有限,这样实际索引的区分度就非常低了,每次查询都要扫描很多的行,加上这个查询是一个高频的查询,导致了系统运行缓慢。

问题解决
这个问题有几种解决方式:

第一种:
修改数据库参数innodb_large_prefix设置为on,这样可以将创建索引的长度扩大到3072,这样可以提高索引数据的区分度,每次查询时扫描的行数就会降低。当天晚上修改了此参数后,查看执行计划rows扫描的行数就降至到了95,并且第二天也无此SQL的慢查询,慢查询日志文件也从前一天的60个文件较少到了1个

第二种:
通过增加缓存的方式,将token放到缓存中,减少对数据库的访问次数

原文地址

https://mp.weixin.qq.com/s/AzErO4Ri7Z48OgfZxp3sSg

干掉/boot分区,移动boot分区到LVM分区里

想要移动/boot分区时,首先使用(Gparted   这个软件,直接apt-get install gparted 就可以安装)

(1)使用gparted查看你的/boot分区挂载在哪个磁盘上

(2)之后使用mount 挂载你的目的磁盘

(3)将源/boot磁盘中的信息全都拷贝到你的目的磁盘中

(4)将源/boot磁盘unmount一下,并将目的磁盘mount到/boot目录下

(5)更新sudo grub-install –boot-directory=目的boot目录  /dev/sda

5.1 检查fstab

(6)reboot  查看是否更新成功

参考:https://blog.csdn.net/liyadian/article/details/102976231

certbot renew: ImportError: cannot import name constants

certbot renew
An unexpected error occurred:
ImportError: cannot import name constants
Please see the logfile ‘/tmp/tmpl4isIP/log’ for more details.

Installing snapd

With the EPEL repository added to your CentOS installation, simply install the snapd package:

$ sudo yum install snapd

Once installed, the systemd unit that manages the main snap communication socket needs to be enabled:

$ sudo systemctl enable --now snapd.socket

To enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap:

$ sudo ln -s /var/lib/snapd/snap /snap

Remove certbot-auto and any Certbot OS packages

If you have any Certbot packages installed using an OS package manager like apt, dnf, or yum, you should remove them before installing the Certbot snap to ensure that when you run the command certbot the snap is used rather than the installation from your OS package manager. The exact command to do this depends on your OS, but common examples are sudo apt-get remove certbot, 

sudo dnf remove certbot, or sudo yum remove certbot.

If you previously used Certbot through the certbot-auto script, you should also remove its installation by following the instructions here.

Install CertbotRun this command on the command line on the machine to install Certbot.

sudo snap install --classic certbot

Prepare the Certbot commandExecute the following instruction on the command line on the machine to ensure that the certbot command can be run.sudo

ln -s /snap/bin/certbot /usr/bin/certbot

Choose how you’d like to run Certbot

Either get and install your certificates…Run this command to get a certificate and have Certbot edit your Nginx configuration automatically to serve it, turning on HTTPS access in a single step.

sudo certbot --nginx

Or, just get a certificateIf you’re feeling more conservative and would like to make the changes to your Nginx configuration by hand, run this command.

sudo certbot certonly --nginx

Test automatic renewalThe Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:

sudo certbot renew --dry-run

The command to renew certbot is installed in one of the following locations:

  • /etc/crontab/
  • /etc/cron.*/*
  • systemctl list-timers