Showing posts with label Centos 7. Show all posts
Showing posts with label Centos 7. Show all posts

Tuesday, December 6, 2016

Centos/RHEL/OEL 7'de GCC 6.2 Kurulumu

GNU derleyicilerinin en güncel sürümü GCC 6.2 ile aşağıdaki dillerde yazılan uygulamalar derlenebilir:
  • C
  • C++
  • Objective-C
  • Objective-C++
  • Java
  • Fortran
  • Ada
  • Go
Centos/RHEL/OEL 7 işletim sistemi için GCC 6.2'nin kurulumu için aşağıdaki adımları izlemeniz gerekir:

[guru@localhost ext]$ sudo yum -y install gmp-devel mpfr-devel libmpc-devel glibc-devel.i686 libgcc.i686 gcc-c++
Loaded plugins: fastestmirror, langpacks
base                                                                      | 3.6 kB  00:00:00     
extras                                                                    | 3.4 kB  00:00:00     
updates                                                                   | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.radoreservers.com
 * extras: mirror.radoreservers.com
 * updates: mirror.radoreservers.com
Package gcc-c++-4.8.5-4.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package glibc-devel.i686 0:2.17-106.el7_2.8 will be installed
--> Processing Dependency: glibc-headers = 2.17-106.el7_2.8 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: glibc = 2.17-106.el7_2.8 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libutil.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libthread_db.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: librt.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libresolv.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_nisplus.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_nis.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_hesiod.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_files.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_dns.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_db.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnss_compat.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libnsl.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libm.so.6 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libdl.so.2 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libcrypt.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libcidn.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libanl.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
--> Processing Dependency: libBrokenLocale.so.1 for package: glibc-devel-2.17-106.el7_2.8.i686
---> Package gmp-devel.x86_64 1:6.0.0-12.el7_1 will be installed
--> Processing Dependency: gmp = 1:6.0.0-12.el7_1 for package: 1:gmp-devel-6.0.0-12.el7_1.x86_64
---> Package libgcc.i686 0:4.8.5-4.el7 will be installed
---> Package libmpc-devel.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr-devel.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc.x86_64 0:2.17-105.el7 will be updated
--> Processing Dependency: glibc = 2.17-105.el7 for package: glibc-devel-2.17-105.el7.x86_64
--> Processing Dependency: glibc = 2.17-105.el7 for package: glibc-common-2.17-105.el7.x86_64
---> Package glibc.i686 0:2.17-106.el7_2.8 will be installed
--> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.17-106.el7_2.8.i686
--> Processing Dependency: libfreebl3.so for package: glibc-2.17-106.el7_2.8.i686
---> Package glibc.x86_64 0:2.17-106.el7_2.8 will be an update
---> Package glibc-headers.x86_64 0:2.17-105.el7 will be updated
---> Package glibc-headers.x86_64 0:2.17-106.el7_2.8 will be an update
---> Package gmp.x86_64 1:6.0.0-11.el7 will be updated
---> Package gmp.x86_64 1:6.0.0-12.el7_1 will be an update
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-105.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-106.el7_2.8 will be an update
---> Package glibc-devel.x86_64 0:2.17-105.el7 will be updated
---> Package glibc-devel.x86_64 0:2.17-106.el7_2.8 will be an update
---> Package nss-softokn-freebl.x86_64 0:3.16.2.3-13.el7_1 will be updated
---> Package nss-softokn-freebl.i686 0:3.16.2.3-14.2.el7_2 will be installed
---> Package nss-softokn-freebl.x86_64 0:3.16.2.3-14.2.el7_2 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
 Package                     Arch            Version                      Repository        Size
=================================================================================================
Installing:
 glibc-devel                 i686            2.17-106.el7_2.8             updates          1.0 M
 gmp-devel                   x86_64          1:6.0.0-12.el7_1             updates          181 k
 libgcc                      i686            4.8.5-4.el7                  base             103 k
 libmpc-devel                x86_64          1.0.1-3.el7                  base              32 k
 mpfr-devel                  x86_64          3.1.1-4.el7                  base              68 k
Installing for dependencies:
 glibc                       i686            2.17-106.el7_2.8             updates          4.2 M
 nss-softokn-freebl          i686            3.16.2.3-14.2.el7_2          updates          187 k
