java8安装
java-1.8.0-openjdk是jre运行环境
openjdk-devel 是java开发环境
/etc/profile文件就是centos7的环境变量配置文件。这个文件是每个用户登录时都会运行的环境变量设置
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
## 加入java环境变量
echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64">> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'>> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin'>> /etc/profile
source /etc/profile
java -version
显示以下信息安装成功
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
centos7安装nexus3
官网地址 https://www.sonatype.com/download-oss-sonatype
下载nexus3到服务器
wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.13.0-01-unix.tar.gz
解压
tar -zxvf nexus-3.13.0-01-unix.tar.gz -C /usr/local/
cd /usr/local/nexus-3.13.0-01/bin/
启动
./nexus run &
错误内存不足,1G服务器不行,故用2G内存的服务器试试
There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 419430400 bytes for committing reserved memory. # An error report file with more information is saved as:
2G内存的服务器可以,提示以下内容即可成功
Started Sonatype Nexus OSS 3.13.0-01
开启远程访问端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --reload
http://144.202.91.42:8081/
nexus3默认端口是:8081
nexus3默认账号是:admin
nexus3默认密码是:admin123
设置开机自启动
vim /usr/lib/systemd/system/nexus.service
[Unit]
Description=nexus service
[Service]
Type=forking
LimitNOFILE=65536 #警告处理
ExecStart=/usr/local/nexus/nexus-3.13.0-01/bin/nexus start
ExecReload=/usr/local/nexus/nexus-3.13.0-01/bin/nexus restart
ExecStop=/usr/local/nexus/nexus-3.13.0-01/bin/nexus stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
将服务加入开机启动
systemctl enable nexus.service
重新加载配置文件
systemctl daemon-reload
修改nexus配置文件
- 修改nexus3的运行用户为root
vim nexus.rc
修改
run_as_user="root"
- 修改nexus3启动时要使用的jdk版本
vim nexus
修改
INSTALL4J_JAVA_PREFIX="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64"
- 修改nexus3默认端口(可选)
cd /usr/local/nexus-3.13.0-01/etc/
vim nexus-default.properties
默认端口:8081
application-port=8081
- 修改nexus3数据以及相关日志的存储位置(可选):
cd /usr/local/nexus-3.13.0-01/bin/
vim nexus.vmoptions
-XX:LogFile=./sonatype-work/nexus3/log/jvm.log
-Dkaraf.data=./sonatype-work/nexus3
-Djava.io.tmpdir=./sonatype-work/nexus3/tmp
/usr/local/sonatype-work/nexus3 是数据存储位置