Java microservice project deployment (government intranet)

Foreword:

For some projects, for security, they can only be deployed in the intranet, so they cannot access the Internet. As a result, many commands of the server cannot be used, and the environment can only be installed by themselves. This deployment is a single microservice deployment (springcloud Alibaba) , Based on centos7 server

One, mysql5.7 installation

1. Resource download npm install mysql (Baidu network disk sharing, if it expires, please prompt)
mysql5.7 download
Extraction code: mri1

2. The tar package has been tarballed and uploaded directly to centos for decompression, a total of six files

tar -xvf mysql5.7

3. Install mysql

sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm

Note: If there is an error in the installation, please add --nodeps --force at the end
4. Start mysql

sudo systemctl start mysqld

View mysql default password

cat /var/log/mysqld.log | grep password

Please refer to another blog of the blogger for the password setting and master-slave replication in the future:
https://blog.csdn.net/qq_45142744/article/details/111316521?spm=1001.2014.3001.5501

Two, JDK1.8 installation

1. Resource download:
jdk download
Extraction code: x0x0
2. Upload to the server, unzip, and enter the jdk directory. pwd obtains the current path

Insert picture description here


3. Modify the /etc/profile environment variable and make it effective

vi /etc/profile

Add the java environment variable at the end of the editor (change JAVA_HOME to the path of pwd just now)

export JAVA_HOME=/data/jdk/jdk1.8.0_281
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

After wq saves and exits, reload environment variables

source /etc/profile

4. Verify that the installation is successful

java -version
Insert picture description here

Three, nacos installation

1. Resource download:
nacos download
Extraction code: kwg8
2. Upload the file to the server and configure it to persist with mysql

tar -zxvf nacos-server-1.0.0.tar.gz //解压

Execute the nacos/conf/nacos-mysql.sql script on the database as follows to generate the nacos database for persistence (this operation will not be demonstrated).
Modify the nacos/conf/application.properties file and add the following configuration above the configuration file


# db mysql
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://localhost:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=user
db.password=123456

Insert picture description here


After setting, save and exit wq, switch to nacos/bin and start nacos

nohup sh startup.sh -m standalone & //后台启动

Note: nacos is started in cluster mode by default on linux, standalone means stand-alone start

Four, nginx installation

1. Resource download (the configuration file has been modified, according to the company's needs, then configure it yourself )
nginx download
Extraction code: u4rc
2. Offline installation of nginx all dependencies
a, installation of gcc and gcc++ (resource download based on centos7)
https://pan .baidu.com/s/1U4icuwB9cEYtFa9HIV66Xg
Extraction code: After fan1 is
uploaded to the server, enter the decompressed directory and execute the following command:

 rpm -Uvh *.rpm --nodeps --force

Verify that the installation is successful

gcc  -v;
gcc-c++  -v;

b. Install prce and libtool, download resources: Download
prce and libtool
Extraction code: 0nct After
uploading to the server, execute the following commands in the prce decompression directory and libtool decompression directory respectively:

//先在pcre里执行,再去libtool
./configure
make
make install

3. After the dependency is completed, after uploading to the server, unzip

If the server is offline, there is usually no unzip command and you need to install it yourself. If you have the unzip command, please skip it. Download the resource:
unzip command download
Extraction code: After
uploading a0fg to the server, execute the following command:

rpm -Uvh unzip-6.0-19.el7.x86_64.rpm

Unzip nginx

tar -xvf nginx-1.6.2

First create the directory generated by nginx, and then enter the nginx directory

./configure --prefix=/data/webserver/slpt //后面的路径就是nginx生成的目录
make
make install

4. After the nginx configuration is complete, go to the sbin directory and execute the following command to start

./nginx

Note: If you start to report error while loading shared libraries: libpcre.so.0, please refer to my other blog

Five, redis installation

1. Resource download
redis resource download
Extraction code: ne8g
2. Decompress after uploading to the server

tar -zxvf redis.rar

3. After decompression, enter the decompressed redis directory and install

make //先make,再make install
make install PREFIX=/data/redis //安装的目录

4. In the unzipped directory, copy redis.conf to the installed redis directory

cp redis.conf /data/redis/bin

5. Just start redis

./redis-server redis.conf 

Six, MongoDB installation


Mongodb resource download Extraction code: 0b51
1. After uploading to the server, decompress:

tar -zxvf mongodb-linux-x86_64-rhel70-4.0.24.tgz

2. Create the data directory and log directory required by mongodb

mkdir /data/mongodb/data/db //用于存储数据
mkdir /data/mongodb/logs //日志
touch /data/mongodb/logs/mongodb.log

3. Write the configuration file in the bin directory of mongodb, there is already a configuration file in the resource, just copy it


#端口号
port = 27017 
##数据目录
dbpath = /home/mongodb/data/db
##日志目录
logpath = /home/mongodb/logs/mongodb.log
##设置后台运行
fork = true
##日志输出方式
logappend = true
##开启认证
auth = true
bind_ip = 0.0.0.0,:: //注意,这里允许所有机器访问,以后需要改的,为了安全,指定ip访问

Insert picture description here


4. Start mongodb in the bin directory:

./mongod -f mongodb.conf //根据当前mongodb配置文件启动
Insert picture description here


5. Configure mongo environment variables

vi /etc/profile

Append mongo environment configuration at the end

export MONGODB_HOME=/data/mongodb/mongodb-linux-x86_64-rhel70-4.0.24
export PATH=$PATH:$HADOOP_HOME/bin:$MONGODB_HOME/bin
Insert picture description here


Save and exit to make the configuration effective, execute the following command

source /etc/profile

6. The installation is successful, and the user assignment and permission configuration after using the mongo client to access

Insert picture description here


are not demonstrated here.

Continuously updating...