Updating for dependencies:
 glibc                       x86_64          2.17-106.el7_2.8             updates          3.6 M
 glibc-common                x86_64          2.17-106.el7_2.8             updates           11 M
 glibc-devel                 x86_64          2.17-106.el7_2.8             updates          1.0 M
 glibc-headers               x86_64          2.17-106.el7_2.8             updates          663 k
 gmp                         x86_64          1:6.0.0-12.el7_1             updates          280 k
 nss-softokn-freebl          x86_64          3.16.2.3-14.2.el7_2          updates          204 k

Transaction Summary
=================================================================================================
Install  5 Packages (+2 Dependent packages)
Upgrade             ( 6 Dependent packages)

Total size: 23 M
Total download size: 5.8 M
Downloading packages:
(1/7): libmpc-devel-1.0.1-3.el7.x86_64.rpm                                |  32 kB  00:00:00     
(2/7): libgcc-4.8.5-4.el7.i686.rpm                                        | 103 kB  00:00:00     
(3/7): mpfr-devel-3.1.1-4.el7.x86_64.rpm                                  |  68 kB  00:00:00     
(4/7): glibc-devel-2.17-106.el7_2.8.i686.rpm                              | 1.0 MB  00:00:00     
(5/7): gmp-devel-6.0.0-12.el7_1.x86_64.rpm                                | 181 kB  00:00:00     
(6/7): nss-softokn-freebl-3.16.2.3-14.2.el7_2.i686.rpm                    | 187 kB  00:00:00     
(7/7): glibc-2.17-106.el7_2.8.i686.rpm                                    | 4.2 MB  00:00:01     
-------------------------------------------------------------------------------------------------
Total                                                            4.8 MB/s | 5.8 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libgcc-4.8.5-4.el7.i686                                                                                                                   1/19 
  Updating   : nss-softokn-freebl-3.16.2.3-14.2.el7_2.x86_64                                                                                             2/19 
  Updating   : glibc-common-2.17-106.el7_2.8.x86_64                                                                                                      3/19 
  Updating   : glibc-2.17-106.el7_2.8.x86_64                                                                                                             4/19 
  Updating   : glibc-headers-2.17-106.el7_2.8.x86_64                                                                                                     5/19 
  Installing : nss-softokn-freebl-3.16.2.3-14.2.el7_2.i686                                                                                               6/19 
  Installing : glibc-2.17-106.el7_2.8.i686                                                                                                               7/19 
  Updating   : 1:gmp-6.0.0-12.el7_1.x86_64                                                                                                               8/19 
  Installing : 1:gmp-devel-6.0.0-12.el7_1.x86_64                                                                                                         9/19 
  Installing : mpfr-devel-3.1.1-4.el7.x86_64                                                                                                            10/19 
  Installing : libmpc-devel-1.0.1-3.el7.x86_64                                                                                                          11/19 
  Installing : glibc-devel-2.17-106.el7_2.8.i686                                                                                                        12/19 
  Updating   : glibc-devel-2.17-106.el7_2.8.x86_64                                                                                                      13/19 
  Cleanup    : glibc-devel-2.17-105.el7.x86_64                                                                                                          14/19 
  Cleanup    : glibc-headers-2.17-105.el7.x86_64                                                                                                        15/19 
  Cleanup    : 1:gmp-6.0.0-11.el7.x86_64                                                                                                                16/19 
  Cleanup    : glibc-common-2.17-105.el7.x86_64                                                                                                         17/19 
  Cleanup    : nss-softokn-freebl-3.16.2.3-13.el7_1.x86_64                                                                                              18/19 
  Cleanup    : glibc-2.17-105.el7.x86_64                                                                                                                19/19 
  Verifying  : 1:gmp-6.0.0-12.el7_1.x86_64                                                                                                               1/19 
  Verifying  : libgcc-4.8.5-4.el7.i686                                                                                                                   2/19 
  Verifying  : glibc-2.17-106.el7_2.8.i686                                                                                                               3/19 
  Verifying  : nss-softokn-freebl-3.16.2.3-14.2.el7_2.i686                                                                                               4/19 
  Verifying  : glibc-devel-2.17-106.el7_2.8.i686                                                                                                         5/19 
  Verifying  : 1:gmp-devel-6.0.0-12.el7_1.x86_64                                                                                                         6/19 
  Verifying  : libmpc-devel-1.0.1-3.el7.x86_64                                                                                                           7/19 
  Verifying  : nss-softokn-freebl-3.16.2.3-14.2.el7_2.x86_64                                                                                             8/19 
  Verifying  : glibc-devel-2.17-106.el7_2.8.x86_64                                                                                                       9/19 
  Verifying  : glibc-headers-2.17-106.el7_2.8.x86_64                                                                                                    10/19 
  Verifying  : glibc-common-2.17-106.el7_2.8.x86_64                                                                                                     11/19 
  Verifying  : glibc-2.17-106.el7_2.8.x86_64                                                                                                            12/19 
  Verifying  : mpfr-devel-3.1.1-4.el7.x86_64                                                                                                            13/19 
  Verifying  : glibc-devel-2.17-105.el7.x86_64                                                                                                          14/19 
  Verifying  : glibc-headers-2.17-105.el7.x86_64                                                                                                        15/19 
  Verifying  : nss-softokn-freebl-3.16.2.3-13.el7_1.x86_64                                                                                              16/19 
  Verifying  : glibc-common-2.17-105.el7.x86_64                                                                                                         17/19 
  Verifying  : glibc-2.17-105.el7.x86_64                                                                                                                18/19 
  Verifying  : 1:gmp-6.0.0-11.el7.x86_64                                                                                                                19/19 

