python
1.1python库管理
#pip版本更新
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
#python库下载
pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
#python库更新
pip install --upgrade pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
#python库卸载
pip uninstall sip
2.1,python环境管理
#创建新的python环境
conda create --name product39 python=3.9.7
#将环境装到指定位置
conda create --prefix=C:\ProgramData\Anaconda3\envs\product39 python=3.9.7
#查看环境
conda info --envs
#激活进入环境、切换环境
conda activate python39
#移除环境
conda remove -n pytorch --all
#显示镜像源
conda config --get channels
#添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
3,pip管理使用
#更改镜像源,升级 pip 至最新版本(>= 10.0.0),执行配置设置
pip install pip -U -i https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
#生成第三方库文件
pip freeze > requirements.txt
#pip卸载
pip uninstall pagename
3,exe文件打包
#打包为单文件 -F ;-w显示控制台内容;-i显示图标
Pyinstaller -F -w main.py
Pyinstaller -F -w -i \\aaa.ico main.py
#打包为多文件 -D
Pyinstaller -D main.py
4,python常用库安装
#将库安装到指定python环境(环境混乱时候使用)
C:\Users\15023\AppData\Local\Programs\Python\Python38-32\python.exe -m pip install xlwt -i https://pypi.tuna.tsinghua.edu.cn/simple
#安装opencv
pip install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple
#安装xlwt
pip install xlwt -i https://pypi.tuna.tsinghua.edu.cn/simple
#安装pywin
pip install pywin32 -i https://pypi.tuna.tsinghua.edu.cn/simple
5,pyqt5安装
#sip的安装:
pip install sip==12.10.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
#pyqt5的安装(指定pyqt5的版本,pip install pyqt5==5.10.1 指定版本为5.10.1,在这个版本是支持内置QtWebEngineWidgets的,可以直接使用)
pip install PyQt5==5.15.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
#pyqt5-tools的安装
pip install pyqt5-tools==5.15.4.3.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
#UI文件转Py文件
pyuic5 -o index.py index.ui
Hexo
#新建博客
hexo init 博客名
#进入博客
cd 博客名
#新增文章(默认目录:source>_posts)
hexo new 文章名字
#清理
hexo clean
#生成
hexo g
#上传
hexo d
linux
1,centos
- python环境管理
#centos中python环境管理
#1,查看指定环境中的库
python3.9 -m pip list
#2,创建虚拟环境
python3.9 -m venv product39
#3,激活虚拟环境
source product39/bin/activate
#4,退出虚拟环境
deactivate
- 防火墙管理
#1,启动防火墙:
systemctl start firewalld
#2.关闭防火墙:
systemctl stop firewalld
#3,查看防火墙状态:
systemctl status firewalld
或
firewall-cmd --state
#4,防火墙重启
systemctl restart firewalld.service
#5,查看防火墙开放的端口
netstat -aptn
- mysql安装
#mysql
#一、mysql安装
#1,下载并安装 MySQL 官方的 Yum Repository(直接下载了安装用的Yum Repository,大概25KB,然后就可以直接yum安装)
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
#2,进行repo的安装(执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件 mysql-community.repo mysql-community-source.repo之后就开始安装MySQL服务器)
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
#3,安装mysql服务
yum install mysql-server
#4,mysql服务管理
systemctl start mysqld # 启动MySQL服务
systemctl status mysqld # 查看MySQL服务状态
systemctl enable mysqld # 设置MySQL服务自启动
#5,mysql密码初始化(一般刚安装密码为空,直接输入mysql -uroot -p后按enter即可进入修改密码)
grep "password" /var/log/mysqld.log # 查找安装后的初始密码,"root@localhost:"后都是密码
mysql -uroot -p # 用初始密码登录数据库
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'; # 修改密码
#6,mysql远程连接配置
mysql -uroot -p # 登录数据库
use mysql; # 进入mysql库
select user,host from user; # 查看用户和访问权限
update user set host='%' where user = 'root';#修改权限
flush privileges; # 刷新权限
#7,服务器端口开放配置
firewall-cmd --zone=public --add-port=3306/tcp --permanent # 开放3306端口
firewall-cmd --reload # 刷新防火墙
firewall-cmd --zone=public --list-ports # 查看开放端口列表
#二、mysql相关配置信息
#1,myslq下文件位置
/etc/my.cnf #myslq下配置文件位置
/var/log/mysql#mysql日志位置
/var/lib/mysql#mysql数据库位置
常用命令:
查看开放的端口列表
firewall-cmd --zone=public --list-ports
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zhM5Z2yc-1668081395168)(C:\Users\15023\AppData\Roaming\Typora\typora-user-images\image-20210121180900683.png)]
查看系统信息:
lscpu : 查看cpu参数
cat /proc/meminfo |grep MemTotal :查看内存大小
fdisk -l |grep Disk :硬盘大小
uname -a : 查看内核/操作系统/CPU信息的linux系统信息命令
cat /etc/issue : 操作系统发行版本
#进程信息
netstat -lntp #查看监听(Listen)的端口
netstat -antp #查看所有建立的TCP连接
netstat -tulpn #查看所有运行中的服务的详细信息
ps -ef #查看所有进程
ps -aux #查看使用内存的进程
top #查看内存使用说明 (shift+m 按照排名)
kill -pid #结束进程:
2,ubuntu
1,安装anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh #下载安装包
bash Anaconda3-2023.03-1-Linux-x86_64.sh #解压安装包,然后一直enter即可
cd /root/anaconda3
conda list #进入默认安装位置后/root/anaconda3后输入conda list检查是否安装成功
vi ~/.bashrc #输入该命令然后按下i在文件最后一行添加export PATH=/root/anaconda3/bin:$PATH然后按esc,再输入“:”号,再输入wq后按下enter即可完成环境变量编辑
source ~/.bashrc #让环境变量生效
2,防火墙配置
sudo ufw status #查看防火墙的状态, “Status: inactive”状态:不活跃,上面提示表示没有开启防火墙
sudo ufw enable #开启防火墙
sudo ufw allow 22 #开放22端口
sudo ufw reload #重启ufw防火墙
sudo netstat -tunlp | grep 22 #查看22端口信息
telnet 192.168.121.135 22#端口属于监听状态,在Windows下能够telnet通
3,redis安装
sudo apt update #更新软件包
sudo apt-get install redis-server #下载redis服务
sudo vi /etc/redis/redis.conf #编辑配置文件,修改密码,开启远程访问
#找到requirepass foobared这一行,将注释符号#去掉,将后面修改成自己的密码,例如,设置密码为123abc,并注释掉使用注释符号#注释bind 127.0.0.1这行,开启远程访问
requirepass 123abc #配置完成后保存退出
/etc/init.d/redis-server start #启动
/etc/init.d/redis-server stop #关闭
/etc/init.d/redis-server restart #重启
redis-cli #输入redis-cli通过默认客户端来测试连接
auth 密码 #进行密码认证
ping #输入ping会返回pang 安装结束
解压缩:
.tar.gz 和 .tgz
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.gz DirName
*
如果文件后缀是.tar 用tar xvf来解压*``
*如果文件后缀是.tar.gz 用tar xzvf来解压*
*如果文件后缀是.tar.bz 用tar xjvf来解压*
文件夹操作:
cd / :进入根目录
cd 、cd ~ 、cd /home :进入前用户的家目录
pwd : 显示当前目录路径
cd …:返回上一级目录
cd …/… :返回上一级目录
ls :查看目录中的文件夹
ls -a:查看目录中隐藏文件
ls -alh
tree :显示文件和目录由根目录开始的树形结构
mkdir dir1 : 创建一个叫做 ‘dir1’ 的目录’
rmdir dir1 :删除一个叫做 ‘dir1’ 的目录’
rm -f
rm -r
less 文件名: 打开文件夹
文件操作:
touch backup.sh : 创建.sh命令
chmod +x backup.sh :给当前
Shell命令:
touch backup.sh #创建sh文件
chmod +x ./test.sh #使脚本具有执行权限
./test.sh #执行脚本
rm test.sh #删除文件
文件搜索:
find / -name MySQL-5.6.45-1.el7.x86_64.rpm-bundle.tar : 从 ‘/’ 开始进入根文件系统搜索文件和目录
find / -name mysqldb -print #查找mysqldb软件所在目录
sz 文件名:下载文件
q :直接退出
wq :保存并退出
java -jar general-0.0.1-SNAPSHOT.jar
脚本:
ubuntu开机自启动jar
cd /etc/init.d #切换到/etc/init.d目录下
touch autoJar.sh #创建文件
chmod +x ./autoJar.sh
###############脚本内容####################
#!/bin/sh
### BEGIN INIT INFO
# Provides: autoJar.sh
# Required-start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the svnd.sh daemon
# Description: starts svnd.sh using start-stop-daemon
### END INIT INFO
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${JAVA_HOME}/bin:$PATH
cd /home/hospital/jar
nohup java -jar rpush-0.1.1-SNAPSHOT.jar &
###设置脚本文件的权限
sudo chmod 755 /etc/init.d/svnd.sh
###将脚本放到启动脚本中去
cd /etc/init.d
sudo update-rc.d autoJar.sh defaults 95
启动项目脚本:
sh bin/stop.sh
git pull
nohup mvn spring-boot:run -Drun.profiles=prod &
tailf nohup.out
项目停止脚本:
#!/bin/bash
PID=$(ps -ef | grep general-0.0.1-SNAPSHOT | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
echo general-0.0.1-SNAPSHOT is already stopped
else
echo kill $PID
kill $PID
fi
设置后台进程:
nohup java -jar /home/codeStore/general-0.0.1-SNAPSHOT.jar &
nohup java -jar /home/admin/codestore/信访局/xfj.jar &
/home/codestore/nohup java -jar /home/codestore/general-0.0.1-SNAPSHOT.jar &
查看启动的进程:
ps -ef | grep java
杀死指定进程:
kill -9 进程号
服务器:47.105.118.98
用户名:root
密码: thisishuitengit.com-py
服务器: 182.92.233.162
用户名:root
密码:yangl123@
2,CentOS8 安装MySQL5.6:
3,CentOS7安装MySQL(详解)
3,idea连接centos:
7,centos安装jdk1.8(https://blog.youkuaiyun.com/weixin_42140801/article/details/107859925)
工具:
pscp:
jenkins:
支持持续化集成、界面操作
tumx:
- 选项卡切换
- 可以连接本地或远程的 sessions
- 强大的 window 和 pane 管理
- 在不同的 session 之间移动 window
- 自动化脚本
ctrl+w ctrl+b+w
ll
tmux new -s session_name : 建立一个新会话
#将war上传到linux的指定位置
pscp -P 22 -pw yangl123@ C:\Users\15023\Desktop\项目开发\spoot脚手架\springboo_2\general\target\general-0.0.1-SNAPSHOT.jar root@182.92.233.162:/home/codeStore
pscp -P 22 -pw thisishuitengit.com-py C:\Users\15023\Desktop\项目开发\spoot脚手架\springboo_2\general\target\general-0.0.1-SNAPSHOT.jar root@47.105.118.98:/home/admin/codestore
pscp -P 22 -pw yangl123, C:\Users\15023\Desktop\项目开发\惠济3.0\huijiH\target\general-0.0.1-SNAPSHOT.jar root@123.57.250.180:/home/codestore
pscp -P 22 -pw yangl123, C:\Users\15023\Desktop\项目开发\惠济3.0\huijiS\target\general-0.0.1-Sj.jar root@123.57.250.180:/home/codestore
C:\Users\15023\Desktop\项目开发\惠济3.0\huijiS\target\general-0.0.1-Sj.jar
#备份数据库
db_user="root"
db_pwd="999699"
db_name="kjzb"
bak_dir="/root/mysql_bak"
time="$(date +"%Y%m%d_%H%M%S")"
/usr/bin/mysqldump -u$db_user -p$db_pwd --skip-lock-tables -h39.96.64.186 -P3306 $db_name > $bak_dir/${db_name}_$time.sql
#remove out-date backup
find $bak_dir -name "$db_name*.sql" -type f -mtime +30 -exec rm -rf {} \; > /dev/null 2>&1
#设置定时任务
crontab -e
vim /etc/crontab (unbunt)
0 0 2 * * * /root/mysql_bak/backup.sh(centos定时时间格式)
0 2 * * * /root/mysql_bak/backup.sh(unbunt定时时间格式)
#查看定时任务
crontab -l
crontab -e配置完成后,如何把保存并退出?
1.Ctrl+o 写入
2.出现“FIile name to Write...”,输入Enter
3.Ctrl+x 保存输出
提示“crontab:installing new crontab”表示成功
#设置mysql软连接
ln -fs /usr/bin/mysqldump /usr/bin
ln -fs /usr/bin/mysql/usr/bin
hostnamectl set-hostname yyc
Nginx
前言:
基本配置:
常用命令:
- 进入ndinx的sbin目录:
- 查看nginx版本号: ./nginx -v
- 启动nginx:. /nginx
- 关闭nginx:./nginx -s stop
- 重新加载nginx :./nginx -s reload
ubuntu:
- 查看版本: nginx -v
- 检测语法:nginx -t
- 启动 :nginx
- 关闭:nginx -s stop
- 查看端口号: netstat -ntpl
nginx文件安装完成之后的文件位置: - /usr/sbin/nginx:主程序 - /etc/nginx:存放配置文件 - /usr/share/nginx:存放静态文件 - /var/log/nginx:存放日志
配置文件:
1),配置文件位置:
/home/development/nginx/conf/nginx.conf
2),nginx配置文件组成
第一部分:全局块
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GodxH0US-1668081449582)(C:\Users\15023\AppData\Roaming\Typora\typora-user-images\image-20200914093411014.png)]
第二部分:events块
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ysjG4MfA-1668081449583)(C:\Users\15023\AppData\Roaming\Typora\typora-user-images\image-20200914093445864.png)]
第三部分:http块
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uyH2tISf-1668081449584)(C:\Users\15023\AppData\Roaming\Typora\typora-user-images\image-20200914093457421.png)]
1,反向代理——实例
1),正向代理
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pdbFSNfw-1668081449585)(file:///C:\Users\15023\AppData\Roaming\Tencent\Users\1502391406\QQ\WinTemp\RichOle\MYHXPN[OQYSDU{`XRP57M@R.png)]
2),反向代理
代理服务器地址,隐藏了真实服务器IP地址。我们只需要将请求发送到反向代理服务器,由反向代理服务器去选择目标服务器获取数据
后,在返回给客户端,此时反向代理服务器和目标服务器对外就是一个服务器,暴露的是代理服务器的地址,隐藏真实服务器的地址。
1,在windows系统的·host文件进行域名和ip对应关系的配置
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QZz47i0T-1668081449586)(C:\Users\15023\AppData\Roaming\Typora\typora-user-images\image-20200914171403346.png)]
2,
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Nrik1nDq-1668081449587)(C:\Users\15023\AppData\Roaming\Typora\typora-user-images\image-20200915172921651.png)]
2,负载均衡——实例
3,动静分离——实例
4,高可用集群——实例
5,执行原理
附录:
(centos8 安装 nginx的详细教程)[https://www.jb51.net/article/175280.htm]
(Ubuntu安装Nginx)[https://www.cnblogs.com/sunleejon/p/12389442.html]
注:命令中不要出现中文
文章参考: