1.環境準備の指示
1.1 Centosマシンを準備して、メモリを大きくする必要があります(3G、できれば4Gを指定しました)。centos7をインストールした後、ファイアウォールをオフにします。
1.2 Nacosクラスターのインストール、必要なソフトウェアとバージョンの説明
- jdk 1.8.0_231
jdkインストールリファレンス私のブログ:Centosサーバーにjdkをインストールする - ドッキングウィンドウの
ドッキングウィンドウのインストール参照:Centos7にドッカーをインストールするMySQLのは、我々がドッキングウィンドウのインストール方法を使用しているためドッカーがインストールされている理由があります - mysql 5.7
mysqlインストールリファレンス:Dockerを使用してmysql5.7、tomcatをcentosでインストールします - nacosnacos-サーバー-1.1.4
- nginx nginx-1.9.9
Nacosインストールパッケージnacos-server-1.1.4.tar.gzのネットディスクアドレス:
リンク:https
://pan.baidu.com/s/169t6yg6rmCWMqewy9zaYnQ抽出コード:d72u
nginx-1.9.9のダウンロードアドレス:http://nginx.org/download/nginx-1.9.9.tar.gz
2.Nacosクラスターのインストール
2.1 jdk、mysql、dockerはここではもはや言葉ではなく、まっすぐ進んでください
2.2nacosクラスターのインストール
2.2.1 / usr / local /ディレクトリに移動し、nacos-server-1.1.4.tar.gzをこのディレクトリにアップロードして解凍し、フォルダnacosの名前をnacos01に変更します。
# 进入到/usr/local/目录
cd /usr/local
# 解压
tar -zxvf nacos-server-1.1.4.tar.gz
# 重命名
mv nacos nacos01
次に、解凍して名前を変更すると、nacos01、nacos02、nacos03の3つのnacosディレクトリがあります。
2.2.2nacosの構成ファイルcluster.confを変更します
ディレクトリ/ usr / local / nacos01 / conf /を入力し、cluster.conf.exampleファイルをコピーして、名前をcluster.confに変更します。
# 拷贝一份,重命名为cluster.conf
cp cluster.conf.example cluster.conf
# 编辑文件
vi cluster.conf
次のコンテンツ(各nacosのIPとポート)を追加します。
192.168.1.6:8847
192.168.1.6:8848
192.168.1.6:8849
2.2.3nacosの構成ファイルapplication.propertiesを変更します
変更1:server.port = 8847(ポートを対応するポートに
変更)変更2は、次のコンテンツを追加します。
#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false
### Specify local server's IP:
nacos.inetutils.ip-address=192.168.1.6
#*************** 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.1.6:3306/nacos_config?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=round&useSSL=false&serverTimezone=GMT%2B8
db.user=root
db.password=123456
Nacos02とnacos03は上記のように動作します。nacos02とnacos03に対応するポートが異なることに注意してください。
2.2.4上記の変更が完了したら、nacos01、nacos02、nacos03を順番に起動します。
# 进入到bin目录
/usr/local/nacos01/bin/
# 启动nacos
./startup.sh
2.3nginxのインストール
2.3.1nginxインストール前の準備
次の依存関係をインストールする必要があります
yum -y install wget
yum -y install gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
2.3.2 nginx-1.9.9.tar.gzをダウンロードし、解凍し、インストールします
# 下载安装包
wget http://nginx.org/download/nginx-1.9.9.tar.gz
# 解压
tar -zxvf nginx-1.9.9.tar.gz
# 进入到/usr/local/nginx-1.9.9/目录
cd /usr/local/nginx-1.9.9/
# 执行下面三个命令安装
./configure
make
make install
2.3.3nginx構成ファイル/usr/local/nginx/conf/nginx.confを変更します
# 编辑
vi /usr/local/nginx/conf/nginx.conf
変更1:次のコンテンツを追加します。
upstream nacos {
server 192.168.1.6:8847;
server 192.168.1.6:8848;
server 192.168.1.6:8849;
}
変更2:次のコンテンツを追加します。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://nacos;
2.3.3nginxを起動します
# 进入到/usr/local/nginx/sbin/目录
cd /usr/local/nginx/sbin/
# 启动nginx
./nginx
# 查看nginx状态
ps -ef | grep nginx