• MINECRAFT > installer un serveur minecraft dans une Debian sans serveur graphique X

      1. Prérequis

      sudo apt update
      sudo apt install openjdk-21-jre-headless
      sudo java --version

      ur que le serveur Minecraft reste actif lorsque l’on quitte le terminal, installer screen:

      sudo apt install screen

       

      Le serveur Minecraft utilise le port TCP 25565 par défaut. Il faut donc libérer ce port :

      sudo ufw allow 25565

      2. installer le serveur Minecraft

      Aller sur la page  https://www.minecraft.net/fr-fr/download/server et enregistrer le fichier .jar qui y est présenté.

       

      exécuter le fichier server.jar pour la première fois :

      sudo java -Xms1G -Xmx2G -jar server.jar nogui

      nogui sans interface graphique.

      Xms1G la RAM « de départ » est de 1 Go.

      Xmx2G la charge maximale de la RAM est limitée à 2 Go.

       

      Lors du premier lancement, on obtient les messages d’erreur suivants :

      Failed to load properties from file: server.properties
      Failed to load eula.txt
      You need to agree ro the EULA in order to run the server. Go to eula.txt for more info.

       

      Le fichier eula.txt, doit être modifié en remplaçant eula=false par eula=true

      vi eula.txt

       

      Le fichier server.properties peut également être modifié :

      vi server.properties

       

      Puis, on redémarre le serveur Minecraft :

      sudo java -Xms1G -Xmx2G -jar server.jar nogui

       

      Une fois le processus de démarrage réussi (peut prendre un certain temps), le terminal présente le message suivant :

      Preparing spawn area: 97%
      Preparing spawn area: 98%
      Time elapsed: 42352 ms
      Done (55.321s)! For help, type "help"

      Taper help pour obtenir une liste des commandes possibles du serveur.

      3. Configurer le serveur Minecraft

      La configuration standard définit, entre autres:

      difficulty= le niveau de difficulté.

      query.port= le port du serveur.

      motd= petite phrase pour présenter le serveur.

      level-name= dossier avec le nom duquel le serveur démarrera.

       

      server.properties

      Another option is to use the /reload command in the server console or in-game, which will also allow changes to be reloaded.

       

      minecraft_server.sh

      enable-jmx-monitoring=false
      rcon.port=25575
      level-seed=
      gamemode=survival
      enable-command-block=false
      enable-query=false
      generator-settings={}
      enforce-secure-profile=true
      level-name=world
      motd=A Minecraft Server
      query.port=25565
      pvp=true
      generate-structures=true
      max-chained-neighbor-updates=1000000
      difficulty=easy
      network-compression-threshold=256
      max-tick-time=60000
      require-resource-pack=false
      use-native-transport=true
      max-players=20
      online-mode=true
      enable-status=true
      allow-flight=false
      initial-disabled-packs=
      broadcast-rcon-to-ops=true
      view-distance=10
      server-ip=
      resource-pack-prompt=
      allow-nether=true
      server-port=25565
      enable-rcon=false
      sync-chunk-writes=true
      op-permission-level=4
      prevent-proxy-connections=false
      hide-online-players=false
      resource-pack=
      entity-broadcast-range-percentage=100
      simulation-distance=10
      rcon.password=
      player-idle-timeout=0
      force-gamemode=false
      rate-limit=0
      hardcore=false
      white-list=false
      broadcast-console-to-ops=true
      spawn-npcs=true
      spawn-animals=true
      log-ips=true
      function-permission-level=2
      initial-enabled-packs=vanilla
      level-type=minecraft\:normal
      text-filtering-config=
      spawn-monsters=true
      enforce-whitelist=false
      spawn-protection=16
      resource-pack-sha1=
      max-world-size=29999984

      Keys

      allow-flight bool false Allows users to use flight on the server while in Survival mode, With allow-flight enabled, griefers may become more common, because it makes their work easier. In Creative mode, this has no effect.

      allow-nether bool true Allows players to travel to the Nether.

      broadcast-console-to-ops boolean true Send console command outputs to all online operators.

      broadcast-rcon-to-ops boolean true Send rcon console command outputs to all online operators.

      difficulty string easy Defines the difficulty of the server. If a legacy difficulty number is specified, it is silently converted to a difficulty name. peaceful (0) - easy (1) - normal (2) - hard (3)

      enable-command-block boolean false Enables command blocks

      enable-jmx-monitoring boolean false Exposes an MBean with the Object name net.minecraft.server:type=Server and two attributes averageTickTime and tickTimes exposing the tick times in milliseconds.

      enable-rcon boolean false Enables remote access to the server console. It’s not recommended to expose RCON to the Internet, because RCON protocol transfers everything without encryption. Everything (including RCON password) communicated between the RCON server and client can be leaked to someone listening in on your connection.

      enable-status boolean true Makes the server appear as "online" on the server list. If set to false, it will suppress replies from clients. This means it will appear as offline, but will still accept connections.

      enable-query boolean false Enables GameSpy4 protocol server listener. Used to get information about server.

      enforce-secure-profile boolean true If set to true, players without a Mojang-signed public key will not be able to connect to the server.

      enforce-whitelist boolean false Enforces the whitelist on the server.

      When this option is enabled, users who are not present on the whitelist (if it’s enabled) get kicked from the server after the server reloads the whitelist file.

      false - No user gets kicked if not on the whitelist. true - Online users not on the whitelist get kicked.

      entity-broadcast-range-percentage integer (10-1000) 100 Controls how close entities need to be before being sent to clients. Higher values means they’ll be rendered from farther away, potentially causing more lag. This is expressed the percentage of the default value. For example, setting to 50 will make it half as usual. This mimics the function on the client video settings (not unlike Render Distance, which the client can customize so long as it’s under the server’s setting).

      force-gamemode boolean false Force players to join in the default game mode.

      false - Players join in the gamemode they left in. true - Players always join in the default gamemode.

      function-permission-level integer (1-4) 2 Sets the default permission level for functions. See permission level for the details on the 4 levels.

      gamemode string survival Defines the mode of gameplay. survival (0) - creative (1) - adventure (2) - spectator (3)

      generate-structures boolean true Defines whether structures (such as villages) can be generated. false - Structures are not generated in new chunks. true - Structures are generated in new chunks. Note: Dungeons still generate if this is set to false.

      generator-settings string {} The settings used to customize world generation. Follow its format and write the corresponding JSON string. Remember to escape all : with \:.

      hardcore boolean false If set to true, server difficulty is ignored and set to hard and players are set to spectator mode if they die.

      hide-online-players boolean false If set to true, a player list is not sent on status requests.

      initial-disabled-packs string blank Comma-separated list of datapacks to not be auto-enabled on world creation.

      initial-enabled-packs string vanilla Comma-separated list of datapacks to be enabled during world creation. Feature packs need to be explicitly enabled.

      level-name string world The "level-name" value is used as the world name and its folder name. The player may also copy their saved game folder here, and change the name to the same as that folder’s to load it instead.

       

      Characters such as ‘ (apostrophe) may need to be escaped by adding a backslash before them.

       

      level-seed string blank Sets a world seed for the player’s world, as in Singleplayer. The world generates with a random seed if left blank.

      Some examples are: minecraft, 404, 1a2b3c.

      level-type string minecraft:normal Determines the world preset that is generated.

      Escaping ":" is required when using a world preset ID, and the vanilla world preset ID’s namespace (minecraft:) can be omitted.

      minecraft:normal - Standard world with hills, valleys, water, etc.

      minecraft:flat - A flat world with no features, can be modified with generator-settings.

      minecraft:large_biomes - Same as default but all biomes are larger.

      minecraft:amplified - Same as default but world-generation height limit is increased.

      minecraft:single_biome_surface - A buffet world which the entire overworld consists of one biome, can be modified with generator-settings.

      buffet - Only for 1.15 or before. Same as default unless generator-settings is set.

      default_1_1 - Only for 1.15 or before. Same as default, but counted as a different world type.

      customized - Only for 1.15 or before. After 1.13, this value is no different than default, but in 1.12 and before, it could be used to create a completely custom world.

       

      max-chained-neighbor-updates int [?] 1000000 Limiting the amount of consecutive neighbor updates before skipping additional ones. Negative values remove the limit.

      max-players int (0-(2^31 - 1)) 20 The maximum number of players that can play on the server at the same time. Note that more players on the server consume more resources. Note also, op player connections are not supposed to count against the max players, but ops currently cannot join a full server. However, this can be changed by going to the file called ops.json in the player’s server directory, opening it, finding the op that the player wants to change, and changing the setting called bypassesPlayerLimit to true (the default is false). This means that that op does not have to wait for a player to leave in order to join. Extremely large values for this field result in the client-side user list being broken.

      max-tick-time integer (-1 or 0–(2^63 - 1)) 60000 The maximum number of milliseconds a single tick may take before the server watchdog stops the server with the message, A single server tick took 60.00 seconds (should be max 0.05); Considering it to be crashed, server will forcibly shutdown. Once this criterion is met, it calls System.exit(1).

      -1 - disable watchdog entirely (this disable option was added in 14w32a)

      max-world-size int (1-29999984) 29999984 This sets the maximum possible size in blocks, expressed as a radius, that the world border can obtain. Setting the world border bigger causes the commands to complete successfully but the actual border does not move past this block limit. Setting the max-world-size higher than the default doesn’t appear to do anything.

      Examples:

      Setting max-world-size to 1000 allows the player to have a 2000×2000 world border.

      Setting max-world-size to 4000 gives the player an 8000×8000 world border.

      motd string A Minecraft Server This is the message that is displayed in the server list of the client, below the name.

      The MOTD supports color and formatting codes.

      The MOTD supports special characters, such as "♥". However, such characters must be converted to escaped Unicode form. An online converter can be found here.

      If the MOTD is over 59 characters, the server list may report a communication error.

      network-compression-threshold int 256 By default it allows packets that are n-1 bytes big to go normally, but a packet of n bytes or more gets compressed down. So, a lower number means more compression but compressing small amounts of bytes might actually end up with a larger result than what went in.

      -1 - disable compression entirely

      0 - compress everything

      Note: The Ethernet spec requires that packets less than 64 bytes become padded to 64 bytes. Thus, setting a value lower than 64 may not be beneficial. It is also not recommended to exceed the MTU, typically 1500 bytes.

      online-mode boolean true Server checks connecting players against Minecraft account database. Set this to false only if the player’s server is not connected to the Internet. Hackers with fake accounts can connect if this is set to false! If minecraft.net is down or inaccessible, no players can connect if this is set to true. Setting this variable to off purposely is called "cracking" a server, and servers that are present with online mode off are called "cracked" servers, allowing players with unlicensed copies of Minecraft to join.

      true - Enabled. The server assumes it has an Internet connection and checks every connecting player.

      false - Disabled. The server does not attempt to check connecting players.

      op-permission-level int (0-4) 4 Sets the default permission level for ops when using /op.

      player-idle-timeout int 0 If non-zero, players are kicked from the server if they are idle for more than that many minutes.

      Note: Idle time is reset when the server receives one of the following packets: Click Window - Enchant Item - Update Sign - Player Digging - Player Block Placement - Held Item Change - Animation (swing arm) - Entity Action - Client Status - Chat Message - Use Entity

      prevent-proxy-connections boolean false If the ISP/AS sent from the server is different from the one from Mojang Studios’ authentication server, the player is kicked.

      previews-chat bool false If set to true, chat preview will be enabled.

      true - Enabled. When enabled, a server-controlled preview appears above the chat edit box, showing how the message will look when sent.

      false - Disabled.

      pvp boolean true Enable PvP on the server. Players shooting themselves with arrows receive damage only if PvP is enabled.

      true - Players can kill each other.

      false - Players cannot kill other players (also known as Player versus Environment (PvE)).

      Note: Indirect damage sources spawned by players (such as lava, fire, TNT and to some extent water, sand and gravel) still deal damage to other players.

      query.port int (1-(2^16 - 2)) 25565 Sets the port for the query server (see enable-query).

      rate-limit int 0 Sets the maximum amount of packets a user can send before getting kicked. Setting to 0 disables this feature.

      rcon.password string blank Sets the password for RCON: a remote console protocol that can allow other applications to connect and interact with a Minecraft server over the internet.

      rcon.port int (1-(2^16 - 2)) 25575 Sets the RCON network port.

      resource-pack string blank Optional URI to a resource pack. The player may choose to use it.

      Note that (<1.15.2), the ":" and "=" characters need to be escaped with a backslash (\), e.g. http\://somedomain.com/somepack.zip?someparam\=somevalue

      The resource pack may not have a larger file size than 250 MiB (Before 1.18: 100 MiB (≈ 100.8 MB)) (Before 1.15: 50 MiB (≈ 50.4 MB)). Note that download success or failure is logged by the client, and not by the server.

      resource-pack-prompt string blank

      Optional, adds a custom message to be shown on resource pack prompt when require-resource-pack is used.

      Expects chat component syntax, can contain multiple lines.

      resource-pack-sha1 string blank Optional SHA-1 digest of the resource pack, in lowercase hexadecimal. It is recommended to specify this, because it is used to verify the integrity of the resource pack.

      Note: If the resource pack is any different, a yellow message "Invalid sha1 for resource-pack-sha1″ appears in the console when the server starts. Due to the nature of hash functions, errors have a tiny probability of occurring, so this consequence has no effect.

      require-resource-pack boolean false When this option is enabled (set to true), players will be prompted for a response and will be disconnected if they decline the required pack.

      server-ip string blank The player should set this if they want the server to bind to a particular IP. It is strongly recommended that the player leaves server-ip blank. Set to blank, or the IP the player want their server to run (listen) on.

      server-port int (1-(2^16 - 2)) 25565 Changes the port the server is hosting (listening) on. This port must be forwarded if the server is hosted in a network using NAT (if the player has a home router/firewall).

      simulation-distance int (3-32) 10 Sets the maximum distance from players that living entities may be located in order to be updated by the server, measured in chunks in each direction of the player (radius, not diameter). If entities are outside of this radius, then they will not be ticked by the server nor will they be visible to players. 10 is the default/recommended. If the player has major lag, this value is recommended to be reduced.

      snooper-enabled bool true Sets whether the server sends snoop data regularly to http://snoop.minecraft.net.

      false - disable snooping.

      true - enable snooping.

      spawn-animals bool true Determines if animals can spawn.

      true - Animals spawn as normal.

      false - Animals immediately vanish.

      If the player has major lag, it is recommended to turn this off/set to false.

      spawn-monsters bool true Determines if monsters can spawn.

      true - Enabled. Monsters appear at night and in the dark.

      false - Disabled. No monsters.

      This setting has no effect if difficulty = 0 (peaceful). If difficulty is not = 0, a monster can still spawn from a monster spawner.

      If the player has major lag, it is recommended to turn this off/set to false.

      spawn-npcs bool true Determines whether villagers can spawn.

      true - Enabled. Villagers spawn.

      false - Disabled. No villagers.

      spawn-protection int 16 Determines the side length of the square spawn protection area as 2x+1. Setting this to 0 disables the spawn protection. A value of 1 protects a 3×3 square centered on the spawn point. 2 protects 5×5, 3 protects 7×7, etc. This option is not generated on the first server start and appears when the first player joins. If there are no ops set on the server, the spawn protection is disabled automatically as well.

      sync-chunk-writes bool true Enables synchronous chunk writes.

      text-filtering-config [more information needed] blank [more information needed]

      use-native-transport bool true Linux server performance improvements: optimized packet sending/receiving on Linux

      true - Enabled. Enable Linux packet sending/receiving optimization

      false - Disabled. Disable Linux packet sending/receiving optimization

      view-distance int (3-32) 10 Sets the amount of world data the server sends the client, measured in chunks in each direction of the player (radius, not diameter). It determines the server-side viewing distance. 10 is the default/recommended. If the player has major lag, this value is recommended to be reduced.

      white-list bool false Enables a whitelist on the server.

      With a whitelist enabled, users not on the whitelist cannot connect. Intended for private servers, such as those for real-life friends or strangers carefully selected via an application process, for example.

      false - No white list is used.

      true - The file whitelist.json is used to generate the white list.

      Note: Ops are automatically whitelisted, and there is no need to add them to the whitelist.

       

      Liste détaillée de tous les paramètres.

      4. Conserver la session du serveur

      Pour que le serveur Minecraft reste actif lors de la fermeture du terminal, il faut d’abord quitter la session ([CTRL] + [A] + [D]), puis afficher toutes les sessions d’écran actives :

      screen -list
      There is a screen on:
         2385.pts-2.mamachine    (31/01/2023 10:30:56)    (Attached)
      1 Socket in /run/screen/S-moi.

       

      On obtient une liste dans laquelle on trouve la connexion établie avec le serveur Minecraft avec l’ID de session qui la précède. Ici, 2385. Pour conserver cette session, taper ce qui suit en remplaçant 2385 par l’ID individuel :

      screen -r 2385

      On peut maintenant fermer la fenêtre de l’écran [Ctrl] + [A] + [D] et se déconnecter sans pour autant fermer le serveur Minecraft.

      OPTIMISATION

      Check minecraft default args first.

      -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M

       

      3Gb spare ram

      -Xmx3G -Xms3G -Xmn768m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA
      -XX:+CMSParallelRemarkEnabled -XX:MaxTenuringThreshold=15 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150
      -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90
      -XX:MaxTenuringThreshold=15 -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true
      -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts
      -XX:ReservedCodeCacheSize=2048m -XX:+UseCodeCacheFlushing -XX:SoftRefLRUPolicyMSPerMB=10000 -XX:ParallelGCThreads=10

       

      1Gb spare RAM

      -Xmx1G -Xms1G -Xmn128m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA
      -XX:+CMSParallelRemarkEnabled -XX:MaxTenuringThreshold=15 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150
      -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90
      -XX:MaxTenuringThreshold=15 -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true
      -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts
      -XX:ReservedCodeCacheSize=2048m -XX:+UseCodeCacheFlushing -XX:SoftRefLRUPolicyMSPerMB=2000 -XX:ParallelGCThreads=10

       

      4+Gb spare RAM

      -Xmx4G -Xms4G -Xmn768m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseNUMA
      -XX:+CMSParallelRemarkEnabled -XX:MaxTenuringThreshold=15 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150
      -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90
      -XX:MaxTenuringThreshold=15 -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true
      -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts
      -XX:ReservedCodeCacheSize=2048m -XX:+UseCodeCacheFlushing -XX:SoftRefLRUPolicyMSPerMB=10000 -XX:ParallelGCThreads=10
      -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:-UsePerfData

       

      G1 garbage colector 4Gb RAM / 4 threads / 4 cores:

      -Xms2G -Xmx2G -Xmn384m -XX:+AggressiveOpts -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled
      -XX:+PerfDisableSharedMem -XX:+UseCompressedOops -XX:-UsePerfData -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=4
      -XX:ConcGCThreads=2 -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=50 -XX:G1HeapRegionSize=1 -XX:G1HeapWastePercent=5
      -XX:G1MixedGCCountTarget=8

       

      8+Gb RAM / 8threads / 4 cores:

      Vanilla Minecraft will hardly use more than 4Gb, but if you need feel free to read and tune your way

      -Xms4G -Xmx4G -Xmn512m -XX:+AggressiveOpts -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled
      -XX:+PerfDisableSharedMem -XX:-UsePerfData -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=2
      -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=50 -XX:G1HeapRegionSize=1 -XX:G1HeapWastePercent=5
      -XX:G1MixedGCCountTarget=8

       

      If you are using a lot of mods and have more than 8Gb RAM you can try this out:

      -Xms4G -Xmx4G -Xmn768m -XX:+AggressiveOpts -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled
      -XX:+PerfDisableSharedMem -XX:+UseCompressedOops -XX:-UsePerfData -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8
      -XX:ConcGCThreads=2 -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=50 -XX:G1HeapRegionSize=1 -XX:G1HeapWastePercent=5
      -XX:G1MixedGCCountTarget=8

      Guide des arguments

      Values with <val> label must be defined manualy.

      -Xms<valr> -Xmx<valr> -Xmn<val>

       

      Xms The start memory. Setting initial and minimum heap size. Oracle recommends setting the minimum heap size -Xms equal to the maximum heap size -Xmx to minimize garbage collections.

      Xmx The max memory GC will use. Setting maximum heap size. Setting a low maximum heap value compared to the amount of live data decrease performance by forcing frequent garbage collections.

      Xmn Minimum java heap size. Oracle recommends that -Xmn and -Xmx be set to the same value. This eliminates potentially costly heap reallocations, and can reduce the amount of heap fragmentation that can occur. Setting -Xms is then unnecessary since the heap size itself is static.

      Advanced JVM args

      -XX:+AggressiveOpts -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem
      -XX:+UseCompressedOops -XX:-UsePerfData

      AggressiveHeap Enables Java heap optimization. This sets various parameters to be optimal for long-running jobs with intensive memory allocation, based on the configuration of the computer (RAM and CPU). By default, the option is disabled and the heap is not optimized.

      AggressiveOpts Enables the use of aggressive performance optimization features, which are expected to become default in upcoming releases. By default, this option is disabled and experimental performance features are not used.

      AlwaysPreTouch Enables touching of every page on the Java heap during JVM initialization. This gets all pages into the memory before entering the main() method. The option can be used in testing to simulate a long-running system with all virtual memory mapped to physical memory. By default, this option is disabled and all pages are committed as JVM heap space fills.

      DisableExplicitGC Another way that applications can interact with garbage collection is by invoking full garbage collections explicitly by calling System.gc(). This can force a major collection to be done when it may not be necessary (for example, when a minor collection would suffice), and so in general should be avoided. The performance effect of explicit garbage collections can be measured by disabling them using the flag -XX:+DisableExplicitGC, which causes the VM to ignore calls to System.gc().

      ParallelRefProcEnabled Enables parallel reference processing. By default, this option is disabled.

      PerfDisableSharedMem I didn’t find an official doc, but it seems that this prevent GC from writing in the file system.

      UsePerfData Enables the perfdata feature. This option is enabled by default to allow JVM monitoring and performance testing. Disabling it suppresses the creation of the hsperfdata_userid directories. To disable the perfdata feature, specify -XX:-UsePerfData.

       

      UseCompressedOops Disables the use of compressed pointers. By default, this option is enabled, and compressed pointers are used when Java heap sizes are less than 32 GB. When this option is enabled, object references are represented as 32-bit offsets instead of 64-bit pointers, which typically increases performance when running the application with Java heap sizes less than 32 GB. This option works only for 64-bit JVMs.

       

      Garbage Colectors Java JRE 1.8.0_261 have these garbage colectors:

      Serial Garbage Colector: The serial collector uses a single thread to perform all garbage collection work, which makes it relatively efficient because there is no communication overhead between threads. It is best-suited to single processor machines, because it cannot take advantage of multiprocessor hardware, although it can be useful on multiprocessors for applications with small data sets (up to approximately 100 MB). The serial collector is selected by default on certain hardware and operating system configurations, or can be explicitly enabled with the option -XX:+UseSerialGC.

       

      Parallel Garbage Colector: The parallel collector (also known as the throughput collector) performs minor collections in parallel, which can significantly reduce garbage collection overhead. It is intended for applications with medium-sized to large-sized data sets that are run on multiprocessor or multithreaded hardware. The parallel collector is selected by default on certain hardware and operating system configurations, or can be explicitly enabled with the option -XX:+UseParallelGC.

       

      Concurrent Mark Sweep (CMS) Collector: The Concurrent Mark Sweep (CMS) collector is designed for applications that prefer shorter garbage collection pauses and that can afford to share processor resources with the garbage collector while the application is running. Typically applications that have a relatively large set of long-lived data (a large tenured generation) and run on machines with two or more processors tend to benefit from the use of this collector. However, this collector should be considered for any application with a low pause time requirement. The CMS collector is enabled with the command-line option -XX:+UseConcMarkSweepGC.

      Garbage-First Garbage Collector: The Garbage-First (G1) garbage collector is a server-style garbage collector, targeted for multiprocessor machines with large memories. It attempts to meet garbage collection (GC) pause time goals with high probability while achieving high throughput. Whole-heap operations, such as global marking, are performed concurrently with the application threads. This prevents interruptions proportional to heap or live-data size. The G1GC is enabled with the command-line option -XX:+UseG1GC.

       

      Z Garbage Colector (ZGC): This garbage colector is only avaiable in JDK 11+, you can use it if you are a advanced user, the current JDK can be downloaded in this link.

      The Z Garbage Collector (ZGC) is a scalable low latency garbage collector. ZGC performs all expensive work concurrently, without stopping the execution of application threads for more than a few milliseconds. It is suitable for applications which require low latency. Pause times are independent of heap size that is being used. ZGC supports heap sizes from 8MB to 16TB. The Z Garbage Collector is enabled with the command-line option -XX:+UseZGC.

       

      The line below shows 3 JVM arguments. They are common to all JVM garbage collectors.

      -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=<var> -XX:ConcGCThreads=<var>

       

      MaxGCPauseMillis The time that the garbage colector will take to clear the memory.The goal for the maximum pause time.

      ParallelGCThreads There are some criterias for this argument, but for the sake of simplicity put all your processor’s threads until 8.

      The maximum number of threads used for parallel work during garbage collection pauses. This is derived from the number of available threads of the computer that the VM runs on in the following way: if the number of CPU threads available to the process is fewer than or equal to 8, use that. Otherwise add five eighths of the threads greater than to the final number of threads.At the start of every pause, the maximum number of threads used is further constrained by maximum total heap size: G1 will not use more than one thread per -XX:HeapSizePerGCThread amount of Java heap capacity.

      ConcGCThreads The maximum number of threads used for concurrent work. By default, this value is -XX:ParallelGCThreads divided by 4.

      G1GC  arguments:

      -XX:+UseG1GC -XX:+G1UseAdaptiveIHOP -XX:InitiatingHeapOccupancyPercent=45 -XX:G1HeapRegionSize=<var>
      -XX:G1NewSizePercent=5 -XX:G1MaxNewSizePercent=60 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8
      -XX:G1MixedGCLiveThresholdPercent=85 -XX:-G1EnableStringDeduplication

       

      G1UseAdaptiveIHOP et InitiatingHeapOccupancyPercent JRE 1.8.0_261 doesn’t surpot it. Defaults for controlling the initiating heap occupancy indicate that adaptive determination of that value is turned on, and that for the first few collection cycles G1 will use an occupancy of 45% of the old generation as mark start threshold.

      G1HeapRegionSize The size of the heap regions. The default value is based on the maximum heap size and it is calculated to render roughly 2048 regions. The size must be a power of 2, and valid values are from 1 to 32 MB.

      G1NewSizePercent et G1MaxNewSizePercent Experimental flag use: -XX:+UnlockExperimentalVMOptions

      The size of the young generation in total, which varies between these two values as percentages of the current Java heap in use.

      G1MixedGCCountTarget The expected length of the space-reclamation phase in a number of collections.

      G1MixedGCLiveThresholdPercent Experimental flag use:

      -XX:+UnlockExperimentalVMOptions

      Old generation regions with higher live object occupancy than this percentage aren’t collected in this space-reclamation phase.

      G1EnableStringDeduplication JRE 1.8.0_261 doesn’t surpot it. String deduplication is disabled by default. You can enable it.

      CMS  arguments:

      -XX:+UseConcMarkSweepGC -XX:-CMSIncrementalMode -XX:-CMSIncrementalPacing -XX:CMSIncrementalDutyCycle=10
      -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalSafetyFactor=10  -XX:CMSIncrementalOffset=0 -XX:CMSExpAvgFactor=25

       

      CMSIncrementalMode Enables incremental mode. Note that the CMS collector must also be enabled (with -XX:+UseConcMarkSweepGC) for this option to work.

      CMSIncrementalPacing Enables automatic pacing. The incremental mode duty cycle is automatically adjusted based on statistics collected while the JVM is running.

      CMSIncrementalDutyCycle The percentage (0 to 100) of time between minor collections that the CMS collector is allowed to run. If CMSIncrementalPacing is enabled, then this is just the initial value.

      CMSIncrementalDutyCycleMin The percentage (0 to 100) that is the lower bound on the duty cycle when CMSIncrementalPacing is enabled.

      CMSIncrementalSafetyFactor The percentage (0 to 100) used to add conservatism when computing the duty cycle.

      CMSIncrementalOffset The percentage (0 to 100) by which the incremental mode duty cycle is shifted to the right within the period between minor collections.

      CMSExpAvgFactor The percentage (0 to 100) used to weight the current sample when computing exponential averages for the CMS collection statistics.

       

      Voili, voilou !

       

       

       

      7. Utiliser screen ou tmux pour gérer la session

      sudo apt install screen
      screen -S minecraft
      java -Xmx1024M -Xms1024M -jar server.jar nogui

      Pour détacher la session, appuyez sur Ctrl+A puis D. Pour revenir à la session, utilisez screen -r minecraft.

      8. Ouvrir les ports du pare-feu

      Si vous avez un pare-feu activé, assurez-vous d’ouvrir le port par défaut de Minecraft (25565) :

      sudo ufw allow 25565/tcp

      10. Automatiser le démarrage du serveur

      Si vous souhaitez que le serveur démarre automatiquement au démarrage du système, vous pouvez créer un service systemd.

      Créez un fichier de service :

      sudo vi /etc/systemd/system/minecraft.service
      [Unit]
      Description=Minecraft Server
      After=network.target
      
      [Service]
      User=your_username
      WorkingDirectory=/path/to/minecraft_server
      ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui
      Restart=always
      
      [Install]
      WantedBy=multi-user.target

      Remplacez your_username par votre nom d’utilisateur et /path/to/minecraft_server par le chemin vers votre répertoire Minecraft.

      Ensuite, activez et démarrez le service :

      sudo systemctl enable minecraft.service
      sudo systemctl start minecraft.service

      Installer Java (21/23) sur Debian

      Téléchargez le package JDK 23:

      wget https://download.oracle.com/java/23/latest/jdk-23_linux-x64_bin.deb

       

      Installez le package téléchargé:

      dpkg -i jdk-23_linux-x64_bin.deb

       

      Vérifier et nettoyer :

      java -version
      rm jdk-23_linux-x64_bin.deb

      Changer de version de Java sur Debian

      Si plusieurs versions de Java sont installées (Java 11, 17 ou 23), voici comment changer la version par défaut de Java en utilisant la commande update-alternatives.

      vérifiez toutes les versions de Java installées sur votre système en exécutant:

      update-alternatives --config java
      There are 3 choices for the alternative java (providing /usr/bin/java).
        Selection    Path                                            Priority   Status
      ------------------------------------------------------------
        0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
      * 1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
        2            /usr/lib/jvm/java-12-openjdk-amd64/bin/java      1122      manual mode
        3            /usr/lib/jvm/java-23-oracle/bin/java             1233      manual mode

       

      Sélectionner la version de Java souhaitée

      sudo update-alternatives --config java

      Saisir le numéro de la version de Java souhaitée puis ENTREE.

       

      Vérifiez le changement :

      java -version
      java version "23.0.1" 2023-09-19 LTS
      Java(TM) SE Runtime Environment (build 23.0.1+10-LTS)
      Java HotSpot(TM) 64-Bit Server VM (build 23.0.1+10-LTS, mixed mode)

       

      Remarque :Si vous avez également besoin de changer la version pour javac, le compilateur Java, vous pouvez utiliser une commande similaire.

      sudo update-alternatives --config javac

       

      Voili, voilou

 

Aucun commentaire

 

Laissez un commentaire