Harvey Mei

Good acts are better than good intentions.

6月 122019
 

Sonatype Nexus 3 最低运行环境要求:

Minimum CPUs: 4
Recommended CPUs: 8+
Host Physical/RAM Minimum ( default ) 4GB

安装JDK 1.8环境

查看Java版本信息

访问Sonatype Nexus下载页面

 选择对应操作系统版本点击下载

解压缩文件到指定路径

进入安装目录

进入可执行程序bin目录

快捷键:Shift+鼠标右键,在此处打开命令窗口

注册nexus为系统服务

确认服务注册成功

启动nexu服务并查看运行状态

使用浏览器访问Web管理控制台

首次登录的初始密码设置

6月 112019
 

安装JDK

[root@iZj6cehstgjoj3qav88fidZ ~]# yum -y install jdk-8u211-linux-x64.rpm

查看JDK版本信息

[root@iZj6cehstgjoj3qav88fidZ ~]# java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
[root@iZj6cehstgjoj3qav88fidZ ~]#

下载Nexus二进制包

[root@iZj6cehstgjoj3qav88fidZ ~]# wget https://download.sonatype.com/nexus/oss/nexus-latest-bundle.tar.gz
--2019-06-25 18:44:20-- https://download.sonatype.com/nexus/oss/nexus-latest-bundle.tar.gz
Resolving download.sonatype.com (download.sonatype.com)... 34.206.81.156, 35.168.192.73
Connecting to download.sonatype.com (download.sonatype.com)|34.206.81.156|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/oss/nexus-2.14.13-01-bundle.tar.gz [following]
--2019-06-25 18:44:21-- https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/oss/nexus-2.14.13-01-bundle.tar.gz
Resolving sonatype-download.global.ssl.fastly.net (sonatype-download.global.ssl.fastly.net)... 151.101.77.194
Connecting to sonatype-download.global.ssl.fastly.net (sonatype-download.global.ssl.fastly.net)|151.101.77.194|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 82396385 (79M) [application/x-gzip]
Saving to: ‘nexus-latest-bundle.tar.gz’

100%[=======================================================================================================================================================>] 82,396,385 12.2MB/s in 5.4s

2019-06-25 18:44:27 (14.5 MB/s) - ‘nexus-latest-bundle.tar.gz’ saved [82396385/82396385]

[root@iZj6cehstgjoj3qav88fidZ ~]#

解压缩文件

[root@iZj6cehstgjoj3qav88fidZ ~]# mkdir -p /usr/local/nexus
[root@iZj6cehstgjoj3qav88fidZ ~]# tar xzf nexus-latest-bundle.tar.gz -C /usr/local/nexus/
[root@iZj6cehstgjoj3qav88fidZ ~]# ls /usr/local/nexus/
nexus-2.14.13-01 sonatype-work
[root@iZj6cehstgjoj3qav88fidZ ~]#

添加用户并修改目录所有权限

[root@iZj6cehstgjoj3qav88fidZ ~]# useradd nexus
[root@iZj6cehstgjoj3qav88fidZ ~]# chown -R nexus.nexus /usr/local/nexus/
[root@iZj6cehstgjoj3qav88fidZ ~]#

切换用户并进入Nexus可执行程序目录

[root@iZj6cehstgjoj3qav88fidZ ~]# su - nexus
Last login: Tue Jun 25 18:36:38 CST 2019 on pts/1
[nexus@iZj6cehstgjoj3qav88fidZ ~]$ cd /usr/local/nexus/nexus-2.14.13-01/bin/
[nexus@iZj6cehstgjoj3qav88fidZ bin]$ ./nexus --help
Usage: ./nexus { console | start | stop | restart | status | dump }
[nexus@iZj6cehstgjoj3qav88fidZ bin]$

启动服务并查看服务运行状态

[nexus@iZj6cehstgjoj3qav88fidZ bin]$ ./nexus start
Starting Nexus OSS...
Started Nexus OSS.
[nexus@iZj6cehstgjoj3qav88fidZ bin]$

