白日依山尽,黄河入海流。欲穷千里目,更上一层楼。 -- 唐·王之涣

Centos7下安装Solr服务和Solr基本用法

Requirements

1
2
3
4
root@pts/6 $ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

refer to solr system requirements

Installation solr

这篇主要是以单实例Solr为说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# download new version 
wget https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.3.0/solr-6.3.0.zip

# init directory about solr
# separate installation folder and data folder
mkdir /TestDisk/solrtest/{installation,data}

# installation
root@pts/6 $ solr-6.3.0/bin/install_solr_service.sh solr-6.3.0.zip \
-d /TestDisk/solrtest/data/ -i /TestDisk/solrtest/installation \
-p 8985 -s lcsolr

Extracting solr-6.3.0.zip to /TestDisk/solrtest/installation


Installing symlink /TestDisk/solrtest/installation/lcsolr -> /TestDisk/solrtest/installation/solr-6.3.0 ...


Installing /etc/init.d/lcsolr script ...


Installing /etc/default/lcsolr.in.sh ...

Service lcsolr installed.
Customize Solr startup configuration in /etc/default/lcsolr.in.sh
Waiting up to 180 seconds to see Solr running on port 8985 [\]
Started Solr server on port 8985 (pid=17625). Happy searching!


Found 1 Solr nodes:

Solr process 17625 running on port 8985
{
"solr_home":"/TestDisk/solrtest/data/data",
"version":"6.3.0 a66a44513ee8191e25b477372094bfa846450316 - shalin - 2016-11-02 19:52:42",
"startTime":"2016-12-26T11:35:08.023Z",
"uptime":"0 days, 0 hours, 0 minutes, 8 seconds",
"memory":"84 MB (%17.1) of 490.7 MB"}

install_solr_service.sh 参数说明:

安装脚本自身必须是root运行才行

  • -d solr数据数据目录,比如存放logs,pid文件,core目录等等。默认在/var/solr
  • -i solr程序安装目录,默认在/opt。安装目录必须先创建好。
  • -p 执行solr绑定的端口,默认是8983端口。
  • -s solr服务的名称,默认是solr。可以指定别的,比如上面的 lcsolr
  • -u solr服务运行或者solr文件拥有者的用户,默认是solr。也只可以指定别的,如果指定的不存在怎会先创建相关用户
  • -n solr安装完毕之后不启动solr服务

如果对于安装的时候参数不熟悉导致的Joke就像 这个错误

solr实际启动之后的主界面如图

solr-index-page.png

Solr basic usage

create core

创建Core的时候建议用命令行来创建,这样会更方便。

因为web界面创建Core,默认要求 installdirdatadir 要必须先存在,而且 要求 solrconfig.xml也必须能被找到。

语法:

## 因为我使用了不用的端口,所以这里加上-p
bin/solr create -c james [-p 8985] 

举例:

1
2
3
4
5
6
7
8
9
10
11
12
13
root@pts/6 $ su - solr -c '/TestDisk/solrtest/installation/lcsolr/bin/solr create -c james -p 8985'

Copying configuration to new core instance directory:
/TestDisk/solrtest/data/data/james

Creating new core 'james' using command:
http://localhost:8985/solr/admin/cores?action=CREATE&name=james&instanceDir=james

{
"responseHeader":{
"status":0,
"QTime":2119},
"core":"james"}

结果如下:
solr-core.png

core详情页
solr-core-index.png

下面的例子只给出具体的命令,不做截图展示

另外给出来的URL可以在浏览器中执行,也可以在命令行用如下的方式

curl certain-url

select from core

http://192.168.100.2:8985/solr/james/select?q=id:2031961177&wt=json&indent=true

delete one record from core

http://192.168.100.2:8985/solr/james/update/?stream.body=<delete><id>2031961722</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

truncate core

http://192.168.100.2:8985/solr/james/update/?stream.body=<delete><query>*:*</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

公众号: DailyJobOps DailyJobOps

Linux 下修改或者重命名用户名称或者UID/GID

摘要

在Linux操作系统下怎么样用命令行去修改用户的名称(也就是重命名),或者UID/GID
切记不要手动用vi之类的文本编辑器去修改 /etc/passwd 文件

