nacos集羣安裝部署

1、下載nacos包

[root@manage-host updates]# wget https://github.com/alibaba/nacos/releases/download/1.2.1/nacos-server-1.2.1.tar.gz
--2020-04-28 10:21:41--  https://github.com/alibaba/nacos/releases/download/1.2.1/nacos-server-1.2.1.tar.gz
正在解析主機 github.com (github.com)... 13.250.177.223
正在連接 github.com (github.com)|13.250.177.223|:443... 已連接。
已發出 HTTP 請求,正在等待迴應... 302 Found
位置:https://github-production-release-asset-2e65be.s3.amazonaws.com/137451403/f7c3dc00-7344-11ea-8010-f3bed54d91af?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200428%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200428T022142Z&X-Amz-Expires=300&X-Amz-Signature=e4b6c0d884a20fdb77f35226dffe97f35b8d7f0407fd91130b05f13e93d7519a&X-Amz-SignedHeaders=host&actor_id=0&repo_id=137451403&response-content-disposition=attachment%3B%20filename%3Dnacos-server-1.2.1.tar.gz&response-content-type=application%2Foctet-stream [跟隨至新的 URL]
--2020-04-28 10:21:43--  https://github-production-release-asset-2e65be.s3.amazonaws.com/137451403/f7c3dc00-7344-11ea-8010-f3bed54d91af?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200428%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200428T022142Z&X-Amz-Expires=300&X-Amz-Signature=e4b6c0d884a20fdb77f35226dffe97f35b8d7f0407fd91130b05f13e93d7519a&X-Amz-SignedHeaders=host&actor_id=0&repo_id=137451403&response-content-disposition=attachment%3B%20filename%3Dnacos-server-1.2.1.tar.gz&response-content-type=application%2Foctet-stream
正在解析主機 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.129.171
正在連接 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.129.171|:443... 已連接。
已發出 HTTP 請求,正在等待迴應... 200 OK
長度:56049322 (53M) [application/octet-stream]
正在保存至: “nacos-server-1.2.1.tar.gz”

100%[====================================================================================================================================================>] 56,049,322  35.5KB/s 用時 29m 5s 

2020-04-28 10:50:51 (31.4 KB/s) - 已保存 “nacos-server-1.2.1.tar.gz” [56049322/56049322])

2、解壓並修改單機的配置文件(以下所有的配置在三臺機器上都操作)

[root@manage-host updates]# tar -xf nacos-server-1.2.1.tar.gz ../
[root@manage-host updates]# cd ../nacos/conf
[root@manage-host conf]# vim application.properties
#*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=8848


#*************** Config Module Related Configurations ***************#
### If user MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:mysql://192.168.0.117:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=nacos
db.password=901Bcpct

3、編輯集羣配置文件

[root@manage-host conf]# cp cluster.conf.example cluster.conf
[root@manage-host conf]# vim cluster.conf
#it is ip
#example
192.168.0.117:8848
192.168.0.194:8848
192.168.0.156:8848

4、配置啓動方式

集羣啓動方式如下

[root@manage-host conf]# vim /usr/lib/systemd/system/nacos.service
[Unit]
Description=Nacos
After=network.target

[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nacos
User=root
WorkingDirectory=/home/deploy/nacos/
ExecStart=/home/deploy/nacos/bin/startup.sh
KillMode=process
TimeoutStopSec=60
Restart=on-failure
RestartSec=5
RemainAfterExit=no

[Install]
WantedBy=multi-user.target

單機啓動方式如下

[root@manage-host conf]# vim /usr/lib/systemd/system/nacos.service
[Unit]
Description=Nacos
After=network.target

[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nacos
User=root
WorkingDirectory=/home/deploy/nacos/
ExecStart=/home/deploy/nacos/bin/startup.sh -m standalone
KillMode=process
TimeoutStopSec=60
Restart=on-failure
RestartSec=5
RemainAfterExit=no

[Install]
WantedBy=multi-user.target

刷新系統配置

systemctl daemon-reload

5、設置開機啓動和啓動服務

[root@data-node1 conf]# systemctl enable nacos
[root@data-node1 conf]# systemctl start nacos

6、查詢日誌,出現successfully則證明啓動成功

7、一臺一臺驗證

http://192.168.0.194:8848/nacos/index.html

 8、配置nginx反向代理

配置文件內容如下

upstream gridcloudcluster {
    server 192.168.0.117:8848 weight=1;
    server 192.168.0.194:8848 weight=1;
    server 192.168.0.156:8848 weight=1;
}


server {
        listen       8849;
        charset UTF-8;
        server_name 192.168.0.117;
      
      location / { 
        proxy_pass http://gridcloudcluster;
        proxy_set_header   Host    $host; 
        proxy_set_header   Remote_Addr    $remote_addr;
        proxy_set_header   X-Real-IP    $remote_addr;
        proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
        index index;
        
        }
     
}

驗證nginx配置是否有誤,並重啓 

[root@manage-host nacos]# /home/deploy/nginx/sbin/nginx -t
nginx: the configuration file /home/deploy/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /home/deploy/nginx/conf/nginx.conf test is successful
[root@manage-host nacos]# /home/deploy/nginx/sbin/nginx -s reload

 9、在瀏覽器上通過nginx訪問,並登陸(默認賬號密碼都是nacos)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章