[nexus@iZj6cehstgjoj3qav88fidZ bin]$ ./nexus status
Nexus OSS is running (14829).
[nexus@iZj6cehstgjoj3qav88fidZ bin]$

查看监听

使用浏览器访问Nexus控制台服务

6月 092019
 

下载JDK

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

下载Maven

http://maven.apache.org/download.cgi

准备就绪的安装包

安装JDK

安装JDK

验证JAVA版本信息

解压缩Maven压缩包

查看Maven完整安装包路径

设置环境变量

控制面板-系统与安全-系统-高级系统设置

高级-环境变量

系统变量-PATH-新增

变量路径

C:\apache-maven-3.6.1-bin\apache-maven-3.6.1\bin

验证maven环境配置及版本信息

修改公共代理仓库为国内镜像服务器

修改conf/settings.xml配置文件,在<mirrors></mirrors>添加以下配置
阿里云镜像配置

<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>

网易163镜像配置

<mirror>
<id>nexus-163</id>
<mirrorOf>*</mirrorOf>
<name>Nexus 163</name>
<url>http://mirrors.163.com/maven/repository/maven-public/</url>
</mirror>
6月 062019
 

实验环境

10.4.7.234 ns1.hostname.com
10.4.7.235 ns2.hostname.com
10.4.7.236 client.hostname.com

设置主机名(10.4.7.234)

[root@iZj6c1pigvpz2jl6zy1cgbZ ~]# hostnamectl set-hostname ns1.hostname.com
[root@iZj6c1pigvpz2jl6zy1cgbZ ~]# exit
logout

[root@ns1 ~]# hostname 
ns1.hostname.com
[root@ns1 ~]# ping -c 4 ns1.hostname.com
PING ns1.hostname.com (10.4.7.234) 56(84) bytes of data.
64 bytes from iZj6c1pigvpz2jl6zy1cgbZ (10.4.7.234): icmp_seq=1 ttl=64 time=0.011 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgbZ (10.4.7.234): icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgbZ (10.4.7.234): icmp_seq=3 ttl=64 time=0.026 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgbZ (10.4.7.234): icmp_seq=4 ttl=64 time=0.027 ms

--- ns1.hostname.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.011/0.022/0.027/0.007 ms
[root@ns1 ~]#

设置主机名(10.4.7.235)

[root@iZj6c1pigvpz2jl6zy1cgaZ ~]# hostnamectl set-hostname ns2.hostname.com
[root@iZj6c1pigvpz2jl6zy1cgaZ ~]# exit
logout

[root@ns2 ~]# hostname
ns2.hostname.com
[root@ns2 ~]# ping -c 4 ns2.hostname.com
PING ns2.hostname.com (10.4.7.235) 56(84) bytes of data.
64 bytes from iZj6c1pigvpz2jl6zy1cgaZ (10.4.7.235): icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgaZ (10.4.7.235): icmp_seq=2 ttl=64 time=0.028 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgaZ (10.4.7.235): icmp_seq=3 ttl=64 time=0.027 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgaZ (10.4.7.235): icmp_seq=4 ttl=64 time=0.028 ms

--- ns2.hostname.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.014/0.024/0.028/0.006 ms
[root@ns2 ~]#

设置主机名(10.4.7.236)

[root@iZj6c1pigvpz2jl6zy1cgcZ ~]# hostnamectl set-hostname client.hostname.com
[root@iZj6c1pigvpz2jl6zy1cgcZ ~]# exit
logout

[root@client ~]# hostname
client.hostname.com
[root@client ~]# ping -c 4 client.hostname.com
PING client.hostname.com (10.4.7.236) 56(84) bytes of data.
64 bytes from iZj6c1pigvpz2jl6zy1cgcZ (10.4.7.236): icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgcZ (10.4.7.236): icmp_seq=2 ttl=64 time=0.028 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgcZ (10.4.7.236): icmp_seq=3 ttl=64 time=0.028 ms
64 bytes from iZj6c1pigvpz2jl6zy1cgcZ (10.4.7.236): icmp_seq=4 ttl=64 time=0.026 ms

