切换阿里源速度会更快
1.备份原文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.编辑apt源列表文件
sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse12345678910
ps:如果没有vim可以直接删除souces.list 然后echo重写
rm /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" > /etc/apt/sources.list
#安装curl
apt install curl
#安装docker
curl -fsSL https://get.docker.com/ | sh
#查看版本
docker -v
mkdir /home/Dockerfile
cd /home/Dockerfile
vi Dockerfile
Dockerfile:
FROM ubuntu
#sshd
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y openssh-server
RUN apt-get install vim -y
RUN apt-get install net-tools -y
RUN apt-get install lsof -y
RUN mkdir /var/run/sshd
RUN echo 'root:111' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
#jdk1.8
# make a new directory to store the jdk files
RUN mkdir /usr/local/java
ADD jdk-8u261-linux-x64.tar.gz /usr/local/java/
RUN ln -s /usr/local/java/jdk1.8.0_261 /usr/local/java/jdk
ENV JAVA_HOME /usr/local/java/jdk
ENV JRE_HOME ${JAVA_HOME}/jre
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH ${JAVA_HOME}/bin:$PATH
#解决ssh连接后环境变量无效的问题
RUN sed -i '2a export $(cat /proc/1/environ |tr '"'"'\0'"'"' '"'"'\\n'"'"' | xargs)' /etc/profile
#zookeeper
ADD zookeeper-3.4.14.tar.gz /usr/local/
RUN mkdir -p /home/zookeeper/data
RUN mkdir -p /home/zookeeper/log
RUN cp /usr/local/zookeeper-3.4.14/conf/zoo_sample.cfg /usr/local/zookeeper-3.4.14/conf/zoo.cfg
RUN sed -i 's/dataDir=\/tmp\/zookeeper/dataDir=\/home\/zookeeper\/data/' /usr/local/zookeeper-3.4.14/conf/zoo.cfg
RUN sed -i 13a\dataLogDir=/home/zookeeper/log /usr/local/zookeeper-3.4.14/conf/zoo.cfg
RUN sed -i '$aserver.1=172.18.0.11:2888:3888' /usr/local/zookeeper-3.4.14/conf/zoo.cfg
RUN sed -i '$aserver.2=172.18.0.12:2888:3888' /usr/local/zookeeper-3.4.14/conf/zoo.cfg
RUN sed -i '$aserver.3=172.18.0.13:2888:3888' /usr/local/zookeeper-3.4.14/conf/zoo.cfg
RUN cd /home/zookeeper/data;echo 1 >>myid
#solr
ADD solr-6.6.0.tgz /usr/local/
RUN mkdir -p /usr/local/solrCloud/solr_cloud_home
RUN cp -r /usr/local/solr-6.6.0/server/solr/* /usr/local/solrCloud/solr_cloud_home/
RUN mkdir -p /usr/local/solrCloud/solr_cloud_collection/cloud_core;cp -r /usr/local/solr-6.6.0/example/example-DIH/solr/solr/* /usr/local/solrCloud/solr_cloud_collection/cloud_core/
#ik分词器
COPY ik-analyzer-solr5-5.4.0.jar /usr/local/solr-6.6.0/server/solr-webapp/webapp/WEB-INF/lib/
RUN mkdir -p /usr/local/solr-6.6.0/server/solr-webapp/webapp/WEB-INF/classes
COPY ext.dic /usr/local/solr-6.6.0/server/solr-webapp/webapp/WEB-INF/classes/
COPY IKAnalyzer.cfg.xml /usr/local/solr-6.6.0/server/solr-webapp/webapp/WEB-INF/classes/
COPY stopword.dic /usr/local/solr-6.6.0/server/solr-webapp/webapp/WEB-INF/classes/
ENV NOTVISIBLE "in users profile"
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
下载地址
http://archive.apache.org/dist/lucene/solr/6.6.0/solr-6.6.0.tgz
http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
docker build -t solr .
vi /etc/hosts
172.18.0.11 server1
172.18.0.12 server2
172.18.0.13 server3
docker network create --subnet=172.18.0.0/16 search_network
docker run -d --name server1 --net search_network --ip 172.18.0.11 -p 22 solr /usr/sbin/sshd -D
docker run -d --name server2 --net search_network --ip 172.18.0.12 -p 22 solr /usr/sbin/sshd -D
docker run -d --name server3 --net search_network --ip 172.18.0.13 -p 22 solr /usr/sbin/sshd -D
合并命令
docker run -d --name server1 --net search_network --ip 172.18.0.11 -p 22 solr /usr/sbin/sshd -D;docker run -d --name server2 --net search_network --ip 172.18.0.12 -p 22 solr /usr/sbin/sshd -D;docker run -d --name server3 --net search_network --ip 172.18.0.13 -p 22 solr /usr/sbin/sshd -D
#提示输入密码,默认都是3个1
ssh server1
#进入自建zookeeper的data文件夹
cd /home/zookeeper/data
#进行编辑id
vi myid
ssh server1
/usr/local/zookeeper-3.4.14/bin/zkServer.sh start
ssh server1
/usr/local/solr-6.6.0/bin/solr start -cloud -p 8983 -s "/usr/local/solrCloud/solr_cloud_home/" -z "172.18.0.11:2181,172.18.0.12:2181,172.18.0.13:2181" -force
访问http://172.18.0.11:8983/solr,启动成功即下图
ssh server1
/usr/local/solr-6.6.0/bin/solr create_collection -c cloudsuite_web_search -shards 3 -replicationFactor 3 -d /usr/local/solrCloud/solr_cloud_collection/cloud_core/conf -p 8983 -force
继续访问http://172.18.0.11:8983/solr,点开cloud即可出现集群图
修改schema
vim /usr/local/solr-6.6.0/example/example-DIH/solr/solr/conf/managed-schema
重启容器
docker restart server1