标签:pull lis 几分钟 deb 建议 tps 安装 version dock
upstream tomcats {
server ctc1:8080 weight=2; # 主机名:端口号,tomcat默认端口号8080,默认使用轮询策略
server ctc2:8080 weight=3;
server ctc3:8080 weight=4;
}
server {
listen 2420;
server_name localhost;
location / {
proxy_pass http://tomcats;# 请求转向tomcats
}
}
version: "3.8"
services:
nginx:
image: nginx
container_name: cngx
ports:
- 80:2420
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf # 挂载配置文件
depends_on:
- tomcat1
- tomcat2
- tomcat3
tomcat1:
image: tomcat
container_name: ctc1
volumes:
- ./tomcat1:/usr/local/tomcat/webapps/ROOT # 挂载web目录
tomcat2:
image: tomcat
container_name: ctc2
volumes:
- ./tomcat2:/usr/local/tomcat/webapps/ROOT
tomcat3:
image: tomcat
container_name: ctc3
volumes:
- ./tomcat3:/usr/local/tomcat/webapps/ROOT
import requests
url="http://localhost"
for i in range(0,10):
reponse=requests.get(url)
print(reponse.text)
//编写完以后用python3 文件名进行测试
多次刷新也可以出结果
upstream tomcats {
server ctc1:8080 weight=2; # 主机名:端口号,tomcat默认端口号8080,默认使用轮询策略
server ctc2:8080 weight=3;
server ctc3:8080 weight=4;
}
server {
listen 2420;
server_name localhost;
location / {
proxy_pass http://tomcats; # 请求转向tomcats
}
}
用程序测试
import requests
url="http://localhost"
context={}
for i in range(0,100):
response=requests.get(url)
if response.text in context:
context[response.text]+=1
else:
context[response.text]=1
print(context)
//编写完以后用python3 文件名进行测试
测试结果里返回的结果和配置文件里的权重比值2:3:4基本一致
docker pull ubuntu
mkdir ~/build
sudo docker run -it -v /home/kingbob/build:/root/build --name ubuntu ubuntu
cat<<EOF>/etc/apt/sources.list #覆盖掉原先内容,注意左边只有一个>,<<EOF>是覆盖;<<EOF>>则变成追加
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
EOF
apt-get update
apt-get install vim # 安装vim软件
apt-get install ssh # 安装sshd,因为在开启分布式Hadoop时,需要用到ssh连接slave:
/etc/init.d/ssh start # 运行脚本即可开启sshd服务器
vim ~/.bashrc
/etc/init.d/ssh start # 在该文件中最后一行添加如下内容,实现进入Ubuntu系统时,都能自动启动sshd服务
ssh-keygen -t rsa # 一直按回车即可
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
apt-get install openjdk-8-jdk
vim ~/.bashrc # 在文件末尾添加以下两行,配置Java环境变量:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc # 使.bashrc生效
#另开一个终端
sudo docker commit 容器id ubuntu:jdk8 #讲其保存说明是jkd8版本的ubuntu
sudo docker run -it -v /home/kingbob/build:/root/build --name ubuntu-jdk8 ubuntu:jdk8
#开启保存的那份镜像ubuntu:jdk8
cd /root/build
tar -zxvf hadoop-3.1.3.tar.gz -C /usr/local #因为做过大数据实验,所以直接拷贝hadoop的压缩包到build文件夹里
cd /usr/local/hadoop-3.1.3
./bin/hadoop version # 验证安装
cd /usr/local/hadoop-3.1.3/etc/hadoop #进入配置文件存放目录
vim hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ # 在任意位置添加
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/local/hadoop-3.1.3/tmp</value>
<description>A base for other temporary derectories.</description>
</property>
</configuration>
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/hadoop-3.1.3/tmp/dfs/name</value>
</property>
<property>
<name>dfs.namenode.data.dir</name>
<value>file:/usr/local/hadoop-3.1.3/tmp/dfs/data</value>
</property>
</configuration>
<configuration>
<property>
<!--使用yarn运行MapReduce程序-->
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<!--jobhistory地址host:port-->
<name>mapreduce.jobhistory.address</name>
<value>master:10020</value>
</property>
<property>
<!--jobhistory的web地址host:port-->
<name>mapreduce.jobhistory.webapp.address</name>
<value>master:19888</value>
</property>
<property>
<!--指定MR应用程序的类路径-->
<name>mapreduce.application.classpath</name>
<value>/usr/local/hadoop-3.1.3/share/hadoop/mapreduce/lib/*,/usr/local/hadoop-3.1.3/share/hadoop/mapreduce/*</value>
</property>
</configuration>
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>2.5</value>
</property>
</configuration>
cd /usr/local/hadoop-3.1.3/sbin
HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
sudo docker commit 容器id ubuntu/hadoopinstalled
# 以下三条对应三个终端
sudo docker run -it -h master --name master ubuntu/hadoopinstalled
sudo docker run -it -h slave01 --name slave01 ubuntu/hadoopinstalled
sudo docker run -it -h slave02 --name slave02 ubuntu/hadoopinstalled
ssh slave
exit
vim /usr/local/hadoop-3.1.3/etc/hadoop/workers
slave01
slave02
cd /usr/local/hadoop-3.1.3
bin/hdfs namenode -format #首次启动Hadoop需要格式化
sbin/start-all.sh #启动所有服务
bin/hdfs dfs -mkdir /user
bin/hdfs dfs -mkdir /user/root #注意input文件夹是在root目录下
bin/hdfs dfs -mkdir input
bin/hadoop jar /usr/local/hadoop-3.1.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount input output
./bin/hdfs dfs -cat output/*
sbin/stop-all.sh
标签:pull lis 几分钟 deb 建议 tps 安装 version dock
原文地址:https://www.cnblogs.com/fzuzb/p/12897951.html