Jiliuke

激流客

一些有用mysql tips

1
2
3
4
5
6
7
8
#统计所有数据库从大到小排列
select TABLE_SCHEMA,round(SUM(DATA_LENGTH + INDEX_LENGTH)/1024/1024,2) as data from information_schema.tables GROUP BY TABLE_SCHEMA order by data desc;
#统计数据库大小
select round(SUM(DATA_LENGTH + INDEX_LENGTH)/1024/1024,2) as data from information_schema.tables where TABLE_SCHEMA="xxxxxx";
#统计数据表大小
select table_name,round(SUM(DATA_LENGTH + INDEX_LENGTH)/1024/1024,2) as data from information_schema.tables where TABLE_SCHEMA="xxxxxx" GROUP BY table_name order by data desc;
#批量修改域名
UPDATE core_config_data SET value = replace (value,'xxx.xxx.com','xxx.xxx.local') WHERE value LIKE '%xxx.xxx.com%';

需求

magento2 在运行的时候会不断在项目中var/log中记录日志,时间久后就会产生巨大的log日志,所以有必要每天切割日志保存,利于日志分析和减少磁盘开销。

方法 (仅对于linux)

1.首先确定当前的项目名称(magento2)和项目路径(/var/www/magento2),项目执行用户www

2.sudo vim /etc/logrotate.d/magento2
3.拷贝以下内容到/etc/logrotate.d/magento2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 {
daily
missingok
rotate 365
maxage 365
compress
copytruncate
prerotate
# logrotate fails if the .1 file already exists, which only
# ever happens if the last copytruncate failed, or during the
# first run after delaycompress is disabled. When this script
# runs, older logs have already been rotated, so it's safe to
# rotate an unexpected log.1 file into log.2.gz. Sometimes the
# argument already has a .1 suffix, so strip it.
[ -e "${1%.1}.1" ] && sudo -u -g bash -c "gzip --best < \"${1%.1}.1\" > \"${1%.1}.2.gz\"" && rm "${1%.1}.1"
true
endscript
notifempty
create 0640 www www
su www www
lastaction
chown www:www -R /var/www/magento2/var/log/*.log
# fix files with broken permissions
chown www:www -R /var/www/magento2/var/log/*.log.[0-9]*.gz 2>/dev/null || true
endscript
}

4.测试

1
2
3
4
#强制执行
sudo logrotate -f /etc/logrotate.d/magento2
#调试模式
sudo logrotate -d /etc/logrotate.d/magento2

当服务器中curl访问https站点出现以下问题时

1
2
3
4
5
6
7
curl: (60) SSL certificate problem: certificate has expired

More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.

问题原因

由于服务器curl证书问题导致无法正确访问https站点

解决办法

1
2
3
4
5
6
#红帽系系统
yum install ca-certificates openssl
curl -k https://curl.se/ca/cacert.pem > cacert.pem
openssl x509 -outform der -in cacert.pem -out cacert.crt
update-ca-trust
ls -l /etc/pki/tls/certs/

参考连接

https://curl.se/docs/sslcerts.html

https://curl.se/docs/caextract.html

在deepin linux中安装nvidia官方驱动的方法

首先,到nvdia官网下载对应显卡的linux驱动
https://www.nvidia.com/Download/index.aspx?lang=en-us
一般对应的下载文件会在~/Downloads下,将它重新命令nvidia.sh便于后面引用。

接下来请按照以下步骤执行。

  1. 卸载nvidia开源驱动和闭源驱动

    1
    sudo apt autoremove nvidia-*
  2. 禁止nouveau驱动

    1
    sudo dedit /etc/modprobe.d/blacklist.conf

    执行以上代码打开blacklist.conf文件后复制以下内容并保存关闭

    1
    2
    3
    4
    5
    blacklist nouveau
    blacklist lbm-nouveau
    options nouveau modeset=0
    alias nouveau off
    alias lbm-nouveau off
  3. blacklist.conf添加执行权限

    1
    sudo chmod +x /etc/modprobe.d/blacklist.conf

    blacklist nouveau是禁用nouveau第三方驱动,之后不需要改回来,由于nouveau是构建在内核中的,所以要执行下面代码集成到内核中

    1
    sudo update-initramfs -u

    好了,到现在为止,前期工作已经完成。

  4. 重启
    可以运行以下命令

    1
    reboot
  5. 重启后查看nouveau有没有运行,没有输出则代表禁用生效

    1
    lsmod | grep nouveau
  6. 同时按住ctrl+alt+F2键,进入tty2。输入当前用户名点击enter然后再输入密码点击enter进入。

  7. 导航到Downloads目录,为nvidia.sh添加执行权限。

    1
    cd ~/Downloads && chmod +x nvidia.sh
  8. 关闭图形界面

    1
    sudo systemctl stop lightdm
  9. 安装显卡驱动

    1
    sudo sh nvidia.sh

    请注意接下来的步骤,一定要完成相同,否则将造成无法登陆图形界面

    注意英文字母中出现大写的“DKMS”选择Yes

    注意英文中出现“32-bit”选择Yes

    注意英文中出现“nvidia-xconfig”一定要选择No

  10. 输入reboot重启电脑,安装完成

参考视频

https://www.ixigua.com/7024358143215960590

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash 
id="user"
pwd="password"
$db="db"
backuppath="/app/"$user"/var/dbbackup"
day=15
[ ! -d $backuppath ] && mkdir -p $backuppath
cd $backuppath

dbname=$db'_'
backupname=$dbname`date +%Y%m%d%H%M%S`
mysqldump -h127.0.0.1 -u$id -p$pwd $db --single-transaction --triggers --skip-tz-utc --ignore-table-data=$db.quote_id_mask | gzip -> $backupname.sql.gz
find $backuppath -name $dbname"*.sql.gz" -type f -mtime +$day -exec rm -rf {} \;

开发中,如果遇到某种特殊情况下,无法访问外网,则可以设置代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//file vendor/magento/framework/HTTP/Adapter/Curl.php after line 26
/**
* Parameters array
*
* @var array
*/
protected $_config = [
'protocols' => (CURLPROTO_HTTP
| CURLPROTO_HTTPS
| CURLPROTO_FTP
| CURLPROTO_FTPS
),
'verifypeer' => true,
'verifyhost' => 2,
'proxy' => "http://127.0.0.1:8888"//add http proxy here
];
1
2
3
4
5
6
//file vendor/magento/zendframework1/library/Zend/Http/Client.php after line 1089
$response = $this->adapter->read();
//remove extra response afteradd proxy
if (false !== stripos($response, "HTTP/1.1 200 Connection established\r\n\r\n")) {
$response = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $response);
}

