commit 9843eaa770a55748a93f1a31ed2ccff7406a60a5 Author: mengyxu Date: Mon Jan 10 12:45:12 2022 +0800 init diff --git a/1.后端/1.Spring boot基础.md b/1.后端/1.Spring boot基础.md new file mode 100644 index 0000000..0a3391c --- /dev/null +++ b/1.后端/1.Spring boot基础.md @@ -0,0 +1,14 @@ +# spring + + + +# mybatis + +- 开启驼峰映射 + + ```properties + mybatis.configuration.map-underscore-to-camel-case=true + ``` + + + diff --git a/1.后端/1.Spring boot整合mongodb.md b/1.后端/1.Spring boot整合mongodb.md new file mode 100644 index 0000000..e385ff6 --- /dev/null +++ b/1.后端/1.Spring boot整合mongodb.md @@ -0,0 +1,108 @@ +# 依赖 + +```xml + + org.springframework.boot + spring-boot-starter-data-mongodb + +``` + +# 配置文件 + +```properties +# mongodb数据源配置 +spring.data.mongodb.uri=mongodb://localhost:27017/open5gs +``` + +# 代码 + +- 实体类 + + ```java + @Setter + @Getter + public class Profiles { + + @Id + private String id; + private String title; + private List pdn; + private Link ambr; + private Security security; + + } + ``` + + + +- Repository类 + + + + ![2](mongo2.png) + + ```java + @Repository + public interface ProfilesRepository extends MongoRepository { + + Profiles findByTitle(String title); + + @Query(value = "{'_id':{'$ne':null}}", fields = "{'title':1,'_id':0}") + List title(); + + } + ``` + +- Repository的使用 + + ```java + @Service + public class ProfileService { + @Autowired + private ProfilesRepository profileRepository; + + public Page find(Profiles exp, BasePageParam pageParam) { + Integer page = pageParam.getPage(); + if (page == null || page < 1) { + page = 1; + } + Integer size = pageParam.getSize(); + if (size == null || size == 0) { + size = 20; + } + PageRequest pageable = PageRequest.of(page - 1, size, Direction.DESC, "_id"); + ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("_class").withMatcher("title", GenericPropertyMatcher.of(StringMatcher.CONTAINING)); + Example example = Example.of(exp, matcher); + return profileRepository.findAll(example, pageable); + } + + public Profiles findByTitle(String title) { + return profileRepository.findByTitle(title); + } + + public List findTitles() { + return profileRepository.title(); + } + + public void save(Profiles profiles) throws SprtException { + Profiles old = profileRepository.findByTitle(profiles.getTitle()); + if (old != null) { + throw new SprtException("已存在相同名称的模板"); + } + profileRepository.save(profiles); + } + + public void update(Profiles profiles) throws SprtException { + profileRepository.save(profiles); + } + + public void delete(Profiles profiles) { + profileRepository.deleteById(profiles.getId()); + } + + } + + ``` + + + diff --git a/1.后端/9.用jdk生成ssl证书.md b/1.后端/9.用jdk生成ssl证书.md new file mode 100644 index 0000000..d81d939 --- /dev/null +++ b/1.后端/9.用jdk生成ssl证书.md @@ -0,0 +1,72 @@ +# 用jdk生成ssl证书 + +- ## 使用keytool命令生成证书 + + 打开CMD命令,cd到jdk的bin目录下,或者先到bin目录下,按住shift右键在此处打开命令窗口 + + keytool   + + -genkey + + -alias tomcat(别名) + + -keypass 123456(别名密码) + + -keyalg RSA(算法) + + -keysize 1024(密钥长度) + + -validity 365(有效期,天单位) + + -keystore D:/keys/tomcat.keystore(指定生成证书的位置和证书名称) + + -storepass 123456(获取keystore信息的密码) + + `keytool -genkey -alias tomcat -keypass 12345678 -keyalg RSA -keysize 1024 -validity 365 -keystore E:/keys/tomcat.keystore -storepass 12345678` + + 执行命令后会有6个问题,依次回答,第一个问题答案为证书的域名,其他的随意填写 + +- 为客户端生成证书, 以便让服务器来验证它 + + `keytool -genkey -alias client1 -keypass 12345678 -keyalg RSA -keysize 1024 -validity 365 -storetype PKCS12 -keystore E:/keys/client1.p12 -storepass 12345678` + +- 由于不能直接将PKCS12格式的证书库导入,必须先把客户端证书导出为一个单独的CER文件,使用如下命令: + + `keytool -export -alias client1 -keystore E:/keys/client1.p12 -storetype PKCS12 -keypass 12345678 -file E:/keys/client1.cer` + +- 将该文件导入到服务器的证书库,添加为一个信任证书: + + `keytool -import -v -file E:/keys/client1.cer -keystore E:/keys/tomcat.keystore -storepass 12345678` + +- 由于是双向SSL认证,客户端也要验证服务器证书,因此,必须把服务器证书添加到浏览器的“受信任的根证书颁发机构”。由于不能直接将keystore格式的证书库导入,必须先把服务器证书导出为一个单独的CER文件,使用如下命令: + + `keytool -keystore E:/keys/tomcat.keystore -export -alias tomcat -file E:/keys/server.cer` + +- 双击server.cer文件,按照提示安装证书,将证书填入到“受信任的根证书颁发机构”。 + +# tomcat配置ssl证书 + +``` + +``` + +# 配置强转https + +``` + + + SSL + /* + + + CONFIDENTIAL + + +``` + diff --git a/1.后端/mongo1.png b/1.后端/mongo1.png new file mode 100644 index 0000000..0fa20e3 Binary files /dev/null and b/1.后端/mongo1.png differ diff --git a/1.后端/mongo2.png b/1.后端/mongo2.png new file mode 100644 index 0000000..5337013 Binary files /dev/null and b/1.后端/mongo2.png differ diff --git a/11随记.md b/11随记.md new file mode 100644 index 0000000..83f8bc7 --- /dev/null +++ b/11随记.md @@ -0,0 +1,6 @@ +# 随记 + +- 抛开产品线只讨论品牌的人,我不说你们是傻子或者水军,但是明显你们不关心产品,只是在发泄情绪或者炫耀智商。 + +- 心理学上说你更容易喜欢上喜欢你的人 + diff --git a/2.前端/CSS笔记.md b/2.前端/CSS笔记.md new file mode 100644 index 0000000..b28f514 --- /dev/null +++ b/2.前端/CSS笔记.md @@ -0,0 +1,43 @@ +# CSS笔记 + +## 尺寸 + +```css +height: 80vh; +width: 80vw; +line-height: 40; +字体粗细 +font-weight: bold; +``` + + + +## 滚动条 + +```css +隐藏底部滚动条 +overflow-x: hidden; +overflow-y: scroll; +``` + +## 背景 + +```css +透明背景 +background: none; +背景颜色 +background-color: #4472c4; +背景图片 +background-image:url('./assets/img/bg13.png'); +background-size: cover; +background-position: center; +background-repeat: no-repeat; +``` + +## 边框 + +```css +立体阴影边框 +box-shadow: 0 0 25px #cac6c6 !important; +``` + diff --git a/2.前端/element-ui笔记.md b/2.前端/element-ui笔记.md new file mode 100644 index 0000000..a20ce64 --- /dev/null +++ b/2.前端/element-ui笔记.md @@ -0,0 +1,33 @@ +# Element-UI笔记 + +## 重写样式 + +- 重写el-table背景 + + 表格背景透明, 便于定制整体背景样式 + + ``` scss + .main-table .el-table, + .el-table__expanded-cell { + background-color: transparent; + border: none; + } + + .main-table .el-table tr { + background-color: transparent !important; + border: none; + } + + .main-table .el-table--enable-row-transition .el-table__header td, + .el-table .cell { + background-color: transparent; + } + + .main-table .el-table--enable-row-transition .el-table__body td, + .el-table .cell { + background-color: transparent; + } + ``` + +- + diff --git a/2.前端/安装与配置.md b/2.前端/安装与配置.md new file mode 100644 index 0000000..45d1737 --- /dev/null +++ b/2.前端/安装与配置.md @@ -0,0 +1,53 @@ +# 开发环境 + +## 安装node.js + +- 官网下载免安装版压缩包 + + [**14.17.5**源码与安装包](https://nodejs.org/en/download/) + + [长期稳定版本与最新版本](https://nodejs.org/zh-cn/) + + [历史版本](https://nodejs.org/dist/) + +- 配置环境变量 + + 配置node_home + + 将node_home配置到path环境变量 + + 使用 node -v 查看是否安装成功 + +## 安装cnpm并使用淘宝镜像(非必须) + +```shell +npm install -g cnpm --registry=https://registry.npm.taobao.org +npm uninstall -g cnpm +``` + +## 安装yarn(非必须) + +`npm install -g yarn` + +## 安装vue脚手架(非必须) + +```shell +npm uninstall @vue-cli //卸载1.0或2.0版本 +npm install @vue/cli //安装最新版本 +npm install @vue/cli@4.0.5 //安装指定版本 +``` + +> vue/cli可以帮助快速搭建vue项目,管理项目依赖等,大大降低了webpack的使用难度 +> +> 如果需要从零开始搭建vue项目建议暗转, 如果只是在已有vue项目上进行迭代开发则无安装必要 + +## 最后一个忘记干啥用的了,照做就行 + +将powershell切换为管理员模式,执行命令 + +```shell +Start-Process powershell -Verb runAs +set-ExecutionPolicy RemoteSigned +y +``` + diff --git a/2.前端/文字颜色自适应背景色.md b/2.前端/文字颜色自适应背景色.md new file mode 100644 index 0000000..d8fd9a7 --- /dev/null +++ b/2.前端/文字颜色自适应背景色.md @@ -0,0 +1,82 @@ +# 文字颜色自适应背景图片 + +- 利用canvas获取图片像素矩阵 + + ```js + const image = new Image(); + image.src = require('./assets/img/bg13.png'); + const canvas = document.getElementById("canvas"); + const context = canvas.getContext("2d"); + image.onload = () => { + context.drawImage(image, 0, 0); //获取像素矩阵 + const data = context.getImageData(0, 0, canvas.width, canvas.height).data; + } + ``` + + + +- 根据像素计算主色调 + + 1. 取平均数方式,优点是简单,缺点是可能不太准 + + ```js + let sr = 0, + sg = 0, + sb = 0, + sum = 0; + const data = context.getImageData(0, 0, canvas.width, canvas.height).data; + for (let i = 0; i < data.length; i += 4) { + if (data[i + 3] >= 255) { + sum++; + sr += data[i]; + sg += data[i + 1]; + sb += data[i + 2]; + } + } + const r = sr / sum, + g = sg / sum, + b = sb / sum; + ``` + + 2. 中位数方式 + + ```js + ``` + + + +- 判断颜色色系 ( 深色系OR浅色系 ),给页面body添加样式 + + ```js + const level = 0.299 * r + 0.587 * g + 0.114 * b; + if (level < 192) { + document.getElementsByTagName("body")[0].className = 'style-dark'; + } else { + document.getElementsByTagName("body")[0].className = 'style-wihte'; + } + ``` + +- CSS样式 + + ```css + .style-dark .el-table *, .style-dark .el-tabs *, + .style-dark .el-input__inner, + .style-dark h1, .style-dark h2, .style-dark small, .style-dark span, .style-dark div *{ + color: white; + } + + .style-dark .el-input__inner * { + background: none !important; + } + + .style-dark .el-button--default { + background: url(assets/img/bg13.png); + } + + .style-dark .el-dialog *{ + color: white !important; + } + + ``` + + \ No newline at end of file diff --git a/3.linux/1.常用命令整理.md b/3.linux/1.常用命令整理.md new file mode 100644 index 0000000..e27acb0 --- /dev/null +++ b/3.linux/1.常用命令整理.md @@ -0,0 +1,192 @@ +# linux常用命令 + +## 常用shell列表 + +| 命令 | 作用 | +| ------------------------------------------------------------ | ------------------------------ | +| yum install --installroot=/usr/local | 表示指定自定义的安装目录 | +| free -hm | 查看内存使用情况 | +| netstat –apn | 查看所有端口占用情况 | +| lsof -i:80 | 查看占用端口程序 | +| df -lh | 查看磁盘用量 | +| > text.txt | 清空文件 | +| echo $LANG | 查看字符集 | +| export LANG=zh_CN.UTF-8 | 临时修改字符集 | +| vim /etc/locale.conf | 修改centos7.5字符配置文件 | +| source /etc/locale.conf | 配置生效 | +| tar -zxvf xxx.tar.gz -C /dest | tar文件解压到指定目录 | +| ln -s /xxx/xxx.jar /etc/init.d/xxx | jar包注册service服务 | +| cd /etc/rc.d/init.d
chkconfig --add monitor
chkconfig monitor on | 开机启动service | +| find /home/ -name xxx | 查找/home目录下名字为xxx的文件 | +| ssh 192.168.0.1 -l root -p 22 | 远程登录到另一台主机 | +| scp root@192.16.0.1:/path/name /path | 从服务器上下载文件 | +| scp /path/name root@192.16.0.1:/path | 上传本地文件到服务器 | +| scp -r root@192.16.0.1:/path /path | 从服务器下载整个目录 | +| scp -r /path root@192.16.0.1:/path | 上传目录到服务器 | +| chown user:user file | 修改文件用户组和用户 | +| systemctl stop firewalld | 关闭防火墙 | +| | | +| | | + +## 其他shell相关知识 + +### 开机自启程序或脚本 + +- 在`/etc/profile`文件中添加启动命令 + +### 后台执行命令或脚本 + +- `nohup command &` + + 如果使用nohup命令提交任务,在默认情况下该任务的所有输出都被重定向到一个名为nohup.out的文件中,除非另外指定了输出文件,如: + + `nohup command > myout.file 2>&1` + + 输出被重定向到myout.file文件中 + + 如果不想做任何输出,可以将输出文件指定为/dev/null,`/dev/null`代表linux的空设备文件,所有往这个文件里面写入的内容都会丢失,俗称“黑洞”。 + + `nohup command > /dev/null 2>&1` + +### shell操作字符串 + +- 判断字符串是否包含另一个字符串 + + - 使用~ + + `if [[ $A =~ $B ]]` + + - 使用通配符* + + `if [[ $A == *$B* ]]` + +- 截取字符串 + + - ${A:B:C} + + `${foo:3:2}` //从下标为3的字符开始截取,共截取2个 + + - ${A#B}/${A##B} + + 清除字符串中符合pattern的字符,从字符串最前匹配 + + ```shell + foo=“file.txt.zip” + echo ${foo#*.} //一个#号代表按照最短匹配清除 + txt.zip + echo ${foo##*.} //2个#号代表按照最长匹配清除 + zip + ``` + + - ${A%B}/${A%%B} + + 清除字符串中符合pattern的字符,从字符串最后匹配 + + ```shell + foo=“file.txt.zip” + echo ${foo%.*} //一个%号代表按照最短匹配清除 + file.txt + echo ${foo%%.*} //2个%号代表按照最长匹配清除 + file + ``` + +- 字符串替换操作 + + - ${A/B/C} + + ```shell + foo="mp3.txt.txt.mp3.avi" + echo ${foo/txt/TXT} + mp3.TXT.txt.mp3.avi + echo ${foo//txt/TXT} + mp3.TXT.TXT.mp3.avi + + foo="txt.txt.txt" + echo ${foo/#txt/TXT} + TXT.txt.txt + echo ${foo/%txt/TXT} + txt.txt.TXT + ``` + +- 大小写转换 + + ```shell + foo="ABcd" + echo ${foo,} + aBcd + echo ${foo,,} + abcd + echo ${foo^} + ABcd + echo ${foo^^} + ABCD + ``` + +### shell算术运算命令 + +| (()) | 用于整数之间常用的运算符,效率高 | +| ------- | ---------------------------------------------------- | +| let | 用于整数运算,类似于(()) | +| expr | 用于整数运算,但是还有其他功能 | +| bc | Linux下的一个计算程序,适合整数及小数运算 | +| $[] | 用于整数运算 | +| awk | awk既可以整数运算,也可以小数运算 | +| declare | 定义变量值和属性,-i参数可以用于定义整形变量,做运算 | +| | | + +## ubuntu系统相关知识 + +- 非root用户无法使用1024以下端口 +- /etc/profile中配置的环境变量重启失效,需要在/etc/environment中配置 +- 执行shell需要用bash + +# VIM快捷键 + +| 快捷键 | 作用 | 快捷键 | 作用 | +| ------- | -------------------------- | ------ | -------------- | +| gg | 跳转到文件开头快捷键 | yy | 复制一行 | +| shift+g | 跳转到文件结尾快捷键 | dd | 删除一行 | +| xxgg | 跳转到指定的xx行数,如 50gg | p | 插入复制的数据 | +| [[ | 跳转到文件开头 | | | +| ]] | 跳转到文件结尾 | | | +| /xx | 从上往下搜索xx | | | +| ?xx | 从下往上搜索xx | | | +| | | | | + +- VIM异常退出 + + VIM异常退出的时候,再次进入编辑会提示: + + ```txt + 交换文件 "xxx.swp" 已存在! + ``` + + 这时候使用 `ll -all` 命令可以看到一个`.xxx.swp`隐藏文件,删掉此文件即可 + +# mysql相关 + +| 命令 | 作用 | +| :---------------------------------------------- | :---------------------------- | +| show VARIABLES like '%max_allowed_packet%'; | 查看mysql可接收最大数据包大小 | +| set global max_allowed_packet = 1024*1024*1024; | 设置mysql可接收最大数据包大小 | +| show global variables like 'wait_timeout'; | 查看mysql连接超时时间 | +| set global wait_timeout=604800; | 设置mysql连接超时时间 | +| mysql -h host -P port -u user -ppassword | 链接mysql | +| | | + +# maven命令 + +| 命令 | 作用 | 命令 | 作用 | +| ----------- | ------------------------- | ----------- | ------------------- | +| mvn clean | 清空输出目录,默认是target | mvn install | 安装jar到本地仓库中 | +| mvn compile | 编译源代码 | mvn deploy | 安装jar到远程仓库中 | +| mvn package | 打包 | | | + +# webService 相关 + +```shell +wsimport -encoding utf-8 -keep -d .\ -p com.sprt.monitor.api.pagw.bean .\location.wsdl + +wsdl2java -d .\ .\location.wsdl +``` + diff --git a/3.linux/2.看门狗脚本.md b/3.linux/2.看门狗脚本.md new file mode 100644 index 0000000..60d224b --- /dev/null +++ b/3.linux/2.看门狗脚本.md @@ -0,0 +1,91 @@ +# 看门狗脚本 + +## 已注册service程序看门狗 + +配置简单,但不够灵活 + +- 脚本程序 + + ```shell + #!/bin/sh + + while [ 1 ] + do + while read line + do + if [ -n "$line" ] && [ ${line:0:1} != "#" ] + then + pm=$(service $line status) + + if [[ ${pm} =~ 'Not running' ]] + then + echo "service $line start" + service $line start + fi + + fi + + done < /home/work/mengyxu/watchdog/service.cfg + + sleep 10 + + done + ``` + +- 配置文件 + ```txt + #monitor + whims + location + ``` + +## 可执行jar程序看门狗 + +可配置启动参数 + +- 脚本程序 + + ```shell + #!/bin/sh + #!/bin/sh + + while [ 1 ] + do + while read line + do + if [ -n "$line" ] && [ ${line:0:1} != "#" ] + then + path=${line%/*} + pro=${line%% *} + par=${line#*.jar} + pm=$(ps -ef | grep java) + + if [[ !($pm =~ $pro) ]] + then + cd $path + nohup java -server $par -jar $pro > /dev/null 2>&1 & + echo "start $pro" + fi + + fi + + done < /home/work/mengyxu/watchdog/jar.cfg + + sleep 10 + + done + + + ``` + + + +- 配置文件 + + ```txt + #/home/work/mengyxu/monitor/monitor.jar + /home/work/mengyxu/whims/whims.jar -Xms32m -Xmx128m + /home/work/mengyxu/location/location.jar -Xms32m -Xmx64m + ``` + + diff --git a/3.linux/3.nginx安装与配置.md b/3.linux/3.nginx安装与配置.md new file mode 100644 index 0000000..40841b2 --- /dev/null +++ b/3.linux/3.nginx安装与配置.md @@ -0,0 +1,261 @@ +# nginx安装与配置 + +## 准备环境 + +```shell +yum -y install gcc +yum install -y pcre pcre-devel +yum install -y zlib zlib-devel +``` + +## 下载 + +nginx官方下载指定版本源码压缩包 + +上传到服务器解压 + +## 编译与安装 + +```shell +./configure --prefix=指定安装目录前缀 --with指定额外的模块 +make +make install DESTDIR=指定安装目录后缀 +``` + +## http反向代理配置 + +* 根据路径分发到不同端口参数配置示例 + +``` +http { + include mime.types; + default_type application/octet-stream; + + server { + listen 80; + server_name localhost; + + location / { + root proxy_pass http://127.0.0.1:8080; + index index.html index.htm; + } + + location /fence { + root proxy_pass http://127.0.0.1:8081; + index index.html index.htm; + } + + location /RfsSniffer { + root proxy_pass http://127.0.0.1:8433; + index index.html index.htm; + } + } +} +``` + +- 根据域名分发到不同端口参数配置示例 + +``` +http { + + server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://127.0.0.1:8081; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + + } + + server { + listen 80; + server_name location.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:8081; + index index.html index.htm; + } + + } + +} +``` + +## tcp转发 + +转发https请求,无需在nginx配置ssl证书,nginx版本号必须 >1.15.2,编译时必须配置以下模块 + +`--with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module` + +- 同一个端口监听http与https请求配置示例,$ssl_preread_protocol,可以让stream区分web ssl/tls和其他协议 + +``` +stream { + upstream http{ + server 127.0.0.1:8081; + } + + upstream https{ + server 127.0.0.1:8433; + } + + map $ssl_preread_protocol $upstream{ + default http; + "TLSv1.3" https; + "TLSv1.2" https; + "TLSv1.1" https; + "TLSv1.0" https; + "TLSv1" https; + "TLSv2" https; + "SSLv2" https; + "SSLv3" https; + } + + server { + listen 0.0.0.0:28181; + ssl_preread on; + proxy_pass $upstream; + } + +} +``` + +- http与stream混合使用 + +``` +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://127.0.0.1:8081; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + server { + listen 80; + server_name location.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:8081; + index index.html index.htm; + } + } + + server { + listen 80; + server_name monitor.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:8082; + index index.html index.htm; + } + } + + server { + listen 80; + server_name whims.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:801; + index index.html index.htm; + } + } + + server { + listen 80; + server_name license.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:88; + index index.html index.htm; + } + } + + server { + listen 80; + server_name robust.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:89; + index index.html index.htm; + } + } + + server { + listen 80; + server_name dzwl.xumy.vip; + + location / { + proxy_pass http://127.0.0.1:805; + index index.html index.htm; + } + } + +} + +stream{ + + log_format proxy '$remote_addr - [$time_local] $protocol $status "$upstream_addr" $remote_addr $remote_port '; + access_log /home/work/logs/nginx/tcp-access.log proxy; + open_log_file_cache off; + + map_hash_bucket_size 64; + + map $ssl_preread_protocol $upstream{ + default http; + "TLSv1.3" $https; + "TLSv1.2" $https; + "TLSv1.1" $https; + "TLSv1.0" $https; + "TLSv1" $https; + "TLSv2" $https; + "SSLv2" $https; + "SSLv3" $https; + } + + map $ssl_preread_server_name $https{ + default dzwl; + } + + + upstream http { + server 127.0.0.1:80; + } + + upstream dzwl { + server 127.0.0.1:806; + } + + server{ + listen 8080; + ssl_preread on; + proxy_pass $upstream; + proxy_connect_timeout 15s; + proxy_timeout 15s; + proxy_next_upstream_timeout 15s; + } + +} +``` + diff --git a/3.linux/4.redis安装与配置.md b/3.linux/4.redis安装与配置.md new file mode 100644 index 0000000..befb239 --- /dev/null +++ b/3.linux/4.redis安装与配置.md @@ -0,0 +1,41 @@ +# redis安装与配置 + +## linux + +- 下载:[官方源码](http://redis.io/download) + + `wget http://download.redis.io/releases/redis-6.0.8.tar.gz` + +- 安装 + + ```shell + tar xzf redis-6.0.8.tar.gz + cd redis-6.0.8 + make + ``` + +- 配置 + + 默认配置文件为解压目录下redis.conf + + | 配置项 | 作用 | 默认 | + | -------------- | --------------------- | --------- | + | daemonize | 是否后台运行redis服务 | no | + | requirepass | redis认证密码 | 无 | + | protected-mode | 是否开启远程保护 | yes | + | bind | 绑定访问地址 | 127.0.0.1 | + +- 启动 + + 在src目录下的redis-server和redis-cli两个可执行文件,直接执行就可以启动redis服务或客户端 + + 建议将这两个文件拷贝到/sbin目录下,并将nginx.conf拷贝到/etc目录下 + + 方便在任意目录执行`redis-server /etc/redis.conf`启动服务 + +- 链接 + + `redis-cli` 链接 + + `auth $password` 进行密码验证 + diff --git a/3.linux/5.docker.md b/3.linux/5.docker.md new file mode 100644 index 0000000..70f6a93 --- /dev/null +++ b/3.linux/5.docker.md @@ -0,0 +1,317 @@ +# docker的安装与使用 + +## 安装(centos) + +- 卸载旧版本 + + ```shell + $ sudo yum remove docker \ + docker-client \ + docker-client-latest \ + docker-common \ + docker-latest \ + docker-latest-logrotate \ + docker-logrotate \ + docker-engine + ``` + + + +- 安装依赖 + + ```shell + yum install -y yum-utils \ + device-mapper-persistent-data \ + lvm2 + ``` + + + +- 设置仓库(非必须) + + 官方源地址(比较慢) + + ```shell + yum-config-manager \ + --add-repo \ + https://download.docker.com/linux/centos/docker-ce.repo + ``` + + 阿里云 + + ```shell + yum-config-manager \ + --add-repo \ + http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo + ``` + + 清华大学源 + + ```shell + yum-config-manager \ + --add-repo \ + https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo + ``` + + + +- 安装**docker** + + 安装最新版本 + + ```shell + yum install docker-ce docker-ce-cli containerd.io + ``` + + 安装指定版本 + + ```shell + yum install docker-ce- docker-ce-cli- containerd.io + ``` + + 启动**docker** + + ```shell + systemctl start docker + ``` + + 设置开机启动 + + ```shell + systemctl enable docker + ``` + + 停止**docker** + + ``` + systemctl stop docker + ``` + +- 卸载**docker** + + 删除安装包 + + ```shell + yum remove docker-ce + ``` + + 删除镜像、容器、配置文件等内容,默认路径为:/var/lib/docker,自定义路径为:/etc/docker/daemon.json中data-root属性 + +## 使用 + +- 镜像 + + 获取最新版本镜像 + + ```shell + docker pull <镜像名称> + docker pull <镜像名称>:latest + ``` + + 获取指定版本 + + ```shell + docker pull <镜像名称>:<版本号> + ``` + + 删除镜像 + + ```shell + docker rmi <镜像ID> + ``` + +- 创建与启动容器 + + 创建新容器并启动 + + ```shell + docker run -itd --<容器名> <镜像名> <容器内执行的命令> + ``` + + 参数说明 + + ```tex + -i: 以交互模式运行容器,通常与 -t 同时使用; + -t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用; + -d: 后台运行容器,并返回容器ID; + -p: 指定端口映射,格式为:主机(宿主)端口:容器端口 + -v: 挂载宿主机的一个目录到容器,格式为:主机(宿主)目录:容器目录; + -e: username="ritchie": 设置环境变量; + -m: :设置容器使用内存最大值; + --privileged 容器内root用户是否真正拥有root权限 + --restart :容器退出是重启策略 + no默认值,表示容器退出时,docker不自动重启容器 + on-failure 若容器的退出状态非0,则docker自动重启容器,还可以指定重启次数,若超过指定次数未能启动容器则放弃 + always 容器退出时总是重启 + unless-stopped 容器退出时总是重启,但不考虑Docker守护进程启动时就已经停止的容器 + 如果容器启动时没有设置–restart参数,则通过下面命令进行更新: + docker update --restart=always <容器ID> + ``` + + 停止容器 + + ```shell + docker stop <容器ID> + ``` + + 启动容器 + + ```shell + docker start <容器ID> + ``` + +- 进入退出 + + 查看所有容器 + + ```shell + docker ps -a + ``` + + 进入容器,**attach**或**exec**(推荐使用,退出容器终端容器不会停止) + + ```shell + docker exec -it <容器ID> /bin/bash + ``` + + 进入容器后输入**exit** 退出容器 + +- 删除与导入导出 + + 删除容器 + + ```shell + docker rm -f <容器ID> + ``` + + 导出容器 + + ```shell + docker export <容器ID> > <文件名> + ``` + + 导入容器 + + ```shell + cat <文件名> | docker import - <镜像名> + ``` + +## Docker安装其他软件 + +- 安装**mysql** + + ```shell + docker pull mysql:5.7.27 + docker run -itd --name mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7.27 + ``` + +- 安装**nginx** + + ```shell + docker pull nginx + docker run -d --name nginx -p 80:80 -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx -v /home/nginx/data:/home nginx + ``` + +- 安装**gitea** + + ```shell + docker pull gitea/gitea + docker run -d --name gitea --privileged --restart=always -p 122:22 -p 3000:3000 -v /home/gitea/data:/data gitea/gitea + ``` + + + +- 安装**gitlab** + + ```shell + docker search gitlab + docker pull twang2218/gitlab-ce-zh + docker run -d -p 443:443 -p 280:80 -p 222:22 --name gitlab --privileged --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab twang2218/gitlab-ce-zh + ``` + + 修改gitlab.rb配置文件 + + ```tex + external_url "http://gitlab.xumy.vip:28080" + nginx['proxy_set_headers'] = { "Host" => "gitlab.xumy.vip:28080" } + ``` + +- 安装禅道 + + 拉取镜像 + + ```shell + docker pull easysoft/zentao:15.7.1 + ``` + + 创建网络驱动 + + ```shell + docker network create --subnet=172.172.172.0/24 zentaonet + ``` + + 启动容器 + + ```tex + sudo docker run --name [容器名] -p [主机端口]:80 --network=[网络驱动名] --ip [容器IP] --mac-address [mac地址] -v [主机禅道目录]:/www/zentaopms -v [主机mysql目录]:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=[数据库密码] -d easysoft/zentao:[镜像标签] + + 其中,容器名:启动的容器名字,可随意指定; + 主机端口:主机端口为web访问端口; + 网络驱动名:刚刚创建的网络驱动名; + 容器IP:在网络驱动范围内选择一个作为该容器的固定ip; + mac地址:指定固定的mac地址,建议范围为02:42:ac:11:00:00 到 02:42:ac:11:ff:ff; + 主机禅道目录:必须指定,方便禅道代码、附件等数据的持久化,非升级情况需指定空目录; + 主机mysql目录:必须指定,方便禅道数据持久化,非升级情况需指定空目录; + 数据库密码: 容器内置mysql用户名为root,默认密码123456,如果不修改可以不指定该变量,如果想更改密码可以设置 MYSQL_ROOT_PASSWORD变量来更改密码; + ``` + + ```shell + docker run --name zentao -p 8080:80 --network=zentaonet --ip 172.172.172.2 --mac-address 02:42:ac:11:00:ff -v /home/zentao/pms:/www/zentaopms -v /home/zentao/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d easysoft/zentao:15.7.1 + ``` + +- 安装**redis** + + ```shell + docker pull redis:latest + docker run -d --name redis -p 6379:6379 redis:latest + ``` + +- 安装**masterlab** + + ```shell + cd /home + git clone https://gitee.com/firego/masterlab-docker.git + cd ./masterlab-docker/www + git clone https://gitee.com/firego/masterlab.git + cd ./masterlab + unzip ./vendor.zip + + + docker run -d --name php74 --expose=9000 -p 9000:9000 --link mysql-server:mysql --link redis:redis \ + -v /home/masterlab-docker/www/:/var/www/html/ \ + -v /home/masterlab-docker/conf/php/php74.ini:/usr/local/etc/php/php.ini \ + -v /home/masterlab-docker/conf/php/php-fpm.d/www74.conf:/usr/local/etc/php-fpm.d/www.conf \ + -v /home/masterlab-docker/log/php-fpm/:/var/log/php-fpm/ \ + gopeak/masterlab:php-fpm-74 + + + docker run -d --name nginx-alpine -p 80:80 -p 443:443 --link php74:fpm74 \ + -v /home/masterlab-docker/www/:/var/www/html/ \ + -v /home/masterlab-docker/conf/nginx/conf.d:/etc/nginx/conf.d/ \ + -v /home/masterlab-docker/conf/nginx/nginx.conf:/etc/nginx/nginx.conf \ + -v /home/masterlab-docker/log/nginx/:/var/log/nginx/ \ + -e "TZ=Asia/Shanghai" \ + nginx:alpine + + docker run -d -it --rm --name php74-cli \ + -p 9002:9002 \ + -v /home/masterlab-docker/www/masterlab:/usr/workspaces/project \ + -w /usr/workspaces/project \ + gopeak/masterlab:php-cli-74 \ + php ./bin/swoole_server.php + + + ``` + + + diff --git a/3.linux/9.gitlab安装.md b/3.linux/9.gitlab安装.md new file mode 100644 index 0000000..1d4af10 --- /dev/null +++ b/3.linux/9.gitlab安装.md @@ -0,0 +1,70 @@ +# gitlab安装 + +## 下载 +[下载地址](https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/) + +## 安装依赖 + +```shell +yum install curl policycoreutils openssh-server openssh-clients policycoreutils-python + +systemctl enable sshd +systemctl start sshd +``` + +```shell +yum install postfix +systemctl enable postfix +systemctl start postfix +``` + +## 配置文件 + +* 默认位置:/etc/gitlab/gitlab.rb +* 内容 + ​external_url 访问地址 + git_data_dir 数据保存位置 + +## 汉化 + +* 打补丁方式 + +```shell +wget https://gitlab.com/xhang/gitlab +git diff v12.0.3 v12.0.3-zh > ../12.0.3-zh.diff +patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ../12.0.3-zh.diff +``` + +* 直接覆盖方式 +```shell +wget https://gitlab.com/xhang/gitlab/repository/12-0-stable-zh/archive.tar.bz2 -O gitlab-12-0-stable-zh.tar.bz2 +\cp -rf gitlab-v12.0.0/* /opt/gitlab/embedded/service/gitlab-rails/ +``` +# 卸载 +* 清理命令 + +```shell +wget https://gitlab.com/xhang/gitlab/repository/12-0-stable-zh/archive.tar.bz2 -O gitlab-12-0-stable-zh.tar.bz2 +\cp -rf gitlab-v12.0.0/* /opt/gitlab/embedded/service/gitlab-rails/ +``` + ++ 停止gitlab + +`gitlab-ctl stop` + +* 卸载gitlab + +`rpm -e gitlab-ce` + +- 查看进程 + +`ps aux | grep gitlab` + +- 杀掉守护进程 + +`kill -9 xxx` + +- 清理残余文件 + +`find / -name gitlab | xargs rm -rf` + diff --git a/4.客户端/android studio.md b/4.客户端/android studio.md new file mode 100644 index 0000000..8a296da --- /dev/null +++ b/4.客户端/android studio.md @@ -0,0 +1,54 @@ +# android studio + + + +# # 下载安装 + +[官方最新版下载地址](https://developer.android.google.cn/studio) + +安装没特别步骤,直接下一步到安装完成 + +## 下载android SDK + +依次点开 file -> settings -> Appearance & Behavior -> System Settings -> Android SDK + +选择需要安装的SDK版本,点击OK下载安装 + +第一次会先安装SDK Tools + +## 创建手机 + +点击右上角手机图标(ADV Manager) + +点击创建虚拟设备(+Create Virtual Device) + +选择手机尺寸下一步(next) + +选择android系统版本完成创建(Finish),没有下载对应版本会先下载 + +## 启动手机 + +点击ADV Manager窗口的表格中Actions列点击启动图标 + +## 安装android程序到手机 + +点击 run 选需要安装的程序 + + + +## 常用快捷键 + +| 快捷键 | 用途 | 快捷键 | 用途 | +| ---------- | ------------ | --------------------- | ---------- | +| Ctrl+Alt+O | 自动导包 | Ctrl+/ Ctrl+Shift+/ | 代码注释 | +| Ctrl+Alt+V | 快速声明变量 | Ctrl+Alt+L | 代码格式化 | +| Ctrl+y | 删除行 | Ctrl+Shift+Z | 向前 | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +| | | | | +