搭建開發測試環境很是麻煩,公司的開發測試服務器中毒作數據恢復,順帶整理下搭建的方式。css
本人是程序員,linux系統知識比較薄弱,故系統的安全方面本文未涉及,請酌情作安全策略。html
原本是內網服務器,用frp暴露到了公網,致使被挖礦。。感受frp仍是不安全,如今只能在須要穿透的時候開下,其餘時候java
關閉。node
mysql數據備份和恢復參考:juejin.im/post/5d8b85…mysql
有些命令可能未默認安裝,若是發現命令沒法使用,再經過下面的方式進行安裝。nginx
centos 7中自帶的查看網絡的命令是: ip addrgit
若是仍是想要 ifconfig程序員
安裝net-toolsgithub
yum install net-tools
yum install vim
若是是虛擬機模式,VM box的網絡模式修改成
橋接
。
[root@zhirui-base ~]# hostnamectl
Static hostname: zhirui-base
Icon name: computer-vm
Chassis: vm
Machine ID: c9cea1249eaf47379236a0ed4e371584
Boot ID: 94a2959e5c684c94ad6e4e4b096af282
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
複製代碼
只查看靜態、瞬態或靈活主機名,分別使用「--static」,「--transient」或「--pretty」選項
[root@zhirui-base ~]# hostnamectl --static set-hostname zhirui-test
[root@zhirui-base ~]# exit
logout
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(192.168.1.234) at 12:33:40.
Type `help' to learn how to use Xshell prompt.
[C:\~]$
複製代碼
若是你只想修改特定的主機名(靜態,瞬態或靈活),你可使用「--static」,「--transient」或「--pretty」選項。
Connecting to 192.168.1.234:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Sun Oct 27 12:29:20 2019 from 192.168.1.119
[root@zhirui-test ~]# hostnamectl --static
zhirui-test
[root@zhirui-test ~]# hostnamectl
Static hostname: zhirui-test
Icon name: computer-vm
Chassis: vm
Machine ID: c9cea1249eaf47379236a0ed4e371584
Boot ID: 94a2959e5c684c94ad6e4e4b096af282
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
[root@zhirui-test ~]#
複製代碼
[root@zhirui-test ~]# vim /etc/hosts
127.0.0.1 zhirui-test localhost
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain
::1 localhost localhost.localdomain localhost6 localhost6.localdomai
複製代碼
在修改靜態/瞬態主機名時,任何特殊字符或空白字符會被移除,而提供的參數中的任何大寫字母會自動轉化爲小寫。一旦修改了靜態主機名,/etc/hostname 將被自動更新。然而,/etc/hosts 不會更新以保存所作的修改,因此你每次在修改主機名後必定要手動更新/etc/hosts,以後再重啓CentOS 7。不然系統再啓動時會很慢。
命令爲:
[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。
複製代碼
[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
複製代碼
[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
複製代碼
最新jdk1.8.0_211我已經上傳到網盤:
連接:pan.baidu.com/s/1B9DRL5iZ… 提取碼:5e92 複製這段內容後打開百度網盤手機App,操做更方便哦)
上傳和解壓到該路徑: /usr/local/base/jdk1.8.0_211
vi /etc/profile 在最後添加以下內容:
#java environment
export JAVA_HOME=/usr/local/base/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解壓後的目錄便可。
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
tar -xvf elasticsearch-6.2.4.tar.gz
複製代碼
咱們將解壓後elasticsearch-6.2.4
的路徑稱爲${elasticsearch}
,後面會用到。
3. 啓動
在root下對${elasticsearch}/bin
目錄權限設置
chmod 775 *
複製代碼
添加用戶"elastic"
adduser elastic
複製代碼
解壓目錄受權給"elastic"用戶
chown -R elastic elasticsearch-6.2.4
複製代碼
su到elastic用戶
su elastic
複製代碼
執行${elasticsearch}/bin/elasticsearch
啓動成功,節點名爲wib4w5f,啓動如圖所示:
ps -ef | grep elastic
查看進程信息:
[root@localhost ~]# ps -ef | grep elastic
root 24494 24002 0 17:54 pts/0 00:00:00 su elastic
elastic 24495 24494 0 17:54 pts/0 00:00:00 bash
root 24670 24521 0 18:03 pts/0 00:00:00 su elastic
elastic 24671 24670 0 18:03 pts/0 00:00:00 bash
elastic 24700 24671 2 18:04 pts/0 00:00:10 /apps/jdk8/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch.KrRABQX8 -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/usr/local/elasticsearch-6.2.4 -Des.path.conf=/usr/local/elasticsearch-6.2.4/config -cp /usr/local/elasticsearch-6.2.4/lib/* org.elasticsearch.bootstrap.Elasticsearch
root 24876 24858 0 18:11 pts/1 00:00:00 grep --color=auto elastic
複製代碼
./elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name
複製代碼
啓動成功:
./elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name01
複製代碼
./elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name02
複製代碼
docker
版本介紹: docker-io
是之前早期的版本,版本號是 1.,最新版是 1.13,而 docker-ce 是新的版本,分爲社區版 docker-ce 和企業版 docker-ee,版本號是 17. ,最新版是 17.12。企業版本須要付費。
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
複製代碼
卸載不會刪除掉docker的數據,能夠數據默認在/var/lib/docker
目錄下。
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
複製代碼
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
複製代碼
yum
的包索引sudo yum makecache fast
複製代碼
yum -y install docker-ce
複製代碼
docker version
複製代碼
systemctl start docker
複製代碼
docker pull rabbitmq:3.8-rc-management
複製代碼
使用docker images
查看
docker run -d --name rabbitmq3.8.2 -p 5672:5672 -p 15672:15672 -v /data:/var/lib/rabbitmq --hostname myRabbit -e RABBITMQ_DEFAULT_VHOST=my_vhost -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin --privileged=true docker.io/rabbitmq:3.8-rc-management
複製代碼
說明: -d 後臺運行容器; --name 指定容器名; -p 指定服務運行的端口(5672:應用訪問端口;15672:控制檯Web端口號); -v 映射目錄或文件; --hostname 主機名(RabbitMQ的一個重要注意事項是它根據所謂的 「節點名稱」 存儲數據,默認爲主機名); -e 指定環境變量;(RABBITMQ_DEFAULT_VHOST:默認虛擬機名;RABBITMQ_DEFAULT_USER:默認的用戶名;RABBITMQ_DEFAULT_PASS:默認用戶名的密碼); --privileged=true 作了-v目錄映射,可能會致使沒權限。
[root@test1 data]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
872e75cf838b docker.io/rabbitmq:3.8-rc-management "docker-entrypoint..." 4 minutes ago Up 4 minutes 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmq3.8.2
複製代碼
須要配置權限,登錄帳號密碼在docker容器啓動的時候有指定爲admin/admin
。 點擊右邊的Virtual Hosts
添加一個爲/
的Virtual Hosts
。
在安裝zookeeper以前須要先安裝好jdk,由於zookeeper啓動須要jdk支持
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz
複製代碼
tar -xf apache-zookeeper-3.5.5-bin.tar.gz
複製代碼
zookeeper的配置文件是 zoo.cfg,須要先建立
[root@localhost ~]# cd apache-zookeeper-3.5.5-bin/conf/
[root@localhost conf]# ll
total 12
-rw-r--r--. 1 2002 2002 535 Feb 15 2019 configuration.xsl
-rw-r--r--. 1 2002 2002 2712 Apr 2 2019 log4j.properties
-rw-r--r--. 1 2002 2002 922 Feb 15 2019 zoo_sample.cfg
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg
複製代碼
而後進行以下配置:
tickTime=2000 ##Zookeeper最小時間單元,單位毫秒(ms),默認值爲3000
dataDir=/var/lib/zookeeper ##Zookeeper服務器存儲快照文件的目錄,必須配置
dataLogDir=/var/lib/log ##Zookeeper服務器存儲事務日誌的目錄,默認爲dataDir
clientPort=2181 ##服務器對外服務端口,通常設置爲2181
initLimit=5 ##Leader服務器等待Follower啓動並完成數據同步的時間,默認值10,表示tickTime的10倍
syncLimit=2 ##Leader服務器和Follower之間進行心跳檢測的最大延時時間,默認值5,表示tickTime的5倍
複製代碼
進入bin
命令下,而後啓動
[root@localhost conf]# cd ../bin
[root@localhost bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /root/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone
複製代碼
集羣安裝參考:www.cnblogs.com/cyfonly/p/5…
# 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
複製代碼
須要主要的是配置路徑
和執行程序路徑
。
#啓動
[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防火牆操做參考:juejin.im/post/5d3b26…
nginx配置文件配置參考:
在安裝後修改配置文件,添加了80端口的監聽
[root@zhirui-base nginx]# vim /etc/nginx/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /wms/website;
index index.html index.htm;
}
}
複製代碼
經過命令/usr/sbin/nginx -c /etc/nginx/nginx.conf -t
檢測,報錯以下:
[root@zhirui-base ~]# /usr/sbin/nginx -c /etc/nginx/nginx.conf -s reload
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
複製代碼
解決方式: 經過grep -r localhost /etc/nginx/
命令查看衝突的地方,發現一個default.conf
下也綁定了80端口。
[root@zhirui-base ~]# grep -r localhost /etc/nginx/
/etc/nginx/conf.d/default.conf: server_name localhost;
Binary file /etc/nginx/.nginx.conf.swp matches
/etc/nginx/nginx.conf: server_name localhost;
複製代碼
將default.conf
更名後再檢測和啓動nginx成功。
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
複製代碼
這裏安裝的是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
複製代碼
若是須要卸載使用以下方式:
參考:www.cnblogs.com/javahr/p/92…
- 使用如下命令查看當前安裝mysql狀況,查找之前是否裝有mysql
`rpm -qa|grep -i mysql` 複製代碼
能夠看到以下圖的所示:
顯示以前安裝了:
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5
- 中止mysql服務、刪除以前安裝的mysql
刪除命令:rpm -e –nodeps 包名
  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` 複製代碼
