搭建開發測試環境非常麻煩,公司的開發測試伺服器中毒做資料恢複,順帶整理下搭建的方式。
本人是程式員,linux系統知識比較薄弱,故系統的安全方面本文未涉及,請酌情做安全政策。
本來是内網伺服器,用frp暴露到了公網,導緻被挖礦。。感覺frp還是不安全,現在隻能在需要穿透的
時候開下,其他時候關閉。
mysql資料備份和恢複參考: https://juejin.im/post/5d8b8587f265da5b752598a1 SpringBoot整合jwt和mybatis-plus的腳手架項目
基本配置
安裝基本指令
有些指令可能未預設安裝,如果發現指令無法使用,再通過下面的方式進行安裝。
安裝ifconfig
centos 7中自帶的檢視網絡的指令是: ip addr
如果還是想要 ifconfig
安裝net-tools
yum install net-tools
安裝vim
yum install vim
網絡配置
如果是虛拟機模式,VM box的網絡模式修改為 橋接
。
修改hostname
修改ip位址
指令為:
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
修改為如下即可,然後重新開機網卡
service network restart
:
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" ###修改為static模式才能配置ip,預設是dhcp模式
IPADDR="192.168.1.254" ###網卡IP位址
BROADCAST-"192.168.1.255" ###子網廣播位址
GATEWAY="192.168.1.1" ###網關位址
NETMASK="255.255.255.0" ###網卡對應網絡掩碼
DNS1="192.168.1.1" ###DNS位址
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp0s3"
UUID="226a0768-3a2f-4485-9694-d8fea85694ad"
DEVICE="enp0s3"
ONBOOT="yes" #系統啟動時是否設定此網絡接口,設定為yes時,系統啟動時激活此裝置。預設設定為yes。
修改dns
1) vi /etc/resolv.conf
[root@localhost ~]# vi /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1 #本機的網關位址(路由器的位址),在ip配置的時候有指定
nameserver 114.114.114.114 #其他dns
naemserver 1.1.1.1
search localdomain
3)確定可用DNS解析
[root@localhost Desktop]# grep hosts /etc/nsswitch.conf
配置更新源
配置更新源為阿裡源
建立
sourceSet.sh
檔案,貼上如下代碼執行即可:
chmod 775 sourceSet.sh
#!/bin/bash
#########################################
#Function: update source
#Usage: bash update_source.sh
#Author: Customer service department
#Company: Alibaba Cloud Computing
#Version: 5.0
#########################################
check_os_release()
{
while true
do
os_release=$(grep "Red Hat Enterprise Linux Server release" /etc/issue 2>/dev/null)
os_release_2=$(grep "Red Hat Enterprise Linux Server release" /etc/redhat-release 2>/dev/null)
if [ "$os_release" ] && [ "$os_release_2" ]
then
if echo "$os_release"|grep "release 5" >/dev/null 2>&1
then
os_release=redhat5
echo "$os_release"
elif echo "$os_release"|grep "release 6" >/dev/null 2>&1
then
os_release=redhat6
echo "$os_release"
else
os_release=""
echo "$os_release"
fi
break
fi
os_release=$(grep "Aliyun Linux release" /etc/issue 2>/dev/null)
os_release_2=$(grep "Aliyun Linux release" /etc/aliyun-release 2>/dev/null)
if [ "$os_release" ] && [ "$os_release_2" ]
then
if echo "$os_release"|grep "release 5" >/dev/null 2>&1
then
os_release=aliyun5
echo "$os_release"
elif echo "$os_release"|grep "release 6" >/dev/null 2>&1
then
os_release=aliyun6
echo "$os_release"
elif echo "$os_release"|grep "release 7" >/dev/null 2>&1
then
os_release=aliyun7
echo "$os_release"
else
os_release=""
echo "$os_release"
fi
break
fi
os_release_2=$(grep "CentOS" /etc/*release 2>/dev/null)
if [ "$os_release_2" ]
then
if echo "$os_release_2"|grep "release 5" >/dev/null 2>&1
then
os_release=centos5
echo "$os_release"
elif echo "$os_release_2"|grep "release 6" >/dev/null 2>&1
then
os_release=centos6
echo "$os_release"
elif echo "$os_release_2"|grep "release 7" >/dev/null 2>&1
then
os_release=centos7
echo "$os_release"
else
os_release=""
echo "$os_release"
fi
break
fi
os_release=$(grep -i "ubuntu" /etc/issue 2>/dev/null)
os_release_2=$(grep -i "ubuntu" /etc/lsb-release 2>/dev/null)
if [ "$os_release" ] && [ "$os_release_2" ]
then
if echo "$os_release"|grep "Ubuntu 10" >/dev/null 2>&1
then
os_release=ubuntu10
echo "$os_release"
elif echo "$os_release"|grep "Ubuntu 12.04" >/dev/null 2>&1
then
os_release=ubuntu1204
echo "$os_release"
elif echo "$os_release"|grep "Ubuntu 12.10" >/dev/null 2>&1
then
os_release=ubuntu1210
echo "$os_release"
elif echo "$os_release"|grep "Ubuntu 14.04" >/dev/null 2>&1
then
os_release=ubuntu1204
echo "$os_release"
else
os_release=""
echo "$os_release"
fi
break
fi
os_release=$(grep -i "debian" /etc/issue 2>/dev/null)
os_release_2=$(grep -i "debian" /proc/version 2>/dev/null)
if [ "$os_release" ] && [ "$os_release_2" ]
then
if echo "$os_release"|grep "Linux 6" >/dev/null 2>&1
then
os_release=debian6
echo "$os_release"
elif echo "$os_release"|grep "Linux 7" >/dev/null 2>&1
then
os_release=debian7
echo "$os_release"
else
os_release=""
echo "$os_release"
fi
break
fi
os_release=$(grep -i "opensuse" /etc/issue 2>/dev/null)
os_release_2=$(grep -i "opensuse" /etc/*release 2>/dev/null)
if [ "$os_release" ] && [ "$os_release_2" ]
then
if echo "$os_release"|grep "openSUSE 13.1" >/dev/null 2>&1
then
os_release=opensuse1301
echo "$os_release"
else
os_release=""
echo "$os_release"
fi
break
fi
break
done
}
modify_aliyun5_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
sed -i 's/\$releasever/5/' /etc/yum.repos.d/CentOS-Base.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
yum clean metadata
yum makecache
cd ~
}
modify_rhel5_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
yum clean metadata
yum makecache
cd ~
}
modify_rhel6_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum clean metadata
yum makecache
cd ~
}
modify_rhel7_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean metadata
yum makecache
cd ~
}
update_ubuntu10_apt_source()
{
echo -e "\033[40;32mBackup the original configuration file,new name and path is /etc/apt/sources.list.back.\n\033[40;37m"
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back
cat > /etc/apt/sources.list <<EOF
#ubuntu
deb http://cn.archive.ubuntu.com/ubuntu/ maverick main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ maverick main restricted universe multiverse
#163
deb http://mirrors.163.com/ubuntu/ maverick main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ maverick main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ maverick-updates universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ maverick-updates universe main multiverse restricted
#lupaworld
deb http://mirror.lupaworld.com/ubuntu/ maverick main universe restricted multiverse
deb-src http://mirror.lupaworld.com/ubuntu/ maverick main universe restricted multiverse
deb http://mirror.lupaworld.com/ubuntu/ maverick-security universe main multiverse restricted
deb-src http://mirror.lupaworld.com/ubuntu/ maverick-security universe main multiverse restricted
deb http://mirror.lupaworld.com/ubuntu/ maverick-updates universe main multiverse restricted
deb http://mirror.lupaworld.com/ubuntu/ maverick-proposed universe main multiverse restricted
deb-src http://mirror.lupaworld.com/ubuntu/ maverick-proposed universe main multiverse restricted
deb http://mirror.lupaworld.com/ubuntu/ maverick-backports universe main multiverse restricted
deb-src http://mirror.lupaworld.com/ubuntu/ maverick-backports universe main multiverse restricted
deb-src http://mirror.lupaworld.com/ubuntu/ maverick-updates universe main multiverse restricted
EOF
apt-get update
}
update_ubuntu1204_apt_source()
{
echo -e "\033[40;32mBackup the original configuration file,new name and path is /etc/apt/sources.list.back.\n\033[40;37m"
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back
cat > /etc/apt/sources.list <<EOF
#12.04
deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
EOF
apt-get update
}
update_ubuntu1210_apt_source()
{
echo -e "\033[40;32mBackup the original configuration file,new name and path is /etc/apt/sources.list.back.\n\033[40;37m"
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back
cat > /etc/apt/sources.list <<EOF
#12.10
deb http://mirrors.aliyun.com/ubuntu/ quantal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ quantal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ quantal-backports main restricted universe multiverse
EOF
apt-get update
}
update_ubuntu1404_apt_source()
{
echo -e "\033[40;32mBackup the original configuration file,new name and path is /etc/apt/sources.list.back.\n\033[40;37m"
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back
cat > /etc/apt/sources.list <<EOF
#14.04
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
EOF
apt-get update
}
update_debian6_apt_source()
{
echo -e "\033[40;32mBackup the original configuration file,new name and path is /etc/apt/sources.list.back.\n\033[40;37m"
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back
cat > /etc/apt/sources.list <<EOF
#debian6
deb http://mirrors.aliyun.com/debian/ squeeze main non-free contrib
deb http://mirrors.aliyun.com/debian/ squeeze-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ squeeze main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ squeeze-proposed-updates main non-free contrib
EOF
apt-get update
}
update_debian7_apt_source()
{
echo -e "\033[40;32mBackup the original configuration file,new name and path is /etc/apt/sources.list.back.\n\033[40;37m"
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back
cat > /etc/apt/sources.list <<EOF
#debian7
deb http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib
EOF
apt-get update
}
update_opensuse_source()
{
mv /etc/zypp/repos.d/* /tmp/
zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/13.1/repo/oss/ openSUSE-13.1-Oss
zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/13.1/repo/non-oss/ openSUSE-13.1-Non-Oss
zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/13.1/ openSUSE-13.1-Update-Oss
zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/13.1-non-oss/ openSUSE-13.1-Update-Non-Oss
zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/13.1/repo/oss/ openSUSE-13.1-Oss-aliyun
zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/13.1/repo/non-oss/ openSUSE-13.1-Non-Oss-aliyun zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/13.1/ openSUSE-13.1-Update-Oss-aliyun
zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/13.1-non-oss/ openSUSE-13.1-Update-Non-Oss-aliyun
}
####################Start###################
#check lock file ,one time only let the script run one time
LOCKfile=/tmp/.$(basename $0)
if [ -f "$LOCKfile" ]
then
echo -e "\033[1;40;31mThe script is already exist,please next time to run this script.\n\033[0m"
exit
else
echo -e "\033[40;32mStep 1.No lock file,begin to create lock file and continue.\n\033[40;37m"
touch $LOCKfile
fi
#check user
if [ $(id -u) != "0" ]
then
echo -e "\033[1;40;31mError: You must be root to run this script, please use root to install this script.\n\033[0m"
rm -rf $LOCKfile
exit 1
fi
echo -e "\033[40;32mStep 2.Begin to check the OS issue.\n\033[40;37m"
os_release=$(check_os_release)
if [ "X$os_release" == "X" ]
then
echo -e "\033[1;40;31mThe OS does not identify,So this script is not executede.\n\033[0m"
rm -rf $LOCKfile
exit 0
else
echo -e "\033[40;32mThis OS is $os_release.\n\033[40;37m"
fi
echo -e "\033[40;32mStep 3.Begin to modify the source configration file and update.\n\033[40;37m"
case "$os_release" in
aliyun5)
modify_aliyun5_yum
;;
redhat5|centos5)
modify_rhel5_yum
;;
redhat6|centos6|aliyun6)
modify_rhel6_yum
;;
centos7|aliyun7)
modify_rhel7_yum
;;
ubuntu10)
update_ubuntu10_apt_source
;;
ubuntu1204)
update_ubuntu1204_apt_source
;;
ubuntu1210)
update_ubuntu1210_apt_source
;;
ubuntu1404)
update_ubuntu1404_apt_source
;;
debian6)
update_debian6_apt_source
;;
debian7)
update_debian7_apt_source
;;
opensuse1301)
update_opensuse_source
;;
esac
echo -e "\033[40;32mSuccess,exit now!\n\033[40;37m"
rm -rf $LOCKfile
開發環境
JDK
下載下傳jdk
最新jdk1.8.0_211我已經上傳到網盤:
連結:
https://pan.baidu.com/s/1B9DRL5iZsPzqn1hVN325kw提取碼:5e92 複制這段内容後打開百度網盤手機App,操作更友善哦)
上傳和解壓到該路徑:
/usr/local/base/jdk1.8.0_211
設定環境變量:
vi /etc/profile
在最後添加如下内容:
#java environment
export JAVA_HOME=/data/jdk1.8.0_211
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
重新加載環境變量:
[root@izwz9hy3mj62nle7573jv5z jdk1.8.0_181]# source /etc/profile
[root@izwz9hy3mj62nle7573jv5z jdk1.8.0_181]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
解除安裝jdk:
如果需要解除安裝,那麼删除環境變量和jdk解壓後的目錄即可。
安裝服務
nginx
添加源
# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安裝
yum install -y nginx
檢視安裝後的目錄
# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz /usr/share/man/man3/nginx.3pm.gz
- Nginx配置路徑:/etc/nginx/
- 執行程式路徑:/usr/sbin/nginx
- PID目錄:/var/run/nginx.pid
- 錯誤日志:/var/log/nginx/error.log
- 通路日志:/var/log/nginx/access.log
- 預設站點目錄:/usr/share/nginx/html
需要主要的是
配置路徑
和
執行程式路徑
啟停指令
#啟動
[root@nginx]#/usr/sbin/nginx -c /etc/nginx/nginx.conf
#檢測配置
[root@nginx]#/usr/sbin/nginx -c /etc/nginx/nginx.conf -t
#重新開機
[root@nginx]# /usr/sbin/nginx -s reload
[root@nginx]# /usr/sbin/nginx -c /etc/nginx/nginx.conf -s reload
測試
如果顯示表示成功
[root@zhirui-base nginx]# curl localhost:80
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test Page for the Nginx HTTP Server on Fedora</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
...
當然也可以在浏覽器打開網址測試。
記得防火牆放開端口!,CentOS7防火牆操作參考:
https://juejin.im/post/5d3b264551882504b7122127nginx配置檔案配置參考:
https://juejin.im/post/5d7e3f51f265da03a31d687b https://juejin.im/post/5d81906c518825300a3ec7camysql
安裝:
這裡安裝的是mariadb,mariadb和mysql是可以通用的,是mysql的開源分支,比mysql更加有前景。
# yum install mariadb-server mariadb
配置配置檔案:
#vim /etc/my.cnf
[mysqld]
character-set-server = utf8 #設定預設編碼, 在[mysqld]下配置,[client][mysql]不配置!!!
lower_case_table_names = 1 #配置大小寫不敏感, 查詢時不區分大小寫, 1:不區分, 0:區分
group_concat_max_len = 204800 #修改最大傳回字元串的長度
啟停操作:
systemctl start mariadb #啟動MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重新開機MariaDB
systemctl enable mariadb #設定開機啟動
配置帳号和權限
第一次登陸的時候不需要密碼
# mysql -uroot -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
update user set password=password("123456") where user='root';
flush privileges;
exit
添加端口到防火牆,并重新開機防火牆:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
如果需要解除安裝使用如下方式:
參考:
https://www.cnblogs.com/javahr/p/9245443.html
- 使用以下指令檢視目前安裝mysql情況,查找以前是否裝有mysql
`rpm -qa|grep -i mysql`
可以看到如下圖的所示:
顯示之前安裝了:
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5
删除指令:rpm -e –nodeps 包名
- 停止mysql服務、删除之前安裝的mysql
rpm -ev --nodeps MySQL-client-5.5.25a-1.rhel5 rpm -ev --nodeps MySQL-server-5.5.25a-1.rhel5
- 查找之前老版本mysql的目錄、并且删除老版本mysql的檔案和庫**
查找結果如下:`find / -name mysql`
删除對應的mysql目錄`find / -name mysql` `/var/lib/mysql``/var/lib/mysql/mysql``/usr/lib64/mysql `
`rm -rf /var/lib/mysql``rm -rf /var/lib/mysql``rm -rf /usr/lib64/mysql`
具體的步驟如圖:查找目錄并删除
注意:解除安裝後/etc/my.cnf不會删除,需要進行手工删除
`rm -rf /etc/my.cnf`
- 再次查找機器是否安裝mysql
`rpm -qa|grep -i mysql`
如果是yum指令安裝的還需要執行如下指令:
yum remove mariadb*
yum remove mysql*
redis
安裝一個倉庫
為了能夠實作yum指令安裝,故先需要安裝該倉庫
yum install epel-release
安裝redis資料庫
`yum ``install` `redis`
安裝完畢後,使用下面的指令啟動redis服務
`# 啟動redis``service redis start``# 停止redis``service redis stop``# 檢視redis運作狀态``service redis status``# 檢視redis程序``ps` `-ef | ``grep` `redis`
設定redis為開機自動啟動
`chkconfig redis on`
進入redis服務
`# 進入本機redis``redis-cli``# 列出所有key``keys *`
修改配置
打開配置檔案
`vi` `/etc/redis``.conf`
修改預設端口
查找 port 6379 修改為相應端口即可
修改預設密碼
查找 requirepass foobared 将 foobared 修改為你的密碼
允許遠端通路
# 找到 bind 127.0.0.1 将其注釋
# 找到 protected-mode yes 将其改為
protected-mode no
nexus
官網位址:
https://www.sonatype.com/download-oss-sonatype# cd /opt
# wget https://download.sonatype.com/nexus/3/nexus-3.2.0-01-unix.tar.gz
# tar zxvf nexus-3.2.0-01-unix.tar.gz
解壓後,在目前目錄中除了nexus-3.2.0-01還有一個
sonatyoe-work
目錄,使用者存放倉庫資料的,可根據需要将其改為其他路徑,或使用軟連結的方式。
這裡說下通過改配置檔案的方式,将其改為其他路徑吧。
檢視nexus-3.2.0-01/bin/nexus.vmoptions檔案:
# vim /opt/nexus-3.2.0-01/bin/nexus.vmoptions
分别對應着以下屬性,有需求可以修改:
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
sonatype-work/nexus3/etc
的目錄下有個配置檔案nexus.properties,可以配置對應的ip位址和端口
用vim打開檔案:
vim nexus.properties
預設是如下配置,如果ip沖突可以按需修改端口等:
# Jetty section
# application-port=8081
# application-host=0.0.0.0
# nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
# nexus-context-path=/
...
也可以在nexus-3.2.0-01/bin/nexus.rc上指定新的帳号運作nexus。
編輯nexus.rc:
那麼linux系統中需要添加一個叫做run_as_user="nexus"
的使用者,用來啟動nexus。
nexus
配置
通路nexus:
http://serverip:8081,配置之前需要先登入
預設帳号是
admin
,預設密碼是
admin123
maven-central
maven-central
修改central倉庫的遠端倉庫位址(建議修改成spring或者阿裡雲的倉庫)
倉庫位址如下:
1.http://repo1.maven.org/maven2 (官方,速度一般)
2.http://maven.aliyun.com/nexus/content/repositories/central/ (阿裡雲,速度快)
3.http://repository.jboss.com/maven2/
4.<https://repository.sonatype.org/content/groups/public/>
5.http://mvnrepository.com/
修改後rebuild下index
配置第三方倉庫
該倉庫用于上傳私有jar用。
點選
Create repository
填寫名稱
3rd-repo
,其他預設即可。
maven-public
maven-public
maven-public
是nexus的中心組,我們使用的nexus的url填寫的就是這個組的位址。是以我們需要在這裡将剛剛建立的倉庫添加到這個組裡面。
選中,添加到右邊即可:
maven部署到nexus
我在這裡整理了幾種部署到maven的方式:
https://juejin.im/post/5d8b7a40f265da5ba273ac05git
安裝jinkens之前需要安裝git,直接用yum指令進行安裝
# yum install git
安裝後需要通過如下方式找到git程式位置,後面的jenkins需要使用。
# find / -name git
/usr/bin/git
可以檢視到git所在位置為
/usr/bin/git
檢視git的版本
# git --version
git version 1.8.3.1
maven
安裝jinkens之前需要安裝maven
下載下傳頁:
http://maven.apache.org/download.cgi下載下傳和安裝:
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz
tar -zxf apache-maven-3.6.2-bin.tar.gz
mv apache-maven-3.6.2
cd apache-maven-3.6.2/conf
vim settings.xml
settings.xml配置
在conf目錄下,有個settings.xml,在使用前需要進行配置。
如果配置後jenkins無法建構,請參考:《[maven配置:jenkins的生産環境]()》
需要配置的幾個配置項:
- 配置下載下傳jar的存儲路徑
<localRepository>/path/to/local/repo</localRepository>
-
<mirrors>
下配置倉庫位址</mirrors>
我在jenkins建構的時候,同時配置了下面兩個倉庫,程式需要的私服私有jar一直跑去阿裡雲下載下傳,然後提示下載下傳不下來。如果出現這種情況,請隻保留私服的倉庫位址試試。
<!-- 私服位址 -->
<mirror>
<id>com.zhirui.group</id>
<mirrorOf>central</mirrorOf>
<name>com.zhirui.group</name>
<url>http://192.168.1.254:8081/repository/maven-public/</url>
</mirror>
<!-- 阿裡雲的倉庫位址 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
jenkins
jenkins安裝比較複雜,我另外寫了篇文章來詳細講解如果安裝和配置,點選檢視《
jenkins自動部署Spring Cloud服務實戰》
jira
jira安裝比較複雜,我另外寫了篇文章來詳細講解如果安裝和配置,點選檢視《
gitblit
幾大代碼管理工具對比,這裡隻講gitblit:
http://www.gitblit.com/
wget http://dl.bintray.com/gitblit/releases/gitblit-1.8.0.tar.gz
修改端口:
server.httpPort = 7000
server.httpsPort = 7443
開始通路
url:
http://192.168.1.234:7000/預設賬号密碼:admin/admin
frp
frp用于内網穿透用,可以實作在公網通路内網的服務。
下載下傳
wget https://github.com/fatedier/frp/releases/download/v0.29.0/frp_0.29.0_linux_amd64.tar.gz
更多的版本下載下傳: https://github.com/fatedier/frp/releases
伺服器端
# 配置和frp用戶端連接配接用
[common]
bind_port = 7000
token = javasea@frp
dashboard_port = 7557
#儀表闆的使用者名和密碼都是可選的,如果沒有設定,預設是admin。
dashboard_user = admin
dashboard_pwd = javasea@frpdash
啟動
# frps -c frps.ini
用戶端
# 配置和frp服務端連接配接用
[common]
server_addr = 120.79.246.166
server_port = 7000
token = javasea@frp #用于和伺服器端認證
# mysql暴露到公網
[mysql]
type = tcp
local_port = 3306
remote_port = 7575
# gitblit暴露到公網
[gitblit]
type = tcp
local_port = 7000
remote_port = 7576
# frpc -c frpc.ini
管理頁面:
url:
http://192.168.1.254:7557, 7557就是上面伺服器端配置的dash端口。