Installed:
  glibc-devel.i686 0:2.17-106.el7_2.8       gmp-devel.x86_64 1:6.0.0-12.el7_1       libgcc.i686 0:4.8.5-4.el7       libmpc-devel.x86_64 0:1.0.1-3.el7      
  mpfr-devel.x86_64 0:3.1.1-4.el7          

Dependency Installed:
  glibc.i686 0:2.17-106.el7_2.8                                         nss-softokn-freebl.i686 0:3.16.2.3-14.2.el7_2                                        

Dependency Updated:
  glibc.x86_64 0:2.17-106.el7_2.8                   glibc-common.x86_64 0:2.17-106.el7_2.8           glibc-devel.x86_64 0:2.17-106.el7_2.8                    
  glibc-headers.x86_64 0:2.17-106.el7_2.8           gmp.x86_64 1:6.0.0-12.el7_1                      nss-softokn-freebl.x86_64 0:3.16.2.3-14.2.el7_2          

Complete!

Şimdi GCC 6.2'nin kaynak kodunu makinamıza indiriyoruz:

[guru@localhost ext]$ sudo wget https://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.gz
--2016-12-02 08:48:23--  https://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.gz
Resolving ftp.gnu.org (ftp.gnu.org)... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 128569126 (123M) [application/x-gzip]
Saving to: ‘gcc-6.2.0.tar.gz’

100%[====================================================================================================================>] 128,569,126 1.15MB/s   in 1m 42s 

2016-12-02 08:50:05 (1.20 MB/s) - ‘gcc-6.2.0.tar.gz’ saved [128569126/128569126]

[guru@localhost ext]$ 

build için bir dizin oluşturup Makefile oluşturmak üzere configure komutunu çalıştırıyoruz:

[guru@localhost ext]$ sudo tar -xzf gcc-6.2.0.tar.gz 
[guru@localhost ext]$ sudo mkdir build
[guru@localhost ext]$ ls
build  gcc-6.2.0  gcc-6.2.0.tar.gz  lost+found
[guru@localhost ext]$ cd build/
[guru@localhost build]$ sudo ../gcc-6.2.0/configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libcilkrts support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libmpx support... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... yes
checking for isl 0.16, 0.15, or deprecated 0.14... no
recommended isl version is 0.16 or 0.15, the minimum required isl version 0.14 is deprecated
checking for isl 0.16 or 0.15... no
The following languages will be built: c,c++,fortran,java,lto,objc
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libgo target-liboffloadmic
    (Any other directories should still work fine.)
checking for default BUILD_CONFIG... bootstrap-debug
checking for --enable-vtable-verify... no
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... no
/ext/gcc-6.2.0/missing: line 81: makeinfo: command not found
checking for expect... no
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gcj... no
checking for gfortran... gfortran
checking for gccgo... no
checking for ar... no
checking for ar... ar
checking for as... no
checking for as... as
checking for dlltool... no
checking for dlltool... no
checking for ld... no
checking for ld... ld
checking for lipo... no
checking for lipo... no
checking for nm... no
checking for nm... nm
checking for objcopy... no
checking for objcopy... objcopy
checking for objdump... no
checking for objdump... objdump
checking for ranlib... no
checking for ranlib... ranlib
checking for readelf... no
checking for readelf... readelf
checking for strip... no
checking for strip... strip
checking for windres... no
checking for windres... no
checking for windmc... no
checking for windmc... no
checking where to find the target ar... host tool
checking where to find the target as... host tool
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... host tool
checking where to find the target gcc... just compiled
checking where to find the target gcj... just compiled
checking where to find the target gfortran... just compiled
checking where to find the target gccgo... host tool
checking where to find the target ld... host tool
checking where to find the target lipo... host tool
checking where to find the target nm... host tool
checking where to find the target objcopy... host tool
checking where to find the target objdump... host tool
checking where to find the target ranlib... host tool
checking where to find the target readelf... host tool
checking where to find the target strip... host tool
checking where to find the target windres... host tool
checking where to find the target windmc... host tool
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile

