02 、Solr7.3.1 在Win10平台下使用Tomcat9的部署及配置

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq279862451/article/details/80675596

solr7在tomcat上的部署

关于solr的下载及其目录介绍请参考上一篇博客----Solr7.3.1 在Win10平台下使用jetty的部署及配置

 solr6.x以上都需要JDK1.8以上版本。这里使用JDK1.8+tomcat9+solr7.x部署。

①准备环境:安装JDK1.8,tomcat9
②将solr-7.3.1/server/solr-webapp/下的webapp复制到tomcat-9.0.8-windows-x64/webapps/下并且重命名(可以随意命名),这里命名为solr。


③复制solr-7.3.1/server/lib/ext下的所有jar,到apache-tomcat9/webapps/solr/WEB-INF/lib/下。(没错,这个就是那个重命名solr下的WEB-INF/lib)

④复制solr-7.3.1/server/lib/下metrics相关的jar,到apache-tomcat9/webapps/solr/WEB-INF/lib/下。

⑤复制solr-7.3.1/server/resources下的log4j.properties文件,
到apache-tomcat9/webapps/solr/WEB-INF/下的classes文件夹中。(classes文件夹如果没有需要自己创建,这是日志文件)
⑥创建solrhome:复制solr-7.3.1/server/下的solr文件夹
到任意目录处(可以重新命名,这里重命名为solr-home,笔者solrhome路径为:D:\WorkEnv\solr-home),自定义solr-home。

⑦配置solrhome路径:修改apache-tomcat9/webapps/solr/WEB-INF/下的web.xml文件。
    <!-- 方法1:默认代码为注释状态。放开之后,替换<env-entry-value></env-entry-value>中间的值为自己的solrhome -->
    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>D:\WorkEnv\solr-home</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

    <!--
     方法2:
     修改tomcat的配置文件, 在apache-tomcat9/bin/catalina.bat文件中的第二行加配置参数。也就是@echo off下面一行。

    set "JAVA_OPTS=-Dsolr.solr.home=D:\WorkEnv\solr-home

⑧取消权限控制,注释web.xml中的最后几行代码。否则项目会包403.


⑨初始化solr-home的数据,在solr-home文件下建一个目录,命名为solrcore1(名字随意取)
复制solr7.3.1/server/solr/configsets/_default/下的conf文件夹,到新建的solrcore1下

在solrcore1下创建文件夹data(空文件加即可)和core.properties(内容只配置name=solrcore1即可,这里的name的值也就是再页面要显示的solr-home名称)


⑩启动tomcat


⑾访问http://localhost:8080/solr/index.html

中文分词器的配置同上。

展开阅读全文

多核平台下的代码优化。

10-21