--- client.hostname.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.013/0.023/0.028/0.008 ms
[root@client ~]#

安装bind及bind-utils软件包

[root@ns1 ~]# yum -y install bind bind-utils
[root@ns2 ~]# yum -y install bind bind-utils
[root@client ~]# yum -y install bind-utils

修改主DNS服务器的主配置文件

[root@ns1 ~]# vi /etc/named.conf
修改以下行内容
13 listen-on port 53 { 10.4.7.234; };
21 allow-query { any; };
35 dnssec-enable no;
36 dnssec-validation no;
添加以下内容
allow-transfer { 10.4.7.235; };
allow-notify { 10.4.7.235; };

新增区域配置

[root@ns1 ~]# vi /etc/named.rfc1912.zones 
zone "hostname.com" IN {
type master;
file "hostname.com.zone";
allow-update { none; };
};

创建区域配置文件

[root@ns1 ~]# vi /var/named/hostname.com.zone
$TTL 600 ; 10 minutes
@ IN SOA ns1.hostname.com. hostmaster.hostname.com. (
20190001 ; serial number
10800 ; refresh time (3 hours)
900 ; retry time (15 minutes)
604800 ; expire time (1 week)
86400 ; minimum (1 day)
)
NS ns1.hostname.com.
NS ns2.hostname.com.
$ORIGIN hostname.com.
$TTL 60 ; 1 minute
ns1 A 10.4.7.234
ns2 A 10.4.7.235
client A 10.4.7.236

检查配置信息

[root@ns1 ~]# named-checkconf 
[root@ns1 ~]# named-checkzone hostname.com. /var/named/hostname.com.zone 
zone hostname.com/IN: loaded serial 20190001
OK
[root@ns1 ~]#

重启服务并查看监听和验证解析

配置从DNS服务器

修改从DNS服务器的主配置文件

[root@ns2 ~]# vi /etc/named.conf
修改客户机DNS配置
13 listen-on port 53 { 10.4.7.235; };
21 allow-query { any; };
35 dnssec-enable no;
36 dnssec-validation no;
增加
masterfile-format text;

添加区域配置

[root@ns2 ~]# vi /etc/named.rfc1912.zones
zone "hostname.com" IN {
type slave;
masters { 10.4.7.234; };
file "slaves/hostname.com.zone";
};

检查配置启动服务

[root@ns2 ~]# named-checkconf 
[root@ns2 ~]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@ns2 ~]# systemctl start named
[root@ns2 ~]#

查看端口监听

检查完全区域传送信息及查看本地已同步的区域配置文件

验证解析

客户机配置

Ping 客户机本机及两台DNS主机的域名,默认只有本机响应

[root@client ~]# ping -c 1 client.hostname.com
PING client.hostname.com (10.4.7.236) 56(84) bytes of data.
64 bytes from iZj6c1pigvpz2jl6zy1cgcZ (10.4.7.236): icmp_seq=1 ttl=64 time=0.011 ms

--- client.hostname.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.011/0.011/0.011/0.000 ms
[root@client ~]# ping -c 1 ns1.hostname.com
ping: ns1.hostname.com: Name or service not known
[root@client ~]# ping -c 1 ns2.hostname.com
ping: ns2.hostname.com: Name or service not known
[root@client ~]# 

查看当前主机DNS配置

[root@client ~]# cat /etc/resolv.conf 
options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
nameserver 100.100.2.136
nameserver 100.100.2.138
[root@client ~]#

修改DNS

[root@client ~]# vi /etc/resolv.conf
options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
#nameserver 100.100.2.136
#nameserver 100.100.2.138
nameserver 10.4.7.234
nameserver 10.4.7.235

再次ping两台DNS服务器的主机名,及使用nslookup查询,主辅DNS均能够响应客户端查询