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