当前位置: 首页 > news >正文

日本 男女做网站网站访问量

日本 男女做网站,网站访问量,杭州百度推广电话,建筑英才网app官方版系列文章目录 rpmbuild从入门到放弃 search-guard插件使用入门手册 文章目录 系列文章目录前言一、资源准备二、spec文件1.基础信息2.%prep3.%Install4.%file5.%post6.%postun 三、成果演示1.执行构建过程图示例2.执行安装RPM包示例3.进程检查4.访问esApi 总结 前言 不管是源…

系列文章目录

rpmbuild从入门到放弃
search-guard插件使用入门手册


文章目录

  • 系列文章目录
  • 前言
  • 一、资源准备
  • 二、spec文件
    • 1.基础信息
    • 2.%prep
    • 3.%Install
    • 4.%file
    • 5.%post
    • 6.%postun
  • 三、成果演示
    • 1.执行构建过程图示例
    • 2.执行安装RPM包示例
    • 3.进程检查
    • 4.访问esApi
  • 总结


前言

不管是源码安装elasticsearch还是通过elastic官网的rpm包进行安装,在安装完成后都需要进行手动配置elastic的安全认证,这样不管从安装效率还是维护都比较麻烦,为了让安装和开启鉴权一起完成,本篇文章就使用rpmbuild自行构建elasticsearch-7.14.2的RPM包,安全认证插件使用的是search-guard,具体构建方式看下方文章即可。阅读下方文章前,请先阅读顶部的两章链接文件,先对整体知识有个大体上的了解。


提示:已在本地centos 7环境执行过构建测试、安装、使用流程,目前未发现异常

一、资源准备

	1、rpmbuild工具安装此处不再描述,详情查看顶部文章链接即可
	2、下载elasticsearch-7.14.2的tar包[root@python2 SOURCES]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.2-linux-x86_64.tar.gz
	3、下载elasticsearch版本对应的search-guard插件[root@python2 SOURCES]# wget https://maven.search-guard.com/search-guard-suite-release/com/floragunn/search-guard-suite-plugin/7.14.2-52.3.0/search-guard-suite-plugin-7.14.2-52.3.0.zip[root@python2 SOURCES]# https://docs.search-guard.com/latest/search-guard-installation

至此源码包准备完成,下面开始编写spec文件

二、spec文件

1.基础信息

文件如下(示例):

#自定义宏,相当于Linux中"Key-Value"变量形式
#--->名称
%define Name elasticsearch
#--->版本
%define Version 7.14.2
#--->本rpm包中需更换的配置文件#--->本rpm包默认安装的路径
%define InstallPath /export/server/elasticsearch-7.14.2
#-->rpm包封装进去的脚本
%define configYaml elasticsearch.yml
%define search_guard  search-guard-suite-plugin-7.14.2-52.3.0.zip
%define search_tlstools search-guard-tlstool-1.7.tar.gz
%define __spec_install_post %{nil}
%define _build_id_links none
# 软件包的名称 
Name: %{Name}
# 软件包的版本 
Version: %{Version}
# 软件包发布序列号,1表示第几次打包 %{?dist} 会再包名中添加操作系统系统
Release: 1
# 软件包的概要信息,不要超过50个 
# 软件授权方式 
License: BSD# 软件分类
Group: System Middleware
# 源代码软件包的官方地址或源码包的下载地址 
URL: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.2-linux-x86_64.tar.gzSummary: The elasticsearch for centos 7.14.2 x86_64.
# 源代码软件包的名字 
Source0: %{Name}-%{Version}-linux-x86_64.tar.gz
Source3: %{configYaml}
Source4: %{search_guard}
Source5: %{search_tlstools}# install使用的虚拟目录,安装后就在该目录下打包 
AutoReqProv: no
#制作过程中用到的软件包
Requires: bash#软件包详细描述信息 
%description
This is %{Name}

2.%prep

解压源码包部分
如下(示例):

# 安装前的准备工作,一般用于解压源码包
%prep
#解压并cd到相关目录  tar xf SOURCES/xxx.tar.gz -C BUILD && cd BUILD
%setup -q -n elasticsearch-7.14.2  #-q 静默 不输出信息  -n 指定解压后的名称

3.%Install

此部分主要用于解压后的源码安装及目录创建等工作
在该文件中主要实现目录创建、search-guard插件的安装及密钥文件的创建工作,并将准备好的文件和目录拷贝到BUILDROOT目录下

