Imitation cattle project deployment

Aliyun ECS

  • This is a one-month free trial , the basic operations are clearly written in the documentation
  • Configuring CentOS 7.6 64-bit
    2 vCPU 4 GiB (I/O optimized)

Download PuTTY

  • The password entered when connecting to Aliyun should be set here

Download the required tools to root

I can't use the teacher's method of copying the link address. The following is the same download address as the teacher's version.
The connection failure may be a network problem, try again a few times, or change the network, change the time period

cd /root
  • MySQL
wget -i -c
  • Maven
wget -i -c
  • Elasticsearch
wget -i -c
  • Chinese plugin for Elasticsearch ik
wget -i -c
  • Tomcat
wget -i -c
  • Kafka
wget -i -c
  • Install JRE
yum list java*
yum install -y  java-1.8.0-openjdk.x86_64 
java -version
  • Upload files from local
    -> Compress the file to upload
    -> Open the command line in the compressed file directory and execute the following command
    -> Then ask if you want to add the key to the cache, I choose y (there is no such step when uploading for the first time)
    -> Then enter the password
pscp Compressed root@public net IP:/root

  • Check the files in the root directory at this time in PUTTY and should be as shown below

I slipped an extra ik,

Install an unzip tool

yum list unzip*
yum install -y unzip.x86_64

Configure Maven

- unzip to /opt under the path
tar -zvxf apache-maven-3.6.1-bin.tar.gz -C /opt
cd /opt
- Bundle Maven add the path to the system path
vim /etc/profile

❗ ❗ ❗ For those who have no experience with Linux, they may not be able to keep up with the rhythm of the teacher at all (I almost tried most of the keyboards, only to find that the INSERT operation is to press the insert key 😅), here are some simple operations, You can try to save yourself

Press the letter "i" to enter "INSERT" mode

Click "Esc" on the upper left of the keyboard to exit "INSERT" mode

:wq exit vi after saving, if it is :wq!, it is forced to exit after saving

:w save without exiting

:w! Forcibly write the file if the file attribute is "read-only"

:q leave vi

:q! If you have modified the file and don't want to save it, use ! to force quit without saving the file.

:e! Restore the file to its original state!

If you use the above button to change the /etc/profile file beyond recognition, you can create a new ECS and start over.
(If there are too many instances created that exceed the free permissions, click the release settings in the figure below)

- At the end of the file add:
export PATH=${PATH}:/opt/apache-maven-3.6.1/bin
- make the file valid
source /etc/profile
- an examination
mvn -version
cd config
- Open configuration file
vim settings.xml
- the local maven Copy the image to the server (you can adjust the display range of the file by pressing the up and down buttons)
        <name>Nexus aliyun</name>

Configure MySQL

- Install MySQL
yum list mysql*
cd /root
yum install -y mysql80-community-release-el7-3.noarch.rpm
- search again
cd /
yum list mysql*
- Install MySQ server
yum install -y mysql-community-server.x86_64   

❗ ❗ ❗The mysql version is wrong, uninstall it

The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not cor rect for this package.
Check that the correct key URLs are configured for this repository.

  • Add --nogpgcheck after the instructions to install the MySQL server
- start up MySQL
systemctl start mysqld
- Check MySQL status
systemctl status mysqld
- turn up MySQL the original password
grep 'password' /var/log/mysqld.log
- Login to the database with the found password
mysql -u root -p
- Change the password of the database
alter user root@localhost identified by 'XXX';
- Sign out and sign in with new password
mysql -u root -p
- Exit after confirming that there is no problem
  • Import MySQL files
- back to root under the folder
cd /root
- Unzip the uploaded file
unzip -d /root
mysql -u root -p
- create database
create database community;
- import data table
source /root/XXX/init_data.sql;
- display table
- Change the avatar path contains localhost path of
update user set header_url = '' where header_url like '%localhost%';

Configure Redis

cd /
yum list redis*
- Install redis
yum install -y redis.x86_64
- turn on redis
systemctl start redis
- an examination redis status
systemctl status redis
keys *
- quit

Configure Kafka

- Enter root
cd /root
- Bundle Kafka unzip to/opt under the folder
tar -zvxf kafka_2.12-2.3.0.tgz -C /opt
- Enter/opt under the folder
cs /opt
- Enter config folder
cd config/
- start up Zookeeper
bin/ -daemon config/zookeeper.peoperties
- start up kafka
nohup bin/ config/ 1>/dev/null 2>&q &
- an examination
bin/ --list --bootstrap-server localhost:9092

Configure Elasticsearch

- decompress
tar -zvxf elasticsearch-6.4.3.tar.gz -C /opt
unzip -d /opt/elasticsearch-6.4.3/plugins/ik
- Modify the configuration file
cd /opt/elasticsearch-6.4.3/
cd /config
vim elasticsearch.yml
vim jvm.options
- create a user
groupadd nowcoder
useradd nowcoder1 -p 123456 -g nowcoder
- Authorize the new user
cd /opt
chown -R nowcoder1:nowcoder *
cd /tmp
chown -R nowcoder1:nowcoder *
- switch to user: 
su - nowcoder1
cd /opt/elasticsearch-6.4.3
- switch back root
su -
- an examination
curl -X GET "localhost:9200/_cat/health?v"

Configure wkhtmltopdf

- return root path
cd /
yum list wkhtmltopdf*
- Install wkhtmltppdf
yum install -y wkhtmltppdf.x86_64
- install a virtual GUI server
yum list *xvfb*
yum install -y xorg-xll-server-Xvfb.x86_64
- test
cd /root/test
xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltoimage 1.png
- Write a script to wrap the above verbose code
cd /opt
xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltoimage "$@"
- Give Execute permission on this file
chmod +x
- test
cd /root/test
/opt/ 2.png

Configure Tomcat

cd /root
- decompress tomcat
tar zvxf apache-tomcat-9.0.68.tar.gz -C /opt
-Bundle tomcat/bin The path is configured to the system environment variable
cd /opt/apache-tomcat-9.0.68/bin
vim /etc/profile
(add in the file pwd)
vim /etc/profile
source /etc/profile
- verify
echo $PATH\
- start up tomcat
- closure tomcat
  • If it is a one-month trial version on Aliyun, you need to configure the port

Configure Nginx

cd /
yum list nginx*
- Install Nginx
yum install -y nginx.x86_64
- configuration file
vim /etc/nginx/nginx.conf
- start up nginx
systemctl start nginx 
- View status
systemctl status nginx 
  • Here is the same problem as tomcat, Aliyun trial version needs to configure port 80 on Aliyun

Modify project configuration

delete all default projects under tomcat

cd /opt/apache-tomcat-9.0.68/
cd webapps
rm -rf *

Modify project configuration

  • global.js
var CONTEXT_PATH = "";
  • HomeController
    public String root(){
        return "forward:/index";
  • Project package
  • Open cmd under the path of the project to upload the project
pscp -P 22 root@my own IP:/root
- source code decompression: 
unzip -d /root
cd community/
- ignore test:
mvn clean package -Dmaven.test.skip=true
  • If the following error occurs

No compiler is provided in this environment. Perhaps you are running on a JRE rather
than a JDK?

  • Solution
yum install -y java-devel
mvn clean package -Dmaven.test.skip=true
cd target/
- copy ROOT.war arrive tomcat Down
cd target/
mv ROOT.war /opt/apache-tomcat-9.0.64/webapps/
- start up tomcat:

Posted by soapsuds on Sun, 23 Oct 2022 06:03:16 +0300