Construction of Ali Cloud Server Deployment Environment

We are in the age of cloud, system operation and maintenance is simpler and more direct than any other era.

Record your recent steps in deploying the Aliyun server environment and share them with you. Make a record of yourself.

OS information:

Linux version 2.6.32-696.3.2.el6.x86_64 (mockbuild@c1bl.rdu2.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Tue Jun 20 01:26:55 UTC 2017

LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.8 (Final)
Release: 6.8
Codename: Final

SSH client: Xshell 5

  • Catalog
    • System Initialization
    • jdk1.8
    • tomcat (running applications)
    • MySQL (database)
    • git (remote checkout code)
    • Aliyun code (code warehouse management)
    • Maven (Compile and Package)

System Initialization

Remote root logs in to the system. Create user and Empowerment

#Create user, - m create home directory, - p specify password
 useradd lucas -p serect -m
#To add sudoer, this command is more convenient than vim/etc/sudoers
visudo
#After finding the root ALL = (ALL) ALL line, copy the line and change the root to its own user name. If sudoer does not need a password, how to write the prefix NOPASSWD:. Note that WD is not WORD
#Upon completion of the modification, the
    ## Allow root to run any commands anywhere
    #root    ALL=(ALL)       ALL
    #lucas   ALL=(ALL)       NOPASSWD:ALL

Rebuild the connection in the xshell, connect to the system with the new user lucas, and continue the following steps

jdk1.8

Download the jdk tarball (see the article attached to share), upload it to the tmp directory using the upload tool that comes with the xshell (or you can install sudo yum install lrzsz directly with rz). I built the following directory under the home directory
/home/lucas
├── apps
├── code
└── tmp
Decompression installation

sudo mkdir /user/java
sudo cp ~/tmp/jdk-8u144-linux-x64.tar.gz .
sudo tar -zxvf jdk-8u144-linux-x64.tar.gz

Open / etc/profile (vim /etc/profile) and add the following

JAVA_HOME=/usr/java/jdk1.8.0_144
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH

Sudo source/etc/profile to take effect immediately

Java-version checks for validity

tomcat

Download tomcat's tarball and upload it to the tmp directory Decompression installation of

cp tmp/apache-tomcat-8.0.36.tar.gz apps/
cd apps/
tar -zxf apache-tomcat-8.0.36.tar.gz
#Direct start
cd apache-tomcat-8.0.36
./bin/catalina.sh start
#view log
tail -f logs/catalina.out 

Copy the war you will need to deploy to tomcat's webapps directory, and then restart Tomcat to access it

mysql

Reference resources

# Install mysql
sudo yum install -y mysql-server mysql mysql-deve
# Inspection and installation
rpm -qi mysql-server

My display is as follows. The installation was successful.

Name : mysql-server Relocations: (not relocatable)
Version : 5.1.73 Vendor: CentOS
Release : 8.el6_8 Build Date: Fri 27 Jan 2017 06:25:43 AM CST
Install Date: Tue 12 Sep 2017 10:46:25 AM CST Build Host: c1bm.rdu2.centos.org
Group : Applications/Databases Source RPM: mysql-5.1.73-8.el6_8.src.rpm
Size : 25884131 License: GPLv2 with exceptions
Signature : RSA/SHA1, Fri 27 Jan 2017 06:35:28 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem http://bugs.centos.org
URL : http://www.mysql.com
Summary : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.

Then start the mysql service, which requires some initialization actions for the first startup

# Startup service
sudo service mysqld start
# Restart service
sudo service mysqld restart
#Setting the root password
mysqladmin -u root password '{Your password}' 

Then login mysql with root account and enter password according to prompt to operate database.

mysql -u root -p

git

centos installation git is still simple

sudo yum install git

#Then you can git clone
git clone git@code.aliyun.com:aaa/bbb.git

The git on the server is only used to package after checking out the code, and it is not submitted.

Aliyun code

Deployment environments have been built. It's still a bit low to deploy them through war upload. Naturally, version management tools come to mind. git, of course. The first reaction is code cloud, but think about Aliyun, it is estimated that there are also corresponding hosting services. Sure enough, https://code.aliyun.com.

git repositories are used in similar ways. First, build a repository, then use ssh-keygen to generate a sshkey to ~/.ssh/id_rsa.pub. After adding to the repository, you can upload code on the local server.

When installing git on windows, you can consider msysgit perhaps tortoisegit I'm using a cygwin variant. babun
Here's how to add readme.md

 git clone git@code.aliyun.com:aaa/bbb.git
 cd ssm
 touch readme.md
 vim readme.md
 git add readme.md
 git commit -m 'Add to readme'
 git push -u origin master

Similarly, upload the code to the warehouse and pull it down on the server.

maven

maven can build code directly into deployment packages, so it's also necessary. Reference resources

cd ~/tmp
#Download tarball
wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
#Copy to / usr/local /, and extract
sudo mv apache-maven-3.5.0-bin.tar.gz /usr/local/
cd /usr/local/
sudo tar zxf apache-maven-3.5.0-bin.tar.gz
sudo rm apache-maven-3.5.0-bin.tar.gz

We need to configure the mirror of maven and use the mirror of Ali Cloud inside the wall, otherwise we can go to the central warehouse outside the wall to pull the tortoise.

cd apache-maven-3.5.0/
sudo vim conf/settings.xml

Find the < mirrors > tab and add the following configuration

    <mirror>  
        <id>alimaven</id>  
        <name>aliyun maven</name>  
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
        <mirrorOf>central</mirrorOf>         
    </mirror>  

Configure / etc/profile to add maven environment variables

#maven
export M2_HOME=/usr/local/apache-maven-3.5.0/
export PATH=$PATH:$M2_HOME/bin

After exit

#Make the configuration take effect immediately
source /etc/profile
maven -version

Success is indicated by seeing an interface similar to the following.

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /usr/local/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_144/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-696.3.2.el6.x86_64", arch: "amd64", family: "unix"

Then you can go to the project directory to execute the mvn clean package package package project, and copy it to the tomcat directory to deploy it. Of course, the first execution is very slow, all kinds of bags pulled once.

appendix

Software involved in the article:
Links: https://pan.baidu.com/s/1kVss1jp Password: tfb2

Reference Articles (Thank you for sharing)

Create user http://www.cnblogs.com/clicli/p/5943788.html
sudoer configuration http://blog.csdn.net/newairzhang/article/details/7715378
Install jdk http://blog.csdn.net/licongcong_0224/article/details/12756959/
mysql Installation Reference http://www.linuxidc.com/Linux/2015-07/120234.htm
maven Installation Reference http://blog.csdn.net/clementad/article/details/46898013

Keywords: Maven MySQL git sudo

Added by mikefn on Sun, 26 May 2019 01:54:03 +0300