查找結果以下:
`find / -name mysql` `/var/lib/mysql``/var/lib/mysql/mysql``/usr/lib64/mysql ` 複製代碼
刪除對應的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*
爲了可以實現yum命令安裝,故先須要安裝該倉庫
yum install epel-release
複製代碼
`yum ``install` `redis`
複製代碼
`# 啓動redis``service redis start``# 中止redis``service redis stop``# 查看redis運行狀態``service redis status``# 查看redis進程``ps` `-ef | ``grep` `redis`
複製代碼
`chkconfig redis on`
複製代碼
`# 進入本機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
複製代碼
官網地址:www.sonatype.com/download-os…
# 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:
run_as_user="nexus" 複製代碼
那麼linux系統中須要添加一個叫作
nexus
的用戶,用來啓動nexus。
訪問nexus:http://serverip:8081,配置以前須要先登陸
默認賬號是admin
,默認密碼是admin123
。
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
是nexus的中心組,咱們使用的nexus的url填寫的就是這個組的地址。因此咱們須要在這裏將剛剛建立的倉庫添加到這個組裏面。
選中,添加到右邊便可:
我在這裏整理了幾種部署到maven的方式:juejin.im/post/5d8b7a…
安裝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
複製代碼
安裝jinkens以前須要安裝maven
下載頁:maven.apache.org/download.cg…
下載和安裝:
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
複製代碼
在conf目錄下,有個settings.xml,在使用前須要進行配置。
若是配置後jenkins沒法構建,請參考:《maven配置:jenkins的生產環境》
須要配置的幾個配置項:
<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自動部署Spring Cloud服務實戰》
jira安裝比較複雜,我另外寫了篇文章來詳細講解若是安裝和配置,點擊查看《jenkins自動部署Spring Cloud服務實戰》
幾大代碼管理工具對比,這裏只講gitblit:
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用於內網穿透用,能夠實如今公網訪問內網的服務。
wget https://github.com/fatedier/frp/releases/download/v0.29.0/frp_0.29.0_linux_amd64.tar.gz
複製代碼
更多的版本下載:github.com/fatedier/fr…
# 配置和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.xx.xx.166
server_port = 7000
token = zhirui@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端口。