update codes

This commit is contained in:
Zhang Peng 2019-08-19 19:19:57 +08:00
parent 50b09e2743
commit 700888cecf
9 changed files with 159 additions and 40 deletions

View File

@ -17,7 +17,7 @@
- [Maven 安装](docs/linux/soft/maven-install.md)
- [Nodejs 安装](docs/linux/soft/nodejs-install.md)
- 开发工具
- [Nexus 运维](docs/linux/soft/nexus-install.md)
- [Nexus 运维](docs/linux/soft/nexus-ops.md)
- [Gitlab 运维](docs/linux/soft/kafka-install.md)
- [Jenkins 运维](docs/linux/soft/jenkins.md)
- [Svn 运维](docs/linux/soft/svn-ops.md)

View File

@ -66,7 +66,7 @@
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1
bind 0.0.0.0
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
@ -499,12 +499,12 @@ replica-priority 100
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
#:q
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass 123456
# requirepass
# Command renaming.
#

View File

@ -1,5 +1,20 @@
#!/usr/bin/env bash
###################################################################################
# 控制台颜色
BLACK="\033[1;30m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
PURPLE="\033[1;35m"
CYAN="\033[1;36m"
RESET="$(tput sgr0)"
###################################################################################
printf "${BLUE}"
cat << EOF
###################################################################################
# 安装 sonatype nexus(用于搭建 maven 私服) 脚本
# @system: 适用于所有 linux 发行版本。
@ -8,7 +23,10 @@
# @author: Zhang Peng
###################################################################################
echo -e "\n>>>>>>>>> install sonatype nexus"
EOF
printf "${RESET}"
printf "${GREEN}>>>>>>>> install nexus begin.${RESET}\n"
mkdir -p /opt/maven
cd /opt/maven
@ -16,3 +34,5 @@ cd /opt/maven
version=3.13.0-01
curl -o /opt/maven/nexus-unix.tar.gz http://download.sonatype.com/nexus/3/nexus-${version}-unix.tar.gz
tar -zxf nexus-unix.tar.gz
printf "${GREEN}<<<<<<<< install nexus end.${RESET}\n"

View File

@ -1,5 +1,18 @@
#!/usr/bin/env bash
###################################################################################
# 控制台颜色
BLACK="\033[1;30m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
PURPLE="\033[1;35m"
CYAN="\033[1;36m"
RESET="$(tput sgr0)"
###################################################################################
printf "${BLUE}"
cat << EOF
###################################################################################
@ -9,6 +22,7 @@ cat << EOF
###################################################################################
EOF
printf "${RESET}"
command -v yum >/dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n"; exit 1; }
@ -37,37 +51,41 @@ if [[ -n $4 ]]; then
password=$4
fi
echo "Current execution: install redis ${version} to ${root}, service port = ${port}, password = ${password}"
echo -e "\n>>>>>>>>> install libs"
printf "${GREEN}>>>>>>>> install redis begin.${RESET}\n"
printf "\t${GREEN}Current execution: install redis ${version} to ${root}, service port = ${port}, password = ${password}${RESET}\n"
yum install -y zlib zlib-devel gcc-c++ libtool openssl openssl-devel tcl
echo -e "\n>>>>>>>>> download redis"
mkdir -p ${root}
curl -o ${root}/redis-${version}.tar.gz http://download.redis.io/releases/redis-${version}.tar.gz
echo -e "\n>>>>>>>>> install redis"
path=${root}/redis-${version}
tar zxf ${root}/redis-${version}.tar.gz -C ${root}
cd ${path}
make && make install
cd -
echo -e "\n>>>>>>>>> config redis"
printf "\n${CYAN}>>>>>>>>> config redis${RESET}\n"
cp ${path}/redis.conf ${path}/redis.conf.default
wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/config/redis-remote-access.conf -O ${path}/redis.conf
mkdir -p /etc/redis
cp ${path}/redis.conf /etc/redis/${port}.conf
sed -i "s/^port 6379/port ${port}/g" /etc/redis/${port}.conf
sed -i "s/^requirepass 123456/requirepass ${password}/g" /etc/redis/${port}.conf
if [[ -n ${password} ]]; then
sed -i "s/^# requirepass/requirepass ${password}/g" /etc/redis/${port}.conf
fi
echo -e "\n>>>>>>>>> add firewall port"
printf "\n${CYAN}>>>>>>>>> add firewall port${RESET}\n"
firewall-cmd --zone=public --add-port=${port}/tcp --permanent
firewall-cmd --reload
echo -e "\n>>>>>>>>> add redis service"
printf "\n${CYAN}>>>>>>>>> add redis service${RESET}\n"
# 注册 redis 服务,并设置开机自启动
cp ${path}/utils/redis_init_script /etc/init.d/redis_${port}
cp ${path}/utils/redis_init_script /etc/init.d/
mv /etc/init.d/redis_init_script /etc/init.d/redis_${port}
sed -i "s/^REDISPORT=.*/REDISPORT=${port}/g" /etc/init.d/redis_${port}
chmod +x /etc/init.d/redis_${port}
chkconfig --add redis_${port}
service redis_${port} start
printf "\n${GREEN}<<<<<<<< install redis end.${RESET}\n"

