Vagrant的VBoxGuestAddition版本升级(debian)

在升级VirtualBox以后,vagrant up的时候GuestAddition版本不对。需要重新安装VBoxGutestAddtion.

手动安装:

1 vagrant up先启动虚拟机(debian), 然后ssh进入,切换到/opt/VBoxGuestAddtion-x.x.x下,用sudo 运行unistanll.sh

2 下载新的版本 , 比如

wget http://download.virtualbox.org/virtualbox/5.2.18/VBoxGuestAdditions_5.2.18.iso

然后mount 这个iso, 进行安装

sudo mkdir -p /mnt/disk
sudo mount -o loop VBoxGuestAdditions_5.2.18.iso /mnt/disk
cd /mnt/disk
sudo ./VBoxLinuxAdditions.run
sudo reboot

退出后重新启动vagrant up 就提示正常了。

今天的收获

定了新机器,在ubuntu18上装了php5.6,然后发现数据库5.7不行,然后看了教程1手动安装了mysql 5.5 (教程地址在最后)然后在设计root密码上耽误点时间,看了教程2后,手动设置了root密码.

教程1 手动降级mysql5.7到5.5
https://askubuntu.com/questions/763240/is-it-possible-to-install-mysql-5-5-or-5-6-on-ubuntu-16-04

教程2 手动覆盖mysql root密码.注意5.7 和5.5用来保存密码的字段的不同
https://www.techrepublic.com/article/how-to-set-change-and-recover-a-mysql-root-password/

mysql 5.7优化

从5.4升级到5.7以后,明显变慢了.看了这篇 文章获得启示,对slow query里面的query进行了优化,主要就是建立联合索引,针对多重条件组合的字段建立联合索引. 问题解决.

折腾老机器

最近得了2块硬盘,想转到一台10年前的ahtlon 64×2 的机器上。开始折腾debian 9.

难点 1: 老主板bios无法从U盘引导,只能装上个光驱,烧了张安装盘。

难点2: 安装过程中网络不可用

难点3 最小安装后,很多软件没有. 需要设定apt然后安装sudo openssh server等等 可以参考 

1 先添加源

https://codeday.me/bug/20181113/370589.html 

那难点4 安装驱动后显示花屏. 

PCIe SSD预习

最近准备给自己的老2008 late的mac pro上ssd, 所以先研究一下。

主板上4个SATA都被占用了,而且通过SATA走SSD没太大意义。所以准备走PCIe. 没想到PCIe也好多名堂。 下面这片文章讲解的稍微透彻。

https://blog.csdn.net/u010109732/article/details/79032845

看按来我只能使用走PCIe通道,使用AHCI协议的产品。因为使用NVME协议 存在不能启动等问题。使用AHCI相比SATA还能快点(600到1000)。

有外国网友推荐了几款PCIe 2的转接卡和AHCI的.M2 SSD.

添加和删除shell设置的变量

最近发现使用git时候报错

fatal: unable to access 'https:///.git/': Failed to connect to 127.0.0.1 port 1080: Connection refused

本地的这个1080估计是安装ss的时候设置的.查看 export, 可以看到

 declare -x ALL_PROXY="socks://127.0.0.1:1080/"
//在命令行输入这个名利,立马消除proxy设置 (2个都消除)
unset ALL_PROXY
unset all_proxy
//如果要重新设置
export ALL_PROXY=socks5://127.0.0.1:1080

在unbuntu上安装不同版本的php并进行手动切换

实验的版本是php5.6, 7.0. 7.1, 7.2 7.3

参考教程 https://www.ostechnix.com/how-to-switch-between-multiple-php-versions-in-ubuntu/

主要使用了update-alternatives 这个工具

Switch Between Multiple PHP Versions
To check the default installed version of PHP, run:
 
You don’t need to remove PHP7.x or reinstall LAMP stack. You can use both PHP5.x and 7.x versions together.

I assume you didn’t uninstall php5.6 in your system yet. Just in case, you removed it already, you can install it again using a PPA like below.

You can install PHP5.6 from a PPA:

$ sudo add-apt-repository -y ppa:ondrej/php
$ sudo apt update
$ sudo apt install php5.6

