??手把手教你Camel 環境搭建??《??記得收藏??》
- 目錄
-
😊開講啦!!!!🏳??🌈 - :person_fencing:1、Vagrant 環境
- 😀1.1、Vagrant 是什么
- 😃1.2、Vagrant 能做什么
- 😄 1.3、Vagrant 相關軟體下載
- 😁1.4、Vagrant 配置環境變數(Windows)
- 🍇1.4.1、VirtualBox
- 🍈1.4.2、Vagrant
- 😆1.5、啟動 Vagrant
- 🍇1.5.1、創建 vagrant 環境目錄
- 🍈1.5.2、vagrant box 下載
- 🍉1.5.3、使用 box 方式安裝系統
- 🍊1.5.4、初始化和 Vagrantfile
- 🍋1.5.5、public_network 配置
- 🍌1.5.6、啟動虛擬機
- 😅1.6、使用 ssh 登錄到虛擬機
- :horse_racing:2、camel 環境
- 🤣2.1、admin 端
- 🍇2.1.1、系統初始化和下載 camel
- 🍈2.1.2、安裝 mariadb
- 🍉2.1.3、安裝 mongodb
- 🍊2.1.4、配置 camel-admin 和生成 camel-admin 的 war 包
- 🍋2.1.5、安裝 tomcat
- 🍌2.1.6、安裝 Dengine
- 🍍2.1.7、啟動 Dengine 和 tomcat
- 🥭2.1.8、訪問管理端首頁
- 😂2.2、agent 端(agent1/agent2)
- 🍇2.2.1、系統初始化
- 🍈2.2.2、安裝依賴包
- 🍉2.2.3、安裝 JDK
- 🍊2.2.4、添加 dns
- 🍋2.2.5、運行 camel-agent
- 🍌2.2.6、安裝 tomcat(可選)
- 🍍2.2.7、安裝 Dengine
- 🥭2.2.8、啟動 Dengine
- :woman_playing_handball:3、camel 使用
- 😀3.1、創建 nginx 集群
- 😃3.2、nginx 集群重命名
- 😄3.3、nginx 集群添加節點
- 😁3.4、新增集群
- 😅3.5、集群重命名
- 😆3.6、新增站點
- 🤣3.7、站點命名
- 😂3.8、映射規則
- 🙂3.9、預覽
- 🙃3.10、創建發布版本
- 😉3.11、發布
- 😊3.12、最終發布頁面
- 🏳??🌈關注蘇州程式大白,持續更新技術分享,謝謝大家支持🏳??🌈
- 🏳??🌈關注蘇州程式大白,持續更新技術分享,謝謝大家支持🏳??🌈
目錄
| 😊開講啦!!!!🏳??🌈 |

🤺1、Vagrant 環境
😀1.1、Vagrant 是什么

Vagrant是一款用來構建虛擬開發環境的工具,它底層支持 VirtualBox、VMware 甚至 AWS 作為虛擬機系統,提供易于配置,重復性好,便攜式的作業環境,也可以和 puppet,chef 結合,實作虛擬機管理的自動化,
😃1.2、Vagrant 能做什么
統一開發環境,一次配置打包,統一分發給團隊成員,統一團隊開發環境,解決諸如“編碼問題”,“缺少模塊”,“組態檔不同”帶來的問題;
避免重復搭建開發環境,新員工加入,不用浪費時間搭建開發環境,快速加入開發,減少時間成本的浪費;
多個相互隔離開發環境,可以在不用box里跑不同的語言,或者編譯安裝同一語言不同版本,搭建多個相互隔離的開發環境,卸載清除時也很快捷輕松,
😄 1.3、Vagrant 相關軟體下載
-
下載 vagrant
-
下載 VirtualBox
注意:以下以安裝在 Windows 上為例,VirtualBox 和 Vagrant 不要裝在同一磁區里,Vagrant 默認選項安裝到C盤,
😁1.4、Vagrant 配置環境變數(Windows)
🍇1.4.1、VirtualBox
VirtualBox:將 %VirtualBox_homt% 添加到 Path 中,這樣 Vagrant 才能被識別:
-
變數名:VBOX_MSI_INSTALL_PATH
-
變數值:D:\軟體\VirtualBox(根據自己安裝目錄)




🍈1.4.2、Vagrant
Vagrant:安裝成功后,自動在 Path 中添加 %Vagrant_home%/bin,檢查一下,
-
變數名:Path
-
變數值:…;C:\HashiCorp\Vagrant\bin



😆1.5、啟動 Vagrant
🍇1.5.1、創建 vagrant 環境目錄
進入運行命令模式,創建測驗檔案夾(vagrant 環境所在目錄)