View File

@ -17,7 +17,7 @@
- [Maven 安装](linux/soft/maven-install.md)
- [Nodejs 安装](linux/soft/nodejs-install.md)
- 开发工具
- [Nexus 运维](linux/soft/nexus-install.md)
- [Nexus 运维](linux/soft/nexus-ops.md)
- [Gitlab 运维](linux/soft/kafka-install.md)
- [Jenkins 运维](linux/soft/jenkins.md)
- [Svn 运维](linux/soft/svn-ops.md)

View File

@ -1,6 +1,6 @@
<div align="center"><img width="100px" src="http://dunwu.test.upcdn.net/images/others/zp.png"/></div>
# Linux 教程
# Linux Tutorial
> Linux 教程

View File

@ -6,7 +6,7 @@
- [Jenkins 安装](jenkins-install.md)
- [Kafka 安装](kafka-install.md)
- [Maven 安装](maven-install.md)
- [Nexus 安装](nexus-install.md)
- [Nexus 安装](nexus-ops.md)
- [Nodejs 安装](nodejs-install.md)
- [RocketMQ 安装](rocketmq-install.md)
- [Svn 安装](svn-ops.md)

View File

@ -1,5 +1,7 @@
# 部署并使用 Nexus 作为 Maven 私服
# Nexus 运维
> Nexus 是一个强大的 Maven 仓库管理器,可以用来搭建 Maven 私服。
>
> 关键词maven, nexus
>
> 部署环境
@ -10,17 +12,22 @@
<!-- TOC depthFrom:2 depthTo:3 -->
- [下载安装 Nexus](#下载安装-nexus)
- [启动停止 Nexus](#启动停止-nexus)
- [使用 Nexus](#使用-nexus)
- [安装 Nexus](#安装-nexus)
- [启动/停止 Nexus](#启动停止-nexus)
- [使用 Nexus 搭建 Maven 私服](#使用-nexus-搭建-maven-私服)
- [配置仓库](#配置仓库)
- [配置 settings.xml](#配置-settingsxml)
- [配置 pom.xml](#配置-pomxml)
- [执行 maven 构建](#执行-maven-构建)
- [将 Nexus 设置为服务](#将-nexus-设置为服务)
- [Nexus 备份和迁移](#nexus-备份和迁移)
- [备份](#备份)
- [迁移](#迁移)
- [参考资料](#参考资料)
<!-- /TOC -->
## 下载安装 Nexus
## 安装 Nexus
进入[官方下载地址](https://www.sonatype.com/download-oss-sonatype),选择合适版本下载。
@ -40,7 +47,7 @@ tar -zxf nexus-unix.tar.gz
- nexus-3.13.0-01 - 包含了 Nexus 运行所需要的文件。是 Nexus 运行必须的。
- sonatype-work - 包含了 Nexus 生成的配置文件、日志文件、仓库文件等。当我们需要备份 Nexus 的时候默认备份此目录即可。
## 启动停止 Nexus
## 启动/停止 Nexus
进入 nexus-3.13.0-01/bin 目录,有一个可执行脚本 nexus。
@ -52,7 +59,8 @@ Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}
```
- 启动 nexus - `./nexus start`
- 停止 nexus -
- 停止 nexus - `./nexus stop`
- 重启 nexus - `./nexus restart`
启动成功后,在浏览器中访问 `http://<ip>:8081`,欢迎页面如下图所示:
@ -60,23 +68,38 @@ Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}
点击右上角 Sign in 登录,默认用户名/密码为admin/admin123。
有必要提一下的是,在 Nexus 的 Repositories 管理页面,展示了可用的 maven 仓库,如下图所示:
## 使用 Nexus 搭建 Maven 私服
### 配置仓库
Nexus 中的仓库有以下类型:
- `hosted` - 宿主仓库。主要用于部署无法从公共仓库获取的构件(如 oracle 的 JDBC 驱动)以及自己或第三方的项目构件;
- `proxy` - 代理仓库。代理公共的远程仓库;
- `virtual` - 虚拟仓库。用于适配 Maven 1
- `group` - 仓库组。Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。
<div align="center"><img src="https://gitee.com/turnon/images/raw/master/images/java/javalib/maven/nexus.png"/></div>
> **最佳实践**
>
> 建议配置如下:
>
> - hosted 仓库
> - maven-releases - 存储私有仓库的发行版 jar 包
> - maven-snapshots - 存储私有仓库的快照版(调试版本) jar 包
> - proxy 仓库
> - maven-central - maven 中央库(如果没有配置 mirror默认就从这里下载 jar 包),从 https://repo1.maven.org/maven2/ 获取资源
> - maven-aliyun - 国内 maven 仓库,提高访问速度。
> - group 仓库
> - maven-public - 私有仓库的公共空间,把上面三个仓库组合在一起对外提供服务,在本地 maven 基础配置 settings.xml 中使用。
<div align="center"><img src="http://dunwu.test.upcdn.net/snap/20181127203156.png"/></div>
> 说明:
>
> - maven-central - maven 中央库(如果没有配置 mirror默认就从这里下载 jar 包),从 https://repo1.maven.org/maven2/ 获取资源
> - maven-releases - 存储私有仓库的发行版 jar 包
> - maven-snapshots - 存储私有仓库的快照版(调试版本) jar 包
> - maven-public - 私有仓库的公共空间,把上面三个仓库组合在一起对外提供服务,在本地 maven 基础配置 settings.xml 中使用。
## 使用 Nexus
### 配置 settings.xml
如果要使用 Nexus还必须在 settings.xml 和 pom.xml 中配置认证信息。
### 配置 settings.xml
一份完整的 `settings.xml`
```xml
@ -186,8 +209,59 @@ $ mvn clean package -Dmaven.skip.test=true -P zp
$ mvn clean deploy -Dmaven.skip.test=true -P zp
```
## 将 Nexus 设置为服务
将 Nexus 添加为服务,以便开机自启动。
`/lib/systemd/system` 目录下创建 `nexus.service` 文件,内容如下:
```ini
[Unit]
Description=nexus
After=network.target
[Service]
Type=forking
LimitNOFILE=65536 #警告处理
Environment=RUN_AS_USER=root
ExecStart=/opt/maven/nexus-3.13.0-01/bin/nexus start
ExecReload=/opt/maven/nexus-3.13.0-01/bin/nexus restart
ExecStop=/opt/maven/nexus-3.13.0-01/bin/nexus stop
Restart=on-failure
PrivateTmp=true
[Install]
WantedBy=multi-user.target
```
保存后,可以使用以下命令应用 nexus 服务:
- `systemctl enable nexus` - 启动 nexus 开机启动
- `systemctl disable nexus` - 关闭 nexus 开机启动
- `systemctl start nexus` - 启动 nexus 服务
- `systemctl stop nexus` - 停止 nexus 服务
- `systemctl restart nexus` - 重启 nexus 服务
## Nexus 备份和迁移
Nexus 三个重要目录:
| 名称 | 目录名 | 重要配置文件 |
| :----------------- | :------------- | :------------------------------------------------ |
| nexus 主目录 | nexus-2.6.4-02 | conf/nexus.properties 里面有 sonatype-work 的地址 |
| sonatype-work 目录 | sonatype-work | nexus/conf/nexus.xml 里面有 storage 的地址 |
| storage 目录 | storage | 里面主要是各种程序的 jar 包等 |
### 备份
Nexus 的数据都存储在 sonatype-work 目录,备份 Nexus 数据只需要将其打包即可。
### 迁移
将原 Nexus 服务器中的 sonatype-work 目录迁移到新 Nexus 服务器的 sonatype-work 目录下。
## 参考资料
- https://www.cnblogs.com/hoobey/p/6102382.html
- https://blog.csdn.net/wzygis/article/details/49276779
- https://blog.csdn.net/clj198606061111/article/details/52200928
- [maven 私库 nexus3 安装及使用](https://blog.csdn.net/clj198606061111/article/details/52200928)
- [Nexus 安装 使用说明](https://www.cnblogs.com/jtlgb/p/7473837.html)
- [企业级开源仓库 nexus3 实战应用–使用 nexus3 配置 yum 私有仓库](http://www.eryajf.net/2002.html)

View File

@ -1,14 +1,18 @@
# Redis 安装
> **Redis** 是一个高性能的 key-value 数据库。
>
> SET 操作每秒钟 110000 次GET 操作每秒钟 81000 次。
<!-- TOC depthFrom:2 depthTo:3 -->
- [安装](#安装)
- [安装 Redis](#安装-redis)
- [启动](#启动)
- [脚本](#脚本)
<!-- /TOC -->
## 安装
## 安装 Redis
安装步骤如下:
@ -56,3 +60,6 @@ cd /opt/redis/redis-4.0.8/src
以上两种安装方式,我都写了脚本去执行:
| [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft) |
## 参考资料