Experimental environment

  • The operating system

    [root@localhost server]# cat /etc/centos-release

    CentOS Linux release 7.7.1908 (Core)

  • LAN IP

    192.168.47.20

  • Nacos version

    Nacos – server – 1.1.4

  • JDK version

    [root@localhost src]# java -version

    Java version “1.8.0_201” Java(TM) SE Runtime Environment (build 1.8.0_201-B09) Java HotSpot(TM) 64-bit Server VM (build 25.201 – b09, mixed mode)

  • MySQL version

    5.7.28

Nacos standalone installation

  • Address for downloading the installation package
    https://github.com/alibaba/nacos
    Copy the code
  • Preparing installation packages
    Tar - ZXVF nacos - server - 1.1.4. Tar. Gz mkdir/application/server / -p nacos mv/application/server/nacos - server - 1.1.4 ln -s / application/server/nacos - server - 1.1.4 / / application/server/nacosCopy the code
    [root@localhost src]# ll /application/server/ total 0 lrwxrwxrwx 1 root root 39 Dec 29 13:50 nacos -> / application/server/nacos - server - 1.1.4 / DRWXR - xr - x 5 root root 72 Dec 29 nacos prominence - server - 1.1.4Copy the code
  • Start the Nacos
     ./startup.sh  -m standalone
    Copy the code
  • Check whether the startup is successful Check whether port 8848 is started successfully
    [root@localhost bin]# netstat -ntlp |grep 8848            
    tcp6       0      0 :::8848                 :::*                    LISTEN      1485/java  
    Copy the code

    Browser access

    http://192.168.47.20:8848/nacos/#/login
    Copy the code

    Initial login information: nacos/nacos

Nacos installation configuration

Boot from the rev.
  • Add the nacos.service file vim /lib/systemd/system/nacos.service
    [Unit]
    Description=nacos
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/application/server/nacos/bin/startup.sh -m standalone
    ExecReload=/application/server/nacos/bin/shutdown.sh
    ExecStop=/application/server/nacos/bin/shutdown.sh
    PrivateTmp=true
    
    [Install]  
    WantedBy=multi-user.target
    Copy the code
  • Join the Nacos service
    systemctl daemon-reload
    Copy the code
  • Set boot to start automatically
    systemctl enable nacos.service
    Copy the code
  • Start/stop
     systemctl start nacos.service
    
    systemctl stop nacos.service
    Copy the code
Support for MySQL
  • MySQL Database Installation

    Self-installed, version requirements: 5.6.5+

  • Create database connection information Create database NACOS

    create database nacos DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    Copy the code

    Create a user name and password

    CREATE USER  'nacos'@'192.168.47.%' IDENTIFIED BY '123456';
    Copy the code

    empowerment

    Grant ALL PRIVILEGES on NACos.* to 'nacOS '@'192.168.47.%';Copy the code
  • Initialize the database file. Locate the nacos-mysql. SQL file in the conf directory of Nacos and execute the SQL file in the created Nacos library

    mysql> use nacos;
    Database changed
    mysql> show tables;+----------------------+ | Tables_in_nacos | +----------------------+ | config_info | | config_info_aggr | | config_info_beta | | config_info_tag | | config_tags_relation | | group_capacity | | his_config_info | | roles | | Tenant_capacity | | tenant_info | | users | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 11 rows in the set (0.00 SEC)Copy the code
  • Modify nacos server application. The properties configuration file to modify the conf/application. The properties files, increase support for mysql data source configuration (currently only supports mysql), Add the URL, user name, and password of the mysql data source

    #database mysqlSpring. The datasource. Platform = mysql db. Num = 1 db. Url. 0 = JDBC: mysql: / / 192.168.47.20:3306 / nacos? characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=nacos db.password=123456Copy the code

Error the collection

Service startup error reported
  • Error description:

    [root@localhost ~]# systemctl start nacos.service Job for nacos.service failed because the control process exited with error code. See "systemctl status nacos.service" and "journalctl -xe" for details. [root@localhost ~]# systemctl status Nacos. Service low nacos. Service - nacos the Loaded: the Loaded (/ usr/lib/systemd/system/nacos. Service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sun 2019-12-29 14:08:15 CST; 4s ago Process: 1835 ExecStart=/application/server/nacos/bin/startup.sh -m standalone (code=exited, status=1/FAILURE) Dec 29 14:08:15 localhost.localdomain startup.sh[1835]: which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin) Dec 29 14:08:15 localhost.localdomain startup.sh[1835]: readlink: missing operand Dec 29 14:08:15 localhost.localdomain startup.sh[1835]: Try 'readlink --help' for more information. Dec 29 14:08:15 localhost.localdomain systemd[1]: nacos.service: control process exited, code=exited status=1 Dec 29 14:08:15 localhost.localdomain startup.sh[1835]: dirname: missing operand Dec 29 14:08:15 localhost.localdomain startup.sh[1835]: Try 'dirname --help' for more information. Dec 29 14:08:15 localhost.localdomain systemd[1]: Failed to start nacos. Dec 29 14:08:15 localhost.localdomain startup.sh[1835]: ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or l... tter! !!!!! Dec 29 14:08:15 localhost.localdomain systemd[1]: Unit nacos.service entered failed state. Dec 29 14:08:15 localhost.localdomain systemd[1]: nacos.service failed. Hint: Some lines were ellipsized, use -l to show in full.Copy the code
  • The reason for the error

    Nacos is developed in Java and requires JDK version 1.8 at startup. JAVA_HOME is already configured in the system environment, but in the service script, From (/ usr/local/sbin, / usr/local/bin: / usr/sbin, / usr/bin these path for javac, just need to our own Java directories as soft links to/usr/bin/Java

  • Error Resolution View the Java installation location

    [root@localhost ~]# which javac
    /usr/local/java/jdk1.8.0_201/bin/javac
    Copy the code

    Building soft links

    Ln -s/usr/local/Java/jdk1.8.0 _201 / bin/javac/usr/bin/javacCopy the code

    If the javac still cannot be started and cannot be found, set the Javac to executable

    Chmod + x/usr/local/Java/jdk1.8.0 _201 / bin/javacCopy the code