Cgb2005 jt-10 (Linux realizes the deployment of Beijing Amoy project, the server retrieves the instructions to close the process firewall, installs nginx in Linux, cold backup and hot backup)

Cool breeze AAA 2022-02-13 07:43:42 阅读数:459

cgb2005 cgb jt-10 jt linux

matters needing attention

1. Deployment of Jingtao project ( No installation nginx)
2. Server retrieval instructions
linux Kill process
Firewall specific port description
3.linux Add to the project nginx Deploy
4. Jingtao database optimization
Database backup

1. Realize the deployment of Beijing Amoy project ( nothing nginx)

linux Not installed yet nginx, Only through ip+ Port number access .

1.1 Modify the upload location of the configuration file of the picture

1). explain : because windows The path and Linux The paths are not the same , So you have to prepare a Linux The root directory of the image upload to save the image .
 Insert picture description here
2). Prepare directory :
 Insert picture description here

3). modify image.properties file
explain : It's on it Windows Configuration path (D:/JT-SOFT/images), Here is Linux Configuration path (/usr/local/src/images).
 Insert picture description here

1.2 Upload installation package

explain :
hold jt Project printing 2 Put a package in an empty directory , After the linux Prepare a directory in your working directory , Drag to upload .
 Insert picture description here

1.3 Project release

command :
java -jar 8081.war: This startup mode will occupy the current end segment and can't do other operations , You can only exit to operate , Because the project is published in linux On the system , So closing the terminal window is equivalent to closing tomact The server .
java -jar 8081.war &: & Indicates that other operations will be performed next , enter Will automatically jump out .

perform :java -jar 8081.war &

 Insert picture description here
enter Key out , perform :java -jar 8082.war &
 Insert picture description here

1.4 Access test

1. because linux No installation nginx, So it's only through ip+ Port number visit .
2. Also because there is no linux, So the picture can't echo .
visit :8081
 Insert picture description here
 Insert picture description here
In the same way :8082
 Insert picture description here

2 About server retrieval instructions ( Apply to linux)

2.1 retrieval java Program

command :jps
effect : Check all java service . The number is the process number (pid)
 Insert picture description here
Close the process :
1.kill PID Number :“ The humble killing process ” If the current process item is used by other processes , It doesn't shut down .
2.kill -15 PID Number : “ Gently kill ” You can do the aftermath before you're killed
3.kill -9 PID Number : Force to kill
 Insert picture description here

2.2 Retrieve any program

command : ps -ef | grep xxxx The service name
explain : ps -ef Means to get the current Linux All the service information in the system . “|” Pass the result of the query before the pipeline as a parameter to the following operation .
Example :
1. retrieval mysql Process number
 Insert picture description here
2. Retrieve all to java The process number at the beginning of the command .
 Insert picture description here

2.3 About the firewall

It's best not to simply eliminate violence to the top and directly close the firewall at work , May be hacked . Usually open a specific port number on the firewall .
 Insert picture description here

1). Check the list of ports open by the firewall ( The premise is to turn on the firewall first

firewall-cmd --list-ports

2). Check that the port is open

firewall-cmd --query-port 80/tcp

 Insert picture description here
3). Turn on the firewall xxxx

# New port
firewall-cmd --zone=public --add-port=80/tcp --permanent

 Insert picture description here
4). Remove port

 firewall-cmd --zone=public --remove-port=9090/tcp --permanent

 Insert picture description here
5). An explanation of firewall operation

–zone # Scope
–add-port=80/tcp # Add port , The format is : port / Communication protocol
–remove-port=80/tcp # Remove port , The format is : port / Communication protocol
–permanent # permanent , Failure after restart without this parameter

6). service iptables restart

firewall-cmd --reload

 Insert picture description here

3 Linux nginx Installation and use

3.1 Linux Project deployment diagram

Now it's time to deploy the project to linux Server ,nginx It belongs to the server agent, so nginx Actually deployed to linux On the system .
 Insert picture description here

3.2 download linux Version of nginx

Download... On the official website linux Version of nginx, Then upload to the working directory :/usr/local/src/
 Insert picture description here

3.3 decompression Nginx service

1. command : tar -zxvf xxxxxx( Because the compressed package is downloaded here )
 Insert picture description here
2. Move the installation package to the directory dedicated to the compressed package software, And decompress nginx Change of name
 Insert picture description here

3.4 nginx Directory structure problem

nginx There is 2 Directory structure :
1. Source directory : be responsible for nginx Installation Compilation and other operations .
 Insert picture description here
Installation command :
Execute this in turn 3 An order .

1. ./configure
2. make
3. make install

1.1 Execute the script file in the current directory :./ xxx( Green files represent script files )
 Insert picture description here
1.2 compile
 Insert picture description here
1.3 install
 Insert picture description here
2. working directory :/usr/local/nginx( be responsible for nginx Reverse proxy and other configuration …)

3.5 start-up nginx test