以下是一段C#代码,主要功能客户端不停的发数据。在服务器端进行侦听,然后把接收到的数据保存。如果在多核的平台下如何对以下的代码段进行优化呢?或者如果提高服务器端接收数据的数量呢?rn客户端代码:rnusing System;rnusing System.Collections.Generic;rnusing System.Text;rnusing System.IO;rnusing System.Net.Sockets;rnusing System.Net;rnnamespace SenderApprnrn class Programrn rn private static int portnum = 10000;rn private static string host = "localhost";rn static void Main(string[] args)rn rn Console.WriteLine("Send data");rn //#region Mainrn //for (int i = 0; i < 1000; i++)rn //rn // Work();rn //rn //#endregionrn portnum = int.Parse(System.Configuration.ConfigurationManager.AppSettings["port"]);rn host = System.Configuration.ConfigurationManager.AppSettings["host"];rn Work();rn Console.Read();rn rn static void Work()rn rn rnrn string returndata="";rn int errorcount = 0;rn dorn rn if (errorcount > 3)rn break;rn tryrn rn TcpClient tcpclient = new TcpClient();rn tcpclient.Connect(host, portnum);rn NetworkStream networkstream = tcpclient.GetStream();rn if (networkstream.CanWrite && networkstream.CanRead)rn rn returndata = "";rn Random r = new Random();rn StringBuilder sb = new StringBuilder();rn sb.Append(r.Next(10));rn sb.Append(",");rn sb.Append(r.Next(10));rn sb.Append(",");rn sb.Append(r.Next(100));rn string datatosend = sb.ToString();rnrn Byte[] sendbytes = Encoding.ASCII.GetBytes(datatosend);rn networkstream.Write(sendbytes, 0, sendbytes.Length);rn // Reads the networkstream into byte buffer.rn byte[] bytes = new byte[tcpclient.ReceiveBufferSize];rn int bytesread = networkstream.Read(bytes,0,(int)tcpclient.ReceiveBufferSize);rn //Returns the data received from the host to the console.rn returndata = Encoding.ASCII.GetString(bytes, 0, bytesread);rn //Console.WriteLine("Host returned to you : \r\n0", returndata);rn networkstream.Close();rn tcpclient.Close();rn rn else if (!networkstream.CanRead)rn rn Console.WriteLine("You can not write data to this stream");rn tcpclient.Close();rn rn else if (!networkstream.CanWrite)rn rn Console.WriteLine("You can not read data from this stream");rn tcpclient.Close();rn rn rn catch (SocketException)rn rn Console.WriteLine("Server not available.");rn errorcount++;rn rn catch (System.IO.IOException)rn rn Console.WriteLine("Server not available.");rn errorcount++;rn rn catch (Exception e)rn rn Console.WriteLine(e.ToString());rn errorcount++;rn rn rn while (returndata == "OK");rn rn rn rnrn服务器端代码:rnusing System;rnusing System.Text;rnusing System.IO;rnusing System.Net;rnusing System.Net.Sockets;rnusing System.Threading;rnrnrnnamespace ServerClientrnrn class Programrn rn rn static void Main()rn   rnrn Thread thread = new Thread(new ThreadStart(Run));rn thread.Start();rn rnrn public static void Run()rn rn Console.WriteLine("Wait for connect");rn int port = 10000;rn IPEndPoint ipe = new IPEndPoint(IPAddress.Any, port);//IPEndPoint将网络端点表示为 IP 地址和端口号。rn Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//创建一个Socket类rn s.Bind(ipe);rn rn string sendStr = "OK";rnrn while (true)rn rn tryrn rn s.Listen(10000);//开始监听rn Socket temp = s.Accept();//为新建连接创建新的Socket。rnrn System.Net.IPAddress addr;rn // 获得本机局域网IP地址rn addr = new System.Net.IPAddress(Dns.GetHostByName(Dns.GetHostName()).AddressList[0].Address);rnrn string recvStr = "";rn byte[] recvBytes = new byte[1024];rn int bytes;rnrnrn bytes = temp.Receive(recvBytes, recvBytes.Length, 0);//从客户端接受信息rn recvStr = recvStr + addr + " ";rn string dt = DateTime.Now.ToString() + " ";rn recvStr = recvStr + dt;rn recvStr += Encoding.ASCII.GetString(recvBytes, 0, bytes);rn //Console.WriteLine("Server Get Message:0",recvStr);//把客户端传来的信息显示出来rnrnrn WriteField(recvStr);rnrn byte[] bs = Encoding.ASCII.GetBytes(sendStr);rn temp.Send(bs,bs.Length,0);//返回客户端成功信息rnrn rn catch (ArgumentNullException e)rn rn Console.WriteLine("ArgumentNullException: 0", e);rnrn rn catch (SocketException e)rn rn Console.WriteLine("SocketException: 0", e);rn rn rn rnrn #region 保存接收到的信息rn private static void WriteField(string strInfo)rn rn string filename = "file.txt";rn StreamWriter sw;rn if (File.Exists(filename))rn rn sw = File.AppendText(filename);rn rn elsern rn sw = File.CreateText(filename);rn rn sw.WriteLine(strInfo);rn sw.Close();rn rn #endregionrn rnrnrn请高手指点! 论坛

没有更多推荐了,返回首页