问题

打包后安装出现双图标

解决办法

desktop中添加StartupWMClass=xxx
xxx通过终端中执行xprop WM_CLASS点击应用程序获取。

使用MIDI游戏问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
WINEPREFIX=~/.deepinwine/apps/XXX_1 WINEDEBUG=+seh deepin-wine5-stable ~/.deepinwine/apps/XXX_1/drive_c/Program\ Files/XXXX/XXX5/LinLink5.exe

#调试字体
WINEPREFIX=/data/home/dyl/.deepinwine/apps/XXX_1 WINEDEBUG=+font,+tid deepin-wine5-stable /data/home/dyl/.deepinwine/apps/XXX_1/drive_c/Program\ Files/XXXX/XXX5/LinLink5.exe &> /data/home/dyl/fonts.log

WINEPREFIX=/data/home/dyl/.deepinwine/apps/XXX_1 WINEDEBUG=+seh deepin-wine5-stable /data/home/dyl/.deepinwine/apps/XXX_1/drive_c/Program\ Files/XXXX/XXX5/LinLink5.exe

#解决midi声音问题
sudo apt-get install timidity

timidity -iAD -B2,8 -Os1l -s 44100

WINE=/usr/bin/deepin-wine5-stable WINEPREFIX=/home/dyl/.deepinwine/apps/XXX_1 winetricks -q directmusic gmdls


解决dotnet40安装卡死问题

1
2
3
LC_ALL=en_US.UTF-8 WINEPREFIX=/home/dyl/.deepinwine/apps/XXXXXX_1 WINEDEBUG=+seh deepin-wine5-stable /home/dyl/.deepinwine/apps/XXXXXX_1/drive_c/yscq_tanwan/Update.exe

WINE=/usr/bin/deepin-wine5-stable WINEPREFIX=/home/dyl/.deepinwine/apps/XXXXXX_1 winetricks -q dotnet40 gdiplus

多版本PHP共存的Debian系统中,特定版本的xdebug支持特定PHP版本,所以需要安装不同的版本的xdebug

前提条件: Debian系统 已安装php7.3-dev php7.4-dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#设定默认php环境变量为7.3
sudo update-alternatives --set php /usr/bin/php7.3
sudo update-alternatives --set phpize /usr/bin/phpize7.3
sudo update-alternatives --set php-config /usr/bin/php-config7.3
#安装xdebug 2.9.8
sudo pecl -d php_suffix=7.3 install http://pecl.php.net/get/xdebug-2.9.8.tgz
sudo pecl uninstall xdebug

#设定默认php环境变量为7.4
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4
#安装xdebug 3.0.2
sudo proxychains pecl -d php_suffix=7.4 install http://pecl.php.net/get/xdebug-3.0.2.tgz
sudo pecl uninstall xdebug

配置Xdebug 3

安装完成后进入php.ini配置文件,在Dynamic Extensions下添加以下代码,方便开发和调试

1
2
zend_extension=xdebug.so
xdebug.mode=develop,debug

国内用户可以使用上海交通大学的flatpak源,修改代码如下:

1
sudo flatpak remote-modify flathub --url=https://mirror.sjtu.edu.cn/flathub
0%