Guest cow Java project_ Discussion area of imitation cattle customer network_ What to do to run the Niuke discussion area project

What to do to run the Niuke discussion area project

1. IDEA import project
2. Open MySQL and SQLyog databases
3. Open Redis: double click Redis server exe

F:\Crazy God said Redis Software\Redis-x64-3.2.100(Windows Version)

redis-cli.exe can also be opened by double clicking to view the data in Redis library [11] at any time.

127.0.0.1:6379> select 11
OK
127.0.0.1:6379[11]>

4. Open Kafka
Start zookeeper first:

F:\Kafka\kafka_2.13-2.7.0\bin\windows>zookeeper-server-start.bat ..\..\config\zookeeper.properties

If the startup is successful, it will display:

[2021-04-14 08:31:02,245] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxnFactory)

Restart Kafka (second command line window):

F:\Kafka\kafka_2.13-2.7.0\bin\windows>kafka-server-start.bat ..\..\config\server.properties

If the log reports an error, delete F: \ kafka \ data \ kafka logs and restart kafka.
If the startup is successful, it will display:

[2021-04-14 08:32:46,162] INFO [GroupCoordinator 0]: Loading group metadata for community-consumer-group with generation 16 (kafka.coordinator.group.GroupCoordinator)
[2021-04-14 08:32:46,162] INFO [GroupMetadataManager brokerId=0] Finished loading offsets and group metadata from __consumer_offsets-28 in 259 milliseconds, of which 190 milliseconds was spent in the scheduler. (kafka.coordinator.group.GroupMetadataManager)

5. Start Elasticsearch: double click Elasticsearch bat

F:\Madness theory ElasticSearch Software\elasticsearch-7.12.0-windows-x86_64\elasticsearch-7.12.0\bin

Start Head (graphical interface of ES):

F:\Madness theory ElasticSearch Software\elasticsearch-head-master\elasticsearch-head-master>npm run start

If the startup is successful, it will display:

Started connect web server on http://localhost:9100

Website to be used
1,http://127.0.0.1:9200/ : if a web page is displayed, ElasticSearch is successfully installed and running.
2,elasticsearch-head http://127.0.0.1:9100/ : graphical interface plug-in client of ES, whose name is Head. It is equivalent to the graphical interface of relational database. You can view the indexes, documents and fields of ES.

6. Click the debug button in the IDEA, and the output will be successful:

