01_安装负载均衡器
<p>负载均衡器最好也部署成高可用(主/备),可参考本文中的nginx高可用部分内容
<a href="https://cloud.tencent.com/developer/article/1633991">https://cloud.tencent.com/developer/article/1633991</a></p>
<h1>1.配置 nginx官方的 Yum 源</h1>
<p>负载均衡需要stream模块,所以本次安装最新1.18版本nginx</p>
<pre><code class="language-bash">vim /etc/yum.repos.d/nginx.repo</code></pre>
<p>添加如下内容:</p>
<pre><code class="language-bash">[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1</code></pre>
<h1>2.安装最新 nignx</h1>
<pre><code class="language-bash">yum -y install nginx</code></pre>
<h1>3.配置 nginx</h1>
<pre><code class="language-bash">[root@rancher-slb ~]# cd /etc/nginx
[root@rancher-slb ~]# rm -rf conf.d
[root@rancher-slb ~]# mv nginx.conf nginx.conf.bak</code></pre>
<p>创建nginx.conf</p>
<pre><code class="language-bash">[root@rancher-slb ~]# vim /etc/nginx/nginx.conf</code></pre>
<p>把下面内容加入</p>
<pre><code class="language-bash">worker_processes 4;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
stream {
upstream rancher_servers_http {
least_conn;
server 172.16.7.201:80 max_fails=3 fail_timeout=5s;
server 172.16.7.202:80 max_fails=3 fail_timeout=5s;
server 172.16.7.203:80 max_fails=3 fail_timeout=5s;
}
server {
listen 80;
proxy_pass rancher_servers_http;
}
upstream rancher_servers_https {
least_conn;
server 172.16.7.201:443 max_fails=3 fail_timeout=5s;
server 172.16.7.202:443 max_fails=3 fail_timeout=5s;
server 172.16.7.203:443 max_fails=3 fail_timeout=5s;
}
server {
listen 443;
proxy_pass rancher_servers_https;
}
}</code></pre>
<h1>4.启动 nginx</h1>
<pre><code class="language-bash">systemctl start nginx && systemtl enable nginx</code></pre>
<h1>5.打开防火墙端口</h1>
<pre><code class="language-bash">80/443</code></pre>
<p>----------------------其它,下面内容不需要安装---------------------------------------------</p>
<h1>1、在nginx机器安装helm</h1>
<h2>1.1 helm安装包下载</h2>
<p><a href="https://github.com/helm/helm/releases">https://github.com/helm/helm/releases</a>
在页的Installation and Upgrading下(如图),复制下载链接或直接点击下载
<a href="https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz">https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz</a>
<img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/c73f976c3b60f497829f3dbeb4e95d06?showdoc=.jpg" alt="" /></p>
<h2>1.2 在线下载并安装</h2>
<pre><code class="language-bash">[root@rancher0 ~]# wget https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz \
&& tar xf helm-v3.0.3-linux-amd64.tar.gz \
&& cd linux-amd64 \
&& mv helm /usr/sbin/</code></pre>