阅读 53

项目环境部署记录

Project Environment Construction

Server Information

  • Vendor: Vultr
  • Location: Los Angeles
  • CPU: 2 vCore
  • RAM: 4096 MB
  • Storage: 80 GB SSD
  • Bandwidth: 3000 GB
  • OS: CentOS 7 x64
  • Price: $20/mo($0.03/h)
  • Refer(Get $25 for 30 days): www.vultr.com/?ref=797494…

Previous Env

Assist

yum install -y net-tools # For netstat scanning port
yum install -y lrzsz # For XShell file transfer
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel # Tools
yum install -y gcc perl-ExtUtils-MakeMaker # Compile Env
复制代码

Dev

  • JDK 1.8.0_201-b09
    • $JAVA_HOME: /usr/java/jdk1.8.0_201-amd64/
    • ${PATH}:/usr/java/jdk1.8.0_201-amd64/bin
  • Git 2.22.0
    • $PATH:/usr/local/git/bin
  • Maven 3.6.1
    • $M2_HOME: /usr/local/maven
    • $M2: $M2_HOME/bin
    • $PATH:/usr/local/maven/bin
    wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
    tar xvf apache-maven-3.6.1-bin.tar.gz
    mv apache-maven-3.6.1 /usr/local/maven
    vim /etc/bashrc
    # add path
    source /etc/bashrc
    复制代码
  • Tomcat 8.5.42
    • HOME: /usr/local/tomcat
    wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz
    tar xzf apache-tomcat-8.5.42.tar.gz
    mv apache-tomcat-8.5.42 /usr/local/tomcat
    复制代码
    • 运行:/usr/local/tomcat/bin/startup.sh
    • 停止:/usr/local/tomcat/bin/shundown.sh
    • 查看日志:vim /usr/local/tomcat/logs/catalina.out
    • 配置manager:
      1. vim /usr/local/tomcat/webapps/manager/META-INF/context.xml
        • 添加Value: <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
        • 注释掉原来的Value
      2. vim /usr/local/tomcat/conf/tomcat-users.xml
        • 添加用户和角色:
      <role rolename="manager-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <user username="${TOMCAT_USERNAME}" password="${TOMCAT_PASSWORD}" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
    复制代码

Port Occupancy Record

Check: netstat -ano | grep 8080

  • Tomcat: 8080, 8005, 8009
  • S*S*R*: 17825
  • SonarQube: 9000
    • ElasticSearch: 9200
  • RabbitMQ: 5671:5671 5672:5672 4369:4369 25672:25672 15671:15671 15672:15672

Global Variable Definition

If u wanna deploy faster, plz use ctrl+F find and replace all ${MySQL_USERNAME}alike to your value( $PATH)

${MySQL_USERNAME}   -> MySQL用户名
${MySQL_PASSWORD}   -> MySQL密码
${MySQL_URL}        -> MySQL服务URL
${MySQL_PORT}       -> MySQL服务端口
${Server_IP}        -> 服务器IP
${TOMCAT_USERNAME}  -> Tomcat 管理员用户名
${TOMCAT_PASSWORD}  -> Tomcat 管理员密码
复制代码

Firewall Problem?

云服务器请自行打开安全组配置

systemctl status firewalld
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload
复制代码

New Env

  • Jenkins 2.176.1
  • SonarQube 6.7.7
  • Docker 18.09.7
    • RabbitMQ 3.7.6

Jenkins

wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
cp jenkins.war /usr/local/tomcat/webapps/
/usr/local/tomcat/bin/startup.sh
复制代码

SonarQube

Download and Modify config

wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-6.7.7.zip
unzip sonarqube-6.7.7.zip
mv sonarqube-6.7.7 /opt/sonarqube
vim /opt/sonarqube/conf/sonar.properties
vim /opt/sonarqube/elasticsearch/config/elasticsearch.yml
复制代码

sonar.properties

# Plz find and change these properties
sonar.jdbc.username=${MySQL_USERNAME}
sonar.jdbc.password=${MySQL_PASSWORD}
sonar.jdbc.url=jdbc:mysql://${MySQL_URL}:${MySQL_PORT}/sonarQube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.web.host=0.0.0.0
sonar.web.context=/sonarQube
sonar.web.port=9000
复制代码

elasticsearch.yml

# Plz find and change these properties
network.host: ${Server_IP}
http.port: 9200
复制代码

Add User and Run

useradd esuser
chown -R esuser.esuser /opt/sonarqube
chmod 777 -R /opt/sonarqube
su esuser
/opt/sonarqube/bin/linux-x86-64/sonar.sh console
/opt/sonarqube/bin/linux-x86-64/sonar.sh start
/opt/sonarqube/bin/linux-x86-64/sonar.sh status
复制代码

http://${Server_IP}:9000/sonar, admin/admin

Docker

yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo docker run hello-world
复制代码

Docker + RabbitMQ

Forked From xiaochunping/rabbitmq

docker search magiklau/magik-rabbitmq:latest
docker pull magiklau/magik-rabbitmq:latest
docker run -d --name rabbitmq -p 5671:5671 -p 5672:5672 -p 4369:4369 -p 25672:25672 -p 15671:15671 -p 15672:15672 magiklau/magik-rabbitmq:latest
复制代码

http://${Server_IP}:15672, guest/guest

Docker-Compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
复制代码

Docker-Compose + Redis-Sentinel

更新中……


复制代码
关注下面的标签,发现更多相似文章
评论