. . . . 
2021-05-13 22:43:06,605 INFO [org.springframework.kafka.KafkaListenerEndpointContainer#3-0-C-1] o.a.k.c.c.i.ConsumerCoordinator [ConsumerCoordinator.java:815] [Consumer clientId=consumer-community-consumer-group-2, groupId=community-consumer-group] Setting offset for partition follow-0 to the committed offset FetchPosition{offset=0, offsetEpoch=Optional.empty, currentLeader=LeaderAndEpoch{leader=Optional[DESKTOP-4OG2TJ0:9092 (id: 0 rack: null)], epoch=0}}
2021-05-13 22:43:06,606 INFO [org.springframework.kafka.KafkaListenerEndpointContainer#1-0-C-1] o.s.k.l.KafkaMessageListenerContainer [LogAccessor.java:292] community-consumer-group: partitions assigned: [delete-0]
2021-05-13 22:43:06,612 INFO [org.springframework.kafka.KafkaListenerEndpointContainer#2-0-C-1] o.s.k.l.KafkaMessageListenerContainer [LogAccessor.java:292] community-consumer-group: partitions assigned: [share-0]
2021-05-13 22:43:06,612 INFO [org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] o.s.k.l.KafkaMessageListenerContainer [LogAccessor.java:292] community-consumer-group: partitions assigned: [publish-0]
2021-05-13 22:43:06,612 INFO [org.springframework.kafka.KafkaListenerEndpointContainer#3-0-C-1] o.s.k.l.KafkaMessageListenerContainer [LogAccessor.java:292] community-consumer-group: partitions assigned: [comment-0, like-0, follow-0]
2021-05-13 22:43:07,137 INFO [RMI TCP Connection(2)-192.168.184.1] o.a.c.c.C.[.[.[/community] [DirectJDKLog.java:173] Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-05-13 22:43:07,138 INFO [RMI TCP Connection(2)-192.168.184.1] o.s.w.s.DispatcherServlet [FrameworkServlet.java:525] Initializing Servlet 'dispatcherServlet'
2021-05-13 22:43:07,139 INFO [RMI TCP Connection(2)-192.168.184.1] o.s.w.s.DispatcherServlet [FrameworkServlet.java:547] Completed initialization in 1 ms

Deploy the project from Windows to Linux

1. Modify project code

IDEA project 8.3 modification
1. Remove / community

# global.js
var CONTEXT_PATH = "/community";	# Windows
var CONTEXT_PATH = "";				# Linux

2. The switch is application Properties, only spring. Com is required for modification profiles. Active = develop / produce.

# profile
spring.profiles.active=develop	# Windows
spring.profiles.active=produce	# Linux

2. Delete target file


Problems encountered in deleting target files and solutions: IDEA: maven packing tips [ERROR] The specified user settings file does not exist_ Xiaobai a - CSDN blog

3,shutdown.sh close tomcat and delete all files in / www/server/tomcat/webapps directory. ps -ef | grep elasticsearch check whether ES is enabled. If not, restart es.

When restarting es, you need to do the following steps:

1. First use ps -ef | grep elasticsearch to see if there are running es processes. If there are, use kill PID to kill es processes.

2. Deleted the data directory of / tmp/elastic/data.

3. Don't forget to switch to a non root user.

[root@wu1 tmp]# su - nowcoder1
[nowcoder1@wu1 ~]$ /opt/elasticsearch-7.12.0/bin/elasticsearch -d	# Background start es
[nowcoder1@wu1 ~]$ su -
Password: 
[root@wu1 ~]# curl -X GET "localhost:9200/_cat/health?v"	# Test es for successful startup
epoch      timestamp cluster  status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1619627359 16:29:19  nowcoder green           1         1      0   0    0    0        0             0                  -                100.0%

4. Package the project into a zip package and upload it to the root directory of the Linux server. Compile and package the project with maven, put it in / www/server/tomcat/webapps directory, and then start up SH start tomcat. Then check the log of tomcat / www / server / tomcat / logs / Catalina 2021-05-16. Whether the log is started successfully.

[root@wu1 ~]# unzip -d /root community.zip	# -d followed by which directory to put.
[root@wu1 ~]# cd community
[root@wu1 community]# mvn clean package -Dmaven.test.skip=true	# Compile and package the project with maven, and skip the test, because the test class written in front of us is not standard, and the last test is the standard test. It takes a long time.
[root@wu1 community]# cd target	# Go to the / root/community/target directory
[root@wu1 target]# ll	# See root War file
[root@wu1 target]# mv ROOT.war /www/server/tomcat/webapps/
[root@wu1 target]# startup.sh		# Start tomcat. Although the message was returned immediately, it actually started after a while
Using CATALINA_BASE:   /www/server/tomcat
Using CATALINA_HOME:   /www/server/tomcat
Using CATALINA_TMPDIR: /www/server/tomcat/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_281-amd64
Using CLASSPATH:       /www/server/tomcat/bin/bootstrap.jar:/www/server/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@wu1 target]# vim /www/server/tomcat/logs/catalina.2021-05-16.log	# Check the log of tomcat to see if it is started successfully.

Change the items that can run on Linux to run on Windows

1. Modify project code

IDEA project 8.3 modification
1. Add / community

# global.js
var CONTEXT_PATH = "/community";	# Windows
var CONTEXT_PATH = "";				# Linux

2. The switch is application When modifying. Spring properties, you only need to profiles. Active = develop / produce.

# profile
spring.profiles.active=develop	# Windows
spring.profiles.active=produce	# Linux

Location of project log under Linux

journalcatalogue
Tomcat log/www/server/tomcat/logs/catalina.2021-05-16.log
Project Log/tmp/community
ElasticSearch log/tmp/elastic/logs
Kafka log/tmp/kafka-logs

Keywords: Linux

Added by jpr on Wed, 09 Feb 2022 14:09:11 +0200