Tongxin OUS installation project deployment environment mysql, redis, jdk, tomcat

install oracle jdk
1: java -version Check the jdk version Uninstall the openjdk that comes with linux
openjdk version “1.8.0_292”
OpenJDK Runtime Environment UnionTech (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM UnionTech (build 25.292-b10, mixed mode)
2: rpm -qa|grep jdk Query the openjdk installation packages and uninstall them one by one
copy-jdk-configs-3.7-3.uel20.noarch
java-1.8.0-openjdk-devel-1.8.0.292.b10-9.up1.uel20.x86_64
java-1.8.0-openjdk-headless-1.8.0.292.b10-9.up1.uel20.x86_64
java-1.8.0-openjdk-1.8.0.292.b10-9.up1.uel20.x86_64
3: Uninstall openjdk related installation packages
sudo rpm -ev java-1.8.0-openjdk-devel-1.8.0.292.b10-9.up1.uel20.x86_64
sudo rpm -ev java-1.8.0-openjdk-1.8.0.292.b10-9.up1.uel20.x86_64
sudo rpm -ev java-1.8.0-openjdk-headless-1.8.0.292.b10-9.up1.uel20.x86_64
sudo rpm -ev copy-jdk-configs-3.7-3.uel20.noarch
4: Execute rpm -qa|grep jdk again to check whether the uninstallation is clean, if not, repeat step 3
5: Create the mkdir tools folder under /usr and upload all the installation packages that need to be installed
jdk-8u131-linux-x64.tar.gz, mysql-5.7.42-1.el7.x86_64.rpm-bundle.tar, redis-stable.tar.gz, tomcat.tar.gz
6: Decompress jdk tar -zxvf jdk-8u131-linux-x64.tar.gz
7: Move the decompressed jdk to the java directory under the /usr/local/java/ directory. You need to create the moved directory in advance as /usr/local/java/jdk1.8.0_131. Record this directory, which needs to be used when configuring environment variables path
8: Set environment variables vim /etc/profile Add environment variable parameters at the end of the file After adding, press the Esc key to enter: wq and then press Enter to save and exit
export JAVA_HOME=/usr/local/java/jdk1.8.0_131
export JRE_HOME=

J

A

V

A

h

o

m

E.

/

j

r

e

e

x

p

o

r

t

C

L

A

S

S

P

A

T

h

=

.

:

{JAVA_HOME}/jre export CLASSPATH=.:

JAVAH?OME/jreexportCLASSPATH=.:{JAVA_HOME}/lib:

J

R

E.

h

o

m

E.

/

l

i

b

e

x

p

o

r

t

P

A

T

h

=

{JRE_HOME}/lib export PATH=

JREH?OME/libexportPATH={JAVA_HOME}/bin:$PATH
9: Reload the configuration file to make the configuration file take effect. (Must be executed) source /etc/profile
10: Check whether jdk is successfully installed java -version

install tomcat
1: Create a tomcat directory under /usr/local/ mkdir tomcat
2: Unzip the tomcat installation package tar -zxvf tomcat.tar.gz
3: Move the decompressed tomcat to /usr/local/tomcat/ under the decompressed directory mv ./apache-tomcat-8.5.88/ /usr/local/tomcat/
4: Check the port of the firewall. Tomcat defaults to port 8080. We need to add port 8080 to the firewall.
New port number: firewall-cmd –zone=public –add-port=8080/tcp –permanent
Restart the firewall: firewall-cmd –reload
Check whether port 8080 is enabled: firewall-cmd –zone=public –list-ports
5: Start tomcat and visit tomcat. If you can see the figure below, it means that tomcat starts successfully.
6: Configure tomcat as a system service Add tomcat configuration parameters under the /etc/profile file vim /etc/profile
Add the following configuration information
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.88
Add to PATH: KaTeX parse error: Expected ‘EOF’, got ‘#’ at position 196: …nv.sh Add the following content #?add tomcat pid …CATALINA_BASE/tomcat.pid”
#add java opts
JAVA_OPTS=”-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m”
Press the Esc key to enter: wq Press the Enter key to save and exit
9: Configure tomcat.service
Execute the following command to add tomcat.service in the /usr/lib/systemd/system directory and edit
vim /usr/lib/systemd/system/tomcat.service

Add the following content to the file Press the Esc key to enter: wq Press the Enter key to save and exit The specific path is configured according to the local environment
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment='JAVA_HOME=/usr/local/java/jdk1.8.0_131/'
Environment='CATALINA_PID=/usr/local/tomcat/apache-tomcat-8.5.88/tomcat.pid'
Environment='CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.5.88/'
Environment='CATALINA_BASE=/usr/local/tomcat/apache-tomcat-8.5.88/'
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX: + UseParallelGC'
PIDFile=/usr/local/tomcat/apache-tomcat-8.5.88/tomcat.pid
ExecStart=/usr/local/tomcat/apache-tomcat-8.5.88/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

10: After the configuration is complete, it is recommended to execute the following command to increase the configuration file permissions
chmod 755 /usr/lib/systemd/system/tomcat.service
11: Execute the following command to reload the system service after completion
systemctl daemon-reload
12: Set the boot to start automatically
systemctl enable tomcat.service
13: start tomcat
systemctl start tomcat.service
14: Test booting from the boot, execute systemctl status tomcat.service after reboot, see the figure below, indicating that the setting is successful

install redis
1: Create the redis directory mkdir redis under /usr/local/
2: Unzip the redis installation package tar -zxvf redis-stable.tar.gz
3: In the decompressed directory, move the decompressed redis to the /usr/local/redis/ directory mv ./redis-stable/ /usr/local/redis/
4: Check the port of the firewall. Redis defaults to port 6379. We need to add port 6379 to the firewall.
New port number: firewall-cmd –zone=public –add-port=6379/tcp –permanent
Restart the firewall: firewall-cmd –reload
Check whether port 6379 is enabled: firewall-cmd –zone=public –list-ports
5: Execute make install PREFIX=/usr/local/redis in the /usr/local/redis/redis-stable directory to install the program in the redis directory
6: Start redis through daemon thread and configure redis.conf file Copy redis.conf from redis-stable source code directory to redis installation directory
cp /usr/local/redis/redis-stable/redis.conf /usr/local/redis/bin/
7: Modify redis.conf as follows: Change the value of #daemonize from no to yes, as shown in the figure below
8: Set boot configuration Create redis.service file vim /usr/lib/systemd/system/redis.service
9: After adding the following content, press the Esc key to enter: wq, press the Enter key to save and exit (note that the installation path must be consistent with the local installation path)
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking

ExecStart needs to be modified to its own address according to the actual situation

ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target
10: Execute the following command to reload the system service after completion
systemctl daemon-reload
11: Set the boot to start automatically
systemctl enable redis.service
12: start redis
systemctl start redis.service
13: Test booting from boot, execute systemctl status redis.service after reboot, and see the figure below, indicating that the setting is successful
14: If you want to set redis non-local access, you need to set the bound ip 127.0.0.1 in redis.conf to 0.0.0.0 (test server can be set, production is not recommended)

install mysql
1: Use the rpm command to view the installed installation package rpm -qa|grep mysql If there is, uninstall the built-in package first
2: Uninstall the built-in installation package sudo rpm -ev pcp-pmda-mysql-4.1.3-13.up1.uel20.x86_64
3: Continue to find if there are any remaining files sudo find / -name mysql If there are any remaining files, continue to delete
Execute sudo find / -name mysql again after deletion to check whether there are residual files

sudo rm -rf /etc/postfix/dynamicmaps.cf.d/mysql
sudo rm -rf /etc/postfix/postfix-files.d/mysql
sudo rm -rf /var/lib/pcp/config/pmlogconf/mysql
sudo rm -rf /var/lib/selinux/targeted/active/modules/100/mysql
sudo rm -rf /usr/lib/python3.7/site-packages/ansible/modules/database/mysql
sudo rm -rf /usr/lib64/perl5/vendor_perl/auto/DBD/mysql
sudo rm -rf /usr/lib64/perl5/vendor_perl/DBD/mysql
sudo rm -rf /usr/share/bash-completion/completions/mysql

4: Decompress the installation package tar -zxvf mysql-5.7.39-linux-glibc2.12-x86_64.tar.gz
5: Move the decompressed folder to the /usr/local/mysql directory
mv ./mysql-5.7.39-linux-glibc2.12-x86_64/ /usr/local/mysql/

6: Then create a subgroup, add the mysql user, and then modify the subgroup and group user and folder permissions;
Execute the following command in the /usr/local/ directory:
groupadd mysql #Create a group
useradd -r -g mysql mysql #create user
chown -R mysql:mysql mysql
chmod -R 775 mysql #Modify group and group user and folder permissions
7: Enter the mysql5.7 directory, first create a data directory to save data files. Enter mkdir data
8: Then enter the bin directory and execute the initialization installation command
./mysqld –initialize –user=mysql –datadir=/usr/local/mysql5.7/data –basedir=/usr/local/mysql5.7
**Pay attention to these two installation paths, datadir is to set the data storage directory of the mysql database, and basedir is to set the installation directory of mysql.
And record the temporary password given in the last line

9: Modify the specified environment variable path; vim /usr/local/mysql5.7/support-files/mysql.server
10: Make a soft link to the startup file Execute the following command:
ln -s /usr/local/mysql5.7/support-files/mysql.server /etc/init.d/mysql
Check whether the execution is successful
ll /etc/init.d/mysql
11: Create a soft connection to the bin directory
ln -s /usr/local/mysql5.7/bin/mysql /usr/local/bin/mysql
Check whether the creation check is successful
ll /usr/local/bin/mysql
12: Create my.cnf file Execute command: vim /etc/my.cnf

[mysql]

Set the default character set of mysql client

default-character-set=utf8
[mysqld]

The role is to prohibit domain name resolution: the host name cannot be used in the mysql authorization table, only IP

skip-name-resolve

Set port 3306

port = 3306
#Set remote access ip
bind-address=0.0.0.0

Set the installation directory of mysql

basedir=/usr/local/mysql5.7

Set the data storage directory of the mysql database

datadir=/usr/local/mysql5.7/data

Maximum number of connections allowed

max_connections=200

The character set used by the server defaults to the 8-bit encoded latin1 character set

character-set-server=utf8

The default storage engine that will be used when creating new tables

default-storage-engine=INNODB
#Set query operations, etc. to be case-insensitive
lower_case_table_names=1

13: Set file permissions chmod -R 775 /etc/my.cnf

14: Set boot self-start chkconfig –add mysql
15: Check whether chkconfig –list is enabled
16: Log in to mysql mysql -u root -p
17: Set the password of the root user
set password for root@localhost = password(‘icomi.cn’)
18: Authorize other machines to log in remotely
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘icomi.cn’ WITH GRANT OPTION;
19: Refresh permissions
FLUSH PRIVILEGES;
20: exit mysql input: quit;
21: Add port number 3306 to the firewall and reload the firewall
firewall-cmd –zone=public –add-port=3306/tcp –permanent
firewall-cmd –reload