1490 lines
36 KiB
Markdown
1490 lines
36 KiB
Markdown
---
|
||
title: Linux
|
||
author: 文永达
|
||
top_img:https://gcore.jsdelivr.net/gh/volantis-x/cdn-wallpaper/abstract/00E0F0ED-9F1C-407A-9AA6-545649D919F4.jpeg
|
||
|
||
---
|
||
# Linux
|
||
|
||
---
|
||
|
||
## 简介
|
||
|
||
在linux系统中,没有盘符的概念。
|
||
一个盘。/根目录
|
||
没有图形化界面
|
||
通过指令操作
|
||
|
||
linux指令是可以传参数的。
|
||
|
||
在Linux系统下,万事万物皆文件。
|
||
|
||
## Linux的文件结构(19个)
|
||
|
||
bin:存放的是二进制的可以执行文件。(重点)
|
||
sbin:存放的是二进制的可以执行文件。super,只有root用户才能访问
|
||
etc:存放系统配置文件(重点)
|
||
usr:用来存放共享的系统资源
|
||
home:家目录(重点)
|
||
root:就是root用户的家目录
|
||
dev:存放设备文件
|
||
|
||
## Linux指令
|
||
|
||
Ctrl+u 删除命令行开始至光标处
|
||
|
||
Ctrl+k 删除光标至命令行结尾
|
||
|
||
Ctrl+a 光标移到最前
|
||
|
||
Ctrl+e 光标移到最后
|
||
|
||
ip addr(ip a):查看主机的ip地址
|
||
clear:清屏
|
||
|
||
### 跳转目录:
|
||
|
||
```shell
|
||
# 跳转指定目录 root目录下的www
|
||
cd /root/www
|
||
# 返回跳转前的目录
|
||
cd -
|
||
# 跳转上一级目录
|
||
cd ../
|
||
# 跳转根目录
|
||
cd /
|
||
# 跳转root目录
|
||
cd ~
|
||
```
|
||
|
||
### 复制粘贴:
|
||
|
||
```shell
|
||
# 把aa.txt复制到init目录下
|
||
cp aa.txt init/
|
||
# 把init文件夹以及所包含的文件复制到 spring文件夹下
|
||
cp -r init spring/
|
||
```
|
||
|
||
|
||
|
||
ls:列出当前目录下的所有文件及目录
|
||
ls -l:给ls指令传了一个参数l。等同于ll。列出当前目录下的所有文件及目录的详情。
|
||
ls bin:ls后可以接目录名,要么接绝对路径。
|
||
tab键:提示作用。自动补全。
|
||
cd (cd ~):代表回到家目录
|
||
pwd:查看当前所在的目录
|
||
方向键↑和↓:浏览历史指令
|
||
|
||
mkdir:创建目录
|
||
mkdir -p:创建多级目录
|
||
cp aa.txt init:复制粘贴。把aa.txt复制到init目录下
|
||
cp -r init spring:复制粘贴。把init目录以及包含的文件复制到spring目录下
|
||
mv aa.txt xiaoqiang.txt:重命名。把aa.txt重命名为xiaoqiang.txt。
|
||
mv bb.txt spring:移动。把bb.txt移动到spring目录。
|
||
mv -f spring aaaaa:在覆盖前不提示
|
||
mv -r aaaaa bbbbb:强行覆盖。前提是被覆盖的目录和覆盖的目录要结构相同。(慎用)
|
||
rm xiaoqiang.txt:删除xiaoqiang.txt
|
||
rm -f spring.xml:强行删除spring.xml,没有确认提示
|
||
rm -r init:递归删除init目录
|
||
rm -rf bbbbb:递归删除bbbbb并且没有确认提示(慎用)
|
||
rmdir aa:删除空目录aa(用的很少)
|
||
rm -rf *:删除所有的目录及文件(慎用)
|
||
|
||
cat:显示文本文件的内容(一部分)。.java,.py,.c++,.xml,.html,.js,.css
|
||
more:分页显示文本文件的内容。只能向下查看,不能向上翻页。
|
||
less:分页显示文本文件的内容。上下翻页。通过PgUp和PgDn进行上下翻页,↑和↓一行一行的查看。输入q退出查看。
|
||
top -n 10 xxxx:查看文本文件的前10行
|
||
tail -n 10 xxxx:查看文本文件的后10行
|
||
tail -f xxxx:实时监控文本文件的变化
|
||
Ctrl + c:几乎可以退出所有的操作
|
||
echo:打印输出一句话。也可以用作向文本文件内写入信息。会自动追加并换行。
|
||
|
||
find: 查找文件夹或目录 find /usr -iname "\*docker\*" 查找/usr目录下 名称为docker 的文件或目录 模糊查询 并忽略大小写
|
||
|
||
### 压缩:
|
||
|
||
1、打包,把多个文件打成一个包。
|
||
2、压缩,把文件占用的大小进行压缩。
|
||
|
||
tar命令:用来进行压缩和解压缩的。
|
||
-c 建立一个压缩文件(打包)
|
||
-x 解开一个压缩文件(解包)
|
||
-z 是否需要使用gzip压缩
|
||
-v 压缩过程中是否显示文件日志
|
||
-f 使用的文件名
|
||
tar -cf:只打包,不压缩,不显示日志
|
||
tar -xf:解压文件,不显示日志
|
||
tar -cvf:只打包,不压缩,显示日志
|
||
tar -xvf:解压文件,显示日志。
|
||
tar -zcvf:打包压缩,显示日志
|
||
tar -zxvf:解压(最常用)
|
||
|
||
### 系统服务:
|
||
|
||
systemstl:操作系统服务。
|
||
status:查看某个服务的状态
|
||
stop:终止某个服务
|
||
start:启动某个服务
|
||
restart:重启某个服务
|
||
|
||
```shell
|
||
systemctl status mysqld
|
||
```
|
||
|
||
网络服务:network
|
||
防火墙服务:firewalld
|
||
Mysql:mysqld
|
||
systemctl status network
|
||
|
||
### 网络状态:
|
||
|
||
```shell
|
||
# -l或--listening 显示监控中的服务器的Socket
|
||
# -n或--numeric 直接使用IP地址,而不通过域名服务器。
|
||
# -p或--programs 显示正在使用Socket的程序识别码和程序名称。
|
||
netstat -lnp | grep 8080
|
||
```
|
||
|
||
### 获取路径:
|
||
|
||
```shell
|
||
readlink -f sample.txt /home/gliu/sample.txt
|
||
realpath -s sample.txt /home/gliu/sample.txt
|
||
find $(pwd) -name sample.txt /home/gliu/sample.txt
|
||
ls -l $PWD/sample.txt
|
||
```
|
||
|
||
## 文件详情:(以home目录为例)
|
||
|
||
d:说明当前文件是一个目录(- 代表的是文件)
|
||
rwx:r,可读;w,可写;x,可执行。(代表当前文件的创建者的权限)
|
||
r-x:代表的是和文件创建者的同组的用户的权限
|
||
r-x:代表的是其他用户
|
||
2:链接数
|
||
root:创建者
|
||
root:创建者所在的组
|
||
6:文件占用空间的大小(字节)
|
||
Apr 11 2018:最后一次修改时间
|
||
home:文件名或目录名
|
||
|
||
## 查找文件
|
||
|
||
### find 命令
|
||
|
||
基本格式:find path expression
|
||
|
||
1. 按照文件名查找
|
||
find / -name httpd.conf # 在根目录下 查找文件httpd.conf,表示在整个硬盘查找
|
||
find /etc -name httpd.conf # 在 /etc 目录下查找文件 httpd.conf
|
||
find /etc -name '\*srm*' # 使用通配符\*(0或者任意多个)。表示在 /etc 目录下查找文件名中含有字符串'srm'的文件
|
||
2. 按照文件特征查找
|
||
find / -amin -10 # 查找在系统中最后10分钟访问的文件(access time)
|
||
find / atime -2 # 查找在系统中最后48小时访问的文件
|
||
find / -empty # 查找在系统中为空的文件或者文件夹
|
||
find / -group cat # 查找在系统中属于 group 为 cat 的文件
|
||
find / -mmin -5 # 查找在系统中最后5分钟里修改过的文件(modify time)
|
||
find / -mtime -1 # 查找在系统中最后24小时里修改过的文件
|
||
find / -user fred # 查找在系统中属于fred这个用户的文件
|
||
find / -size +10000c # 查找出大鱼10000字节的文件(c:字节,w:双字, k:KB, M:MB, G:GB)
|
||
find / -size -1000k
|
||
3. 使用混合查找方式查找文件
|
||
参数有:!, -and(-a), -or(-0)
|
||
find /tmp -size +10000c -and -mtime +2 # 在/tmp目录下查找大于10000字节并在最后2分钟内修改的文件
|
||
find / -user fred -or -user george # 在根目录下查找用户是fred或者george的文本文件
|
||
find /tmp ! -user panda #在/tmp目录中查找所有不属于panda用户的文件
|
||
|
||
|
||
|
||
## 进程管理
|
||
|
||
ps 查看前台进程
|
||
ps -aux 查看所有进程详细信息 UID 用户 PID 进程ID
|
||
ps -ef 查看所有进程详细信息 UID 用户 PID 进程ID PPID 父进程ID
|
||
父进程id为1 为系统进程
|
||
top 动态显示进程
|
||
ps -aux|grep network 查看所有进程详细信息,并搜索network进程
|
||
kill 根据PID,终止进程
|
||
kill -9 强制终止
|
||
|
||
## vi命令 编辑器
|
||
|
||
i 切换到编辑模式
|
||
ESC 切换到命令模式
|
||
:wq 保存并退出
|
||
:q 不保存退出
|
||
:w 保存
|
||
:q! 强制不保存退出
|
||
:wq! 强制保存退出
|
||
a 在光标后插入
|
||
A 在光标当前行的行尾插入
|
||
i 在光标前插入
|
||
I 在光标当前行的行头插入
|
||
:set nu 显示行号
|
||
:set nonu 取消显示行号
|
||
gg 到文本的第一行
|
||
G 到文本的最后一行
|
||
u 后退一步 相当于 Ctrl + z
|
||
Ctrl + r 前进一步
|
||
Shift + zz 保存退出 跟:wq一样
|
||
起始行号,结束行号 del 删除对应范围内的行
|
||
|
||
安装vim编辑器
|
||
|
||
```shell
|
||
yum install -y vim
|
||
```
|
||
|
||
## 配置网络
|
||
|
||
```shell
|
||
cd /etc/sysconfig/network-scripts
|
||
vi ifcfg-ens33
|
||
|
||
TYPE=Ethernet
|
||
PROXY_METHOD=none
|
||
BROWSER_ONLY=no
|
||
BOOTPROTO=dhcp
|
||
DEFROUTE=yes
|
||
IPV4_FAILURE_FATAL=no
|
||
IPV6INIT=yes
|
||
IPV6_AUTOCONF=yes
|
||
IPV6_DEFROUTE=yes
|
||
IPV6_FAILURE_FATAL=no
|
||
IPV6_ADDR_GEN_MODE=stable-privacy
|
||
NAME=ens33
|
||
UUID=08913b58-0bc2-42c5-8b59-6782e0029d7b
|
||
DEVICE=ens33
|
||
ONBOOT=yes
|
||
|
||
# 修改ONBOOT=yes
|
||
systemctl restart network
|
||
|
||
ip addr
|
||
```
|
||
|
||
## 端口映射
|
||
|
||
```shell
|
||
# 将 80 端口 映射到 8080端口上 dport为目标端口 to-port为来源端口
|
||
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80
|
||
# 查看iptables规则
|
||
iptables -t nat -L -n -v
|
||
|
||
##
|
||
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
|
||
pkts bytes target prot opt in out source destination
|
||
12925 4377K DOCKER all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
|
||
0 0 REDIRECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 redir ports 80
|
||
```
|
||
|
||
## 软件安装
|
||
|
||
rpm 本地安装
|
||
yum centos安装软件 需要源
|
||
|
||
安装screenFetch
|
||
|
||
```shell
|
||
#使用wget 下载安装包
|
||
wget https://github.com/KittyKatt/screenFetch/archive/master.zip
|
||
#使用unzip解压,unzip需要安装
|
||
yum install unzip
|
||
unzip master.zip
|
||
#移动
|
||
mv screenFetch-master/screenfetch-dev /usr/bin/screenfetch
|
||
```
|
||
|
||
## wget 下载工具
|
||
|
||
#### 格式
|
||
|
||
wget [参数] [URL地址]
|
||
|
||
wget -O 图片名.png https://www.baidu.com/img/bd_logo1.png
|
||
|
||
#### 记录和输入文件参数
|
||
|
||
| 短格式 | 长格式 | 说明 |
|
||
| ------ | ------------------- | ---------------------------------------------------- |
|
||
| -o | –output-file=FILE | 把记录写到FILE文件中 |
|
||
| -a | –append-output=FILE | 把记录追加到FILE文件中 |
|
||
| -d | –debug | 打印调试输出 |
|
||
| -q | –quiet | 安静模式(没有输出) |
|
||
| -v | –verbose | 冗长模式(这是缺省设置) |
|
||
| -nv | –non-verbose | 关掉冗长模式,但不是安静模式 |
|
||
| -i | –input-file=FILE | 下载在FILE文件中出现的URLs |
|
||
| -F | –force-html | 把输入文件当作HTML格式文件对待 |
|
||
| -B | –base=URL | 将URL作为在-F -i参数指定的文件中出现的相对链接的前缀 |
|
||
| | –sslcertfile=FILE | 可选客户端证书 |
|
||
| | –sslcertkey=KEYFILE | 可选客户端证书的KEYFILE |
|
||
| | –egd-file=FILE | 指定EGD socket的文件名 |
|
||
|
||
#### 下载参数
|
||
|
||
| 短格式 | 长格式 | 说明 |
|
||
| ------ | --------------------- | -------------------------------------------------------- |
|
||
| | –bind-address=ADDRESS | 指定本地使用地址(主机名或IP,当本地有多个IP或名字时使用) |
|
||
| -t | –tries=NUMBER | 设定最大尝试链接次数(0 表示无限制). |
|
||
| -O | –output-document=FILE | 把文档写到FILE文件中 |
|
||
| -nc | –no-clobber | 不要覆盖存在的文件或使用.#前缀 |
|
||
| -c | –continue | 接着下载没下载完的文件 |
|
||
| | –progress=TYPE | 设定进程条标记 |
|
||
| -N | –timestamping | 不要重新下载文件除非比本地文件新 |
|
||
| -S | –server-response | 打印服务器的回应 |
|
||
| | –spider | 不下载任何东西 |
|
||
| -T | –timeout=SECONDS | 设定响应超时的秒数 |
|
||
| -w | –wait=SECONDS | 两次尝试之间间隔SECONDS秒 |
|
||
| | –waitretry=SECONDS | 在重新链接之间等待1…SECONDS秒 |
|
||
| | –random-wait | 在下载之间等待0…2*WAIT秒 |
|
||
| -Y | –proxy=on/off | 打开或关闭代理 |
|
||
| -Q | –quota=NUMBER | 设置下载的容量限制 |
|
||
| | –limit-rate=RATE | 限定下载速率 |
|
||
|
||
|
||
|
||
## 用户
|
||
|
||
who am i 查看当前用户
|
||
who --count 查看当前登录用户数量
|
||
exit 退出登录
|
||
groupadd 创建用户组
|
||
groupdel 删除用户组
|
||
useradd xiaoqiang -g user 创建一个用户xiaoqiang,并指定用户组user
|
||
passwd xiaoqiangf 给xiaoqiang用户指定密码
|
||
su 切换用户 从root切换到其他用户不需要输入密码 如果从其他用户切换到root用户,需要输入密码
|
||
|
||
### 权限管理
|
||
|
||
Linux 下文件有三种权限 r 读 w写 x可执行
|
||
|
||
---
|
||
|
||
```shell
|
||
chmod 755 file
|
||
```
|
||
|
||
## Shell 脚本
|
||
|
||
### 为什么大多数 shell 脚本都包含 #! /bin/bash 在 shell 脚本的开头?
|
||
|
||
“`#!/bin/bash`”这一行被称为`shebang` 行,在某些文献中,它被称为`hashbang` 行,这是因为它以两个字符`hash '#'` 和`bang '!' `开头。
|
||
|
||
```shell
|
||
#! /bin/bash
|
||
|
||
echo 'Hello, World!'
|
||
```
|
||
|
||
当你在脚本的最顶部包含“`#!/bin/bash`”行时,系统知道你想使用 `bash` 作为脚本的解释器。因此,你现在可以直接运行 `hello.sh` 脚本,而无需在其前面加上 `bash`。
|
||
|
||
使用 `#!/bin/bash` 表示该脚本是 `bash shell` 脚本,无论系统上正在使用什么 `shell`,都应该使用 `bash` 作为解释器运行。如果你使用的是 `zsh` 特定的语法,你可以通过添加 `#! /bin/zsh` 作为脚本的第一行。
|
||
|
||
`#!` 和 `/bin/bash` 之间的空格无关紧要。你也可以使用 `#!/bin/bash`。
|
||
|
||
## yum
|
||
|
||
### 改阿里源
|
||
|
||
```shell
|
||
yum install -y wget && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && yum clean all && yum makecache
|
||
```
|
||
|
||
## 安装MySQL
|
||
|
||
有些Linux会自带MariaDB数据库,所以需要先卸载
|
||
|
||
列出安装的MariaDB的包
|
||
|
||
```shell
|
||
rpm -qa | grep mariadb
|
||
```
|
||
|
||
得到查看到的包名
|
||
|
||
卸载包 后面加上包名
|
||
|
||
```shell
|
||
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
|
||
```
|
||
|
||
自此下载MariaDB已经完成了
|
||
|
||
切换到home目录下
|
||
|
||
```shell
|
||
cd /home/
|
||
```
|
||
|
||
安装 wget 并下载yum库
|
||
|
||
```shell
|
||
yum install wget -y
|
||
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
|
||
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
|
||
cd /etc/yum.repos.d/
|
||
vim mysql-community.repo
|
||
```
|
||
|
||
选择要安装的MySQL版本
|
||
|
||
```shell
|
||
[mysql57-community]
|
||
name=MySQL 5.7 Community Server
|
||
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
|
||
enabled=0 // 将这里的0改为1
|
||
gpgcheck=1
|
||
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
|
||
|
||
[mysql80-community]
|
||
name=MySQL 8.0 Community Server
|
||
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
|
||
enabled=1 //将这里的1改为0
|
||
gpgcheck=1
|
||
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
|
||
```
|
||
|
||
enabled=0为禁用对应版本的YUM库,enabled=1为启用,默认8.0的配置为enabled=1,安装5.7的话,我们就把8.0的enabled=1修改为enabled=0,然后把5.7的enabled=0修改为enabled=1
|
||
|
||
安装MySQL并启动
|
||
|
||
```shell
|
||
yum install mysql-community-server
|
||
service mysqld start
|
||
```
|
||
|
||
第一步安装成功之后,然后启动MySQL
|
||
|
||
如果失败了,提示GPG
|
||
|
||
RPM 维护一个单独的密钥环,因为它是一个系统范围的应用程序,而用户的 GPG 公钥环是一个用户特定的文件。要将 MySQL 公钥导入 RPM 密钥环,首先获取密钥,然后使用 rpm --import 导入密钥
|
||
|
||
```shell
|
||
# centos
|
||
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
|
||
|
||
# Ubuntu:
|
||
wget -q -O - https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 | apt-key add -
|
||
|
||
yum install mysql-community-server
|
||
```
|
||
|
||
查看MySQL初始密码
|
||
|
||
```shell
|
||
sudo grep 'temporary password' /var/log/mysqld.log
|
||
```
|
||
|
||
登录MySQL
|
||
|
||
```shell
|
||
mysql -u root -p
|
||
```
|
||
|
||
设置密码的验证强度等级
|
||
|
||
```shell
|
||
set global validate_password_policy=LOW;
|
||
```
|
||
|
||
设置密码长度为6位
|
||
|
||
```shell
|
||
set global validate_password_length=6;
|
||
```
|
||
|
||
修改MySQL初始密码
|
||
|
||
```shell
|
||
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
|
||
```
|
||
|
||
给root权限开启远程登录
|
||
|
||
```shell
|
||
use mysql;
|
||
select user,host from user;
|
||
update user set host = '%' where user = 'root';
|
||
flush privileges;
|
||
```
|
||
|
||
---
|
||
|
||
### AlmaLinux 安装 (dnf包管理器方式)
|
||
|
||
1. 首先确保系统是最新的。
|
||
|
||
```shell
|
||
sudo dnf clean all
|
||
sudo dnf update
|
||
sudo dnf groupinstall "Development Tools"
|
||
```
|
||
|
||
2. 安装 MySQL
|
||
默认情况下,MySQL 在 AlmaLinux 9 基础存储库中可用。 只需使用以下命令安装 MySQL 服务器包 `dnf` 命令:
|
||
|
||
```shell
|
||
sudo dnf install mysql mysql-server
|
||
```
|
||
|
||
设置表名不区分大小写
|
||
|
||
```shell
|
||
vim /etc/my.cnf.d/mysql-server.cnf
|
||
# 在 [mysqld] 中添加
|
||
lower_case_table_names=1
|
||
```
|
||
|
||
初始化后查询是否生效
|
||
|
||
```mysql
|
||
show global variables like '%lower_case%';
|
||
# lower_case_table_names 为 1
|
||
```
|
||
|
||
启动 MySQL 服务并通过运行以下命令使其在启动时自动启动:
|
||
|
||
```shell
|
||
sudo systemctl status mysqld
|
||
sudo systemctl enable --now mysqld
|
||
```
|
||
|
||
确认安装并检查已安装的 MySQL 构建版本:
|
||
```shell
|
||
mysql --version
|
||
```
|
||
|
||
3. 在 AlmaLinux 9 上保护 MySQL。
|
||
默认情况下,MySQL 未加固。 您可以使用 `mysql_secure_installation` 脚本。 您应该仔细阅读以下每个步骤,这些步骤将设置 root 密码、删除匿名用户、禁止远程 root 登录、删除测试数据库和访问安全 MySQL:
|
||
|
||
```shell
|
||
mysql_secure_installation
|
||
```
|
||
|
||
对提示使用以下选项:
|
||
```shell
|
||
Enter current password for root (enter for none): Just press the Enter
|
||
Set root password? [Y/n]: Y
|
||
New password: Enter your password
|
||
Re-enter new password: Repeat your password
|
||
Remove anonymous users? [Y/n]: Y
|
||
Disallow root login remotely? [Y/n]: Y
|
||
Remove test database and access to it? [Y/n]: Y
|
||
Reload privilege tables now? [Y/n]: Y
|
||
```
|
||
|
||
安全后,您可以使用以下命令登录 MySQL shell:
|
||
```shell
|
||
sudo mysql -u root -p
|
||
```
|
||
|
||
要创建数据库、数据库用户并向数据库用户授予所有权限,请运行以下命令:
|
||
```mysql
|
||
CREATE DATABASE test_db;
|
||
CREATE USER 'test_user'@'localhost' IDENTIFIED BY 'your-password';
|
||
GRANT ALL ON tests_db.* TO 'test_user'@'localhost';
|
||
FLUSH PRIVILEGES;
|
||
EXIT
|
||
```
|
||
|
||
|
||
### AlmaLinux 安装 (rpm手动方式)
|
||
|
||
```shell
|
||
mkdir mysql_install
|
||
cd mysql_install
|
||
# 下载安装包
|
||
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.41-1.el7.x86_64.rpm-bundle.tar
|
||
tar -xvf mysql-5.7.41-1.el7.x86_64.rpm-bundle.tar
|
||
|
||
rpm -ivh mysql-community-common-5.7.41-1.el7.x86_64.rpm
|
||
|
||
rpm -ivh mysql-community-libs-5.7.41-1.el7.x86_64.rpm
|
||
|
||
rpm -ivh mysql-community-libs-compat-5.7.41-1.el7.x86_64.rpm
|
||
# 如果出现以下错误
|
||
error: Failed dependencies:
|
||
libcrypto.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64
|
||
libcrypto.so.10(libcrypto.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64
|
||
libssl.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64
|
||
libssl.so.10(libssl.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64
|
||
# 执行
|
||
dnf install -y https://repo.almalinux.org/almalinux/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-4.el8_6.x86_64.rpm
|
||
|
||
rpm -ivh mysql-community-devel-5.7.41-1.el7.x86_64.rpm
|
||
# 如果出现以下错误
|
||
error: Failed dependencies:
|
||
/usr/bin/pkg-config is needed by mysql-community-devel-5.7.41-1.el7.x86_64
|
||
# 执行
|
||
dnf install openssl-devel -y
|
||
|
||
rpm -ivh mysql-community-client-5.7.41-1.el7.x86_64.rpm
|
||
# 如果出现以下错误
|
||
错误:依赖检测失败:
|
||
libncurses.so.5()(64bit) 被 mysql-community-client-5.7.41-1.el7.x86_64 需要
|
||
libtinfo.so.5()(64bit) 被 mysql-community-client-5.7.41-1.el7.x86_64 需要
|
||
# 执行
|
||
dnf install libncurses* -y
|
||
dnf install epel-release -y
|
||
dnf install ncurses-compat-libs -y
|
||
|
||
rpm -ivh mysql-community-server-5.7.41-1.el7.x86_64.rpm
|
||
# 如果出现以下提示
|
||
/usr/lib/tmpfiles.d/mysql.conf:23: Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.
|
||
# 执行
|
||
vim /usr/lib/tmpfiles.d/mysql.conf
|
||
# 将/var/run/mysqld 改为 /run/mysqld
|
||
|
||
# 如果出现以下提示
|
||
error: Failed dependencies:
|
||
libcrypt.so.1()(64bit) is needed by mysql-community-server-5.7.41-1.el7.x86_64
|
||
libcrypt.so.1(GLIBC_2.2.5)(64bit) is needed by mysql-community-server-5.7.41-1.el7.x86_64
|
||
# 执行
|
||
dnf install -y libxcrypt-compat
|
||
|
||
# 如果出现以下提示
|
||
error: Failed dependencies:
|
||
/usr/bin/perl is needed by mysql-community-server-5.7.41-1.el7.x86_64
|
||
perl(Getopt::Long) is needed by mysql-community-server-5.7.41-1.el7.x86_64
|
||
perl(strict) is needed by mysql-community-server-5.7.41-1.el7.x86_64
|
||
dnf install -y perl.x86_64
|
||
# 如果出现以下提示
|
||
error: Failed dependencies:
|
||
net-tools is needed by mysql-community-server-5.7.41-1.el7.x86_64
|
||
# 执行
|
||
dnf install net-tools -y
|
||
|
||
rpm -ivh mysql-community-embedded-compat-5.7.41-1.el7.x86_64.rpm
|
||
|
||
```
|
||
|
||
**编辑配置文件**
|
||
|
||
```shell
|
||
vim /etc/my.cnf
|
||
|
||
# For advice on how to change settings please see
|
||
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
|
||
[client]
|
||
port = 3306
|
||
user = mysql
|
||
|
||
[mysqld]
|
||
#
|
||
# Remove leading # and set to the amount of RAM for the most important data
|
||
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
|
||
# innodb_buffer_pool_size = 128M
|
||
#
|
||
# Remove leading # to turn on a very important data integrity option: logging
|
||
# changes to the binary log between backups.
|
||
# log_bin
|
||
#
|
||
# Remove leading # to set options mainly useful for reporting servers.
|
||
# The server defaults are faster for transactions and fast SELECTs.
|
||
# Adjust sizes as needed, experiment to find the optimal values.
|
||
# join_buffer_size = 128M
|
||
# sort_buffer_size = 2M
|
||
# read_rnd_buffer_size = 2M
|
||
basedir=/usr/local/mysql
|
||
datadir=/var/lib/mysql
|
||
socket=/var/lib/mysql/mysql.sock
|
||
|
||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||
symbolic-links=0
|
||
|
||
log-error=/var/log/mysqld.log
|
||
pid-file=/var/run/mysqld/mysqld.pid
|
||
|
||
max_connections = 400
|
||
character-set-server = utf8mb4
|
||
explicit_defaults_for_timestamp = true
|
||
lower_case_table_names = 1
|
||
```
|
||
|
||
**初始化**
|
||
|
||
```shell
|
||
mysqld --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql
|
||
# 给mysql用户添加数据目录权限
|
||
chown mysql:mysql /var/lib/mysql -R
|
||
systemctl start mysqld
|
||
systemctl enable mysqld
|
||
|
||
# 查看root随机生成密码
|
||
grep 'temporary password' /var/log/mysqld.log
|
||
# 若没有提示,则没有密码,可直接登录
|
||
mysql -uroot
|
||
```
|
||
|
||
## 配置Java环境变量
|
||
|
||
将tar.gz格式的jdk解压后移动到/usr目录下
|
||
|
||
```shell
|
||
mv jdk1.8.0_301/ /usr/
|
||
```
|
||
|
||
编辑/etc目录下profile文件 G到最后一行
|
||
|
||
```shell
|
||
vim /etc/profile
|
||
|
||
export JAVA_HOME=/usr/jdk1.8.0_301
|
||
export PATH=$PATH:$JAVA_HOME/bin
|
||
|
||
```
|
||
|
||
:wq保存退出
|
||
|
||
重新加载配置文件
|
||
|
||
```shell
|
||
source /etc/profile
|
||
```
|
||
|
||
---
|
||
|
||
## CentOS7防火墙
|
||
|
||
放行特定端口
|
||
|
||
```shell
|
||
firewall-cmd --add-port=6379/tcp --permanent
|
||
```
|
||
|
||
移除放行端口
|
||
|
||
```shell
|
||
firewall-cmd --permanent --remove-port=8080/tcp
|
||
```
|
||
|
||
查询端口是否开放
|
||
|
||
```shell
|
||
firewall-cmd --query-port=8080/tcp
|
||
```
|
||
|
||
任何修改操作,配置完成后,需要重新加载firewall
|
||
|
||
重新加载防火墙
|
||
|
||
```shell
|
||
firewall-cmd --reload
|
||
```
|
||
|
||
查看防火墙开放的端口
|
||
|
||
```shell
|
||
firewall-cmd --list-all
|
||
```
|
||
|
||
指定作用域开发防火墙端口
|
||
|
||
```shell
|
||
firewall-cmd --zone=public --add-port=3306/tcp --permanent
|
||
# -zone 作用域
|
||
# -add-port 添加端口,格式为端口/协议
|
||
# -permanent 永久生效,没有此参数重启后失效
|
||
|
||
```
|
||
|
||
## 查看硬盘空间
|
||
|
||
```shell
|
||
# 统计磁盘整体情况,包括磁盘大小,已使用,可用
|
||
df -lh
|
||
# 查看根目录下文件夹大小
|
||
du -sh /*
|
||
```
|
||
|
||
## 扩容
|
||
|
||
### LVM
|
||
|
||
Orale VirtualBox
|
||
|
||