Artık make komutu ile build işlemini başlatabiliriz:

[root@localhost build]# sudo make

Build işlemi bittikten sonra nihayet kurulumu gerçekleştirebiliriz:

[root@localhost build]# sudo make install
make[1]: Entering directory `/ext/build'
/bin/sh ../gcc-6.2.0/mkinstalldirs /usr/local /usr/local
make[2]: Entering directory `/ext/build/fixincludes'
rm -rf /usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.2.0/install-tools
/bin/sh ../../gcc-6.2.0/fixincludes/../mkinstalldirs /usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.2.0/install-tools
mkdir -p -- /usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.2.0/install-tools
/bin/sh ../../gcc-6.2.0/fixincludes/../mkinstalldirs /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.2.0/install-tools/include
mkdir -p -- /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.2.0/install-tools/include
/bin/install -c -m 644 ../../gcc-6.2.0/fixincludes/README-fixinc \

Kurulum sonrasında g++ derleyecisinin sürümünü kontrol edebiliriz:

[guru@localhost Desktop]$ g++ --version
g++ (GCC) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Son olarak GNU kütüphanelerinin sembolik linklerini yeni kütüphaneye bağlamamız gerekir:

sudo cp /ext/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so /lib64/
sudo rm /lib64/libstdc++.so.6
sudo ln -s /lib64/libstdc++.so /lib64/libstdc++.so.6

Saturday, July 23, 2016

Spring Boot Uygulamalarının RHEL 7'de systemd Servisi Olarak Eklenmesi

Spring Boot, Spring tabanlı web uygulaması geliştirmeyi kolaylaştıran özellikleri ile son dönemde tercih edilen kurumsal uygulama geliştirme yaklaşımıdır.
Java Tools and Technologies Landscape 2016
Spring boot uygulamalarının dağıtımını jar ya da war olarak yapabilirsiniz. jar olarak yayına çıktığınızda herhangi bir uygulama sunucusuna ihtiyaç duymadan, sadece Java Sanal Makinasını kullanarak çalıştırabilirsiniz. jar olarak çıkmak için maven projesinin pom.xml dosyasında packaging tanımını jar olarak vermeniz gerekir:
<packaging>jar</packaging>
Bu jar dosyasının çalıştırılabilir bir jar dosyası olması için pom.xml'de spring-boot maven eklentisinde basit bir tanımlama yapmanız gerekir:
<build>
   <plugins>
      . . . .
      <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
         <configuration>
            <executable>true</executable>
         </configuration>
      </plugin>
      . . .
   </plugins>
</build>
 Ardından aşağıdaki maven komutunu projenin kök dizininde çalıştırmalısınız:
