ranger审计Solr部署
安装前准备
1.1. 创建用户和用户组
groupadd solr
useradd -g solr solr
1.2. 添加环境变量
vi /etc/profile
export SOLR_HOME=/opt/solr
export PATH=$PATH:$SOLR_HOME/bin
source /etc/profile
安装solr
1.1. 解压安装包
tar -zxf solr-8.11.2.gz -C /opt/
ln -s /opt/solr-8.11.2 /opt/solr
1.2. 复制文件
scp -rp /opt/solr-8.11.2 xxx.xxx.xxx5:/opt
ln -s /opt/solr-8.11.2 /opt/solr
1.3. 执行安装
cd /opt/solr
./bin/install_solr_service.sh /opt/solr-8.11.2.tgz
配置solr
1.1. 配置install.properties文件
cd /opt/ranger-admin/contrib/solr_for_audit_setup/
内容如下:
SOLR_USER=solr
SOLR_GROUP=solr
MAX_AUDIT_RETENTION_DAYS=90
SOLR_INSTALL=false
SOLR_DOWNLOAD_URL=
SOLR_INSTALL_FOLDER=/opt/solr
SOLR_RANGER_HOME=/opt/solr/ranger_audit_server
SOLR_RANGER_PORT=8983
SOLR_DEPLOYMENT=solrcloud
SOLR_RANGER_DATA_FOLDER=/opt/solr/ranger_audit_server/data
SOLR_ZK=xxx.xxx.xxx3:2181,xxx.xxx.xxx4:2181,xxx.xxx.xxx5:2181/ranger_audits
SOLR_HOST_URL=http://`hostname -f`:${SOLR_RANGER_PORT}
SOLR_SHARDS=3
SOLR_REPLICATION=2
SOLR_LOG_FOLDER=/log/solr/ranger_audits
SOLR_RANGER_COLLECTION=ranger_audits
SOLR_MAX_MEM=2g
1.2. 配置solr.in.sh文件
sh /opt/ranger-admin/contrib/solr_for_audit_setup/setup.sh
cd /opt/solr/ranger_audit_server/scripts/
cp solr.in.sh /etc/default/
1.3. 添加solr的znode
cd /opt/solr/ranger_audit_server/scripts/
bash add_ranger_audits_conf_to_zk.sh
1.4. 修改权限
chown solr:solr /opt/solr-8.11.2
启动服务
1.1. 启动
su - solr
cd /opt/solr
bin/solr start
http://xxx.xxx.xxx.222:8983/solr/#/
1.2. 创建audit 索引
cd /opt/solr/ranger_audit_server/scripts
修改create_ranger_audits_collection.sh脚本
内容如下:
SOLR_HOST_URL=http://`hostname -f`:${SOLR_RANGER_PORT}
SOLR_ZK=xxx.xxx.xxx3:2181,xxx.xxx.xxx4:2181,xxx.xxx.xxx5:2181/ranger_audits
SOLR_INSTALL_DIR=/opt/solr
SHARDS=3
REPLICATION=2
CONF_NAME=ranger_audits
COLLECTION_NAME=ranger_audits
which curl 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "curl is not found. Please install it for creating the collection"
exit 1
fi
set -x
curl --negotiate -u : "${SOLR_HOST_URL}8983/solr/admin/collections?action=CREATE&name=${COLLECTION_NAME}&numShards=${SHARDS}&replicationFactor=${REPLICATION}&collection.configName=$CONF_NAME&maxShardsPerNode=100"
1.3. 添加audit索引
bash create_ranger_audits_collection.sh
1.4. 重启ranger-admin
su - admin
ranger-admin restart