|
||
|
||
需要选择最后一个,因为前几个是之前的备份快照
|
||
|
||

|
||
|
||
分配大小即可,只能增加不能缩小
|
||
|
||
查看现有分区大小
|
||
|
||
```shell
|
||
df -Th
|
||
```
|
||
|
||

|
||
|
||
查看扩容后磁盘大小
|
||
|
||
```shell
|
||
lsblk
|
||
```
|
||
|
||

|
||
|
||
创建分区
|
||
|
||
```shell
|
||
fdisk /dev/sda
|
||
```
|
||
|
||

|
||
|
||

|
||
|
||
刷新分区并创建物理卷
|
||
|
||
```shell
|
||
partprobe /dev/sda
|
||
pvcreate /dev/sda4
|
||
```
|
||
|
||

|
||
|
||
查看卷组名称,以及卷组使用情况
|
||
|
||
```shell
|
||
vgdisplay
|
||
```
|
||
|
||

|
||
|
||
将物理卷扩展到卷组
|
||
|
||
```shell
|
||
vgextend rl /dev/sda4
|
||
```
|
||
|
||

|
||
|
||
查看当前逻辑卷的空间状态
|
||
|
||
```shell
|
||
lvdisplay
|
||
```
|
||
|
||

|
||
|
||
将卷组中的空闲空间扩展到根分区逻辑卷
|
||
|
||
```shell
|
||
lvextend -l +100%FREE /dev/rl/root
|
||
```
|
||
|
||

