您好,登錄后才能下訂單哦!
這篇文章主要介紹“docker-rancher-k8s-rancher環(huán)境怎么搭建”,在日常操作中,相信很多人在docker-rancher-k8s-rancher環(huán)境怎么搭建問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”docker-rancher-k8s-rancher環(huán)境怎么搭建”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
#在已經(jīng)安裝好docker的rancher-mysql節(jié)點操作
#安裝mysql
#安裝mysql客戶端
yum -y install mysql
#創(chuàng)建數(shù)據(jù)庫
mysql -h227.0.0.1 -uroot -p123456 <<-'EOF' create database rancher; EOF
#rancher節(jié)點1下操作,換行別忘記在命令行后面增加空格+\
sudo docker run -d --restart=unless-stopped -p 80:8080
-p 9345:9345 rancher/server:v1.6.26
--db-host (數(shù)據(jù)庫IP)
--db-port (數(shù)據(jù)庫端口)
--db-user (數(shù)據(jù)庫賬戶)
--db-pass (數(shù)據(jù)庫密碼)
--db-name rancher (數(shù)據(jù)庫名稱)
--advertise-address (節(jié)點1內(nèi)網(wǎng)IP)
#rancher節(jié)點2下操作
sudo docker run -d --restart=unless-stopped -p 80:8080
-p 9345:9345 rancher/server:v1.6.26
--db-host (數(shù)據(jù)庫IP)
--db-port (數(shù)據(jù)庫端口)
--db-user (數(shù)據(jù)庫賬戶)
--db-pass (數(shù)據(jù)庫密碼)
--db-name rancher (數(shù)據(jù)庫名稱)
--advertise-address (節(jié)點2內(nèi)網(wǎng)IP)
#rancher-proxy負載節(jié)點下操作
#創(chuàng)建ngx配置
mkdir -p /data/nginx/conf/vhost.d
#創(chuàng)建nginx.conf
tee /data/nginx/conf/nginx.conf <<-'EOF'
#run user
user www www;#run work pro
worker_processes 2;#open file number
worker_rlimit_nofile 65535;#run pid
pid ./nginx.pid;events {
??worker_connections 65535;
??use epoll;
}http {
??include mime.types;
??default_type application/octet-stream;server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; #gzip gzip on; gzip_comp_level 2; gzip_min_length 1024; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; keepalive_timeout 60; resolver 8.8.8.8; access_log off; #vhost site include vhost.d/*.conf;} EOF
#創(chuàng)建[00]0.0.0.0conf
tee /data/nginx/conf/vhost.d/[00]0.0.0.0.conf <<-'EOF'
upstream backend {
??#node server ip
??server rancher-node1的ip;
??server rancher-node2的ip;
}map $http_upgrade $connection_upgrade {
??default Upgrade;
??'' close;
}server {
??listen 80;server_name _; location / { proxy_pass http://backend; # WebScoket Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 900s; #proxy_set_header Origin xxx; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }} EOF
#拉取基礎(chǔ)鏡像
docker pull uhub.service.ucloud.cn/pub_snake/pub_centos_ngx_php:v190307001
#運行容器
docker run --name rancher_proxy -dit
-v /data/nginx/conf/nginx.conf:/data/nginx/conf/nginx.conf
-v /data/nginx/conf/vhost.d/[00]0.0.0.0.conf:/data/nginx/conf/vhost.d/[00]0.0.0.0.conf
-p 80:80
uhub.service.ucloud.cn/pub_snake/pub_centos_ngx_php:v190307001
#進入容器
docker exec -it rancher_proxy /bin/bash
#啟動容器中的ngx,到此不出意外rancher就可以通過rancher-proxy負載服務(wù)的IP直接訪問了
/data/nginx/sbin/nginx -c /data/nginx/conf/nginx.conf
到此,關(guān)于“docker-rancher-k8s-rancher環(huán)境怎么搭建”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。