8.21-部署eleme项目

news2024/12/26 2:12:01

1.设置主从从mysql57服务器

(1)配置主数据库

  [root@msater_5 ~]# systemctl stop firewalld
  [root@msater_5 ~]# setenforce 0
  [root@msater_5 ~]# systemctl disable firewalld
  Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
  Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  [root@msater_5 ~]# ls
  anaconda-ks.cfg  mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
  [root@msater_5 ~]# tar -xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz 
  [root@msater_5 ~]# ls
  anaconda-ks.cfg                      mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
  mysql-5.7.44-linux-glibc2.12-x86_64
  [root@msater_5 ~]# cp -r mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql
  [root@msater_5 ~]# rm -rf /etc/my.cnf
  [root@msater_5 ~]# mkdir /usr/local/mysql/mysql-files
  [root@msater_5 ~]# useradd -r -s /sbin/nologin mysql
  [root@msater_5 ~]# chown mysql:mysql /usr/local/mysql/mysql-files/
  [root@msater_5 ~]# chown 750 /usr/local/mysql/mysql-files/
  [root@msater_5 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql
  2024-08-21T09:39:14.991434Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2024-08-21T09:39:15.126969Z 0 [Warning] InnoDB: New log files created, LSN=45790
  2024-08-21T09:39:15.150963Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  2024-08-21T09:39:15.214887Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3ac52ccc-5fa1-11ef-98a1-000c29374e2c.
  2024-08-21T09:39:15.215926Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2024-08-21T09:39:16.034519Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
  2024-08-21T09:39:16.034537Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
  2024-08-21T09:39:16.036321Z 0 [Warning] CA certificate ca.pem is self signed.
  2024-08-21T09:39:16.384066Z 1 [Note] A temporary password is generated for root@localhost: RV3DtuxCi;A-
  [root@msater_5 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql57
  [root@msater_5 ~]# vim /usr/local/mysql/my.cnf
  ​
  [mysqld]
  basedir=/usr/local/mysql
  datadir=/usr/local/mysql/data
  socket=/tmp/mysql.sock
  port=3306
  log-error=/usr/local/mysql/data/db01-master.err
  log-bin=/usr/local/mysql/data/binlog
  server-id=10
  character_set_server=utf8mb4
  ​
  ​
  [root@msater_5 ~]# service mysql57 start
  Starting MySQL.Logging to '/usr/local/mysql/data/db01-master.err'.
   SUCCESS! 
  ​
  [root@msater_5 ~]# /usr/local/mysql/bin/mysql -p
  Enter password: 
  ​
  mysql> alter user 'root'@'localhost' identified by 'root';
  Query OK, 0 rows affected (0.00 sec)
  ​
  mysql> create user 'zzz'@'%' identified by 'zzz';
  Query OK, 0 rows affected (0.00 sec)
  ​
  mysql> grant all on *.* to 'zzz'@'%';
  Query OK, 0 rows affected (0.01 sec)
  ​
  ​
  mysql> flush privileges;
  Query OK, 0 rows affected (0.01 sec)
  ​
  mysql> create user 'slave'@'%' identified by 'slave';
  Query OK, 0 rows affected (0.00 sec)
  ​
  mysql> grant replication slave on *.* to 'slave'@'%';
  Query OK, 0 rows affected (0.00 sec)
  ​
  mysql> flush privileges;
  Query OK, 0 rows affected (0.00 sec)
  ​

(2)配置slave01数据库

  
  [root@slave01_5 ~]# ls
  anaconda-ks.cfg  mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
  [root@slave01_5 ~]# systemctl stop firewalld
  [root@slave01_5 ~]# systemctl disable firewalld
  Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
  Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  [root@slave01_5 ~]# setenforce 0
  [root@slave01_5 ~]# tar -xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz 
  [root@slave01_5 ~]# cp -r mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql
  [root@slave01_5 ~]# rm -rf /etc/my.cnf
  [root@slave01_5 ~]# mkdir /usr/local/mysql/mysql-files
  [root@slave01_5 ~]# useradd -r -s /sbin/nologin mysql
  [root@slave01_5 ~]# chown mysql:mysql /usr/local/mysql/mysql-files/
  [root@slave01_5 ~]# chown 750 /usr/local/mysql/mysql-files/
  [root@slave01_5 ~]# yum -y install rsync

(3)配置slave02数据库

  
  [root@slave02_5 ~]# ls
  anaconda-ks.cfg  mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
  [root@slave02_5 ~]# scp mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz 192.168.2.57:/root
  The authenticity of host '192.168.2.57 (192.168.2.57)' can't be established.
  ECDSA key fingerprint is SHA256:E2ARFFif/HyOpjlCgDRoPqYSl2OL4PwdcX1h9cPRJiY.
  ECDSA key fingerprint is MD5:35:b0:cd:3b:e0:fa:10:4a:22:5e:94:aa:b7:5c:e2:79.
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added '192.168.2.57' (ECDSA) to the list of known hosts.
  root@192.168.2.57's password: 
  mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz          100%  663MB  85.5MB/s   00:07    
  [root@slave02_5 ~]# scp mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz 192.168.2.58:/root
  The authenticity of host '192.168.2.58 (192.168.2.58)' can't be established.
  ECDSA key fingerprint is SHA256:E2ARFFif/HyOpjlCgDRoPqYSl2OL4PwdcX1h9cPRJiY.
  ECDSA key fingerprint is MD5:35:b0:cd:3b:e0:fa:10:4a:22:5e:94:aa:b7:5c:e2:79.
  Are you sure you want to continue connecting (yes/no)? yes
  Warning: Permanently added '192.168.2.58' (ECDSA) to the list of known hosts.
  root@192.168.2.58's password: 
  mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz          100%  663MB  83.1MB/s   00:07    
  [root@slave02_5 ~]# systemctl stop firewalld
  [root@slave02_5 ~]# systemctl disable firewalld
  ​
  [root@slave02_5 ~]# setenforce 0
  [root@slave02_5 ~]# tar -xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz 
  [root@slave02_5 ~]# cp -r mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql
  [root@slave02_5 ~]# rm -rf /etc/my.cnf
  [root@slave02_5 ~]# mkdir /usr/local/mysql/mysql-files
  [root@slave02_5 ~]# useradd -r -s /sbin/nologin mysql
  [root@slave02_5 ~]# chown mysql:mysql /usr/local/mysql/mysql-files/
  [root@slave02_5 ~]# chown 750 /usr/local/mysql/mysql-files/
  [root@slave02_5 ~]# yum -y install rsync
  ​

(4)同步data

  
  [root@msater_5 ~]# service mysql57 stop
  Shutting down MySQL.... SUCCESS! 
  [root@msater_5 ~]# rm -rf /usr/local/mysql/data/auto.cnf
  [root@msater_5 ~]# yum -y install rsync
  ​
  [root@msater_5 ~]# rsync -av /usr/local/mysql/data root@192.168.2.58:/usr/local/mysql/
  ​
  [root@msater_5 ~]# rsync -av /usr/local/mysql/data root@192.168.2.59:/usr/local/mysql/

(5)修改slave01配置文件

  
  [root@slave01_5 ~]# ls /usr/local/mysql/
  bin   docs     lib      man          README  support-files
  data  include  LICENSE  mysql-files  share
  [root@slave01_5 ~]# vim /usr/local/mysql/my.cnf
  ​
  [mysqld]
  basedir=/usr/local/mysql
  datadir=/usr/local/mysql/data
  socket=/tmp/mysql.sock
  port=3306
  log-error=/usr/local/mysql/data/err.log
  relay-log=/usr/local/mysql/data/relaylog
  character_set_server=utf8mb4
  server-id=11
  ​
  [root@slave01_5 ~]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql57
  [root@slave01_5 ~]# sed -i '$aexport PATH=$PATH:/usr/local/mysql/bin' /etc/profile
  [root@slave01_5 ~]# source /etc/profile
  ​

(6)修改slave02配置文件

  
  [root@slave02_5 ~]# ls /usr/local/mysql
  bin   docs     lib      man          README  support-files
  data  include  LICENSE  mysql-files  share
  [root@slave02_5 ~]# vim /usr/local/mysql/my.cnf
  ​
  [mysqld]
  basedir=/usr/local/mysql
  datadir=/usr/local/mysql/data
  socket=/tmp/mysql.sock
  port=3306
  log-error=/usr/local/mysql/data/err.log
  relay-log=/usr/local/mysql/data/relaylog
  character_set_server=utf8mb4
  server-id=12
   
  [root@slave02_5 ~]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql57
  [root@slave02_5 ~]# sed -i '$aexport PATH=$PATH:/usr/local/mysql/bin' /etc/profile
  [root@slave02_5 ~]# source /etc/profile
  ​

(7)主服务器锁表

  
  [root@msater_5 ~]# mysql -proot
  mysql: [Warning] Using a password on the command line interface can be insecure.
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 3
  Server version: 5.7.44-log MySQL Community Server (GPL)
  ​
  Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  ​
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  ​
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  ​
  mysql> select user,host from mysql.user;
  +---------------+-----------+
  | user          | host      |
  +---------------+-----------+
  | slave         | %         |
  | zzz           | %         |
  | mysql.session | localhost |
  | mysql.sys     | localhost |
  | root          | localhost |
  +---------------+-----------+
  5 rows in set (0.00 sec)
  ​
  mysql> flush tables with read lock;
  Query OK, 0 rows affected (0.00 sec)
  ​
  mysql> show master status;
  +---------------+----------+--------------+------------------+-------------------+
  | File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  +---------------+----------+--------------+------------------+-------------------+
  | binlog.000002 |      154 |              |                  |                   |
  +---------------+----------+--------------+------------------+-------------------+
  1 row in set (0.00 sec)

(8)配置主从服务

  
  [root@slave01_5 ~]# mysql -uroot -proot
  mysql: [Warning] Using a password on the command line interface can be insecure.
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 2
  Server version: 5.7.44 MySQL Community Server (GPL)
  ​
  Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  ​
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  ​
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  ​
  mysql>  change master to master_host="192.168.2.57",master_user="slave",master_password="slave",master_log_file="binlog.000002",master_log_pos=154;
  Query OK, 0 rows affected, 2 warnings (0.01 sec)
  ​
  mysql> start slave;
  Query OK, 0 rows affected (0.01 sec)
  ​
  mysql> show slave status\G;
  *************************** 1. row ***************************
                 Slave_IO_State: Waiting for master to send event
                    Master_Host: 192.168.2.57
                    Master_User: slave
                    Master_Port: 3306
                  Connect_Retry: 60
                Master_Log_File: binlog.000002
            Read_Master_Log_Pos: 154
                 Relay_Log_File: relaylog.000002
                  Relay_Log_Pos: 317
          Relay_Master_Log_File: binlog.000002
               Slave_IO_Running: Yes
              Slave_SQL_Running: Yes
  ​

(9)配置主从从服务

  
  [root@slave02_5 ~]# mysql -proot
  ​
  mysql> change master to master_host="192.168.2.57",master_user="slave",master_password="slave",master_log_file="binlog.000002",master_log_pos=154;
  Query OK, 0 rows affected, 2 warnings (0.01 sec)
  ​
  mysql> start slave;
  Query OK, 0 rows affected (0.01 sec)
  ​
  mysql> show slave status\G;
  *************************** 1. row ***************************
                 Slave_IO_State: Waiting for master to send event
                    Master_Host: 192.168.2.57
                    Master_User: slave
                    Master_Port: 3306
                  Connect_Retry: 60
                Master_Log_File: binlog.000002
            Read_Master_Log_Pos: 154
                 Relay_Log_File: relaylog.000002
                  Relay_Log_Pos: 317
          Relay_Master_Log_File: binlog.000002
               Slave_IO_Running: Yes
              Slave_SQL_Running: Yes
  ​

2.在mysql中添加eleme数据库设置为utf8mb4

  
  [root@msater_5 ~]# mysql -proot
  ​
  mysql> unlock tables;
  Query OK, 0 rows affected (0.00 sec)
  ​
  mysql> create database if not exists eleme charset utf8mb4;
  Query OK, 1 row affected (0.00 sec)
  ​
  mysql> show databases;
  +--------------------+
  | Database           |
  +--------------------+
  | information_schema |
  | eleme              |
  | mysql              |
  | performance_schema |
  | sys                |
  | test               |
  +--------------------+
  6 rows in set (0.00 sec)

3.添加表t_user(master)

  
  mysql> use eleme;
  Database changed
  ​
  mysql> create table t_user(
      -> id int primary key auto_increment,
      -> name varchar(45) not null,
      -> username varchar(45) not null,
      -> password varchar(45) not null,
      -> remark varchar(45)
      -> );
  Query OK, 0 rows affected (0.01 sec)
  ​
  mysql> show tables;
  +-----------------+
  | Tables_in_eleme |
  +-----------------+
  | t_user          |
  +-----------------+
  1 row in set (0.00 sec)

4.添加2行记录(master)

  
  mysql> insert into t_user (id,name,username,password,remark)values(1,"超级管理员","adm"in","admin","超级管理员");
  Query OK, 1 row affected (0.01 sec)
  ​
  mysql> insert into t_user (id,name,username,password,remark)values(2,"普通用户","guest,","guest","普通用户");
  Query OK, 1 row affected (0.00 sec)
  ​
  mysql> select * from t_user;
  +----+-----------------+----------+----------+-----------------+
  | id | name            | username | password | remark          |
  +----+-----------------+----------+----------+-----------------+
  |  1 | 超级管理员      | admin    | admin    | 超级管理员      |
  |  2 | 普通用户        | guest    | guest    | 普通用户        |
  +----+-----------------+----------+----------+-----------------+
  2 rows in set (0.00 sec)
  ​

5.远程登录工具查看表数据:

6.使用mycat为三台数据库设置负载均衡(读写分离)

(1)前期环境部署

  
  [root@mycat ~]# ls
  anaconda-ks.cfg             Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
  jdk-8u192-linux-x64.tar.gz
  [root@mycat ~]# tar -xf jdk-8u192-linux-x64.tar.gz 
  [root@mycat ~]# tar -xf Mycat-server-1.6.5-release-20180122220033-linux.tar.gz 
  [root@mycat ~]# cp -r jdk1.8.0_192/ /usr/local/jdk
  [root@mycat ~]# cp -r mycat/ /usr/local/mycat
  [root@mycat ~]# sed -i '$aexport JAVA_HOME=/usr/local/jdk' /etc/profile
  [root@mycat ~]# source /etc/profile
  [root@mycat ~]# sed -i '$aexport PATH=$PATH:$JAVA_HOME/bin' /etc/profile
  [root@mycat ~]# source /etc/profile
  [root@mycat ~]# javac -version
  javac 1.8.0_192
  [root@mycat ~]#  /usr/local/mycat/bin/mycat console

(2)修改server.xml配置文件

  
  [root@mycat ~]# vim /usr/local/mycat/conf/server.xml
  ​
   93         <user name="haha" defaultAccount="true">
   94                 <property name="password">haha</property>
   95                 <property name="schemas">eleme</property>
  ​
  # 注释
  ​
  107 <!--
  108         <user name="user">
  109                 <property name="password">user</property>
  110                 <property name="schemas">TESTDB</property>
  111                 <property name="readOnly">true</property>
  112         </user>
  113 -->
  ​

(3)修改schema.xml 配置文件

1.设置schema标签 添加dataNode="xxx" name=eleme

2.修改dataHost标签

  
   [root@mycat ~]# vim /usr/local/mycat/conf/schema.xml 
   
    1 <?xml version="1.0"?>
    2 <!DOCTYPE mycat:schema SYSTEM "schema.dtd">
    3 <mycat:schema xmlns:mycat="http://io.mycat/">
    4 
    5         <schema name="eleme" dataNode="dn1" checkSQLschema="false" sqlMaxLimit="10    0"> 
    6         </schema>
    7         <!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
    8                 /> -->
    9         <dataNode name="dn1" dataHost="localhost1" database="eleme" />
   10 <!--    <dataNode name="dn2" dataHost="localhost1" database="db2" />
   11         <dataNode name="dn3" dataHost="localhost1" database="db3" />-->
   12         <!--<dataNode name="dn4" dataHost="sequoiadb1" database="SAMPLE" />
   13          <dataNode name="jdbc_dn1" dataHost="jdbchost" database="db1" />
   14         <dataNode       name="jdbc_dn2" dataHost="jdbchost" database="db2" />
   15         <dataNode name="jdbc_dn3"       dataHost="jdbchost" database="db3" /> -->
   16         <dataHost name="localhost1" maxCon="1000" minCon="10" balance="0" 17                           writeType="0" dbType="mysql" dbDriver="native" switchTyp    e="1"  slaveThreshold="100">
   18                 <heartbeat>select user()</heartbeat>
   19                 <!-- can have multi write hosts -->
   20                 <writeHost host="hostM1" url="192.168.2.57:3306" user="haha"
   21                                    password="haha">
   22                         <!-- can have multi read hosts --> 23                         <readHost host="hostS2" url="192.168.2.58:3306" user="haha    " password="haha" /> 24                         <readHost host="hostS3" url="192.168.2.59:3306" user="haha    " password="haha" />
   25                 </writeHost>
   26 <!--
   27                 <writeHost host="hostS1" url="localhost:3316" user="root"
   28                                    password="123456" />
   29 -->          30                 <!-- <writeHost host="hostM2" url="localhost:3316" user="root" pas    sword="123456"/> -->
   31         </dataHost>
  ​

(4)启动服务

  
  [root@mycat ~]# /usr/local/mycat/bin/mycat start
  Starting Mycat-server...
  [root@mycat ~]# netstat -lntup | grep 8066
  tcp6       0      0 :::8066                 :::*                    LISTEN      1916/j

7.客户端测试mycat

  
  [root@client ~]# cd /usr/local/mysql/bin
  [root@client bin]# ./mysql -h192.168.2.19 -P8066 -uhaha -phaha
  mysql: [Warning] Using a password on the command line interface can be insecure.
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 83
  Server version: 5.6.29-mycat-1.6.5-release-20180122220033 MyCat Server (OpenCloundDB)
  ​
  Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  ​
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  ​
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  ​
  mysql> show databases;
  +----------+
  | DATABASE |
  +----------+
  | eleme    |
  +----------+
  1 row in set (0.01 sec)
  ​
  mysql> use eleme;
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  ​
  Database changed
  mysql> show tables;
  +-----------------+
  | Tables_in_eleme |
  +-----------------+
  | t_user          |
  +-----------------+
  1 row in set (0.01 sec)
  ​
  mysql> select * from t_user;
  +----+-----------------+----------+----------+-----------------+
  | id | name            | username | password | remark          |
  +----+-----------------+----------+----------+-----------------+
  |  1 | 超级管理员      | admin    | admin    | 超级管理员      |
  |  2 | 普通用户        | guest    | guest    | 普通用户        |
  +----+-----------------+----------+----------+-----------------+
  2 rows in set (0.01 sec)
  ​
  mysql> 
  ​

8.部署java17环境

(1)java01

  
  [root@java01 ~]# ls
  anaconda-ks.cfg  jdk-17_linux-x64_bin.tar.gz 
  [root@java01 ~]# tar -xf jdk-17_linux-x64_bin.tar.gz 
  [root@java01 ~]# ls
  anaconda-ks.cfg  jdk-17.0.12  jdk-17_linux-x64_bin.tar.gz 
  [root@java01 ~]# cp -r jdk-17.0.12/ /usr/local/jdk
  [root@java01 ~]# vim /etc/profile
  export JAVA_HOME=/usr/local/jdk
  export PATH=$PATH:$JAVA_HOME/bin
  [root@java01 ~]# source /etc/profile
  ​
  [root@java01 ~]# javac --version
  javac 17.0.12
  ​
  [root@java01 ~]# firewall-cmd --add-port=8080/tcp --permanent
  success
  [root@java01 ~]# firewall-cmd --reload
  success
  ​
  [root@java01 ~]# ls
  anaconda-ks.cfg  application_(1).yml  eleme_server-0.0.1-SNAPSHOT.jar  jdk-17.0.12  jdk-17_linux-x64_bin.tar.gz
  ​
  [root@java01 ~]# mv application_\(1\).yml application.yml 
  [root@java01 ~]# ls
  anaconda-ks.cfg  application.yml  eleme_server-0.0.1-SNAPSHOT.jar  jdk-17.0.12  jdk-17_linux-x64_bin.tar.gz
  ​
  ​
  [root@java01 ~]# vim application.yml 
  ​
  server:
    port: 8080
  spring:
    datasource:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://192.168.2.19:8066/eleme
      username: haha
      password: haha
  ​
  [root@java01 ~]# java -jar eleme_server-0.0.1-SNAPSHOT.jar 
  ​

(2)浏览器访问:192.168.2.11:8080

(3)java02

  
  [root@java02 ~]# ls
  anaconda-ks.cfg  eleme_server-0.0.1-SNAPSHOT.jar  jdk-17_linux-x64_bin.tar.gz
  application.yml  
  ​
  [root@java02 ~]# tar -xf jdk-17_linux-x64_bin.tar.gz 
  ​
  [root@java02 ~]# cp -r jdk-17.0.12/ /usr/local/jdk
  [root@java02 ~]# vim /etc/profile
  [root@java02 ~]# source /etc/profile
  [root@java02 ~]# javac -version
  javac 17.0.12
  ​
  [root@java02 ~]# vim application.yml 
  ​
  server:
    port: 8080
  spring:
    datasource:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://192.168.2.19:8066/eleme
      username: haha
      password: haha
  ​
  [root@java02 ~]# java -jar eleme_server-0.0.1-SNAPSHOT.jar 
  ​

(4)浏览器访问:192.168.2.12:8080

9.部署LVS-DR模式

(1)lvs

  
  [root@lvs ~]# ifconfig ens33:0 192.168.2.150 broadcast 192.168.2.121 netmask 255.255.255.255 up
  [root@lvs ~]# route add -host 192.168.2.150 dev ens33:0
  [root@lvs ~]# yum -y install ipvsadm
  [root@lvs ~]# ipvsadm -C
  [root@lvs ~]# ipvsadm -A -t 192.168.2.150:8080 -s rr
  [root@lvs ~]# ipvsadm -a -t 192.168.2.150:8080 -r 192.168.2.11 -g
  [root@lvs ~]# ipvsadm -a -t 192.168.2.150:8080 -r 192.168.2.12 -g
  [root@lvs ~]# systemctl stop firewalld
  [root@lvs ~]# systemctl disable firewalld
  Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
  Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  [root@lvs ~]# setenforce 0
  [root@lvs ~]# systemctl stop firewalld
  [root@lvs ~]# ipvsadm -Ln
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
  TCP  192.168.2.150:8080 rr
    -> 192.168.2.11:8080            Route   1      0          1         
    -> 192.168.2.12:8080            Route   1      0          1         

(2)java01

  
  [root@java01 ~]# ifconfig lo:0 192.168.2.150 broadcast 192.168.2.150 netmask 255.255.255.255 up
  [root@java01 ~]# route add -host 192.168.2.150 dev lo:0
  [root@java01 ~]# vim arp.sh
  [root@java01 ~]# source arp.sh
  ​

(3)java02

  
  [root@java02 ~]# ifconfig lo:0 192.168.2.150 broadcast 192.168.2.150 netmask 255.255.255.255 up
  [root@java02 ~]# route add -host 192.168.2.150 dev lo:0
  [root@java02 ~]# vim arp.sh
  [root@java02 ~]# source arp.sh
  ​

(4)浏览器访问:192.168.2.150:8080(外网地址)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2072764.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

# 利刃出鞘_Tomcat 核心原理解析(八)-- Tomcat 集群

利刃出鞘_Tomcat 核心原理解析&#xff08;八&#xff09;-- Tomcat 集群 一、Tomcat专题 - Tomcat集群 - 介绍及准备工作 1、Tomcat集群 简介 由于单台Tomcat的承载能力是有限的&#xff0c;当我们的业务系统用户量比较大&#xff0c;请求压力比较大时&#xff0c;单台Tomc…

i.MX6裸机开发(8):中断

相比STM32的NVIC&#xff0c;i.MX 6ULL的中断控制系统更复杂&#xff0c;它的中断管理器使用的是GIC V2&#xff0c;GIC V2的实现方式与我们熟知的NVIC差别较大。 本章重点讲解i.MX 6U的GIC基本结构以及实现方法&#xff0c;更详细的介绍可以参考《ARM Generic Interrupt Contr…

快速学习初阶“堆“(数据结构C语言)

前言&#xff1a; 二叉树是什么&#xff1f; 同样也和之前的"栈"跟"队列"是一样的&#xff0c;是一种存储数据的方式&#xff0c;只不过二叉树的结构更为复杂。 那么为什么要用二叉树存储数据呢&#xff1f;真的多此一举吗&#xff1f; 它的实际作用是什么…

买对不买贵,宠物空气净化器应该怎么选才能选到好的产品

你是否还在为家中无处不在的猫毛而烦恼&#xff1f;每当有风吹来&#xff0c;就把四处躲藏的猫毛给吹出来&#xff0c;不经意间就可能让这些”蒲公英“悄悄附在你的食物上&#xff0c;或是不经意间吸入鼻腔&#xff0c;让人既无奈又尴尬。你是否每天下班回家后的第一件事&#…

AnyV2V:一种用于各种视频编辑任务的即插即用框架

人工智能咨询培训老师叶梓 转载标明出处 视频编辑任务通常涉及根据额外的控制信息&#xff08;如文本提示、主题、风格等&#xff09;编辑源视频&#xff0c;以生成与源视频和提供的控制信息相符的新视频。然而&#xff0c;现有方法往往局限于特定类型的编辑任务&#xff0c;难…

面向对象06:super关键字详解

本节内容视频链接&#xff1a;面向对象10&#xff1a;Super详解_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV12J41137hu?p69&vd_sourceb5775c3a4ea16a5306db9c7c1c1486b5 Java中的‌super关键字是一个特殊的引用&#xff0c;‌用于指代父类对象‌。‌在子…

搜维尔科技:Xsens通过其先进的动作捕捉技术和惯性跟踪传感器,实现了与机器人的高效互动,提高了机器人的操作精度、自然性和稳定性

‌Xsens通过实时动作捕捉技术和MTI惯性跟踪传感器与机器人进行互动‌&#xff0c;这些技术为机器人提供了高精度的运动数据和稳定的导航能力&#xff0c;从而实现了机器人操作的精确性和效率的提升。 Xsens的技术主要应用于两大领域&#xff1a;人类物理交互行为的建模和分析&a…

如何使用ssm实现基于java的小型超市管理系统+vue

TOC ssm195基于java的小型超市管理系统vue 绪论 1.1 研究背景 现在大家正处于互联网加的时代&#xff0c;这个时代它就是一个信息内容无比丰富&#xff0c;信息处理与管理变得越加高效的网络化的时代&#xff0c;这个时代让大家的生活不仅变得更加地便利化&#xff0c;也让…

Git 的配置

1. 忽略特殊文件 在⽇常开发中&#xff0c;我们有些⽂件不想或者不应该提交到远端&#xff0c;⽐如保存了数据库密码的配置⽂件&#xff0c;那怎么让 Git 知道呢&#xff1f;在 Git ⼯作区的根⽬录下创建⼀个特殊的 .gitignore ⽂件&#xff0c;然后把要忽略的⽂件名填进去&am…

【中仕公考怎么样】2025年山东各考试汇总

准备同时备考山东多项考试的考生看过来啦!本篇文章带大家了解一下2025年山东省各项考试时间节点! ①国考 公告发布:2024年10月14日(参考去年) 笔试时间:11月下旬 笔试内容:行测申论&#xff0c;部分有专业科目;面试形式:结构化 ②省考 公告发布:2024年11月 笔试时间:202…

Unet改进8:在不同位置添加SpatialGroupEnhance||空间群智能增强:改进卷积网络中的语义特征学习

本文内容:在不同位置添加SpatialGroupEnhance 论文简介 卷积神经网络(Convolutional Neural Networks, cnn)通过收集分层的、不同部分的语义子特征来生成复杂对象的特征表示。这些子特征通常以分组的形式分布在每一层的特征向量中[43,32],代表各种语义实体。然而,这些子特征…

python --cnlunar(黄历)

import datetime import cnlunara cnlunar.Lunar(datetime.datetime(2024, 8, 26, 10, 30), godType8char) # 常规算法 # a cnlunar.Lunar(datetime.datetime(2022, 2, 3, 10, 30), godType8char, year8CharbeginningOfSpring) # 八字立春切换算法 dic {日期: a.date,农历…

如何使用ssm实现毕业生就业管理平台

TOC ssm192毕业生就业管理平台jsp 绪论 1.1 研究背景 当前社会各行业领域竞争压力非常大&#xff0c;随着当前时代的信息化&#xff0c;科学化发展&#xff0c;让社会各行业领域都争相使用新的信息技术&#xff0c;对行业内的各种相关数据进行科学化&#xff0c;规范化管理…

如何使用ssm实现保险业务管理系统设计与实现

TOC ssm131保险业务管理系统设计与实现jsp 绪论 1.1 研究背景 当前社会各行业领域竞争压力非常大&#xff0c;随着当前时代的信息化&#xff0c;科学化发展&#xff0c;让社会各行业领域都争相使用新的信息技术&#xff0c;对行业内的各种相关数据进行科学化&#xff0c;规…

Pytorch构建网络模型结构都有哪些方式

目录 前言 1.使用nn.Module基类 2.使用nn.Sequential容器 3. 使用nn.ModuleList 4. 使用nn.ModuleDict 5. 混合使用nn.Module和原生Python代码 6.表格总结 前言 nn.Module&#xff1a;最通用、最灵活的方式&#xff0c;适用于几乎所有场景。nn.Sequential&#xff1a;适…

基于Springboot/Vue的企业内部培训考试系统

本系统不开源&#xff01; 本系统不开源&#xff01; 本系统不开源&#xff01; 前言&#xff1a; 时间宝贵的朋友直接跳过这段进入主题吧。 首先&#xff0c;好久没有静心写点东西了&#xff0c;有些经验之谈、生活经历以及一些规划和感悟吧&#xff0c;大体写一下就当自我…

Linux下编译安装PETSc

本文记录在Linux编译安装PETSc的流程。 1 下载代码 git clone https://gitlab.com/petsc/petsc.git cd ./petsc git checkout v3.21.4 2 安装依赖 3 PETSc Without MPI 3.1 Debug版本 3.1.1 配置 export PETSC_ARCHarch-linux-c-debug-dto python3 ./configure --prefix/…

水凝胶与柔性电子啥关系?能用来干啥?

大家好&#xff0c;今天我们来聊一聊一篇关于水凝胶在柔性电子领域应用的文章——《Smart materials for flexible electronics and devices: hydrogel》发表于《RSC Advances》。随着科技的不断发展&#xff0c;柔性电子设备越来越受到关注&#xff0c;而水凝胶作为一种具有独…

python-小理和01串(赛氪OJ)

[题目描述] 小理有一个 01 串&#xff0c;串中只包含 0 和 1 &#xff0c;小理要把这个串划分成连续的 m 段&#xff0c;使得每一段至少包含一个 0 和一个 1 。小理想最大化 m &#xff0c;m 最大是多少呢&#xff1f;输入格式&#xff1a; 输入包含一行一个 01 串 S 。保证中至…

OpenCV绘图函数详解及其用法示例

MFC类库中的CDC类有划线,画矩形,画椭圆,画多边形,文字等绘图函数,OpenCV也有类似的绘图函数。二者的区别在于MFC画图是在一定的区域内绘制图形,而OpenCV则是在图像上绘制,主要用于图像标注。 OpenCV的常用绘图函数有arrowedLine,circle ,drawContours, drawMarker, dra…