<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## 搭建生產可用的Nacos集群 ``` 軟件包其中有JDK安裝包 鏈接:https://pan.baidu.com/s/1QiWfPZVCg-kEmysfNSzHCg 提取碼:virc ``` ### 搭建方案 ![](https://img.kancloud.cn/d0/3d/d03d68020fc9d13aa7e80333cc687469_889x455.png) ### 簡介 生產環境中部署`nacos`需要使用集群模式`cluster`保證高可用,本文主要詳細介紹如何搭建搭建生產可用的Nacos集群 * nacos采用raft協議實現集群,有leader的概念 ![](https://img.kancloud.cn/2f/b5/2fb56e47353f346c52e62978ecd5abf4_1920x738.png) ### 主機規劃 #### mysql | 節點 | 端口 | | :-- | :-- | | 59.110.164.254| 3306| #### nacos集群 | 節點 | 端口 | | :-- | :-- | | 192.168.235.130| 8848 | | 192.168.235.131| 8848 | | 192.168.235.132 | 8848 | nacos集群中,每臺機器安裝JDK ##### jdk安裝步驟 * 1.將下載好的jdk跟maven上傳到服務器上 * 2.解壓jdk到/usr/local/ tar -zxvf jdk-8u91-linux-x64.tar.gz -C /usr/local/ * 3.配置環境變量 vi /etc/profile 在最下面,按i進入insert模式,添加一下內容 JAVA\_HOME=/usr/local/jdk1.8.0\_91 export JAVA\_HOME CLASSPATH=.:$JAVA\_HOME/lib export CLASSPATH PATH=$PATH:$JAVA\_HOME/bin:$CLASSPATH export PATH 按esc進入命令行模式,再按:wq保存退出 * 4.激活配置 source /etc/profile #### openresty集群 | 節點 | 端口 | | :-- | :-- | | 192.168.235.133| 80 | | 192.168.235.134| 80| VIP > 192.168.235.135 ### 準備階段 mysql中新建數據庫nacos,導入初始化腳本,本文采用單節點部署mysql方式,為了快速部署nacos集群,生產環境選用Galera mysql集群方式部署。 ### 初始化腳本 ![](https://img.kancloud.cn/06/79/06799a87078a9a05c456a344a704ccec_916x376.png) 找到 `conf/nacos-mysql.sql` ,將其導入到數據庫中。 導入后查看數據庫 ![](https://img.kancloud.cn/76/a0/76a0f02b6e697bd422a8a653e46ed5c8_1192x448.png) ### 192.168.235.130 * 創建目錄 ``` mkdir /app ``` * 將文章頂部百度網盤中的文件上傳到 192.168.235.130中的/app目錄 ![](https://img.kancloud.cn/b2/cf/b2cf732cfc08d6979f60da7f54ae83df_1917x242.png) * 修改application.properties文件,最后部分增加如下配置 ``` spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://59.110.164.254:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=root db.password=root ``` * 修改cluster.conf文件,nacos集群的三臺主機信息 ``` # ip:port 192.168.235.130:8848 192.168.235.131:8848 192.168.235.132:8848 ``` * 啟動 ``` cd /app/nacos-server/bin ./startup.sh ``` * 查看啟動情況 ``` tail -f /app/nacos-server/logs/start.out ``` ### 192.168.235.131 * 創建目錄 ``` mkdir /app ``` * 將文章頂部百度網盤中的文件上傳到 192.168.235.131中的/app目錄 ![](https://img.kancloud.cn/b2/cf/b2cf732cfc08d6979f60da7f54ae83df_1917x242.png) * 修改application.properties文件,最后部分增加如下配置 ``` spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://59.110.164.254:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=root db.password=root ``` * 修改cluster.conf文件,nacos集群的三臺主機信息 ``` # ip:port 192.168.235.130:8848 192.168.235.131:8848 192.168.235.132:8848 ``` * 啟動 ``` cd /app/nacos-server/bin ./startup.sh ``` * 查看啟動情況 ``` tail -f /app/nacos-server/logs/start.out ``` ### 192.168.235.132 * 創建目錄 ``` mkdir /app ``` * 將文章頂部百度網盤中的文件上傳到 192.168.235.132中的/app目錄 ![](https://img.kancloud.cn/b2/cf/b2cf732cfc08d6979f60da7f54ae83df_1917x242.png) * 修改application.properties文件,最后部分增加如下配置 ``` spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://59.110.164.254:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=root db.password=root ``` * 修改cluster.conf文件,nacos集群的三臺主機信息 ``` # ip:port 192.168.235.130:8848 192.168.235.131:8848 192.168.235.132:8848 ``` * 啟動 ``` cd /app/nacos-server/bin ./startup.sh ``` * 查看啟動情況 ``` tail -f /app/nacos-server/logs/start.out ``` ### 192.168.235.133 * OpenResty安裝 ``` ●Centos:yum install -y readline-devel pcre-devel openssl-devel gcc GeoIP-devel ●wget https://openresty.org/download/openresty-1.11.2.1.tar.gz ●tar -zxvf openresty-1.11.2.1.tar.gz ●cd openresty-1.11.2.1 ●./configure --with-luajit --with-pcre --with-http_gzip_static_module --with-http_realip_module --with-http_geoip_module --with-http_ssl_module --with-http_stub_status_module --prefix=/app/openresty ●make && make install ``` * 安裝完成 * ![](https://img.kancloud.cn/cf/48/cf48a4ca7226216c7aad5bd6685182ff_1025x356.png) * OpenResty配置/app/openresty/nginx/conf/nginx.conf ``` #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream nacosCluster { server 192.168.235.130:8848; server 192.168.235.131:8848; server 192.168.235.132:8848; } server { listen 80; server_name nacostest.com; location / { proxy_pass http://nacosCluster; } } } ~ ``` * OpenResty啟動 ``` cd /app/openresty/nginx/sbin ./nginx ``` * 驗證 http://192.168.235.133/nacos 用戶名/密碼 nacos nacos ![](https://img.kancloud.cn/a8/13/a8136d9e4491577facd9a42ff8499928_1716x740.png) ### 192.168.235.134 * OpenResty安裝 ``` ●Centos:yum install -y readline-devel pcre-devel openssl-devel gcc GeoIP-devel ●wget https://openresty.org/download/openresty-1.11.2.1.tar.gz ●tar -zxvf openresty-1.11.2.1.tar.gz ●cd openresty-1.11.2.1 ●./configure --with-luajit --with-pcre --with-http_gzip_static_module --with-http_realip_module --with-http_geoip_module --with-http_ssl_module --with-http_stub_status_module --prefix=/app/openresty ●make && make install ``` * 安裝完成 * ![](https://img.kancloud.cn/cf/48/cf48a4ca7226216c7aad5bd6685182ff_1025x356.png) * OpenResty配置/app/openresty/nginx/conf/nginx.conf ``` #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream nacosCluster { server 192.168.235.130:8848; server 192.168.235.131:8848; server 192.168.235.132:8848; } server { listen 80; server_name nacostest.com; location / { proxy_pass http://nacosCluster; } } } ~ ``` * OpenResty啟動 ``` cd /app/openresty/nginx/sbin ./nginx ``` * 驗證 http://192.168.235.134/nacos 用戶名/密碼 nacos nacos ![](https://img.kancloud.cn/c4/83/c483d4d0aed9a10ed237520c7f7ded6f_1920x791.png) ### 192.168.235.133 * 安裝keepalived ``` yum install -y net-tools psmisc net-snmp ipvsadm keepalived ``` ![](https://img.kancloud.cn/21/ef/21efa6337b6060e0c07194f038d07422_948x438.png) * 安裝killall命令 ``` yum install psmisc -y ``` * 配置執行腳本 vi /etc/keepalived/check_nginx.sh ``` #!/bin/bash count=$(ps -ef |grep nginx |egrep -cv "grep|$$") if [ "$count" -eq 0 ];then killall keepalived fi ``` chmod +x /etc/keepalived/check_nginx.sh * 配置/etc/keepalived/keepalived.conf,vip 192.168.235.135 ``` ! Configuration File for keepalived global_defs { # 陸脫脮始鎂碌脴路 notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } # 脫錄鎂路壟脣碌脴路 notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id NGINX_MASTER } vrrp_script check_nginx { script "/etc/keepalived/check_nginx.sh" } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 51 # VRRP 路脫 ID實脌攏盧每賂枚媒祿碌脛 priority 100 # 脫脧錄露攏盧鹵賂路鎂脦脝脡脰 90 advert_int 1 # 指露簍VRRP 脨脤擄眉盲時錄洌兟 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.235.135/24 } track_script { check_nginx } } ``` * 啟動keepalived ``` service keepalived start service keepalived status ``` ![](https://img.kancloud.cn/63/e5/63e5d61a487da067093baaa1a1c3b518_1447x407.png) * 查看虛擬VIP ![](https://img.kancloud.cn/d6/72/d672034b102d5d4a246ae6421dcd7d9b_1315x341.png) ![](https://img.kancloud.cn/19/d2/19d28d1ea66dc61ba2854249b25f9543_1920x757.png) ### 192.168.235.134 * 安裝keepalived ``` yum install -y net-tools psmisc net-snmp ipvsadm keepalived ``` ![](https://img.kancloud.cn/21/ef/21efa6337b6060e0c07194f038d07422_948x438.png) * 安裝killall命令 ``` yum install psmisc -y ``` * 配置執行腳本 vi /etc/keepalived/check_nginx.sh ``` #!/bin/bash count=$(ps -ef |grep nginx |egrep -cv "grep|$$") if [ "$count" -eq 0 ];then killall keepalived fi ``` chmod +x /etc/keepalived/check_nginx.sh * 配置/etc/keepalived/keepalived.conf,vip 192.168.235.135 ``` ! Configuration File for keepalived global_defs { # 陸脫脮始鎂碌脴路 notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } # 脫錄鎂路壟脣碌脴路 notification_email_from Alexandre.Cassen@firewall.loc smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id NGINX_MASTER } vrrp_script check_nginx { script "/etc/keepalived/check_nginx.sh" } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 51 # VRRP 路脫 ID實脌攏盧每賂枚媒祿碌脛 priority 90 # 脫脧錄露攏盧鹵賂路鎂脦脝脡脰 90 advert_int 1 # 指露簍VRRP 脨脤擄眉盲時錄洌兟 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.235.135/24 } track_script { check_nginx } } ``` * 啟動keepalived ``` service keepalived start service keepalived status ``` ![](https://img.kancloud.cn/63/e5/63e5d61a487da067093baaa1a1c3b518_1447x407.png) * 查看虛擬VIP ![](https://img.kancloud.cn/d6/72/d672034b102d5d4a246ae6421dcd7d9b_1315x341.png) ![](https://img.kancloud.cn/19/d2/19d28d1ea66dc61ba2854249b25f9543_1920x757.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看