|
||
|
||
刷新根分区
|
||
|
||
```shell
|
||
xfs_growfs /dev/rl/root
|
||
```
|
||
|
||

|
||
|
||
扩容成功
|
||
|
||

|
||
|
||
## 分配Swap
|
||
|
||
查看分区大小
|
||
|
||
```shell
|
||
free -h
|
||
```
|
||
|
||
使用dd命令创建一个swap分区
|
||
|
||
```shell
|
||
dd if=/dev/zero of=/home/swap bs=1024 count=4194304
|
||
```
|
||
|
||
count的值是:size(多少M)* 1024
|
||
|
||
格式化swap分区
|
||
|
||
```shell
|
||
mkswap /home/swap
|
||
```
|
||
|
||
把格式化后的文件分区设置为swap分区
|
||
|
||
```shell
|
||
swapon /home/swap
|
||
```
|
||
|
||
swap分区自动挂载
|
||
|
||
```shell
|
||
vim /etc/fstab
|
||
# G 在文件末尾加上
|
||
/home/swap swap swap default 0 0
|
||
```
|
||
|
||
关闭Swap
|
||
|
||
```shell
|
||
swapoff /home/swap
|
||
```
|
||
|
||
### 修改swap使用率
|
||
|
||
swappiness的值的大小对如何使用swap分区是有着很大的联系的。swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,swappiness=100的时候表示积极的使用swap分区,并且把内存上的数据及时的搬运到swap空间里面。两个极端
|
||
|
||
查看swappiness
|
||
|
||
```shell
|
||
cat /proc/sys/vm/swappiness
|
||
```
|
||
|
||
修改swappiness值为60
|
||
|
||
```shell
|
||
sysctl vm.swappiness=60
|
||
```
|
||
|
||
但是这只是临时性的修改,还要做一步
|
||
|
||
```shell
|
||
vim /etc/sysctl.conf
|
||
# 编辑这行
|
||
vm.swappiness=60
|
||
```
|
||
|
||
## Windows Linux子系统
|
||
|
||
### WSL2
|
||
|
||
打开 Windows Terminal PowerShell
|
||
|
||
#### 安装
|
||
|
||
```powershell
|
||
wsl --install
|
||
```
|
||
|
||
微软官方文档 [安装 WSL | Microsoft Docs](https://docs.microsoft.com/zh-cn/windows/wsl/install)
|
||
|
||
默认安装Ubuntu 20.04 LTS版
|
||
|
||
更改默认安装的Linux发行版
|
||
|
||
```powershell
|
||
wsl --install -d <Distribution Name>
|
||
```
|
||
|
||
/mnt目录下是Windows系统的挂载盘,可直接访问Windows磁盘文件
|
||
|
||
#### 通过FinalShell连接WSL2
|
||
|
||
1. 需要先删除ssh,再安装ssh
|
||
|
||
```shell
|
||
apt-get remove --purge openssh-server #先删ssh
|
||
apt-get install openssh-server #再安装ssh
|
||
rm /etc/ssh/ssh_config
|
||
service ssh --full-restart #重启ssh服务
|
||
```
|
||
|
||
2. 修改配置文件
|
||
|
||
```shell
|
||
vim /etc/ssh/sshd_config
|
||
|
||
Port 6666 # 指定连接端口 6666
|
||
ListenAddress 0.0.0.0 # 指定连接的IP
|
||
PasswordAuthentication yes # 开启密码认证
|
||
PermitRootLogin yes # 开启root用户登录
|
||
|
||
```
|
||
|
||
3. 重启ssh(每次重启wsl都要执行该语句)
|
||
|
||
```shell
|
||
service ssh --full-restart
|
||
```
|
||
|
||
4. 重新生成host key
|
||
|
||
```shell
|
||
dpkg-reconfigure openssh-serve
|
||
```
|
||
|
||
FinalShell就可以连接WSL2了
|
||
|
||
#### 启用systemctl
|
||
|
||
进入当前发行版
|
||
|
||
编辑 /etc/wsl.conf
|
||
|
||
```shell
|
||
vim /etc/wsl.conf
|
||
# 内容如下
|
||
[boot]
|
||
systemd=true
|
||
```
|
||
|
||
重启WSL
|
||
|
||
```powershell
|
||
wsl --shutdown
|
||
```
|
||
|
||
## 安装 7zip
|
||
|
||
```shell
|
||
# 更新系统数据库
|
||
sudo dnf update -y
|
||
# 启用 Epel repository
|
||
sudo dnf install epel-release
|
||
# 安装 7-Zip
|
||
sudo dnf install p7zip p7zip-plugins
|
||
# 检验是否安装上
|
||
7z
|
||
|
||
# 使用
|
||
# 创建压缩文件 命令中的选项a用于压缩
|
||
7z a data.7z data.txt
|
||
# 显示每个存档文件的详细信息列表
|
||
7z l data.7z
|
||
# 解压缩
|
||
# 注意 -o 用来指定解压缩文件存放目录,-o 后是没有空格的,直接接目录
|
||
7z x data.7z -r -o./data
|
||
```
|
||
|
||
|
||
|
||
## 安装 Nginx
|
||
|
||
```shell
|
||
tar -zxvf nginx-1.21.4.tar.gz
|
||
cd nginx-1.21.4/
|
||
./configure
|
||
make
|
||
make install
|
||
```
|
||
|
||
AlmaLinux 下安装
|
||
|
||
```shell
|
||
# 确保软件是最新的
|
||
sudo dnf clean all
|
||
sudo dnf update
|
||
sudo dnf groupinstall "Development Tools"
|
||
# 安装
|
||
sudo dnf install nginx
|
||
|
||
sudo systemctl restart nginx
|
||
sudo systemctl status nginx
|
||
sudo systemctl enable nginx
|
||
|
||
sudo firewall-cmd --permanent --add-service=http
|
||
sudo firewall-cmd --permanent --add-service=https
|
||
sudo firewall-cmd --reload
|
||
```
|
||
|
||
- `/etc/nginx`: 包含所有 Nginx 配置文件的主目录。
|
||
- `/etc/nginx/nginx.conf`: 主要的 Nginx 配置文件。
|
||
- `/etc/nginx/sites-available`:定义各个网站的目录。请记住,Nginx 不会使用在此目录中找到的配置文件,除非它们链接到该目录。`/etc/nginx/sites-enabled`
|
||
- `/etc/nginx/sites-enabled`: Nginx 积极服务的网站列表。
|
||
- `/var/log/nginx`: Nginx日志目录
|
||
|
||
## 安装 Redis
|
||
|
||
在安装Redis之前,运行下面的命令来重建软件包缓存并获得最新版本的软件包信息。
|
||
|
||
```shell
|
||
sudo dnf makecache
|
||
```
|
||
|
||
现在,运行下面的dnf命令来安装Redis。在提示时输入y,然后按ENTER键继续。
|
||
|
||
```shell
|
||
sudo dnf install redis
|
||
```
|
||
|
||
Redis安装完毕后,运行下面的systemctl命令,启动并启用Redis服务。
|
||
|
||
```shell
|
||
sudo systemctl start redis
|
||
sudo systemctl enable redis
|
||
```
|
||
|
||
最后,使用下面的命令验证Redis的服务状态。
|
||
|
||
```shell
|
||
sudo systemctl is-enabled redis
|
||
sudo systemctl status redis
|
||
redis-server
|
||
```
|
||
|
||
下面的输出确认Redis正在运行并被启用,这意味着它将在系统启动时自动运行。
|
||
|
||
### 配置Redis
|
||
|
||
使用下面的vim编辑器命令打开Redis配置文件"/etc/redis.conf"。
|
||
|
||
```
|
||
sudo vim /etc/redis.conf
|
||
```
|
||
|
||
### Redis-CLI
|
||
|
||
```shell
|
||
redis-cli
|
||
auth <password>
|
||
|
||
```
|
||
|
||
## 安装.Net 6 SDK
|
||
|
||
```shell
|
||
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
|
||
sudo yum install dotnet-sdk-6.0
|
||
dotnet --info
|
||
```
|
||
|
||
## 安装Node.js
|
||
|
||
从官网下载Node.js安装包
|
||
|
||
地址:[Download | Node.js (nodejs.org)](https://nodejs.org/en/download/)
|
||
|
||

|
||
|
||
上传
|
||
|
||
```shell
|
||
# 解压
|
||
tar -xvf node-v18.12.1-linux-x64.tar.xz
|
||
# 重命名为nodejs
|
||
mv node-v18.12.1-linux-x64 nodejs
|
||
# 移动到指定目录
|
||
mv nodejs /usr/local
|
||
# 软链接方式让npm和node命令全局生效
|
||
ln -s /usr/local/nodejs/bin/npm /usr/local/bin/
|
||
ln -s /usr/local/nodejs/bin/node /usr/local/bin/
|
||
# or 加入环境变量
|
||
vim /etc/profile
|
||
# 加入下面行
|
||
export PATH=$PATH:/usr/local/nodejs/bin
|
||
# 查看nodejs是否安装成功
|
||
node -v
|
||
npm -v
|
||
# 如果报错
|
||
wget https://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
|
||
tar -zxvf glibc-2.17.tar.gz
|
||
cd glibc-2.17
|
||
mkdir build
|
||
cd build
|
||
|
||
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin #安装 make && make install
|
||
|
||
docker run -itd --name nodejs -v /usr/local/bin/npm:/usr/local/bin/npm n
|
||
```
|
||
|
||
### AlmaLinux 安装
|
||
|
||
```shell
|
||
dnf update -y
|
||
dnf install nodejs -y
|
||
```
|
||
|
||
|
||
|
||
## 安装宝塔面板
|
||
|
||
## 安装 Neofetch
|
||
|
||
```shell
|
||
dnf install epel-release
|
||
dnf install neofetch
|
||
neofetch
|
||
```
|
||
|
||
|
||
|
||
## 安装 Screenfetch
|
||
|
||
```shell
|
||
dnf install git
|
||
git clone https://github.com/KittyKatt/screenFetch.git
|
||
cp screenFetch/screenfetch-dev /usr/bin/screenfetch
|
||
chmod +x /usr/bin/screenfetch
|
||
screenfetch
|
||
```
|
||
|
||
## 安装 Edge 和 Chrome
|
||
|
||
### Edge
|
||
|
||
更新源
|
||
|
||
```shell
|
||
sudo dnf update -y
|
||
#sudo dnf install dnf-utils -y
|
||
```
|
||
|
||
添加Edge源
|
||
|
||
```shell
|
||
sudo dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/edgexxxxxxxxxx2 1sudo dnf confsudo dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/edge2
|
||
```
|
||
|
||
再次更新源
|
||
|
||
```shell
|
||
sudo dnf update -y
|
||
```
|
||
|
||
安装Edge
|
||
|
||
```shell
|
||
sudo dnf install microsoft-edge-stable -y
|
||
```
|
||
|
||
### Chrome
|
||
|
||
下载chrome安装文件
|
||
|
||
```shell
|
||
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
|
||
```
|
||
|
||
安装chrome
|
||
|
||
```shell
|
||
sudo dnf install ./google-chrome-stable_current_x86_64.rpm -y
|
||
```
|
||
|
||
## 安装 Supervisor
|
||
|
||
### 安装
|
||
|
||
```shell
|
||
sudo dnf update -y
|
||
sudo dnf install epel-release -y
|
||
sudo dnf install supervisor -y
|
||
```
|
||
|
||
### 配置
|
||
|
||
```shell
|
||
sudo vim /etc/supervisord.conf
|
||
# 开启web服务管理界面
|
||
# 修改port中的ip为0.0.0.0,以允许任何ip访问
|
||
# 修改用户名密码
|
||
# 去掉行首的 ; 以使配置生效
|
||
[inet_http_server] ; inet (TCP) server disabled by default
|
||
port=0.0.0.0:9001 ; (ip_address:port specifier, *:port for all iface)
|
||
username=user ; (default is no username (open server))
|
||
password=123 ; (default is no password (open server))
|
||
# 修改包含子配置文件,文件类型为.conf,默认为.ini
|
||
[include]
|
||
files = supervisord.d/*.conf
|
||
```
|
||
|
||
### 常用命令
|
||
|
||
```shell
|
||
# 启动 supervisord
|
||
sudo systemctl start supervisord
|
||
# 开机启动 supervisord
|
||
sudo systemctl enable supervisord
|
||
# 检查是否开机启动 supervisord
|
||
sudo systemctl is-enable supervisord
|
||
# 检查 supervisord 状态
|
||
sudo systemctl status supervisord
|
||
# 更新新的配置到supervisord(不会重启原来已运行的程序)
|
||
sudo supervisorctl update
|
||
# 载入所有配置文件,并按新的配置启动、管理所有进程(会重启原来已运行的程序)
|
||
sudo supervisorctl reload
|
||
# 启动某个进程
|
||
sudo supervisorctl start xxx
|
||
# 重启某个进程
|
||
sudo supervisorctl restart xxx
|
||
# 停止某个进程(xxx),xxx为[program:theprogramname]里配置的值
|
||
sudo supervisorctl stop xxx
|
||
# 重启所有属于名为groupworker这个分组的进程(start,restart同理)
|
||
sudo supervisorctl restart groupworker
|
||
# 停止全部进程
|
||
sudo supervisorctl stop all
|
||
# 查看服务状态
|
||
sudo supervisorctl status
|
||
```
|
||
|
||
### 程序配置
|
||
|
||
```conf
|
||
[program:ckadminnetcore]
|
||
command=dotnet CK.Admin.WebApi.dll --urls http://[*]:8888
|
||
directory=/root/www/ckadminnetcore/publish
|
||
environment=ASPNETCORE_ENVIRONMENT=Production
|
||
user=root
|
||
autostart=true
|
||
autorestart=true
|
||
stderr_logfile=/var/log/ckadminnetcore/err.log
|
||
stdout_logfile=/var/log/ckadminnetcore/out.log
|
||
stopasgroup=true
|
||
```
|
||
|
||
## 安装 FastGithub
|
||
|
||
```shell
|
||
wget https://gitee.com/chcrazy/FastGithub/releases/download/2.1.4/fastgithub_linux-x64.zip
|
||
dnf install -y libicu
|
||
# 配置系统代理
|
||
# 配置系统环境变量
|
||
vim /etc/profile
|
||
|
||
# 尾行加上
|
||
export http_proxy="http://127.0.0.1:38457"
|
||
export https_proxy="http://127.0.0.1:38457"
|
||
|
||
# 生效
|
||
source /etc/profile
|
||
|
||
unzip fastgithub_linux-x64.zip
|
||
cd fastgithub_linux-x64
|
||
./fastgithub
|
||
```
|
||
|
||
## 安装 ohmyzsh
|
||
|
||
### 安装zsh
|
||
|
||
```shell
|
||
dnf install -y zsh
|
||
```
|
||
|
||
### 脚本安装
|
||
|
||
```shell
|
||
sh -c "$(wget -O- https://install.ohmyz.sh/)"
|
||
```
|
||
|
||
### 配置
|
||
|
||
```shell
|
||
vim ~/.zshrc
|
||
|
||
# 修改主题
|
||
# ZSH_THEME='robbyrussell'
|
||
ZSH_THEME='agnoster'
|
||
|
||
source ~/.zshrc
|
||
```
|
||
|
||
### 切换为默认shell
|
||
|
||
```shell
|
||
dnf install util-linux-user -y
|
||
chsh -s /bin/zsh
|
||
|
||
#查看默认Shell
|
||
echo $SHELL
|
||
```
|
||
|
||
### 主题
|
||
|
||
#### Powerlevel10K
|
||
|
||
```shell
|
||
|
||
```
|
||
|
||
安装Nerd Fonts
|
||
|
||
```shell
|
||
unzip nerd-fonts.zip
|
||
|
||
```
|
||
|
||
运行install.sh提示/usr/bin/env: ‘bash\r’: No such file or directory
|
||
|
||
```shell
|
||
vim install.sh
|
||
|
||
:set ff
|
||
# 可以看到fileformat=dos
|
||
|
||
:set ff=unix
|
||
:set ff
|
||
# 可以看到fileformat=unix 即保存成功
|
||
:wq
|
||
```
|
||
|
||
|
||
|
||
## 安装 ElasticSearch
|
||
|
||
```shell
|
||
cd /etc/yum.repos.d
|
||
vim elasticsearch.repo
|
||
|
||
[elasticsearch]
|
||
name=Elasticsearch repository for 8.x packages
|
||
baseurl=https://artifacts.elastic.co/packages/8.x/yum
|
||
gpgcheck=1
|
||
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
||
enabled=0
|
||
autorefresh=1
|
||
type=rpm-md
|
||
|
||
dnf install --enablerepo=elasticsearch elasticsearch -y
|
||
```
|
||
|
||
## 安装 Rsync
|
||
|
||
```shell
|
||
dnf install rsync -y
|
||
```
|
||
|
||
### 配置
|
||
|
||
```shell
|
||
vim /etc/rsyncd.conf
|
||
|
||
# /etc/rsyncd: configuration file for rsync daemon mode
|
||
|
||
# See rsyncd.conf man page for more options.
|
||
|
||
# configuration example:
|
||
|
||
uid = root
|
||
gid = root
|
||
ignore errors
|
||
hosts allow = 10.0.3.0/24
|
||
secrets file = /etc/rsyncd.secrets
|
||
# use chroot = yes
|
||
# max connections = 4
|
||
# pid file = /var/run/rsyncd.pid
|
||
# exclude = lost+found/
|
||
# transfer logging = yes
|
||
# timeout = 900
|
||
# ignore nonreadable = yes
|
||
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
|
||
|
||
# [ftp]
|
||
# path = /home/ftp
|
||
# comment = ftp export area
|
||
# 同步模块名称
|
||
[syncwspswwwroot]
|
||
# 服务器同步的路径
|
||
path = /root/wwwroot
|
||
log file = /var/log/rsync.log
|
||
# 只读模式 不允许客户端向同步路径进行同步上传文件
|
||
read only = yes
|
||
|
||
[mysql_bakup]
|
||
path = /root/mysql_bakup
|
||
read only = yes
|
||
```
|
||
|