dnf -y remove rpmconf yum-utils epel-release
2. 安装最新系统的重要三个内核文件,选取自己系统适合的内核文件(Centos自行在官方的BaseOS查找)#Rocky Linux 8 _x64
dnf -y install https://os.iso.st/r9/minimal/Packages/rocky-release-9.0-2.1.el9.noarch.rpm https://os.iso.st/r9/minimal/Packages/rocky-repos-9.0-2.1.el9.noarch.rpm https://os.iso.st/r9/minimal/Packages/rocky-gpg-keys-9.0-2.1.el9.noarch.rpm
#Rocky Linux 8 _aarch64
dnf -y install https://os.iso.st/r9arch/minimal/Packages/rocky-release-9.0-2.1.el9.noarch.rpm https://os.iso.st/r9arch/minimal/Packages/rocky-repos-9.0-2.1.el9.noarch.rpm https://os.iso.st/r9arch/minimal/Packages/rocky-gpg-keys-9.0-2.1.el9.noarch.rpm
显示下图即可进行下一步dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync
等待时间根据网络情况或许很久,请耐心等待;rm -rf /usr/share/redhat-logos
②:file ... epel-rpm-macros-systemd.el8 .... el9 类似的长文,等同上述,存在兼容问题,卸载稍后重装即可dnf remove -y epel-rpm-macros-systemd
此处根据CPU性能,可能会等待许久。等待结束即表示升级成功。rpm -qa | grep kernel
输出如下:[root@sp ~]# rpm -qa | grep kernel
警告:Found bdb_ro Packages database while attempting sqlite backend: using bdb_ro backend.
kernel-tools-libs-5.14.0-70.13.1.el9_0.x86_64
kernel-srpm-macros-1.0-11.el9.noarch
kernel-headers-5.14.0-70.13.1.el9_0.x86_64
kernel-modules-5.14.0-70.13.1.el9_0.x86_64
kernel-modules-4.18.0-372.13.1.el8_6.x86_64
kernel-core-4.18.0-372.16.1.el8_6.x86_64
kernel-core-4.18.0-372.13.1.el8_6.x86_64
kernel-4.18.0-372.16.1.el8_6.x86_64
kernel-4.18.0-372.13.1.el8_6.x86_64
kernel-devel-4.18.0-372.16.1.el8_6.x86_64
kernel-5.14.0-70.13.1.el9_0.x86_64
kernel-tools-5.14.0-70.13.1.el9_0.x86_64
kernel-modules-4.18.0-372.16.1.el8_6.x86_64
kernel-core-5.14.0-70.13.1.el9_0.x86_64
kernel-devel-5.14.0-70.13.1.el9_0.x86_64
kernel-devel-4.18.0-372.13.1.el8_6.x86_64
上面出现警告,我们需要重建rpm仓库cd /var/lib/rpm
rm -f __db.00*
rpm --rebuilddb
重新运行即可正常;对于输出存在5.x内核的,直接卸载旧内核rpm -e --nodeps `rpm -qa|grep -i kernel|grep 4.18`
如果没有5.x内核,进行内核安装在卸载即可dnf -y install kernel kernel-core shim
5. 此时有人注意到执行dnf命令时,会有如下报错dnf module disable perl:5.26 perl-IO-Socket-SSL:2.066 perl-libwww-perl:6.34 python36:3.6
再次执行dnf即可正常dnf update -y
reboot
sudo dnf –y upgrade
升级完成后,重新启动系统以确保变更生效,包括与内核相关的变更。sudo reboot
2、获取migrate2rocky转换脚本 Rocky Linux 提供了一个名为migrate2rocky的工具,该工具已在许多RHEL变体版本(比如CentOS、Alma Linux和Oracle Linux)上成功地测试。migrate2rocky脚本可用于轻松地就地迁移到 Rocky Linux。curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh
(2)使脚本可执行。chmod +x migrate2rocky.sh
3、开始从CentOS迁移到Rocky Linux的过程sudo bash migrate2rocky.sh –r
Preparing to migrate CentOS Linux 8 to Rocky Linux 8. Determining repository names for CentOS Linux 8.... Found the following repositories which map from CentOS Linux 8 to Rocky Linux 8: CentOS Linux 8 Rocky Linux 8 appstream appstream baseos baseos extras extrassudo dnf distro-sync -y
sudo reboot
4、 检查操作系统版本 为了确认您已成功迁移到Rocky Linux,请检查操作系统版本。cat /etc/redhat-release
Rocky Linux release 8.5 (Green Obsidian)
sudo pacman -Syu :进行全面系统更新(即通俗意义的"滚")
sudo pacman -Sy: 刷新本地镜像源
sudo pacman -Syy : 强制刷新本地镜像源
sudo pacman -S packagename : 安装指定软件
sudo pacman -Sy packagename : 刷新数据库后安装指定软件
sudo pacman -Sv packagename : 显示一些操作信息后安装指定软件
sudo pacman -U pkg.tar.xz :安装本地包
sudo pacman -U link.tar.xz :安装远程包
sudo pacman -R packagename :删除指定软件,保留其全部已经安装的依赖关系
sudo pacman -Rs packagename :删除指定软件,并删除仅与该软件存在依赖关系的其他软件
sudo pacman -Rsc packagename :删除指定软件,并删除所有与该软件存在依赖关系的其他软件
sudo pacman -Rd packagename :删除指定软件,不检查依赖
sudo pacman -Ss keyword:在仓库中搜索含关键字的软件
sudo pacman -Qs keyword:在已安装软件中搜索含关键词的软件
sudo pacman -Qi packagename:搜索指定软件的详细信息
sudo pacman -Ql packagename:列出指定软件的文件
sudo pacman -Sw packagename:只下载指定软件而不安装
sudo pacman -Sc :清理未安装的软件包
sudo pacman -Scc :清理所有的缓存文件
<?php
class Daemon {
private $pidfile;
function __construct() {
$this->pidfile = dirname(__FILE__).'/daemontest.pid';
}
private function startDeamon() {
if (file_exists($this->pidfile)) {
echo "The file $this->pidfile exists.\n";
exit();
}
$pid = pcntl_fork();
if ($pid == -1) {
//这里是创建进程失败
die('could not fork');
} else if ($pid) {
//这里是父进程
echo 'start ok';
exit($pid);
} else {
//这里是子进程
file_put_contents($this->pidfile, getmypid());
return getmypid();
}
}
private function start(){
$pid = $this->startDeamon();
while (true) {
//在这里写你的业务代码,比如每隔1秒钟,往当前目录下的test.txt文件里面添加当前时间
file_put_contents(dirname(__FILE__).'/test.txt', date('Y-m-d H:i:s'), FILE_APPEND);
sleep(1);
}
}
private function stop(){
if (file_exists($this->pidfile)) {
$pid = file_get_contents($this->pidfile);
posix_kill($pid, 9);
unlink($this->pidfile);
}
}
public function run($argv) {
if($argv[1] == 'start') {
$this->start();
}else if($argv[1] == 'stop') {
$this->stop();
}else if($argv[1] == 'restart'){
$this->stop();
$this->start();
}else{
echo 'param error';
}
}
}
$deamon = new Daemon();
$deamon->run($argv);
启动:php Daemon.php start
停止:php Daemon.php stop
重启:php Daemon.php restart
二、使用linux命令来实现守护进程<?php
while(true){
//在这里写你的业务代码,比如每隔1秒钟,往当前目录下的test.txt文件里面添加当前时间
file_put_contents(dirname(__FILE__).'/test.txt', date('Y-m-d H:i:s'), FILE_APPEND);
sleep(1);
}
普通运行方式:php test.php
守护进程运行方式:nohup php test.php &
查看进程端口:netstat -lnpt
杀死进程:kill -9 pid
我们通过nohup命令和&结合,就可以实现守护进程运行php脚本了,非常方便。from PIL import Image
img = Image.open(img_path)
img.save(img_path2)
import cv2
img = cv2.imread(img_path)
cv2.imwrite(img_path2, img)
import base64
def img_base64(img_path):
with open(img_path,"rb") as f:
base64_str = base64.b64encode(f.read())
return base64_str
import cv2
from PIL import Image
import numpy as np
def pil_cv2(img_path):
image = Image.open(img_path)
img = cv2.cvtColor(np.asarray(image),cv2.COLOR_RGB2BGR)
return img
import cv2
from PIL import Image
def cv2_pil(img_path):
image = cv2.imread(img_path)
image = Image.fromarray(cv2.cvtColor(image,cv2.COLOR_BGR2RGB))
return image
import base64
from io import BytesIO
def pil_base64(image):
img_buffer = BytesIO()
image.save(img_buffer, format='JPEG')
byte_data = img_buffer.getvalue()
base64_str = base64.b64encode(byte_data)
return base64_str
import base64
from io import BytesIO
from PIL import Image
def base64_pil(base64_str):
image = base64.b64decode(base64_str)
image = BytesIO(image)
image = Image.open(image)
return image
import cv2
def cv2_base64(image):
base64_str = cv2.imencode('.jpg',image)[1].tostring()
base64_str = base64.b64encode(base64_str)
return base64_str
import base64
import numpy as np
import cv2
def base64_cv2(base64_str):
imgString = base64.b64decode(base64_str)
nparr = np.fromstring(imgString,np.uint8)
image = cv2.imdecode(nparr,cv2.IMREAD_COLOR)
return image
pstree -ap|grep gunicorn
得到如下的结果。|-grep,6194 --col gunicorn
| `-gunicorn,30080 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,4413 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,8030 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,8135 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,8137 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,11532 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,13460 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,19728 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,23585 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,23825 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,27921 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,28899 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,28900 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,28901 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,35637 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,36963 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43074 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43118 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43232 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43307 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43308 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,44018 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,46996 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,47000 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| `-gunicorn,47650 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
很显然,30080就是Gunicorn的主进程。kill -HUP 30080
执行上述命令后,再次执行"pstree -ap|grep gunicorn",我们很容易发现,除了主进程,其他的Gunicorn进程都已经销毁,并新建了进程(进程ID发生了变化)。kill -9 30080
或者killall -9 gunicorn
pip install redis-py-cluster
or
pip install rediscluster
from rediscluster import StrictRedisCluster
startup_nodes = [
{"host":"192.168.3.25", "port":6379}, # 主
{"host":"192.168.3.25", "port":7001}, # 6379的从数据库
{"host":"192.168.3.25", "port":6380}, # 主
{"host":"192.168.3.25", "port":7002}, # 6380的从数据库
{"host":"192.168.3.25", "port":6381}, # 主
{"host":"192.168.3.25", "port":7003} # 6381的从数据库
]
conn = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
conn.set('name', 'lowman')
conn.set('kind', '屌丝')
conn.set('money', '3块8')
print("My name is: ", conn.get('name'))
print "I have money: ", conn.get('money')
其他的各项操作方法与 python 的 redis 库保持一致. startup_nodes 参数中即使存在 错误节点参数 也能连接成功: 理论上, 只要保证有一个节点参数正确就可以正常连接Use the -o option:
scp -o "StrictHostKeyChecking no" 1.txt user@host:1.txt
ssh -o "StrictHostKeyChecking no" user@host
hot key
ctrl + enter 执行sql
ctrl + shift + ↑ 向上复制一行
ctrl + shift + ↓ 向下复制一行
ctrl + alt + F 对sql语句进行格式化,对于很长的sql语句很有用
ctrl + d 删除当前行
alt + ↑ 向上选定一条sql语句
alt + ↓ 向下选定一条sql语句
ctrl + / 行注释
ctrl + shift+ / 块注释
ctrl + f 查找、替换
ctrl + space sql提示(如果写了from table后也会自动提示field)
ctrl + shift + E 执行计划
ctrl + shift + U 将选定的sql转换成大写字母
ctrl + shift + L 将选定的sql转换成小写字母
小技巧