# 源码安装
#目前还是在/export/rpmbuild/BUILD/目录中,执行以下操作
#rm -rf /export/rpmbuild/BUILDROOT
%install
%{_rm} -rf %{buildroot} # 清理之前的安装
mkdir -p /tmp/search-guard-tlstool
tar -zxvf %{SOURCE5} -C /tmp/search-guard-tlstool
cd /tmp/search-guard-tlstool/config/ && cp example.yml tlsconfig.yml
sed -i '/^#/d; /^$/d' tlsconfig.yml
sed -i '/root\.ca\.example\.com/c\      dn: CN=root.ca.com.local,OU=CA,O=com,DC=com,DC=local' tlsconfig.yml
sed -i '/signing\.ca\.example\.com/c\      dn: CN=root.ca.com.local,OU=CA,O=com,DC=com,DC=local' tlsconfig.yml
sed -i 's/#nodesDn/nodesDn/' tlsconfig.yml
sed -i 's/#- "CN=\*.example.com,OU=Ops,O=Example Com\\\\, Inc.,DC=example,DC=com"/- "CN=\*.com.local,OU=Ops,O=com,DC=com,DC=local"/' tlsconfig.yml
sed -i 's/# nodeOid: "1.2.3.4.5.5"/nodeOid: "1.2.3.4.5.5"/' tlsconfig.yml
sed -i '88,99d' tlsconfig.yml
sed -i 's/- name: node1/- name: esnode/' tlsconfig.yml
sed -i '/dn: CN=node1\.example\.com*/c\    dn: CN=esnode.com.local,OU=Ops,O=com,DC=com,DC=local' tlsconfig.yml
sed -i 's/dns: node1.example.com/dns: esnode/' tlsconfig.yml
sed -i '/dn: CN=spock\.example\.com/c\    dn: CN=spock.com.local,OU=Ops,O=com,DC=com,DC=local' tlsconfig.yml
sed -i '/dn: CN=kirk\.example\.com/c\    dn: CN=kirk.com.local,OU=Ops,O=com,DC=com,DC=local' tlsconfig.yml
sed -i 's/pkPassword: auto/pkPassword: none/' tlsconfig.yml
cd /tmp/search-guard-tlstool/tools/
./sgtlstool.sh -c ../config/tlsconfig.yml -ca
./sgtlstool.sh -c ../config/tlsconfig.yml -crt
cd out/ && chmod 644 root-ca.* signing-ca.* esnode* kirk.*
mkdir -p %{buildroot}%{InstallPath}/plugins/search-guard-7
mkdir -p %{buildroot}%{InstallPath}/{modules,logs,data,lib,config,bin}
cp -rp /tmp/search-guard-tlstool/tools/out/{root-ca.pem,kirk.pem,kirk.key,esnode.pem,esnode.key} %{buildroot}%{InstallPath}/config# 复制自定义的或额外的配置文件和脚本
unzip %{SOURCE4} -d %{buildroot}%{InstallPath}/plugins/search-guard-7/
cp -rp %{_builddir}/%{Name}-%{Version}/* %{buildroot}%{InstallPath}/
rm -rf %{buildroot}%{InstallPath}/jdk

4.%file

主要用于安装后目录下都包含哪些文件或子目录

%files
%defattr(-,elasticsearch,elasticsearch,-)
%dir %{InstallPath}
%dir %{InstallPath}/bin
%dir %{InstallPath}/config
%dir %{InstallPath}/lib
%dir %{InstallPath}/logs
%dir %{InstallPath}/data
%dir %{InstallPath}/modules
%dir %{InstallPath}/plugins
%{InstallPath}/bin/*
%{InstallPath}/config/*
%{InstallPath}/lib/*
%{InstallPath}/modules/*
%{InstallPath}/plugins/*
%{InstallPath}/NOTICE.txt
%{InstallPath}/LICENSE.txt
%{InstallPath}/README.asciidoc

5.%post

主要用于安装rpm后做的相关操作,比如启动进程、创建用户等工作。在此文件中,该部分主要用于替换elasticsearch.yml文件、授权、设置所需要的内核参数、初始化search-guard插件并重置es密码

%post
#!/bin/sh
cat >%{InstallPath}/config/elasticsearch.yml<<EOF
cluster.name: cityosnode.name: wangyingkai-test-01path.data: %{InstallPath}/data
path.logs: %{InstallPath}/logs
# Lock the memory on startup:
#bootstrap.memory_lock: true
network.host: $local_ip
http.port: 9200discovery.seed_hosts: ["$local_ip"]
cluster.initial_master_nodes: ["$local_ip"]
#discovery.zen.minimum_master_nodes:#gateway.recover_after_nodes: 3# Search Duard Configure
action.auto_create_index: true
node.master: true
node.data: true
searchguard.ssl.transport.pemcert_filepath: esnode.pem
searchguard.ssl.transport.pemkey_filepath: esnode.key
searchguard.ssl.transport.pemtrustedcas_filepath: root-ca.pem
searchguard.ssl.transport.enforce_hostname_verification: false
searchguard.ssl.transport.resolve_hostname: false
searchguard.authcz.admin_dn:
- CN=kirk.com.local,OU=Ops,O=com,DC=com,DC=local
searchguard.cert.oid: 1.2.3.4.5.5
EOF# edit config file 修改yml文件
sed -i "s/node.name:.*/node.name: $local_ip/g" %{InstallPath}/config/elasticsearch.yml# useradd elasticsearch 创建用户
id elasticsearch > /dev/null 2>&1
if [ $? == 0 ];thenecho 'elasticsearch user exist.'
elseuseradd -s /sbin/nologin elasticsearch
fi#chown 设置目录权限
chown -R elasticsearch:elasticsearch %{InstallPath}#设置kernel参数
if ! grep -w "fs.file-max" /etc/sysctl.conf |grep -v ^# >/dev/null
thensed -i '$a\\nfs.file-max = 65536' /etc/sysctl.conf
fiif ! grep -w "vm.max_map_count" /etc/sysctl.conf |grep -v ^#  >/dev/null
thensed -i '$a\\nvm.max_map_count = 262144' /etc/sysctl.conf
fi
sysctl -p > /dev/null
# 启动 Elasticsearch 服务
su elasticsearch -c "%{InstallPath}/bin/elasticsearch -d -p %{InstallPath}/%{Name}.pid"
# 等待 Elasticsearch 启动,修改密码
until curl -s http://$local_ip:9200 > /dev/null; doecho "Waiting for Elasticsearch to start..."sleep 10
done# 生成哈希密码并更新配置文件
HASHED_PASSWORD=$(%{InstallPath}/plugins/search-guard-7/tools/hash.sh -p "0gvzJr66iNs5")
# 转义特殊字符
ESCAPED_HASHED_PASSWORD=$(echo "$HASHED_PASSWORD" | sed 's/[\/&]/\\&/g')
# 更新 sg_internal_users.yml 文件
if [ -n "$ESCAPED_HASHED_PASSWORD" ]; thensed -i 's/^  hash: ".*"/  hash: "'"$ESCAPED_HASHED_PASSWORD"'"/' %{InstallPath}/plugins/search-guard-7/sgconfig/sg_internal_users.ymlsed -i 's/\r//g' %{InstallPath}/plugins/search-guard-7/sgconfig/sg_internal_users.yml
fi#修改完配置文件并执行初始化
cd %{InstallPath}/plugins/search-guard-7/tools && sh sgadmin.sh -h $local_ip -cd ../sgconfig -key ../../../config/kirk.key -cert ../../../config/kirk.pem -cacert ../../../config/root-ca.pem -nhnv -icl

