summaryrefslogtreecommitdiffstats
path: root/Readme/ReadMe.md
blob: 77834fc85d75521bd809736b0d2ed14c7d4734f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# PART 1. agl-app-warehouse Environmental Construction Manual

[TOC]

## 1. Basic Environment

### 1.1 Hardware

* cpu ---------------- 3.30GHz or more
* Memory---------- 4Gbytes or more
* HDD--------------- 100Mbytes or more

### 1.2 Software

* Centos7.2
* JDK 1.8
* apache-tomcat-8
* Redis
* MySQL 5.7.22

*The IP address used in this environment construction is "192.168.200.107"[^1].

[^1]: The IP address in this manual is replaced by "$IP", so please rewrite it to the IP address which used  in the actual environment construction.



## 2. JDK

### 2.1 Installation

```shell
# yum install java-1.8.0-openjdk
```

### 2.2 Configuration

#### 2.2.1 Environmental Variables Configuration

```shell
# echo "export JAVA_HOME=$(readlink -e $(which java)|sed 's:/bin/java::')" > /etc/profile.d/java.sh
```

```shell
# echo "PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile.d/java.sh
```

```shell
# source /etc/profile.d/java.sh
```

### 2.3 Confirmation

```shell
# java -version
  OpenJDK version "1.8.0_171"
  OpenJDK Runtime Environment (build 1.8.0_171-b10)
  OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)
```



## 3. Tomcat

### 3.1 Installation

#### 3.1.1 New User

```shell
# useradd -s /sbin/nologin tomcat
```

#### 3.1.2 Download

```shell
# mkdir -p /usr/local/src/tomcat
```

```shell
# cd /usr/local/src/tomcat/
```

```shell
# wget http://ftp.riken.jp/net/apache/tomcat/tomcat-8/v8.5.31/bin/apache-tomcat-8.5.31.tar.gz
```

#### 3.1.3 "tar.gz" Deployment

```shell
# tar zxvf apache-tomcat-8.5.31.tar.gz
```

```shell
# mv apache-tomcat-8.5.31 /opt/
```

```shell
# chown -R tomcat. /opt/apache-tomcat-8.5.31
```

```shell
# ln -s /opt/apache-tomcat-8.5.31 /opt/tomcat
```

### 3.2 Configuration

#### 3.2.1 Environmental Variables Configuration

```shell
# echo 'export CATALINA_HOME=/opt/tomcat' > /etc/profile.d/tomcat.sh
```

```shell
# source /etc/profile.d/tomcat.sh
```

#### 3.2.2 Tomcat User Configuration

```shell
# vi /opt/tomcat/conf/tomcat-users.xml
```

Add the following contents in "tomcat-users.xml":

```xml
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
```

```shell
# vi /opt/tomcat/webapps/manager/META-INF/context.xml
```

Remove "< value >... < / value > "

#### 3.2.3 Service Definition File

Create "/etc/systemd/system/tomcat.service" and store it as follows:

Modify the permission of the created definition file to 755.

```shell
# vi /etc/systemd/system/tomcat.service
```

```shell
# chmod 755 /etc/systemd/system/tomcat.service
```

File contents :

```
[Unit]
Description=Apache Tomcat 8
After=syslog.target network.target

[Service]
User=tomcat
Group=tomcat
Type=oneshot
PIDFile=/opt/tomcat/tomcat.pid
RemainAfterExit=yes

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
ExecReStart=/opt/tomcat/bin/shutdown.sh;/opt/tomcat/bin/startup.sh

[Install]
WantedBy=multi-user.target
```

#### 3.2.4 Auto Start

Auto start when the server starts.

```shell
# systemctl enable tomcat
```

#### 3.2.5 Set of Firewalld

Create '/etc/firewalld/services/tomcat.xml ' and write it as follows:

```shell
# vi /etc/firewalld/services/tomcat.xml
```

```shell
# firewall-cmd --add-service=tomcat --permanent
```

```shell
# firewall-cmd reload
```

File contents:

```xml
<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Apache Tomcat 8</short>
  <description>Apache Tomcat 8</description>
  <port protocol="tcp" port="8080"/>
</service>
```

### 3.3 Launch