進創建 vagrantdemo 目錄
C:\Users\Administrator>md vagrantdemo
C:\Users\Administrator>cd vagrantdemo
🍈1.5.2、vagrant box 下載
box 是一個zip包,包含了 vagrant 的配置資訊和 VirtualBox 的虛擬機鏡像檔案,
下載 box
🍉1.5.3、使用 box 方式安裝系統
命令格式
vagrant box add "box_name" remoteUrl or localFile
box_name 可以是任意字符,用于標識 box,
使用 remoteUrl(遠程地址)添加 box,
vagrant box add "centos7" https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
這種方式需要即時下載,較慢,建議下載下來 box,在本地添加,
或是使用 localFile(本地 box 檔案)添加 box,
后面加絕對路徑或進入同層目錄,
agrant box add "centos7" CentOS-7.1.1503-x86_64-netboot.box
🍊1.5.4、初始化和 Vagrantfile
vagrant init "box_name"
初始化后會在當前目錄(C:\Users\Administrator\vagrantdemo)生成以一個 Vagrantfile 檔案

Vagrantfile 詳細使用請自行查閱資料或官方檔案,
這里環境使用的 Vagrantfile,可以復制使用,
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define :admin do |admin|
admin.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", "admin", "--memory", "1024"]
end
admin.vm.box = "centos7"
admin.vm.hostname = "camel-admin"
admin.vm.network "public_network"
end
config.vm.define :agent1 do |agent1|
agent1.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", "agent1", "--memory", "512"]
end
agent1.vm.box = "centos7"
agent1.vm.hostname = "agent1"
agent1.vm.network "public_network"
end
config.vm.define :agent2 do |agent2|
agent2.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", "agent2", "--memory", "512"]
end
agent2.vm.box = "centos7"
agent2.vm.hostname = "agent2"
agent2.vm.network "public_network"
end
end
🍋1.5.5、public_network 配置
配置 Virtualbox 網路,使 vagrant 虛擬機獲得本地 dhcp 分發的 ip,


添加 nat 網路

編輯 nat 網路


🍌1.5.6、啟動虛擬機
vagrant up


啟動后會打開 3 臺虛擬機 admin,agent1,agent2,
對應 127.0.0.1 的 2222、2200、2201 埠,
并獲得本地 ip 地址,
😅1.6、使用 ssh 登錄到虛擬機
windows 默認沒有 ssh 命令,可以安裝 babun 或 cmder
使用如下命令連接
C:\Users\Administrator\vagrantdemo>vagrant ssh
下面使用xshell連接,初始賬號密碼都是vagrant
連接 camel-admin
ssh 127.0.0.1 2222
連接后使用 sudo passwd root 修改 root 密碼

使用 ip a 查看獲取到的局域網 dhcp ip

再次登錄
ssh 192.168.1.210 連接 admin
連接 agent1
ssh 127.0.0.1 2200

連接agent2
ssh 127.0.0.1 2201

🏇2、camel 環境
admin 端需要安裝 camel-admin 和 Dengine
agent 端需要安裝 camel-agent 和 Dengine
🤣2.1、admin 端
🍇2.1.1、系統初始化和下載 camel
清除 vagrant 默認防火墻策略
chmod 755 /etc/rc.d/rc.local
echo "/usr/sbin/iptables -F" >> /etc/rc.local
iptables -F
關閉也可以
systemctl stop firewalld
systemctl disable firewalld
依賴包安裝
yum install -y vim unzip maven net-tools git gcc gcc-c++ automake autoconf
libtool make ncurses-devel zlib zlib-devel libtermcap-devel libevent-devel readline-devel patch
下載 camel-master.zip 專案地址
nzip camel-master.zip

🍈2.1.2、安裝 mariadb
yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
mariadb 初始化
mysql -uroot
MariaDB [(none)]> grant all on *.* to root@localhost identified by '123456';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> create database camel;
MariaDB [(none)]> use camel;
MariaDB [(none)]>
source /root/camel-master/camel-admin/src/main/resources/init-data/create_table.sql

🍉2.1.3、安裝 mongodb
下載 mongodb
注意:下載 3.0.7 版本,3.0.7 以上版本有問題最新 3.4.1 啟動報錯
mongodb 初始化
tar zxvf mongodb-linux-x86_64-rhel70-3.0.7.tgz
mv mongodb-linux-x86_64-rhel70-3.0.7 mongodb
cd mongodb
mkdir db logs

cd bin
vim mongodb.conf
dbpath=/root/mongodb/db
logpath=/root/mongodb/logs/mongodb.log
port=27017
fork=true
nohttpinterface=true