修改用户名称

Usage:

usermod -l login-name old-name

修改用户的名称 old-name 改成 login-name,别的都没有改变。其实我们也应该考虑是否把用户的HOME目录也改成新的用户。

另外这里有个问题需要注意

阅读更多

Centos命令系列 之 screen

摘要

作为运维人员经常会遇到等到远程主机的链接因为网络原因或者别的其他不可抗拒的原因断掉,此时远程为执行完成的命令也会断掉而导致很多任务需要重新执行。

这给大家介绍一个在这种情况下很好用的命令 screen,具体好用在那里,下面具体介绍,包括从其安装到配置到使用

What to do

在正式介绍之前,先给大家介绍下 screen 都能做什么事情

  • 通过一个SSH session使用多个shell窗口
  • 即使网络断开链接也能保持shell窗口处理激活状态
  • 可以在任何地方断开或者重连同一个shell session
  • 不用为了跑一个耗时的任务而长时间保持几个shell session处于激活状态
阅读更多

SHELL输出颜色和闪烁控制

Shell 颜色和闪烁控制

在Shell下有时候需要定制输出,比如给输出加上颜色,或者显示高亮,或者添加闪烁等。
然后这些颜色代码或者控制码等相对不好记住。这个时候我们可以考虑把最终想要的结果制定成对应的函数,
在使用的时候直接调用函数会方便很多

格式

echo -e "\033[字背景颜色;字体颜色m字符串\033[控制码"
阅读更多

gitlab报错 - RPC failed

导语

部门使用的代码管理仓库是gitlab,随着业务发展,代码量也越来越大,到目前已经大于100M,今天新入职员工全量拉取代码时候报错,查找原因是因为代码仓库太大导致拉取超时。 这里记录下处理过程


报错

fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; result=18, HTTP code = 200

解决

因为这边使用的docker搭建的gitlab,处理方式有点不同
必须先进入到gitlab容器中去操作,重启 gitlab 也必须是进入到docker 容器中重启,
否则从服务器直接重启容器会导致配置丢失,恢复成默认值

nginx client_max_body_size

之前修改过gitlab前端nginx的 client_max_body_size 大小,确保上传下载超大文件的可能性

vi /etc/nginx/nginx.conf
client_max_body_size 50M;

## check and reload nginx config
nginx -t
nginx -s reload

gitlab timeout

## need to enter gitlab container firstly
## then edit the config
vi config/unicorn.rb
timeout 300

## then restart gitlab in container
## remember that must be in container
/etc/init.d/gitlab restart

git http.postBuffer

另外建议也修改下本地 http.postBuffer 参数

## modify in commandline 
git config --global http.postBuffer 524288000

## check config list 
git config --list

最后重新拉取,没有问题


公众号: DailyJobOps DailyJobOps

Nginx - Centos下Nginx报错集合

整理Centos系统下Nginx遇到的问题,一遍后续排查问题方便


[emerg] could not build the server_names_hash…

开始使用nginx只有一个虚拟主机,默认server_name 会使用 localhost, 今天配置nginx的server_name是一个正式存在的域名的时候,报错如下:

root@pts/0 $ nginx -t
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed

How to fix

在nginx的配置文件nginx.conf的http段添加如下配置:

# vi /etc/nginx/nginx.conf
...
http {
        ...
        server_names_hash_max_size 512;
        server_names_hash_bucket_size 128;
        ...
}
...

root@pts/0 $ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

nginx官方对server_name的说明请参考 链接

公众号: DailyJobOps DailyJobOps

Octpress加速

Issue

When visit my own Octpress blog via github(opscolin.github.io), it visited very slow.
And after commont some google related setting in _config.yml, it's still very slow

Method

Except modify _config.yml to commont some google related setting, there still have some font cache and ajax script.

M1

replace with some replaced-source like 360 lib
1, source/_includes/head.html
    ajax.googleapis.com ---> userso.com
2, source/_includes/custom/head.html
    fonts.googleapis.com ---> userso.com

M2

refer to http://www.chanjar.me/blog/2014/06/29/jia-kuai-octopressguo-nei-fang-wen-su-du/

公众号: DailyJobOps DailyJobOps