```shell
# systemctl start tomcat
```

### 3.4 Confirmation

Access to 'http://$IP:8080/'



## 4. Redis

### 4.1 Installation

```shell
# yum -y install epel-release
```

```shell
# yum install -y redis
```

### 4.2 Configuration

#### 4.2.1 "redis.conf" File Modification

```shell
# vi /etc/redis.conf
```

Before:

```
bind 127.0.0.1
#requirepass foobared
```

After:

```
#bind 127.0.0.1
requirepass appmarket
```

#### 4.2.2 Auto Start

Auto start  when the server starts.

```shell
# systemctl enable redis.service
```

#### 4.2.3  Set of Firewalld

```shell
# firewall-cmd --add-port=6379/tcp --permanent
```

```shell
# firewall-cmd reload
```

### 4.3 Launch

```shell
# systemctl start redis.service
```

### 4.4 Confirmation

```shell
# redis-cli -a appmarket
  redis 127.0.0.1:6379> ping
  PONG
```



## 5. MySql

### 5.1 Installation

#### 5.1.1 Preparation

```shell
# yum remove mariadb-libs.x86_64
```

```shell
# rm -rf /var/lib/mysql
```

#### 5.1.2 Installation

```shell
# yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
```

```shell
# yum -y install mysql-community-server
```

#### 5.1.3 Correct Installation Confirmation

```shell
# mysqld --version
  mysqld Ver 5.7.22 for Linux on x86_64 (MySQL Community Server (GPL))
```

### 5.2 Configuration

#### 5.2.1 MySQL User Configuration

##### 5.2.1.1 User Configuration

Get the password generated from the record file and use it when executing the "mysql_secure_installation "command.

```shell
# systemctl start mysqld
# cat /var/log/mysqld.log | grep root
  xxxx[Note] A temporary password is generated for root@localhost: uhsd!Aid;3Zt
```

mysql_secure_installation Command is being executed:

```
NOTE:+E23:K42 RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current	password for the root user. If you've just installed MySQL, and	you haven't set the root password yet, the password will be blank,so you should just press enter here.
Enter current password for root (enter for none):uhsd!Aid;3Zt
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation.
Set root password? [Y/n] y
New password: 123456
Re-enter new password: 123456
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone	to log into MySQL without having to have a user account created for	them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
Remove anonymous users? [Y/n] y
… Success!
Normally, root should only be allowed to connect from 'localhost'. This	ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
… Success!
By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? [Y/n] n
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far	will take effect immediately.
Reload privilege tables now? [Y/n] y
… Success!
Cleaning up…
All done! If you've completed all of the above steps, your MySQL installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#
```

##### 5.2.1.2  Add User Permissions

```shell
# mysql -u root -p
  Enter password:123456
```

```shell
mysql> grant all privileges on *.* to root@'%'identified by '123456';
```

#### 5.2.2 Modification of "/etc/my.cnf "

```shell
# vi /etc/my.cnf
```

Add the following contents in my "my.cnf file":

```
[mysqld]
character_set_server = utf8
```

#### 5.2.3 Auto Start

```shell
# systemctl enable mysqld.service
```

#### 5.2.4 Set of Firewalld

```shell
# firewall-cmd --permanent --zone=public --add-port=3306/tcp
```

```shell
# firewall-cmd --permanent --zone=public --add-port=3306/udp
```

```shell
# firewall-cmd --reload
```

### 5.3 Launch

```shell
# systemctl start mysqld.service
```

### 5.4 Confirmation

```shell
# mysql -u root -p
Enter password:123456
```

```shell
mysql> use mysql;
Database changed
```

```
mysql> select host,user from user;
+--------------+------+
| host         | user |
+--------------+------+
| localhost    | root |
| 192.168.1.1 | root |
| %             | root |
+--------------+------+
```



## 6. AglAppWarehouse

Copy the war-file("warehouse.war" and "webservice.war" ) into the "/opt/tomcat/webapps" directory.

### 6.1 Server Construction

#### 6.1.1 Server Configuration

##### 6.1.1.1 Redis Information Settings

```shell
# vi /opt/tomcat/webapps/webservice/WEB-INF/classes/redis.properties
```

Modify the file "redis.properties" as follows :