啟動 mongodb
/root/mongodb/bin/mongod --bind_ip localhost -f /root/mongodb/bin/mongodb.conf

mongodb 建庫
/root/mongodb/bin/mongo
> use camel_runtime
switched to db camel_runtime
> db.movie.insert({"name":"tutorials yiibai"})
WriteResult({ "nInserted" : 1 })
> use camel_nginx_log
switched to db camel_nginx_log
> db.movie.insert({"name":"tutorials yiibai"})
WriteResult({ "nInserted" : 1 })
> use camel_config
switched to db camel_config
> db.movie.insert({"name":"tutorials yiibai"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
camel_config 0.000GB
camel_nginx_log 0.000GB
camel_runtime 0.000GB
local 0.000GB
> exit

🍊2.1.4、配置 camel-admin 和生成 camel-admin 的 war 包
camel-admin 組態檔修改
grep -r "/data/appdatas/camel/" ./*
./src/main/resources/spring/applicationContext-properties.xml: <value>file:/data/appdatas/camel/jdbc-mysql.properties</value>
./src/main/resources/spring/applicationContext-properties.xml: <value>file:/data/appdatas/camel/mongo.properties</value>
./src/main/resources/spring/applicationContext-properties.xml: <value>file:/data/appdatas/camel/camel.properties</value>

mkdir -p /data/appdatas/camel/
cp /root/camel-master/camel-admin/src/main/resources/init-data/camel.properties /data/appdatas/camel/
vim camel.properties
# threshold of local nginx config check
local.nginx.config.check=true
cp /root/camel-master/camel-admin/src/main/resources/init-data/jdbc-mysql.properties /data/appdatas/camel/
vim /data/appdatas/camel/jdbc-mysql.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.username=root
jdbc.password=123456
jdbc.maxPoolSize=50
jdbc.minPoolSize=1
jdbc.initialPoolSize=1
jdbc.idleConnectionTestPeriod=1800
jdbc.maxIdleTime=3600
jdbc.checkoutTimeout=5000
jdbc.url=jdbc:mysql://127.0.0.1:3306/camel?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&noAccessToProcedureBodies=true&socketTimeout=5000&connectTimeout=5000
紅色camel為之前mariadb新建的資料庫名
cp src/main/resources/init-data/mongo.properties /data/appdatas/camel/
vim /data/appdatas/camel/mongo.properties
mongodb.url=127.0.0.1:27017
mongodb.dbname_config=camel_config
mongodb.dbname_nginx_log=camel_nginx_log
mongodb.dbname_runtime=camel_runtime
isCluster=false
connections-per-host=1800
slave-ok=false
添加 dns
否則后面下載無法決議
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
構建 camel-admin
cd /root/camel-master/camel-admin/
mvn clean compile
時間較長,最后看到 BUILD SUCCESS 構建成功

生成 camel-admin 的 war 包
cd /root/camel-master/camel-admin/
mvn install package -Dmaven.test.skip=true
在 /root/camel-master/camel-admin/target/ 目錄下生成 war 包

🍋2.1.5、安裝 tomcat
這里使用 tomcat7,jdk 在之前 camel-admin 構建程序中已安裝,為 openjdk將之前生成的 camel-admin 的 war 包放到 tomcat 專案目錄,
cp camel-admin-1.0.0.war /opt/apache-tomcat-7.0.59/webapps/
🍌2.1.6、安裝 Dengine
注意:Dengine 默認安裝到 /usr/loca/nginx,安裝 Dengine 之前,洗掉系統中安裝在 /usr/loca/nginx 目錄的 nginx,其他 nginx 不要安裝到 /usr/loca/nginx 目錄
cd /root/camel-master/Dengine/
./install_dengine
權限確認,/usr/local/nginx/conf/phoenix-slb/ 權限 777
chmod 777 /usr/local/nginx/conf/phoenix-slb/
訪問策略配置
vim /usr/local/nginx/conf/nginx_status.conf
req_status_zone server "$host:$server_addr:$server_port" 10M;
check_shm_size 50M;
req_status server;
server {
listen 6666;
server_name aaabbbccc;
location /status {
check_status;
access_log off;
allow 192.168.0.210;
# deny all;
}
location /degrade{
upstream_degrade_interface;
access_log off;
allow 192.168.0.210;
# deny all;
}
location / {
return 444;
}
}
server {
listen 80 default_server;
server_name aaabbbccc;
location /status {
echo "ok";
default_type text/plain;
access_log off;
allow 192.168.0.210;
# deny all;
}
location /reqstatus {
req_status_show;
access_log off;
allow 192.168.0.210;
# deny all;
}
location / {
return 444;
}
error_page 404 403 =444 @static;
location @static{
return 444;
}
}
🍍2.1.7、啟動 Dengine 和 tomcat
啟動 Dengine
/usr/local/nginx/sbin/nginx
開機自啟動
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
啟動 tomcat
cd /opt/apache-tomcat-7.0.59/bin/
./startup.sh
開機自啟動
echo "/opt/apache-tomcat-7.0.59/bin/startup.sh" >> /etc/rc.local
🥭2.1.8、訪問管理端首頁
http://192.168.0.210:8080/camel-admin-1.0.0/

😂2.2、agent 端(agent1/agent2)
🍇2.2.1、系統初始化
清除 vagrant 默認防火墻策略
chmod 755 /etc/rc.d/rc.local
echo "/usr/sbin/iptables -F" >> /etc/rc.local
iptables -F
關閉也可以
systemctl stop firewalld
systemctl disable firewalld
🍈2.2.2、安裝依賴包
yum -y install maven git gcc gcc-c++ automake autoconf libtool make ncurses-devel
zlib zlib-devel libtermcap-devel libevent-devel readline-devel patch
🍉2.2.3、安裝 JDK
yum search java | grep -i --color JDK

yum install java-1.7.0-openjdk
🍊2.2.4、添加 dns
vim /etc/resolv.conf
nameserver 8.8.8.8
🍋2.2.5、運行 camel-agent
cd /root/camel-master/camel-agent
運行 agent
mvn spring-boot:run > /root/camel-agent.out 2>&1 &
生成 war 包(可選)
mvn clean package
可以將 /root/camel-master/camel-agent/target 目錄下生成的 war 包放到 tomcat 工程目錄運行

🍌2.2.6、安裝 tomcat(可選)
注意:如果已經使用 mvn spring-boot:run 方式啟動 agent,跳過此步
這里使用 tomcat7,jdk 為 java-1.7.0-openjdk
將之前生成的 camel-admin 的 war 包放到 tomcat 專案目錄
cp /root/camel-master/camel-agent/target/camel-agent-1.0.0.war /opt/apache-tomcat-7.0.59/webapps/
cd /opt/apache-tomcat-7.0.59/bin
./startup.sh
🍍2.2.7、安裝 Dengine
注意:Dengine 默認安裝到 /usr/loca/nginx,安裝 Dengine 之前,洗掉系統中安裝在 /usr/loca/nginx 目錄的 nginx,其他 nginx 不要安裝到 /usr/loca/nginx 目錄,
cd /root/camel-master/Dengine/
./install_dengine
權限確認,/usr/local/nginx/conf/phoenix-slb/ 權限 777
chmod 777 /usr/local/nginx/conf/phoenix-slb/
訪問策略配置
vim /usr/local/nginx/conf/nginx_status.conf
req_status_zone server "$host:$server_addr:$server_port" 10M;
check_shm_size 50M;
req_status server;
server {
listen 6666;
server_name aaabbbccc;
location /status {
check_status;
access_log off;
allow 192.168.0.210;
# deny all;
}
location /degrade{
upstream_degrade_interface;
access_log off;
allow 192.168.0.210;
# deny all;
}
location / {
return 444;
}
}
server {
listen 80 default_server;
server_name aaabbbccc;
location /status {
echo "ok";
default_type text/plain;
access_log off;
allow 192.168.0.210;
# deny all;
}
location /reqstatus {
req_status_show;
access_log off;
allow 192.168.0.210;
# deny all;
}
location / {
return 444;
}
error_page 404 403 =444 @static;
location @static{
return 444;
}
}
cd /root/camel-master/Dengine/
./install_dengine
🥭2.2.8、啟動 Dengine
啟動 Dengine
/usr/local/nginx/sbin/nginx
開機自啟動
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
開機自啟動 camel-agent
echo " mvn spring-boot:run > /root/camel-agent.out 2>&1 &" >> /etc/rc.local
🤾?♀3、camel 使用
😀3.1、創建 nginx 集群

😃3.2、nginx 集群重命名

😄3.3、nginx 集群添加節點


😁3.4、新增集群

😅3.5、集群重命名



😆3.6、新增站點

🤣3.7、站點命名


😂3.8、映射規則
編輯



詳細

添加新指令



保存

🙂3.9、預覽




🙃3.10、創建發布版本


😉3.11、發布

選擇發布版本

😊3.12、最終發布頁面


🏳??🌈關注蘇州程式大白,持續更新技術分享,謝謝大家支持🏳??🌈

🏳??🌈關注蘇州程式大白,持續更新技術分享,謝謝大家支持🏳??🌈

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/293848.html
標籤:其他
上一篇:Linux安裝Docker