[guru@server1 hr-boot]$ mvn clean install spring-boot:repackage
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building hr-boot-rest-jpa 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hr ---
[INFO] Deleting /home/guru/hr-boot/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hr ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hr ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 12 source files to /home/guru/hr-boot/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hr ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/guru/hr-boot/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hr ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ hr ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ hr ---
[INFO] Building jar: /home/guru/hr-boot/target/hr-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.3.6.RELEASE:repackage (default) @ hr ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ hr ---
[INFO] Installing /home/guru/hr-boot/target/hr-0.0.1-SNAPSHOT.jar to /home/guru/.m2/repository/com/example/hr/0.0.1-SNAPSHOT/hr-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/guru/hr-boot/pom.xml to /home/guru/.m2/repository/com/example/hr/0.0.1-SNAPSHOT/hr-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.3.6.RELEASE:repackage (default-cli) @ hr ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.497 s
[INFO] Finished at: 2016-07-23T09:09:38+03:00
[INFO] Final Memory: 30M/174M
[INFO] ------------------------------------------------------------------------ 
target dizininin yeniden oluşturulduğunu ve içeriğine göz attığınızda ise jar dosyasını göreceksiniz:
[guru@server1 hr-boot]$ cd target
[guru@server1 target]$ ls -lh
total 27M
drwxrwxr-x 3 guru guru  72 Jul 23 09:26 classes
drwxrwxr-x 3 guru guru  24 Jul 23 09:26 generated-sources
-rw-rw-r-- 1 guru guru 27M Jul 23 09:26 hr-0.0.1-SNAPSHOT.jar
-rw-rw-r-- 1 guru guru 14K Jul 23 09:26 hr-0.0.1-SNAPSHOT.jar.original
drwxrwxr-x 2 guru guru  27 Jul 23 09:26 maven-archiver
drwxrwxr-x 3 guru guru  34 Jul 23 09:26 maven-status
war olarak çıkmak için ise maven projesinin pom.xml dosyasında packaging tanımını war olarak vermeniz gerekir:
<packaging>war</packaging>
Çalıştırdığımız komutta bir değişiklik yapmıyoruz:
[guru@server1 hr-boot]$ mvn clean install spring-boot:repackage
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building hr-boot-rest-jpa 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hr ---
[INFO] Deleting /home/guru/hr-boot/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hr ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hr ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 12 source files to /home/guru/hr-boot/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hr ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/guru/hr-boot/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hr ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ hr ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.5:war (default-war) @ hr ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hr] in [/home/guru/hr-boot/target/hr-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [151 msecs]
[INFO] Building war: /home/guru/hr-boot/target/hr-0.0.1-SNAPSHOT.war
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.3.6.RELEASE:repackage (default) @ hr ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ hr ---
[INFO] Installing /home/guru/hr-boot/target/hr-0.0.1-SNAPSHOT.war to /home/guru/.m2/repository/com/example/hr/0.0.1-SNAPSHOT/hr-0.0.1-SNAPSHOT.war
[INFO] Installing /home/guru/hr-boot/pom.xml to /home/guru/.m2/repository/com/example/hr/0.0.1-SNAPSHOT/hr-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.3.6.RELEASE:repackage (default-cli) @ hr ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.809 s
[INFO] Finished at: 2016-07-23T09:14:35+03:00
[INFO] Final Memory: 30M/175M
[INFO] ------------------------------------------------------------------------
target dizininin yeniden oluşturulduğunu ve içeriğine göz attığınızda ise war dosyasını göreceksiniz:
[guru@server1 target]$ ls -lh
total 50M
drwxrwxr-x 3 guru guru  72 Jul 23 09:14 classes
drwxrwxr-x 3 guru guru  24 Jul 23 09:14 generated-sources
drwxrwxr-x 4 guru guru  35 Jul 23 09:14 hr-0.0.1-SNAPSHOT
-rw-rw-r-- 1 guru guru 27M Jul 23 09:14 hr-0.0.1-SNAPSHOT.war
-rw-rw-r-- 1 guru guru 24M Jul 23 09:14 hr-0.0.1-SNAPSHOT.war.original
drwxrwxr-x 2 guru guru  27 Jul 23 09:14 maven-archiver
drwxrwxr-x 3 guru guru  34 Jul 23 09:14 maven-status
target dizinindeki  hr-0.0.1-SNAPSHOT.jar dosyasını /home/guru dizinine hr-app adıyla kopyalalım:
[guru@erver1 hr-boot]$ cd target/
[guru@server1 target]$ ls
classes  generated-sources  hr-0.0.1-SNAPSHOT.jar  hr-0.0.1-SNAPSHOT.jar.original  maven-archiver  maven-status
[guru@server1 target]$ cp hr-0.0.1-SNAPSHOT.jar /home/guru/hr-app
[guru@server1 target]$ ls -lh /home/guru/hr-app
-rwxrwxr-x 1 guru guru 27M Jul 23 16:34 /home/guru/hr-app
Bu dosyaya yakından baktığınızda aslında başlığında bir betiğin yer aldığını göreceksiniz:
[guru@server1 ~]$ head -240 hr-app
#!/bin/bash
#
#    .   ____          _            __ _ _
#   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
#  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
#   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
#    '  |____| .__|_| |_|_| |_\__, | / / / /
#   =========|_|==============|___/=/_/_/_/
#   :: Spring Boot Startup Script ::
#

### BEGIN INIT INFO
# Provides:          hr
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: hr-boot-rest-jpa
# Description:       HR Spring Boot Project
# chkconfig:         2345 99 01
### END INIT INFO

[[ -n "$DEBUG" ]] && set -x

# Initialize variables that cannot be provided by a .conf file
WORKING_DIR="$(pwd)"
# shellcheck disable=SC2153
[[ -n "$JARFILE" ]] && jarfile="$JARFILE"
[[ -n "$APP_NAME" ]] && identity="$APP_NAME"

# Follow symlinks to find the real jar and detect init.d script
cd "$(dirname "$0")" || exit 1
[[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
while [[ -L "$jarfile" ]]; do
  [[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile")
  jarfile=$(readlink "$jarfile")
  cd "$(dirname "$jarfile")" || exit 1
  jarfile=$(pwd)/$(basename "$jarfile")
done
jarfolder="$(dirname "$jarfile")"
cd "$WORKING_DIR" || exit 1
. . .
RHEL 7'de servislerin yönetimi için systemd hizmetini kullanıyoruz. Servisin tanımı ve diğer servislerle bağımlılığını /usr/lib/systemd/system dizininde service uzantılı bir dosyada tanımlıyoruz. Örneğimizde bu dosyaya hr-boot.service adını vereceğiz:
[Unit]
Description=hr-boot service
Wants=mysqld.service
After=network.target mysqld.service

[Service]
Type=simple
ExecStart=/home/guru/hr-app
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
Spring boot uygulamamız MySQL sunucusunu kullanıyor. Servisimizin çalışabilmesi için öncelikle MySQL sunucusunun başlatılması gerektiğini Wants ile tanımlıyoruz.
Şimdi önce servisi etkinleştireceğiz ve sonra servisi başlatabiliriz:
[guru@server1 hr-boot]$ sudo systemctl enable hr-boot
Created symlink from /etc/systemd/system/multi-user.target.wants/hr-boot.service to /usr/lib/systemd/system/hr-boot.service.
[guru@server1 hr-boot]$ sudo systemctl start hr-boot
[guru@server1 hr-boot]$ sudo systemctl status hr-boot
● hr-boot.service - hr-boot
   Loaded: loaded (/usr/lib/systemd/system/hr-boot.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2016-07-23 15:05:55 EEST; 1h 39min ago
 Main PID: 24437 (hr-app)
   CGroup: /system.slice/hr-boot.service
           ├─24437 /bin/bash /home/guru/hr-app
           └─24456 /usr/bin/java -jar /home/guru/hr-app

Jul 23 15:06:10 server1.example.com hr-app[24437]: 2016-07-23 15:06:10.939  INFO 24456 --- [           main] o.s.j.e.a.AnnotationMB...tartup
Jul 23 15:06:10 server1.example.com hr-app[24437]: 2016-07-23 15:06:10.959  INFO 24456 --- [           main] o.s.c.support.DefaultL...483647
Jul 23 15:06:10 server1.example.com hr-app[24437]: 2016-07-23 15:06:10.961  INFO 24456 --- [           main] o.s.m.s.b.SimpleBroker...ing...
Jul 23 15:06:10 server1.example.com hr-app[24437]: 2016-07-23 15:06:10.963  INFO 24456 --- [           main] o.s.m.s.b.SimpleBroker...ns]]]]
Jul 23 15:06:10 server1.example.com hr-app[24437]: 2016-07-23 15:06:10.965  INFO 24456 --- [           main] o.s.m.s.b.SimpleBroker...arted.
Jul 23 15:06:11 server1.example.com hr-app[24437]: 2016-07-23 15:06:11.115  INFO 24456 --- [           main] s.b.c.e.t.TomcatEmbedd...(http)
Jul 23 15:06:11 server1.example.com hr-app[24437]: 2016-07-23 15:06:11.124  INFO 24456 --- [           main] com.example.hr.HrBootA...5.437)
Jul 23 15:07:09 server1.example.com hr-app[24437]: 2016-07-23 15:07:09.445  INFO 24456 --- [MessageBroker-1] o.s.w.s.c.WebSocketMes...ECTED(
Jul 23 16:23:51 server1.example.com hr-app[24437]: 2016-07-23 16:23:51.487  INFO 24456 --- [MessageBroker-1] o.s.w.s.c.WebSocketMes...ECTED(
Jul 23 16:45:19 server1.example.com systemd[1]: Started hr-boot.
Hint: Some lines were ellipsized, use -l to show in full.
[guru@server1 hr-boot]$ sudo systemctl stop hr-boot
[guru@server1 hr-boot]$ sudo systemctl status hr-boot
● hr-boot.service - hr-boot
   Loaded: loaded (/usr/lib/systemd/system/hr-boot.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Sat 2016-07-23 16:45:52 EEST; 7s ago
 Main PID: 24437 (code=killed, signal=TERM)

Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.589  INFO 24456 --- [       Thread-3] o.s.m.s.b.SimpleBroker...ing...
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.589  INFO 24456 --- [       Thread-3] o.s.m.s.b.SimpleBroker...ns]]]]
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.590  INFO 24456 --- [       Thread-3] o.s.m.s.b.SimpleBroker...opped.
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.616  INFO 24456 --- [       Thread-3] o.s.j.e.a.AnnotationMB...utdown
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.621  INFO 24456 --- [       Thread-3] o.s.s.concurrent.Threa...cutor'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.625  INFO 24456 --- [       Thread-3] o.s.s.c.ThreadPoolTask...duler'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.626  INFO 24456 --- [       Thread-3] o.s.s.concurrent.Threa...cutor'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.626  INFO 24456 --- [       Thread-3] o.s.s.concurrent.Threa...cutor'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.627  INFO 24456 --- [       Thread-3] j.LocalContainerEntity...fault'
Jul 23 16:45:52 server1.example.com systemd[1]: Stopped hr-boot.
Hint: Some lines were ellipsized, use -l to show in full.
Eğer hr-boot servisini başlattığımızda mysqld servisi kapalı ise systemd önce mysqld servisini başlatacaktır:
[guru@server1 ~]$ sudo systemctl status mysqld
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: inactive (dead) since Sat 2016-07-23 16:53:30 EEST; 1min 25s ago
 Main PID: 12912 (code=exited, status=0/SUCCESS)
   Status: "MariaDB server is down"

