diff --git a/README.md b/README.md index e786c24..6963a22 100644 --- a/README.md +++ b/README.md @@ -4,37 +4,53 @@ > > :book: [电子书](https://dunwu.github.io/linux-tutorial/) | [电子书(国内)](http://turnon.gitee.io/linux-tutorial/) -| :wrench: | :shell: | :memo: | :books: | -| :---------------------------: | :-------------------: | :---------------: | :-------------------: | -| [软件安装配置](#软件安装配置) | [运维脚本](#运维脚本) | [知识点](#知识点) | [学习资源](#学习资源) | +| :wrench: | :shell: | :memo: | :books: | +| :-------------------: | :-------------------: | :---------------: | :-------------------: | +| [软件运维](#软件运维) | [运维脚本](#运维脚本) | [知识点](#知识点) | [学习资源](#学习资源) | -## 软件安装配置 +## 软件运维 -- [JDK 安装](docs/linux/soft/jdk-install.md) -- [Elastic 安装](docs/linux/soft/elastic) -- [Gitlab 安装](docs/linux/soft/kafka-install.md) -- [Jenkins 安装](docs/linux/soft/jenkins.md) -- [Kafka 安装](docs/linux/soft/kafka-install.md) -- [Maven 安装](docs/linux/soft/maven-install.md) -- [Nexus 安装](docs/linux/soft/nexus-install.md) -- [Nginx 教程](https://github.com/dunwu/nginx-tutorial) -- [Nodejs 安装](docs/linux/soft/nodejs-install.md) -- [RocketMQ 安装](docs/linux/soft/rocketmq-install.md) -- [Svn 安装](docs/linux/soft/svn-install.md) -- [Tomcat 安装](docs/linux/soft/tomcat-install.md) -- [Zookeeper 安装](docs/linux/soft/zookeeper-install.md) -- [Nacos 安装](docs/linux/soft/nacos-install.md) +> 本章节内容介绍日常开发中常见的一些软件、工具的安装、配置。 + +- 开发环境 + - [JDK 安装](docs/linux/soft/jdk-install.md) + - [Maven 安装](docs/linux/soft/maven-install.md) + - [Nodejs 安装](docs/linux/soft/nodejs-install.md) +- 开发工具 + - [Nexus 运维](docs/linux/soft/nexus-install.md) + - [Gitlab 运维](docs/linux/soft/kafka-install.md) + - [Jenkins 运维](docs/linux/soft/jenkins.md) + - [Svn 运维](docs/linux/soft/svn-ops.md) + - [YApi 运维](docs/linux/soft/yapi-ops.md) +- 中间件服务 + - [Elastic 运维](docs/linux/soft/elastic) + - [Kafka 运维](docs/linux/soft/kafka-install.md) + - [RocketMQ 运维](docs/linux/soft/rocketmq-install.md) + - [Zookeeper 运维](docs/linux/soft/zookeeper-install.md) + - [Nacos 运维](docs/linux/soft/nacos-install.md) +- 服务器 + - [Nginx 教程](https://github.com/dunwu/nginx-tutorial) + - [Tomcat 运维](docs/linux/soft/tomcat-install.md) +- 数据库 + - [Mongodb 运维](docs/linux/soft/mongodb-ops.md) + - [Redis 运维](docs/linux/soft/redis-ops.md) ## 运维脚本 - [系统运维脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/sys) -- [软件安装配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) +- [软件运维配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) - [工具脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) +- [Vim 应用指南](docs/linux/ops/vim.md) +- [Zsh 应用指南](docs/linux/ops/zsh.md) +- [Shell 教程](docs/linux/ops/shell.md) +- [Python 教程](docs/linux/ops/python.md) -> 提供一键式安装、配置软件脚本 +> 提供一键式运维、配置软件脚本 ## 知识点 +### Linux + - [Linux 命令教程](docs/linux/cli/README.md) - [查看 Linux 命令帮助信息](docs/linux/cli/查看Linux命令帮助信息.md) - [Linux 文件目录管理](docs/linux/cli/Linux文件目录管理.md) @@ -48,21 +64,20 @@ - [Linux 运维](docs/linux/ops/README.md) - [linux 典型运维应用](docs/linux/ops/linux典型运维应用.md) - [samba 使用详解](docs/linux/ops/samba使用详解.md) + +### Docker + - [Docker 教程](docs/docker) - [Docker 应用指南](docs/docker/docker.md) - [Docker Cheat Sheet](docs/docker/docker-cheat-sheet.md) + +### Git + - [Git 教程](docs/git/README.md) - [Git 快速指南](docs/git/git-quickstart.md) - [Git 配置](docs/git/git-configuration.md) - [git-flow 工作流](docs/git/git-flow.md) - [Git 常见问题](docs/git/git-faq.md) -- [Vim](docs/linux/tool/vim.md) -- 脚本语言 - - [一篇文章让你彻底掌握 shell 语言](docs/lang/shell.md) - - [一篇文章让你彻底掌握 python 语言](docs/lang/python.md) -- 运维 - - [Linux 典型运维应用](docs/linux/ops/linux典型运维应用.md) - - [samba 使用详解](docs/linux/ops/samba使用详解.md) ## 学习资源 diff --git a/docs/README.md b/docs/README.md index 34cc81c..e41a86b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,37 +4,53 @@ > > :book: [电子书](https://dunwu.github.io/linux-tutorial/) | [电子书(国内)](http://turnon.gitee.io/linux-tutorial/) -| :wrench: | :shell: | :memo: | :books: | -| :---------------------------: | :-------------------: | :---------------: | :-------------------: | -| [软件安装配置](#软件安装配置) | [运维脚本](#运维脚本) | [知识点](#知识点) | [学习资源](#学习资源) | +| :wrench: | :shell: | :memo: | :books: | +| :-------------------: | :-------------------: | :---------------: | :-------------------: | +| [软件运维](#软件运维) | [运维脚本](#运维脚本) | [知识点](#知识点) | [学习资源](#学习资源) | -## 软件安装配置 +## 软件运维 -- [JDK 安装](linux/soft/jdk-install.md) -- [Elastic 安装](linux/soft/elastic) -- [Gitlab 安装](linux/soft/kafka-install.md) -- [Jenkins 安装](linux/soft/jenkins.md) -- [Kafka 安装](linux/soft/kafka-install.md) -- [Maven 安装](linux/soft/maven-install.md) -- [Nexus 安装](linux/soft/nexus-install.md) -- [Nginx 教程](https://github.com/dunwu/nginx-tutorial) -- [Nodejs 安装](linux/soft/nodejs-install.md) -- [RocketMQ 安装](linux/soft/rocketmq-install.md) -- [Svn 安装](linux/soft/svn-install.md) -- [Tomcat 安装](linux/soft/tomcat-install.md) -- [Zookeeper 安装](linux/soft/zookeeper-install.md) -- [Nacos 安装](linux/soft/nacos-install.md) +> 本章节内容介绍日常开发中常见的一些软件、工具的安装、配置。 + +- 开发环境 + - [JDK 安装](linux/soft/jdk-install.md) + - [Maven 安装](linux/soft/maven-install.md) + - [Nodejs 安装](linux/soft/nodejs-install.md) +- 开发工具 + - [Nexus 运维](linux/soft/nexus-install.md) + - [Gitlab 运维](linux/soft/kafka-install.md) + - [Jenkins 运维](linux/soft/jenkins.md) + - [Svn 运维](linux/soft/svn-ops.md) + - [YApi 运维](linux/soft/yapi-ops.md) +- 中间件服务 + - [Elastic 运维](linux/soft/elastic) + - [Kafka 运维](linux/soft/kafka-install.md) + - [RocketMQ 运维](linux/soft/rocketmq-install.md) + - [Zookeeper 运维](linux/soft/zookeeper-install.md) + - [Nacos 运维](linux/soft/nacos-install.md) +- 服务器 + - [Nginx 教程](https://github.com/dunwu/nginx-tutorial) + - [Tomcat 运维](linux/soft/tomcat-install.md) +- 数据库 + - [Mongodb 运维](linux/soft/mongodb-ops.md) + - [Redis 运维](linux/soft/redis-ops.md) ## 运维脚本 - [系统运维脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/sys) -- [软件安装配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) +- [软件运维配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) - [工具脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) +- [Vim 应用指南](linux/ops/vim.md) +- [Zsh 应用指南](linux/ops/zsh.md) +- [Shell 教程](linux/ops/shell.md) +- [Python 教程](linux/ops/python.md) -> 提供一键式安装、配置软件脚本 +> 提供一键式运维、配置软件脚本 ## 知识点 +### Linux + - [Linux 命令教程](linux/cli/README.md) - [查看 Linux 命令帮助信息](linux/cli/查看Linux命令帮助信息.md) - [Linux 文件目录管理](linux/cli/Linux文件目录管理.md) @@ -48,21 +64,20 @@ - [Linux 运维](linux/ops/README.md) - [linux 典型运维应用](linux/ops/linux典型运维应用.md) - [samba 使用详解](linux/ops/samba使用详解.md) + +### Docker + - [Docker 教程](docker) - [Docker 应用指南](docker/docker.md) - [Docker Cheat Sheet](docker/docker-cheat-sheet.md) + +### Git + - [Git 教程](git/README.md) - [Git 快速指南](git/git-quickstart.md) - [Git 配置](git/git-configuration.md) - [git-flow 工作流](git/git-flow.md) - [Git 常见问题](git/git-faq.md) -- [Vim](linux/tool/vim.md) -- 脚本语言 - - [一篇文章让你彻底掌握 shell 语言](lang/shell.md) - - [一篇文章让你彻底掌握 python 语言](lang/python.md) -- 运维 - - [Linux 典型运维应用](linux/ops/linux典型运维应用.md) - - [samba 使用详解](linux/ops/samba使用详解.md) ## 学习资源 diff --git a/docs/linux/cli/Linux文件内容查看编辑.md b/docs/linux/cli/Linux文件内容查看编辑.md index 63590d8..5fc4409 100644 --- a/docs/linux/cli/Linux文件内容查看编辑.md +++ b/docs/linux/cli/Linux文件内容查看编辑.md @@ -1,6 +1,6 @@ --- title: Linux 文件内容查看编辑 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux文件压缩和解压.md b/docs/linux/cli/Linux文件压缩和解压.md index d4c21dc..1185ff3 100644 --- a/docs/linux/cli/Linux文件压缩和解压.md +++ b/docs/linux/cli/Linux文件压缩和解压.md @@ -1,6 +1,6 @@ --- title: Linux 文件压缩和解压 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux文件目录管理.md b/docs/linux/cli/Linux文件目录管理.md index a6df8e7..d2899e1 100644 --- a/docs/linux/cli/Linux文件目录管理.md +++ b/docs/linux/cli/Linux文件目录管理.md @@ -1,6 +1,6 @@ --- title: Linux 文件目录管理命令 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux用户管理.md b/docs/linux/cli/Linux用户管理.md index a3d53c7..5b050f4 100644 --- a/docs/linux/cli/Linux用户管理.md +++ b/docs/linux/cli/Linux用户管理.md @@ -1,6 +1,6 @@ --- title: Linux 用户管理 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux硬件管理.md b/docs/linux/cli/Linux硬件管理.md index 3d5c6ef..bae5e85 100644 --- a/docs/linux/cli/Linux硬件管理.md +++ b/docs/linux/cli/Linux硬件管理.md @@ -1,6 +1,6 @@ --- title: Linux 硬件管理 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux系统管理.md b/docs/linux/cli/Linux系统管理.md index c1f13be..3e3a185 100644 --- a/docs/linux/cli/Linux系统管理.md +++ b/docs/linux/cli/Linux系统管理.md @@ -1,6 +1,6 @@ --- title: Linux 系统管理 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux网络管理.md b/docs/linux/cli/Linux网络管理.md index e95e91f..ea01a90 100644 --- a/docs/linux/cli/Linux网络管理.md +++ b/docs/linux/cli/Linux网络管理.md @@ -1,6 +1,6 @@ --- title: Linux 网络管理 -date: 2018/02/27 +date: 2018-02-27 categories: - linux tags: diff --git a/docs/linux/cli/Linux软件管理.md b/docs/linux/cli/Linux软件管理.md index 1182438..ad250ce 100644 --- a/docs/linux/cli/Linux软件管理.md +++ b/docs/linux/cli/Linux软件管理.md @@ -1,6 +1,6 @@ --- title: Linux 软件管理 -date: 2018/02/26 +date: 2018-02-26 categories: - linux tags: diff --git a/docs/linux/cli/查看Linux命令帮助信息.md b/docs/linux/cli/查看Linux命令帮助信息.md index fc8c92b..e0e6078 100644 --- a/docs/linux/cli/查看Linux命令帮助信息.md +++ b/docs/linux/cli/查看Linux命令帮助信息.md @@ -1,6 +1,6 @@ --- title: 查看 Linux 命令帮助信息 -date: 2018/09/26 +date: 2018-09-26 categories: - linux tags: diff --git a/docs/lang/python.md b/docs/linux/ops/python.md similarity index 99% rename from docs/lang/python.md rename to docs/linux/ops/python.md index 5f44bfe..10b1bfd 100644 --- a/docs/lang/python.md +++ b/docs/linux/ops/python.md @@ -1,6 +1,6 @@ --- title: Python -date: 2018/06/28 +date: 2018-06-28 categories: - linux tags: diff --git a/docs/linux/ops/samba使用详解.md b/docs/linux/ops/samba使用详解.md index e9f8416..cab94cf 100644 --- a/docs/linux/ops/samba使用详解.md +++ b/docs/linux/ops/samba使用详解.md @@ -1,6 +1,6 @@ --- title: samba 使用详解 -date: 2018/09/28 +date: 2018-09-28 categories: - linux tags: diff --git a/docs/lang/shell.md b/docs/linux/ops/shell.md similarity index 100% rename from docs/lang/shell.md rename to docs/linux/ops/shell.md diff --git a/docs/linux/tool/vim.md b/docs/linux/ops/vim.md similarity index 99% rename from docs/linux/tool/vim.md rename to docs/linux/ops/vim.md index e4d1181..4b658e9 100644 --- a/docs/linux/tool/vim.md +++ b/docs/linux/ops/vim.md @@ -1,14 +1,4 @@ ---- -title: Vim 快速指南 -date: 2017/11/17 -categories: - - linux -tags: - - linux - - vim ---- - -# Vim 快速指南 +# Vim 应用指南 diff --git a/docs/linux/ops/zsh.md b/docs/linux/ops/zsh.md new file mode 100644 index 0000000..a6b54a6 --- /dev/null +++ b/docs/linux/ops/zsh.md @@ -0,0 +1,140 @@ +# Zsh 应用指南 + + + +- [1. Zsh 简介](#1-zsh-简介) + - [1.1. Zsh 是什么?](#11-zsh-是什么) +- [2. Zsh 安装](#2-zsh-安装) + - [2.1. 环境要求](#21-环境要求) + - [2.2. 安装 zsh](#22-安装-zsh) + - [2.3. 安装 oh-my-zsh](#23-安装-oh-my-zsh) + - [2.4. 配置 oh-my-zsh](#24-配置-oh-my-zsh) +- [3. 快捷键](#3-快捷键) +- [4. 参考资料](#4-参考资料) + + + +## 1. Zsh 简介 + +### 1.1. Zsh 是什么? + +使用 Linux 的人都知道:**_Shell_ 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁。_Shell_ 既是一种命令语言,又是一种程序设计语言**。 + +Shell 的类型有很多种,linux 下默认的是 bash,虽然 bash 的功能已经很强大,但对于以懒惰为美德的程序员来说,bash 的提示功能不够强大,界面也不够炫,并非理想工具。 + +[**Zsh**](http://www.zsh.org/) 也是一种 Shell(据传说 99% 的 Bash 操作 和 Zsh 是相同的),它的功能极其强大,只是配置过于复杂,起初只有极客才在用。后来,出现了一个名叫 [**oh-my-zsh**](https://github.com/robbyrussell/oh-my-zsh) 的开源项目,使用 zsh 就变得十分简易了。 + +## 2. Zsh 安装 + +### 2.1. 环境要求 + +- CentOS 6.7 64 bit +- root 用户 + +### 2.2. 安装 zsh + +- 先看下你的 CentOS 支持哪些 shell:`cat /etc/shells`,正常结果应该是这样的: + +```bash +/bin/sh +/bin/bash +/sbin/nologin +/bin/dash +/bin/tcsh +/bin/csh +``` + +如果已经有 zsh ,那么我们就不必安装了。 + +- CentOS 安装:`sudo yum install -y zsh` +- Ubuntu 安装:`sudo apt-get install -y zsh` +- 检查系统的 shell:`cat /etc/shells`,你会发现多了一个:`/bin/zsh` + +### 2.3. 安装 oh-my-zsh + +使用 [**Zsh**](http://www.zsh.org/),怎么能离开灵魂伴侣 [**oh-my-zsh**](https://github.com/robbyrussell/oh-my-zsh)? + +```bash +# 安装 oh-my-zsh +wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh +``` + +### 2.4. 配置 oh-my-zsh + +#### 插件 + +> oh-my-zsh 插件太多,不一一列举,请参考:[oh-my-zsh 插件列表](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) + +- 启用 oh-my-zsh 中自带的插件。 +- 查看 oh-my-zsh 插件数:`ls -l /root/.oh-my-zsh/plugins |grep "^d"|wc -l` +- 编辑配置文件:`vim /root/.zshrc` +- 插件推荐: + - [`zsh-autosuggestions`](https://github.com/zsh-users/zsh-autosuggestions) + - 这个插件会对历史命令一些补全,类似 fish 终端 + - 安装,复制该命令:`git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-\~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions` - 编辑:`vim \~/.zshrc`,找到这一行,后括号里面的后面添加:`plugins=( 前面的一些插件名称,换行,加上:zsh-autosuggestions)` - 刷新下配置:`source \~/.zshrc` + - extract + - 功能强大的解压插件,所有类型的文件解压一个命令 x 全搞定,再也不需要去记 tar 后面到底是哪几个参数了。 + - z + - 强大的目录自动跳转命令,会记忆你曾经进入过的目录,用模糊匹配快速进入你想要的目录。 + - [`zsh-syntax-highlighting`](https://github.com/zsh-users/zsh-syntax-highlighting) + - 这个插件会对终端命令高亮显示,比如正确的拼写会是绿色标识,否则是红色,另外对于一些 shell 输出语句也会有高亮显示,算是不错的辅助插件 + - 安装,复制该命令:`git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-\~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting` + - 编辑:`vim \~/.zshrc`,找到这一行,后括号里面的后面添加:`plugins=( 前面的一些插件名称,换行,加上:zsh-syntax-highlighting)` - 刷新下配置:`source \~/.zshrc` + - [`wd`](https://github.com/mfaerevaag/wd) + - 简单地讲就是给指定目录映射一个全局的名字,以后方便直接跳转到这个目录,比如: + - 编辑配置文件,添加上 wd 的名字:`vim /root/.zshrc` + - 我常去目录:**/opt/setups**,每次进入该目录下都需要这样:`cd /opt/setups` + - 现在用 wd 给他映射一个快捷方式:`cd /opt/setups ; wd add setups` + - 以后我在任何目录下只要运行:`wd setups` 就自动跑到 /opt/setups 目录下了 + - [`autojump`](https://github.com/wting/autojump) + - 这个插件会记录你常去的那些目录,然后做一下权重记录,你可以用这个命令看到你的习惯:`j --stat`,如果这个里面有你的记录,那你就只要敲最后一个文件夹名字即可进入,比如我个人习惯的 program:`j program`,就可以直接到:`/usr/program` + - 插件下载:`wget https://github.com/downloads/wting/autojump/autojump_v21.1.2.tar.gz` + - 解压:`tar zxvf autojump_v21.1.2.tar.gz` + - 进入解压后目录并安装:`cd autojump_v21.1.2/ ; ./install.sh` + - 再执行下这个:`source /etc/profile.d/autojump.sh` + - 编辑配置文件,添加上 autojump 的名字:`vim /root/.zshrc` + +#### 主题 + +> oh-my-zsh 主题太多,不一一列举,请参考:[oh-my-zsh 主题列表](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes) + +- 查看 oh-my-zsh 主题数:`ls -l /root/.oh-my-zsh/themes |grep "^-"|wc -l` +- 个人比较推荐的是(排名有先后): + - `ys` + - `agnoster` + - `avit` + - `blinks` +- 编辑配置文件:`vim /root/.zshrc` +- 配置好新主题需要重新连接 shell 才能看到效果 + +zsh 效果如下: + +
+ +## 3. 快捷键 + +- 呃,这个其实可以不用讲的,你自己用的时候你自己会发现的,各种便捷,特别是用 Tab 多的人一定会有各种惊喜的。 +- 使用 ctrl-r 来搜索命令历史记录。按完此快捷键后,可以输入关键命令词语,如果历史记录有含有此词语会显示出来。 +- 命令别名: - 在命令行中输入 alias 可以查看已经有的命令别名 - 自己新增一些别名,编辑文件:`vim \~/.zshrc`,在文件加入下面格式的命令,比如以下是网友提供的一些思路: + +```shell +alias cls='clear' +alias ll='ls -l' +alias la='ls -a' +alias grep="grep --color=auto" +alias -s html='vim' # 在命令行直接输入后缀为 html 的文件名,会在 Vim 中打开 +alias -s rb='vim' # 在命令行直接输入 ruby 文件,会在 Vim 中打开 +alias -s py='vim' # 在命令行直接输入 python 文件,会用 vim 中打开,以下类似 +alias -s js='vim' +alias -s c='vim' +alias -s java='vim' +alias -s txt='vim' +alias -s gz='tar -xzvf' # 在命令行直接输入后缀为 gz 的文件名,会自动解压打开 +alias -s tgz='tar -xzvf' +alias -s zip='unzip' +alias -s bz2='tar -xjvf' +``` + +## 4. 参考资料 + +- [oh-my-zsh Github](https://github.com/robbyrussell/oh-my-zsh) diff --git a/docs/linux/soft/README.md b/docs/linux/soft/README.md index c83dcd1..80d3683 100644 --- a/docs/linux/soft/README.md +++ b/docs/linux/soft/README.md @@ -9,7 +9,7 @@ - [Nexus 安装](nexus-install.md) - [Nodejs 安装](nodejs-install.md) - [RocketMQ 安装](rocketmq-install.md) -- [Svn 安装](svn-install.md) +- [Svn 安装](svn-ops.md) - [Tomcat 安装](tomcat-install.md) - [Zookeeper 安装](zookeeper-install.md) - [Nacos 安装](nacos-install.md) diff --git a/docs/linux/soft/fastdfs.md b/docs/linux/soft/fastdfs.md index 2ec1a54..751c913 100644 --- a/docs/linux/soft/fastdfs.md +++ b/docs/linux/soft/fastdfs.md @@ -33,7 +33,7 @@ storage 接受到写文件请求时,会根据配置好的规则(后面会介 **meta data** :文件相关属性,键值对( Key Value Pair) 方式,如:width=1024,heigth=768 。 -![](http://www.ityouknow.com/assets/images/2018/fastdfs/fastdfs_arch.png) +
diff --git a/docs/linux/soft/maven-install.md b/docs/linux/soft/maven-install.md index 54601d5..5b41c11 100644 --- a/docs/linux/soft/maven-install.md +++ b/docs/linux/soft/maven-install.md @@ -43,4 +43,4 @@ export PATH=\$MAVEN_HOME/bin:\$PATH 以上两种安装方式,我都写了脚本去执行: -| [安装脚本](https://github.com/dunwu/OS/tree/master/codes/deploy/tool/maven) | +| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) | diff --git a/docs/linux/soft/mongodb-install.md b/docs/linux/soft/mongodb-ops.md similarity index 91% rename from docs/linux/soft/mongodb-install.md rename to docs/linux/soft/mongodb-ops.md index 760558a..6e43e0b 100644 --- a/docs/linux/soft/mongodb-install.md +++ b/docs/linux/soft/mongodb-ops.md @@ -46,4 +46,4 @@ cd /opt/mongodb/mongodb-3.6.3/bin ## 脚本 -| [安装脚本](https://github.com/dunwu/linux/tree/master/codes/deploy/tool/mongodb) | +| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) | diff --git a/docs/linux/soft/mysql-ops.md b/docs/linux/soft/mysql-ops.md new file mode 100644 index 0000000..f454836 --- /dev/null +++ b/docs/linux/soft/mysql-ops.md @@ -0,0 +1,493 @@ +# Mysql 维护 + +## 安装配置 + +通过 rpm 包安装 + +centos 的 yum 源中默认是没有 mysql 的,所以我们需要先去官网下载 mysql 的 repo 源并安装。 + +### 安装 mysql yum 源 + +官方下载地址:https://dev.mysql.com/downloads/repo/yum/ + +(1)下载 yum 源 + +```bash +$ wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm +``` + +(2)安装 yum repo 文件并更新 yum 缓存 + +```bash +$ rpm -ivh mysql80-community-release-el7-1.noarch.rpm +``` + +执行结果: + +会在 /etc/yum.repos.d/ 目录下生成两个 repo 文件 + +```bash +$ ls | grep mysql +mysql-community.repo +mysql-community-source.repo +``` + +更新 yum: + +```bash +$ yum clean all +$ yum makecache +``` + +(3)查看 rpm 安装状态 + +```bash +$ yum search mysql | grep server +mysql-community-common.i686 : MySQL database common files for server and client +mysql-community-common.x86_64 : MySQL database common files for server and +mysql-community-test.x86_64 : Test suite for the MySQL database server + : administering MySQL servers +mysql-community-server.x86_64 : A very fast and reliable SQL database server +``` + +通过 yum 安装 mysql 有几个重要目录: + +``` +# 数据库目录 +/var/lib/mysql/ +# 配置文件 +/usr/share/mysql(mysql.server命令及配置文件) +# 相关命令 +/usr/bin(mysqladmin mysqldump等命令) +# 启动脚本 +/etc/rc.d/init.d/(启动脚本文件mysql的目录) +# 配置文件 +/etc/my.cnf +``` + +### 安装 mysql 服务器 + +```bash +$ yum install mysql-community-server +``` + +### 启动 mysql 服务 + +```bash +# 启动 mysql 服务 +systemctl start mysqld.service + +# 查看运行状态 +systemctl status mysqld.service + +# 开机启动 +systemctl enable mysqld +systemctl daemon-reload +``` + +### 初始化数据库密码 + +查看一下初始密码 + +```bash +$ grep "password" /var/log/mysqld.log +2018-09-30T03:13:41.727736Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: %:lt+srWu4k1 +``` + +执行命令: + +```bash +mysql -uroot -p<临时密码> +``` + +输入临时密码,进入 mysql,如果要修改密码,执行以下指令: + +```bash +ALTER user 'root'@'localhost' IDENTIFIED BY '你的密码'; +``` + +注:密码强度默认为中等,大小写字母、数字、特殊符号,只有修改成功后才能修改配置再设置更简单的密码 + +### 配置远程访问 + +```sql +mysql> CREATE USER 'root'@'%' IDENTIFIED BY '你的密码'; +mysql> GRANT ALL ON *.* TO 'root'@'%'; +mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码'; +mysql> FLUSH PRIVILEGES; +``` + +### 跳过登录认证 + +``` +vim /etc/my.cnf +``` + +在 [mysqld] 下面加上 skip-grant-tables + +作用是登录时跳过登录认证,换句话说就是 root 什么密码都可以登录进去。 + +执行 `service mysqld restart`,重启 mysql + +## 部署 + +### 主从节点部署 + +假设需要配置一个主从 Mysql 服务器环境 + +- master 节点:192.168.8.10 +- slave 节点:192.168.8.11 + +#### 配置主从同步 + +(1)主节点配置 + +执行 `vi /etc/my.cnf` ,添加如下配置: + +```ini +[mysqld] +server-id=1 +log-bin=mysql-bin +``` + +- `server-id` - 服务器 ID 号; +- `log-bin` - 同步的日志路径及文件名,一定注意这个目录要是mysql有权限写入的; + +(2)从节点配置 + +执行 `vi /etc/my.cnf` ,添加如下配置: + +```ini +[mysqld] +server-id=2 +log-bin=mysql-bin +``` + +(3)创建用于复制操作的用户 + +```sql +mysql> CREATE USER 'sync'@'192.168.8.11' IDENTIFIED WITH mysql_native_password BY '密码'; -- 创建用户 +mysql> GRANT REPLICATION SLAVE ON *.* TO 'sync'@'192.168.8.11'; -- 授权 +mysql> FLUSH PRIVILEGES; -- 刷新授权表信息 +``` + +(4)查看主节点状态 + +```sql +mysql> show master status; ++------------------+----------+--------------+---------------------------------------------+-------------------+ +| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | ++------------------+----------+--------------+---------------------------------------------+-------------------+ +| mysql-bin.000001 | 4202 | | mysql,information_schema,performance_schema | | ++------------------+----------+--------------+---------------------------------------------+-------------------+ +1 row in set (0.00 sec) +``` + +(5)在Slave节点上设置主节点参数 + +`MASTER_LOG_FILE` 和 `MASTER_LOG_POS` 参数要分别与 `show master status` 指令获得的 `File` 和 `Position` 属性值对应。 + +```sql +mysql> CHANGE MASTER TO +MASTER_HOST='192.168.199.149', +MASTER_USER='sync', +MASTER_PASSWORD='密码', +MASTER_LOG_FILE='binlog.000001', +MASTER_LOG_POS=4202; + +``` + +(6)查看主从同步状态 + +``` +mysql> show slave status\G; +``` + +说明:如果以下两项参数均为 YES,说明配置正确。 + +- `Slave_IO_Running` +- `Slave_SQL_Running` + +(7)启动 slave 进程 + +``` +mysql> start slave; +``` + +#### 同步主节点已有数据到从节点 + +主库操作: + +(1)停止主库的数据更新操作 + +```sql +mysql> flush tables with read lock; +``` + +(2)新开终端,生成主数据库的备份(导出数据库) + +```bash +$ mysqldump -uroot -p<密码> test > test.sql +``` + +(3)将备份文件传到从库 + +```bash +$ scp test.sql root@192.168.8.11:/root/ +``` + +(4)主库解锁 + +```mysql +mysql> unlock tables; +``` + + 从库操作: + +(1)停止从库slave + +```mysql +mysql> stop slave; +``` + +(2)新建数据库test + +```mysql +mysql> create database test default charset utf8; +``` + +(3)导入数据 + +```bash +$ mysql -uroot -ptest123 cmdb show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| cmdb | +| mysql | +| performance_schema | +| test | ++--------------------+ +``` + +## 运维 + +### 创建用户 + +``` +CREATE USER 'username'@'host' IDENTIFIED BY 'password'; +``` + +说明: + +- username:你将创建的用户名 +- host:指定该用户在哪个主机上可以登陆,如果是本地用户可用 localhost,如果想让该用户可以**从任意远程主机登陆**,可以使用通配符`%` +- password:该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器 + +示例: + +```sql +CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456'; +CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456'; +CREATE USER 'pig'@'%' IDENTIFIED BY '123456'; +CREATE USER 'pig'@'%' IDENTIFIED BY ''; +CREATE USER 'pig'@'%'; +``` + +### 授权 + +命令: + +```sql +GRANT privileges ON databasename.tablename TO 'username'@'host' +``` + +说明: + +- privileges:用户的操作权限,如`SELECT`,`INSERT`,`UPDATE`等,如果要授予所的权限则使用`ALL` +- databasename:数据库名 +- tablename:表名,如果要授予该用户对所有数据库和表的相应操作权限则可用`*`表示,如`*.*` + +示例: + +```sql +GRANT SELECT, INSERT ON test.user TO 'pig'@'%'; +GRANT ALL ON *.* TO 'pig'@'%'; +GRANT ALL ON maindataplus.* TO 'pig'@'%'; +``` + +注意: + +用以上命令授权的用户不能给其它用户授权,如果想让该用户可以授权,用以下命令: + +```sql +GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION; +``` + +### 撤销授权 + +命令: + +``` +REVOKE privilege ON databasename.tablename FROM 'username'@'host'; +``` + +说明: + +privilege, databasename, tablename:同授权部分 + +例子: + +``` +REVOKE SELECT ON *.* FROM 'pig'@'%'; +``` + +注意: + +假如你在给用户`'pig'@'%'`授权的时候是这样的(或类似的):`GRANT SELECT ON test.user TO 'pig'@'%'`,则在使用`REVOKE SELECT ON *.* FROM 'pig'@'%';`命令并不能撤销该用户对 test 数据库中 user 表的`SELECT` 操作。相反,如果授权使用的是`GRANT SELECT ON *.* TO 'pig'@'%';`则`REVOKE SELECT ON test.user FROM 'pig'@'%';`命令也不能撤销该用户对 test 数据库中 user 表的`Select`权限。 + +具体信息可以用命令`SHOW GRANTS FOR 'pig'@'%';` 查看。 + +### 更改用户密码 + +```sql +SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword'); +``` + +如果是当前登陆用户用: + +```sql +SET PASSWORD = PASSWORD("newpassword"); +``` + +示例: + +```sql +SET PASSWORD FOR 'pig'@'%' = PASSWORD("123456"); +``` + +### 备份与恢复 + +Mysql 备份数据使用 mysqldump 命令。 + +mysqldump 将数据库中的数据备份成一个文本文件,表的结构和表中的数据将存储在生成的文本文件中。 + +备份: + +(1)备份一个数据库 + +语法: + +``` +mysqldump -u -p [ ...] > backup.sql +``` + +- username 数据库用户 +- dbname 数据库名称 +- table1 和 table2 参数表示需要备份的表的名称,为空则整个数据库备份; +- BackupName.sql 参数表设计备份文件的名称,文件名前面可以加上一个绝对路径。通常将数据库被分成一个后缀名为 sql 的文件 + +(2)备份多个数据库 + +``` +mysqldump -u -p --databases ... > backup.sql +``` + +(3)备份所有数据库 + +``` +mysqldump -u -p -all-databases > backup.sql +``` + +恢复: + +Mysql 恢复数据使用 mysqldump 命令。 + +语法: + +``` +mysql -u -p < backup.sql +``` + +### 卸载 + +(1)查看已安装的 mysql + +```bash +$ rpm -qa | grep -i mysql +perl-DBD-MySQL-4.023-6.el7.x86_64 +mysql80-community-release-el7-1.noarch +mysql-community-common-8.0.12-1.el7.x86_64 +mysql-community-client-8.0.12-1.el7.x86_64 +mysql-community-libs-compat-8.0.12-1.el7.x86_64 +mysql-community-libs-8.0.12-1.el7.x86_64 +``` + +(2)卸载 mysql + +```bash +$ yum remove mysql-community-server.x86_64 +``` + +## 问题 + +### JDBC 与 Mysql 因 CST 时区协商无解导致偏差了 14 或 13 小时 + +**现象** + +数据库中存储的 Timestamp 字段值比真实值少了 13 个小时。 + +**原因** + +- 当 JDBC 与 MySQL 开始建立连接时,会获取服务器参数。 +- 当 MySQL 的 `time_zone` 值为 `SYSTEM` 时,会取 `system_time_zone` 值作为协调时区,若得到的是 `CST` 那么 Java 会误以为这是 `CST -0500` ,因此会给出错误的时区信息(国内一般是`CST +0800`,即东八区)。 + +> 查看时区方法: +> +> 通过 `show variables like '%time_zone%';` 命令查看 Mysql 时区配置: +> +> ``` +> mysql> show variables like '%time_zone%'; +> +------------------+--------+ +> | Variable_name | Value | +> +------------------+--------+ +> | system_time_zone | CST | +> | time_zone | SYSTEM | +> +------------------+--------+ +> ``` + +**解决方案** + +方案一 + +``` +mysql> set global time_zone = '+08:00'; +Query OK, 0 rows affected (0.00 sec) + +mysql> set time_zone = '+08:00'; +Query OK, 0 rows affected (0.00 sec) +``` + +方案二 + +修改 `my.cnf` 文件,在 `[mysqld]` 节下增加 `default-time-zone = '+08:00'` ,然后重启。 + +## 参考资料 + +- https://www.cnblogs.com/xiaopotian/p/8196464.html +- https://www.cnblogs.com/bigbrotherer/p/7241845.html +- https://blog.csdn.net/managementandjava/article/details/80039650 +- http://www.manongjc.com/article/6996.html +- https://www.cnblogs.com/xyabk/p/8967990.html +- [MySQL 8.0主从(Master-Slave)配置](https://blog.csdn.net/zyhlwzy/article/details/80569422) + +## :door: 传送门 + +| [技术文档归档](https://github.com/dunwu/blog) | [数据库教程系列](https://github.com/dunwu/db-tutorial/codes) | diff --git a/docs/linux/soft/nexus-install.md b/docs/linux/soft/nexus-install.md index f858b41..5f5337c 100644 --- a/docs/linux/soft/nexus-install.md +++ b/docs/linux/soft/nexus-install.md @@ -24,7 +24,7 @@ 进入[官方下载地址](https://www.sonatype.com/download-oss-sonatype),选择合适版本下载。 -![](http://dunwu.test.upcdn.net/snap/20181127203029.png) +
本人希望将 Nexus 部署在 Linux 机器,所以选用的是 Unix 版本。 @@ -56,13 +56,13 @@ Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload} 启动成功后,在浏览器中访问 `http://:8081`,欢迎页面如下图所示: -![](http://dunwu.test.upcdn.net/snap/20181127203131.png) +
点击右上角 Sign in 登录,默认用户名/密码为:admin/admin123。 有必要提一下的是,在 Nexus 的 Repositories 管理页面,展示了可用的 maven 仓库,如下图所示: -![](http://dunwu.test.upcdn.net/snap/20181127203156.png) +
> 说明: > diff --git a/docs/linux/soft/nodejs-install.md b/docs/linux/soft/nodejs-install.md index 9c9b0cb..8beaaac 100644 --- a/docs/linux/soft/nodejs-install.md +++ b/docs/linux/soft/nodejs-install.md @@ -52,7 +52,7 @@ nvm use 8.9.4 ## 脚本 -| [安装脚本](https://github.com/dunwu/OS/tree/master/codes/deploy/tool/nodejs) | +| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) | ## 更多内容 diff --git a/docs/linux/soft/redis-install.md b/docs/linux/soft/redis-ops.md similarity index 90% rename from docs/linux/soft/redis-install.md rename to docs/linux/soft/redis-ops.md index 54a7959..77dcb8b 100644 --- a/docs/linux/soft/redis-install.md +++ b/docs/linux/soft/redis-ops.md @@ -55,4 +55,4 @@ cd /opt/redis/redis-4.0.8/src 以上两种安装方式,我都写了脚本去执行: -| [安装脚本](https://github.com/dunwu/linux/tree/master/codes/deploy/tool/redis) | +| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) | diff --git a/docs/linux/soft/svn-install.md b/docs/linux/soft/svn-ops.md similarity index 86% rename from docs/linux/soft/svn-install.md rename to docs/linux/soft/svn-ops.md index 8f2add0..fd83dbc 100644 --- a/docs/linux/soft/svn-install.md +++ b/docs/linux/soft/svn-ops.md @@ -1,6 +1,8 @@ -# Svn 安装、配置、使用指南 +# Svn 运维 -Svn 是 Subversion 的简称,是一个开放源代码的版本控制系统,它采用了分支管理系统。 +> Svn 是 Subversion 的简称,是一个开放源代码的版本控制系统,它采用了分支管理系统。 +> +> 本文目的在于记录 svn 的安装、配置、使用。 @@ -13,7 +15,7 @@ Svn 是 Subversion 的简称,是一个开放源代码的版本控制系统, - [1.6. 启动关闭 svn](#16-启动关闭-svn) - [1.7. 开机自启动 svn 方法](#17-开机自启动-svn-方法) - [1.8. svn 客户端访问](#18-svn-客户端访问) -- [2. 更多内容](#2-更多内容) +- [2. 参考资料](#2-参考资料) @@ -145,12 +147,9 @@ $ vi /etc/sysconfig/svnserve

-## 2. 更多内容 +## 2. 参考资料 -- **引申** - - [操作系统、运维部署总结系列](https://github.com/dunwu/OS) -- **引用** - - https://www.cnblogs.com/liuxianan/p/linux_install_svn_server.html - - https://blog.csdn.net/testcs_dn/article/details/45395645 - - https://www.cnblogs.com/moxiaoan/p/5683743.html - - https://blog.csdn.net/realghost/article/details/52396648 +- https://www.cnblogs.com/liuxianan/p/linux_install_svn_server.html +- https://blog.csdn.net/testcs_dn/article/details/45395645 +- https://www.cnblogs.com/moxiaoan/p/5683743.html +- https://blog.csdn.net/realghost/article/details/52396648 diff --git a/docs/linux/soft/tomcat-install.md b/docs/linux/soft/tomcat-install.md index f97072a..dd07401 100644 --- a/docs/linux/soft/tomcat-install.md +++ b/docs/linux/soft/tomcat-install.md @@ -44,7 +44,7 @@ cd /opt/tomcat/apache-tomcat-8.5.28/bin ## 脚本 -| [安装脚本](https://github.com/dunwu/OS/tree/master/codes/deploy/tool/tomcat) | +| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) | ## 更多内容 diff --git a/docs/linux/soft/yapi-ops.md b/docs/linux/soft/yapi-ops.md new file mode 100644 index 0000000..4276c0e --- /dev/null +++ b/docs/linux/soft/yapi-ops.md @@ -0,0 +1,117 @@ +# YApi 运维 + +> [YApi](https://github.com/YMFE/yapi) 是一个可本地部署的、打通前后端及 QA 的、可视化的接口管理平台。 +> +> 本文目的在于记录 svn 的安装、配置、使用。 + +
+ + + +- [1. 普通部署](#1-普通部署) + - [1.1. 环境要求](#11-环境要求) + - [1.2. 部署](#12-部署) + - [1.3. 升级](#13-升级) +- [2. Docker 部署](#2-docker-部署) + - [2.1. 环境要求](#21-环境要求) + - [2.2. 部署](#22-部署) +- [3. 参考资料](#3-参考资料) + + + +## 1. 普通部署 + +### 1.1. 环境要求 + +- nodejs(7.6+) +- mongodb(2.6+) +- git + +### 1.2. 部署 + +#### 方式一. 可视化部署[推荐] + +执行 yapi server 启动可视化部署程序,输入相应的配置和点击开始部署,就能完成整个网站的部署。部署完成之后,可按照提示信息,执行 node/{网站路径/server/app.js} 启动服务器。在浏览器打开指定 url, 点击登录输入您刚才设置的管理员邮箱,默认密码(ymfe.org) 登录系统(默认密码可在个人中心修改)。 + +```bash +$ npm install -g yapi-cli --registry https://registry.npm.taobao.org +$ yapi server +``` + +#### 方式二. 命令行部署 + +如果 github 压缩文件无法下载,或需要部署到一些特殊的服务器,可尝试此方法 + +```bash +mkdir yapi +cd yapi +git clone https://github.com/YMFE/yapi.git vendors //或者下载 zip 包解压到 vendors 目录(clone 整个仓库大概 140+ M,可以通过 `git clone --depth=1 https://github.com/YMFE/yapi.git vendors` 命令减少,大概 10+ M) +cp vendors/config_example.json ./config.json //复制完成后请修改相关配置 +cd vendors +npm install --production --registry https://registry.npm.taobao.org +npm run install-server //安装程序会初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置 +node server/app.js //启动服务器后,请访问 127.0.0.1:{config.json配置的端口},初次运行会有个编译的过程,请耐心等候 +``` + +安装后的目录结构如下: + +``` +|-- config.json +|-- init.lock +|-- log +`-- vendors + |-- CHANGELOG.md + |-- LICENSE + |-- README.md + |-- client + |-- common + |-- config_example.json + |-- doc + |-- exts + |-- nodemon.json + |-- npm-debug.log + |-- package.json + |-- plugin.json + |-- server + |-- static + |-- test + |-- webpack.alias.js + |-- yapi-base-flow.jpg + |-- ydocfile.js + `-- ykit.config.js +``` + +### 1.3. 升级 + +升级项目版本是非常容易的,并且不会影响已有的项目数据,只会同步 vendors 目录下的源码文件。 + +``` +cd {项目目录} +yapi ls //查看版本号列表 +yapi update //升级到最新版本 +yapi update -v v1.1.0 //升级到指定版本 +``` + +## 2. Docker 部署 + +### 2.1. 环境要求 + +- 系统:`CentOS 7.4` +- 硬件要求:`1 GB RAM minimum` +- ip:`http://192.168.1.121` +- docker version:`17.12.1-ce, build 7390fc6` +- docker-compose version:`1.18.0, build 8dd22a9` + +> 建议部署成 http 站点,因 chrome 浏览器安全限制,部署成 https 会导致测试功能在请求 http 站点时文件上传功能异常。--[来源](https://yapi.ymfe.org/devops.html) + +### 2.2. 部署 + +- 一个好心人的维护: +- 使用方法: - work path:`mkdir -p /opt/git-data` - clone:`cd /opt/git-data && git clone https://github.com/branchzero/yapi-docker.git` - permission:`chmod -R 777 /opt/git-data` - run command:`cd /opt/git-data/yapi-docker && docker-compose up -d` - open chrome:`http://192.168.1.121:3000` +- 初始化管理员账号名:`admin@admin.com`,密码:`ymfe.org` + +## 3. 参考资料 + +- [官方 Github](https://github.com/YMFE/yapi) +- [官网在线演示](http://yapi.demo.qunar.com/) +- [官方使用手册](https://hellosean1025.github.io/yapi/index.html)