1). explain :nginx The start-up of should be in “/usr/local/nginx”(nginx Working directory of )
 Insert picture description here
explain :

conf: Profile directory
html: Default page directory
logs: Log directory
sbin:nginx Start Directory

2). Get into sbin After the catalog , start-up nginx.
linux Version of nginx command :

./nginx start-up nginx
./nginx -s reload restart nginx
./nignx -s stop stop it nginx

 Insert picture description here

3). Start the effect test :`http://192.168.126.129:80``

 Insert picture description here

3.6 Linux nginx Implement reverse proxy / Load balancing

3.6.1 Implement domain name / Picture echo agent

demand : Require users to pass http://manage.jt.com Mode of access Linux Medium nginx, And load balancing .
1). It needs to be modified first hosts file .
 Insert picture description here
2). close windows Medium nginx Prevent interference .
 Insert picture description here

3). modify .conf file
 Insert picture description here
 Insert picture description here
 Insert picture description here

 #1. To configure tomact colony
server {

listen 80;
server_name manage.jt.com;
location / {

proxy_pass http://jt;
}
}
upstream jt {

server 192.168.126.129:8081;
server 192.168.126.129:8082;
}
#2. To configure linux Picture agent
server {

listen 80;
server_name image.jt.com;
location / {

# Configure the image disk address .
root /usr/local/src/images;
}
}

4).ctrl+s preservation :
 Insert picture description here
5). start-up nginx
 Insert picture description here
6). Access test
 Insert picture description here

4 Jingtao database optimization

4.1 Prepare the second virtual machine

Change the name of the virtual machine , And re unzip a copy linux System to virtual machine .
 Insert picture description here
 Insert picture description here

4.2 Modify virtual machine ip

explain : Because now you are decompressing the same linux System , So now the host ip identical , You need to modify the of the second virtual machine ip.

4.2.1 modify MAC Address

modify MAC Address , Then click OK , Re running the virtual machine .
 Insert picture description here

4.2.2 modify ip Address

explain : Because now the host ip identical , So now you can't connect through remote tools , Now it can only be changed through a black window .
1). Check IP Address
command : ip addr
 Insert picture description here
without IP Then execute the following command to restart the network card .

service NetworkManager stop
chkconfig NetworkManager off Permanent ban Manager network card
service network restart restart network network card

2). modify IP Address
2.1). find IP Directory of addresses

cd /etc/sysconfig/network-scripts/

 Insert picture description here
2.2). compile ifcfg-ens33 file .

 vim ifcfg-ens33

 Insert picture description here
Click on i—> hold 129 Change it to 130---->Esc—>:wq sign out .
 Insert picture description here
3). Restart NIC Check IP Is the address correct
 Insert picture description here
4). Connect via remote tools
 Insert picture description here

4.3 Why we need to build Mysql colony

describe : If a single database is used in the project , If the equipment is damaged due to irresistible factors , Data loss , Will directly affect the use of users , It needs to be optimized .
solve : Database backup .
 Insert picture description here

4.4 Database data backup method

4.4.1 Database cold backup

explain : Periodically pass the files in the database through sql The way to dump . Ensure that the data is backed up within a certain period of time .
shortcoming :
1. The database cold backup is operated manually , Very inconvenient
2. Database cold backup is performed regularly , therefore May cause data loss .

But companies still use this method , Because it's better to lose some than all , Database cold backup is the last effective means to restore data .

Be careful :
1. Start the database first to connect successfully .
2. What's starting up here is linux The database inside .( Start command :systemctl start mariadb)
step :
1. Select the database to export .
 Insert picture description here
2. Select the directory to export
 Insert picture description here

4.4.2 Database hot backup

Hot backup : Continuously synchronize the data of the master database to the slave database .
 Insert picture description here

explain : Because the database synchronization operation is very frequent in the work , So as a database developer , Also designed how to synchronize the database .

 Insert picture description here
The steps of synchronization :

  1. If the master database needs to start the synchronization strategy , The binary log file must be opened .( It's off by default .)
  2. When the user " to update " Database time , The main database will write the update information to the binary log file . ( The main database task ends )
  3. From the library will use IO The thread reads the updated binary log file in the main library .
  4. IO The thread will read the information using asynchronous First save to the relay log .( relay : A medium for temporarily storing data )
  5. SQL The thread will read the information in the relay log , After the sql Statements are synchronized to the slave database . At this point, the master-slave synchronization is realized …

4.5 Install from library mysql

1). Test network connection
 Insert picture description here

2) A little : Step view day09–>5.3.
 Insert picture description here

4.6 matters needing attention

explain : Because it is necessary to realize the master-slave synchronization of the database , therefore Before configuring master-slave The information in the database must be consistent .
step :
1. take Main library The information of is exported by cold backup .
 Insert picture description here
2. In the database Slave Library Import jtdb.sql File can .
 Insert picture description here

copyright:author[Cool breeze AAA],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130743383750.html