Jul 23 11:10:16 server1.example.com mysqld[12912]: Version: '10.1.11-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Mar...Server
Jul 23 11:10:16 server1.example.com systemd[1]: Started MariaDB database server.
Jul 23 16:53:28 server1.example.com systemd[1]: Stopping MariaDB database server...
Jul 23 16:53:28 server1.example.com mysqld[12912]: 2016-07-23 16:53:28 140506222205696 [Note] /usr/sbin/mysqld: Normal shutdown
Jul 23 16:53:28 server1.example.com mysqld[12912]: 2016-07-23 16:53:28 140506222205696 [Note] Event Scheduler: Purging the queue. 0 events
Jul 23 16:53:28 server1.example.com mysqld[12912]: 2016-07-23 16:53:28 140505547527936 [Note] InnoDB: FTS optimize thread exiting.
Jul 23 16:53:28 server1.example.com mysqld[12912]: 2016-07-23 16:53:28 140506222205696 [Note] InnoDB: Starting shutdown...
Jul 23 16:53:30 server1.example.com mysqld[12912]: 2016-07-23 16:53:30 140506222205696 [Note] InnoDB: Shutdown completed; log seque...602918
Jul 23 16:53:30 server1.example.com mysqld[12912]: 2016-07-23 16:53:30 140506222205696 [Note] /usr/sbin/mysqld: Shutdown complete
Jul 23 16:53:30 server1.example.com systemd[1]: Stopped MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[guru@server1 ~]$ sudo systemctl status hr-boot
● hr-boot.service - hr-boot
   Loaded: loaded (/usr/lib/systemd/system/hr-boot.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Sat 2016-07-23 16:45:52 EEST; 9min ago
 Main PID: 24437 (code=killed, signal=TERM)

Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.589  INFO 24456 --- [       Thread-3] o.s.m.s.b.SimpleBroker...ing...
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.589  INFO 24456 --- [       Thread-3] o.s.m.s.b.SimpleBroker...ns]]]]
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.590  INFO 24456 --- [       Thread-3] o.s.m.s.b.SimpleBroker...opped.
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.616  INFO 24456 --- [       Thread-3] o.s.j.e.a.AnnotationMB...utdown
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.621  INFO 24456 --- [       Thread-3] o.s.s.concurrent.Threa...cutor'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.625  INFO 24456 --- [       Thread-3] o.s.s.c.ThreadPoolTask...duler'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.626  INFO 24456 --- [       Thread-3] o.s.s.concurrent.Threa...cutor'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.626  INFO 24456 --- [       Thread-3] o.s.s.concurrent.Threa...cutor'
Jul 23 16:45:51 server1.example.com hr-app[24437]: 2016-07-23 16:45:51.627  INFO 24456 --- [       Thread-3] j.LocalContainerEntity...fault'
Jul 23 16:45:52 server1.example.com systemd[1]: Stopped hr-boot.
Hint: Some lines were ellipsized, use -l to show in full.
[guru@server1 ~]$ sudo systemctl start hr-boot
[guru@server1 ~]$ sudo systemctl status mysqld
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Sat 2016-07-23 16:55:14 EEST; 3s ago
 Main PID: 27975 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─27975 /usr/sbin/mysqld

Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] InnoDB: Highest supported file format...acuda.
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] InnoDB: 128 rollback segment(s) are active.
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] InnoDB: Waiting for purge to start
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] InnoDB:  Percona XtraDB (http://www.p...602918
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] Plugin 'FEEDBACK' is disabled.
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140190882457344 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] Server socket created on IP: '::'.
Jul 23 16:55:14 server1.example.com mysqld[27975]: 2016-07-23 16:55:14 140191628089472 [Note] /usr/sbin/mysqld: ready for connections.
Jul 23 16:55:14 server1.example.com mysqld[27975]: Version: '10.1.11-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Mar...Server
Jul 23 16:55:14 server1.example.com systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[guru@server1 ~]$ sudo systemctl status hr-boot
● hr-boot.service - hr-boot
   Loaded: loaded (/usr/lib/systemd/system/hr-boot.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2016-07-23 16:55:13 EEST; 12s ago
 Main PID: 27976 (hr-app)
   CGroup: /system.slice/hr-boot.service
           ├─27976 /bin/bash /home/guru/hr-app
           └─27999 /usr/bin/java -jar /home/guru/hr-app

Jul 23 16:55:25 server1.example.com hr-app[27976]: 2016-07-23 16:55:25.899  INFO 27999 --- [           main] o.s.w.s.handler.Simple...ndler]
Jul 23 16:55:25 server1.example.com hr-app[27976]: 2016-07-23 16:55:25.970  INFO 27999 --- [           main] .m.m.a.ExceptionHandle...andler
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.039  INFO 27999 --- [           main] o.s.w.s.handler.Simple...ndler]
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.456  INFO 27999 --- [           main] o.s.j.e.a.AnnotationMB...tartup
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.472  INFO 27999 --- [           main] o.s.c.support.DefaultL...483647
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.473  INFO 27999 --- [           main] o.s.m.s.b.SimpleBroker...ing...
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.473  INFO 27999 --- [           main] o.s.m.s.b.SimpleBroker...ns]]]]
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.474  INFO 27999 --- [           main] o.s.m.s.b.SimpleBroker...arted.
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.579  INFO 27999 --- [           main] s.b.c.e.t.TomcatEmbedd...(http)
Jul 23 16:55:26 server1.example.com hr-app[27976]: 2016-07-23 16:55:26.589  INFO 27999 --- [           main] com.example.hr.HrBootA...2.792)
Hint: Some lines were ellipsized, use -l to show in full.
[guru@server1 ~]$ 
Servisimizin konfigürasyonu için çalıştırılabilir dosya ile aynı isimli ancak uzantısı .conf olan bir dosya oluşturuyoruz. Tipik olarak Java Sanal Makinasının ayarlarını yapmak için kullanırız:
[guru@server1 ~]$ ls -lh hr-app.conf 
-r-------- 1 guru guru 80 Jul 23 17:04 hr-app.conf
[guru@server1 ~]$ cat hr-app.conf 
JAVA_OPTS="-Xms2048m -Xmx2048m -Xcomp -XX:+UseG1GC -XX:+UseStringDeduplication"
jcmd komutunu kullanarak, servis olarak çalıştırdığımız Java prosesinin, Java Sanal Makinası parametrelerinin hr-app.conf dosyasında JAVA_OPTS ile tanımladığımız değerlere sahip olduğunu doğrulayabiliriz:
[guru@server1 ~]$ sudo jcmd 
33366 sun.tools.jcmd.JCmd
29067 /home/guru/hr-app
[guru@server1 ~]$ sudo jcmd  29067 VM.command_line
29067:
VM Arguments:
jvm_args: -Dsun.misc.URLClassPath.disableJarChecking=true -Xms2048m -Xmx2048m -Xcomp -XX:+UseG1GC -XX:+UseStringDeduplication 
java_command: /home/guru/hr-app
java_class_path (initial): /home/guru/hr-app
Launcher Type: SUN_STANDARD
[guru@server1 ~]$