6.%postun

这部分主要用于卸载后需要做的任务,比如:删除目录等任务工作,在该spec文件中,这部分主要用于根据pid是否存在停止程序、删除目录,完成相应的卸载工作

%postun -p /bin/sh
#!/bin/bash
PID_FILE="%{InstallPath}/%{Name}.pid"
DIR_TO_REMOVE="%{InstallPath}"# Check if the PID file exists and read the PID from it
if [ -f "$PID_FILE" ]; thenPID=$(cat "$PID_FILE")# Check if a process with the given PID existsif ps -p $PID > /dev/null 2>&1; then# Kill the process with the PID found in the PID filekill $PID# Wait a moment to allow the process to terminatesleep 1fi# Remove the PID filerm -f "$PID_FILE"
fi# Remove the directory
rm -rf "$DIR_TO_REMOVE"

三、成果演示

1.执行构建过程图示例

在这里插入图片描述
在这里插入图片描述

2.执行安装RPM包示例

在这里插入图片描述
在这里插入图片描述

3.进程检查

在这里插入图片描述

4.访问esApi

在这里插入图片描述在这里插入图片描述


总结

通过完成本篇文章,已经对rombuild有了60%的理解和使用,熟能生巧,希望也对大家的实际工作能起到帮助作用。加油!!!

http://www.tj-hxxt.cn/news/69560.html

相关文章:

  • 网站如何让百度收录怎样申请网站注册
  • 公司域名申请流程郑州seo顾问外包
  • 红酒购物网站源码如何推广引流
  • 建设银行E路航如何自动进入网站seo网络优化前景怎么样
  • 手机网站 后台sem搜索
  • 天津做网站需要多少钱网域名查询地址
  • 郑州地区网站建设公司四川百度推广排名查询
  • 上海做外贸网站建设自己建网站
  • 武汉个人做网站厂家怎么给自己的公司做网站
  • 网站开发用主要软件分类达人介绍
  • 武汉城建集团有限公司郑州整站网站优化
  • 网站备案类型免费自学电商教程
  • 人力资源网站怎么做网络营销方案策划书
  • 比较好的做网站的公司今天的最新消息新闻
  • 上网出现危险网站网站seo方案策划书
  • 网站设计手机型交换友链
  • 有源码帮忙搭建网站吗站长之家是什么
  • 从零开始学微信公众号运营推广深圳品牌seo
  • 龙岩做网站奶盘seo伪原创工具
  • 设计院门户网站建设方案外链工具软件
  • 崇明建设镇乡镇府网站外贸网站平台哪个好
  • 个人网页模板关于爱国网站seo方案模板
  • 品牌设计有哪些河北seo推广方案
  • 网页微信手机登录上海seo网络优化
  • 苏州网站搭建公司潍坊网站建设seo
  • 企业百度网站怎么做发文章用哪个平台比较好
  • 贵州三线建设博物馆网站网站超级外链
  • 个人网站做企业网站seo检测优化
  • 免费建设微网站制作徐州关键词优化排名
  • 云之创网站建设百度指数查询排行榜