```
redis.host=192.168.200.107
redis.port=6379
redis.password=appmarket
```

##### 6.1.1.2  App File Saving Path Settings

```shell
# mkdir -p -m 777 /data/appmarket/log/web
```

```shell
# mkdir -p -m 777 /data/appmarket/log/webservice
```

```shell
# vi /opt/tomcat/webapps/webservice/WEB-INF/classes/fileManager.properties
```

Modify the file "fileManager.properties" as follows :

```
upload_path=/data/appmarket/filesystem/
upload_path_checked=/data/appmarket/filesystem/
```

##### 6.1.1.3 Mybatis Info Settings

```shell
# vi /opt/tomcat/webapps/webservice/WEB-INF/classes/spring-mybatis.xml
```

Modify the file "spring-mybatis.xml" as follows :

```xml
<property name="url" value="jdbc:mysql://192.168.200.107:3306/appmarket……/>
```

##### 6.1.1.4 Log Info Saving Path Settings

```shell
# vi /opt/tomcat/webapps/webservice/WEB-INF/classes/properties.properties
```

Modify the webservice file "properties.properties" as follows :

```
log_ws_common_default=/data/appmarket/log/webservice/common-default.log
log_ws_console_default=/data/appmarket/log/webservice/console-default.log
log_ws_common_error=/data/appmarket/log/webservice/common-error.log
log_ws_logistics_component=/data/appmarket/log/webservice/logistics-component.log
```

```shell
# vi /opt/tomcat/webapps/warehouse/WEB-INF/classes/config/properties.properties
```

Modify the warehouse file "properties.properties" as follows :

```
log_ws_common_default=/data/appmarket/log/web/common-default.log
log_ws_console_default=/data/appmarket/log/web/console-default.log
log_ws_common_error=/data/appmarket/log/web/common-error.log
log_ws_logistics_component=/data/appmarket/log/web/logistics-component.log
```

##### 6.1.1.5  Tomcat Server Configuration

```shell
# vi /opt/tomcat/conf/server.xml
```

Modify the webservice file "server.xml" as follows :

```xml
<Context debug="0" docBase="/data/appmarket/filesystem" path="resource" reloadable="false"/>
```

#### 6.1.2  Database Configuration

```shell
# mysql -u root -p
Enter password:123456
```

```shell
mysql> source /data/ftp/pub/db_data/appmarket.sql;
```

### 6.2 Launch

```shell
# systemctl start tomcat
```

### 6.3  Set of Port

```shell
# firewall-cmd --add-masquerade
```

```shell
# firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
```

### 6.4 Confirmation

Access to "http://$IP:8080/warehouse/"



# PART 2. Code Compilation Manual

## 1. Base Environment

* eclipse  :Neon.2 Release (4.6.2)
* apache-tomcat-8.0
* JDK 1.8

## 2. New Project

### 2.1 Create a Root Maven Project

![project_start](img/new_maven_project_start.PNG)

![maven_project](img/new_maven_project.PNG)

![maven_project2](img/new_maven_project2.PNG)

### 2.2  Create Maven Modules

There are six maven modules.

1. appmarket-core
2. appmarket-model
3. appmarket-persistence
4. appmarket-utils
5. warehouse
6. webservice

![maven_model_start](img/maven_model_start.PNG)

Input the module name by maven modules.
![avatar](img/new_maven_model.PNG)

Selecting an archetype by maven modules( 1,2,3,4 choose ① , 5,6 choose ②)

![avatar](img/new_maven_model2.PNG)

![avatar](img/new_maven_model3.PNG)

### 2.3  Replace Files

Replace  the workspace project files of eclipse with the files in the source code.



## 3. Code Compilation

### 3.1 Import Maven Projects

![maven_import](img/maven_import.PNG)

![maven_import1](img/maven_import1.PNG)

![maven_import2](img/maven_import2.PNG)

### 3.2 Update Project

![maven_update](img/maven_update.PNG)

## 4. War Export

### 4.1 Export

Export "warehouse.war "and "webservice.war".

Right click on the project name(warehouse)

![create_war1](img/create_war1.PNG)



Select the save Path of war file

![create_war2](img/create_war2.PNG)