Switch from PHP7.x to PHP5.x
First disable PHP7.2 module using command:

$ sudo a2dismod php7.2

$ sudo a2enmod php5.6
Set PHP5.6 as default version:

$ sudo update-alternatives --set php /usr/bin/php5.6
Alternatively, you can run the following command to set which system wide version of PHP you want to use by default.

$ sudo update-alternatives --config php
Enter the selection number to set it as default version or simply press ENTER to keep the current choice.

In case, you have installed other PHP extensions, set them as default as well.

$ sudo update-alternatives --set phar /usr/bin/phar5.6
Finally, restart your Apache web server:

$ sudo a2enmod php7.2
$ sudo a2dismod php5.6
$ sudo update-alternatives --set php /usr/bin/php7.2
$ sudo systemctl restart apache2

uuid 低位高位修复SQL

我曾经写过一篇关于php 二进制打包的参数h和H搞错造成的数据录入错误。 对于已经录入的数据,如何修复呢。 有个高手同事写了以下的sql.

UPDATE table_name SET user_uuid_fixed = UNHEX(
CONCAT(
MID(HEX(user_uuid), 2, 1),
MID(HEX(user_uuid), 1, 1),

MID(HEX(user_uuid), 4, 1),
MID(HEX(user_uuid), 3, 1),

MID(HEX(user_uuid), 6, 1),
MID(HEX(user_uuid), 5, 1),

MID(HEX(user_uuid), 8, 1),
MID(HEX(user_uuid), 7, 1),

MID(HEX(user_uuid), 10, 1),
MID(HEX(user_uuid), 9, 1),

MID(HEX(user_uuid), 12, 1),
MID(HEX(user_uuid), 11, 1),

MID(HEX(user_uuid), 14, 1),
MID(HEX(user_uuid), 13, 1),

MID(HEX(user_uuid), 16, 1),
MID(HEX(user_uuid), 15, 1),

MID(HEX(user_uuid), 18, 1),
MID(HEX(user_uuid), 17, 1),

MID(HEX(user_uuid), 20, 1),
MID(HEX(user_uuid), 19, 1),

MID(HEX(user_uuid), 22, 1),
MID(HEX(user_uuid), 21, 1),

MID(HEX(user_uuid), 24, 1),
MID(HEX(user_uuid), 23, 1),

MID(HEX(user_uuid), 26, 1),
MID(HEX(user_uuid), 25, 1),

MID(HEX(user_uuid), 28, 1),
MID(HEX(user_uuid), 27, 1),

MID(HEX(user_uuid), 30, 1),
MID(HEX(user_uuid), 29, 1),

MID(HEX(user_uuid), 32, 1),
MID(HEX(user_uuid), 31, 1)
)
);

UPDATE table_name SET journey_fixed = UNHEX(
CONCAT(
MID(HEX(journey), 2, 1),
MID(HEX(journey), 1, 1),

MID(HEX(journey), 4, 1),
MID(HEX(journey), 3, 1),

MID(HEX(journey), 6, 1),
MID(HEX(journey), 5, 1),

MID(HEX(journey), 8, 1),
MID(HEX(journey), 7, 1),

MID(HEX(journey), 10, 1),
MID(HEX(journey), 9, 1),

MID(HEX(journey), 12, 1),
MID(HEX(journey), 11, 1),

MID(HEX(journey), 14, 1),
MID(HEX(journey), 13, 1),

MID(HEX(journey), 16, 1),
MID(HEX(journey), 15, 1),

MID(HEX(journey), 18, 1),
MID(HEX(journey), 17, 1),

MID(HEX(journey), 20, 1),
MID(HEX(journey), 19, 1),

MID(HEX(journey), 22, 1),
MID(HEX(journey), 21, 1),

MID(HEX(journey), 24, 1),
MID(HEX(journey), 23, 1),

MID(HEX(journey), 26, 1),
MID(HEX(journey), 25, 1),

MID(HEX(journey), 28, 1),
MID(HEX(journey), 27, 1),

MID(HEX(journey), 30, 1),
MID(HEX(journey), 29, 1),

MID(HEX(journey), 32, 1),
MID(HEX(journey), 31, 1)
)
);

佩服。