sentry

### 参考 ###
http://readthedocs.org/docs/sentry/en/latest/index.html
http://raven.readthedocs.org/en/latest/config/index.html?highlight=key
http://blog.shanbay.com/archives/998

### 服务端安装 ###
#1 Setting up an Environment
easy_install -U virtualenv
virtualenv /www/sentry/
source /www/sentry/bin/activate

#2 Install Sentry
pip install sentry #easy_install -U sentry

#3 Initializing the Configuration
sentry init /etc/sentry.conf.py
//Configure db
///or psql
'ENGINE': 'postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'sentry', # Or path to database file if using sqlite3.
'USER': 'postgres', # Not used with sqlite3.
'PASSWORD': '*', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '5190', # Set to empty string for default. Not used with sqlite3.
'OPTIONS': {'autocommit': True,},

///or msyql
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sentry',
'USER': 'root',
'PASSWORD': '*',
'HOST': 'localhost',
'PORT': '3306',

///or sqlite
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(CONF_ROOT, 'sentry.db'),
'USER': 'postgres',
'PASSWORD': '',
'HOST': '',
'PORT': '',

//Configure Outbound Mail
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = '*'
EMAIL_HOST_USER = '*'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

SENTRY_PUBLIC = True
SENTRY_ALLOW_PROJECT_CREATION = True

#4 Running Migrations
#pip install psycopg2
#pip install MySQL-python
sentry --config=/etc/sentry.conf.py upgrade
//no create user
//must no exception

#5 create a new user
sentry --config=/etc/sentry.conf.py createsuperuser

#6 Starting the Web Service
sentry --config=/etc/sentry.conf.py start
//or
mkdir -p /www/sentry/log
nohup sentry --config=/etc/sentry.conf.py start >/www/sentry/log/sentry.log&

//or
/ebs_data/opt/typhoonae/etc/supervisord.conf
[program:sentry-web]
directory=/www/sentry/
command=/www/sentry/bin/sentry --config=/etc/sentry.conf.py start http
autostart=true
autorestart=true
redirect_stderr=true

///Restart supervisor
/ebs_data/opt/typhoonae/bin/supervisorctl shutdown
/ebs_data/opt/typhoonae/bin/supervisord

#7 Login with super user
http://x.x.x.x:9000/

#10 在sentry上创建相应的Project,在配置页面获取dsn添加到一下配置文件
/ebs_data/opt/typhoonae/parts/appsengine/etc/sentry_config.py

### 客户端安装 ###
#1 pip install raven

#2 在django的settings.py文件里的INSTALL_APPS加上一行:

INSTALLED_APPS = [
...
'raven.contrib.django',
]

#3 test
http://192.168.10.147:8080/tests?name=apps.base.tests.sentry_test


### 给模块新追加异常Logger的逻辑 ###
# 1,

import logging, logging.config
from typhoonae import log4

logging.config.fileConfig( log4._LOG_CONF_FILE )
logger = logging.getLogger("file_sync")
logger.setLevel(logging.DEBUG)

exception_logger = logging.getLogger("file_sync_except")
exception_logger.setLevel(logging.ERROR)
from raven.handlers.logging import SentryHandler
handler = SentryHandler('http://11c37937cf1849ceb381b5e092d25c02:835ca6e3a44f4f2d8645739cf59479a1@192.168.10.147:9000/6')
exception_logger.addHandler(handler)


# 2,
import unittest
from apps.file_sync.log4 import exception_logger


class SentryTest(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_log_error(self):
exception_logger.info('--------- file_sync test info ------------')
exception_logger.error('--------- file_sync test error ------------')
在CDH(Cloudera Distribution Including Apache Hadoop)中,Sentry 是一个用于提供细粒度权限管理的安全模块。它支持与 Hive、Impala 和 Hue 等服务的集成,以实现对数据访问的精确控制[^1]。 ### 集成配置 #### 为Hive服务启用Sentry 在Hive中启用Sentry时,需要确保Hive Metastore (HMS) 的heap size至少配置为10GB,因为Sentry需要使用12个连接与HMS进行通信。这可以通过从Cloudera Manager (CM) 打开Hive服务,并搜索Java Heap Size of Hive Metastore Server in Bytes属性来检查和调整[^3]。 #### 为Impala服务启用Sentry 对于Impala服务,同样需要通过Cloudera Manager界面操作来启用Sentry功能,这样可以保证Impala能够利用Sentry提供的安全特性来进行数据访问控制。 #### 配置HDFS开启ACLs与Sentry权限同步 为了使Sentry的权限设置能够在HDFS层面生效,还需要配置HDFS以开启ACLs并同步这些权限到Sentry中,从而确保文件系统的安全性与数据库级别的权限一致。 #### 为Hue服务启用Sentry 当为Hue服务启用Sentry时,用户将能够通过Hue界面更细致地管理数据访问权限,这通常涉及到在Cloudera Manager中进行相应的配置更改。 #### 将Hive, Spark 和 Hue 组添加到Sentry的管理组 此外,还需要将相关的用户组如Hive、Spark和Hue添加到Sentry的管理组中,以便这些组件能够正确地应用Sentry定义的安全策略。 ### 使用指南 在实际使用过程中,除了上述的基础配置之外,还需要考虑如何在HiveServer2中使用UDF(User-Defined Functions),以及如何保护Hive Metastore等高级话题。 例如,在HiveServer2中使用自定义函数时,必须确保这些函数不会绕过由Sentry实施的安全策略。同时,保护Hive Metastore免受未经授权的访问也是至关重要的,因为它存储了关于表结构的关键元数据。 ### 安全配置 在部署CDH环境时,还应注意一些特定的安全配置步骤,比如在离线部署期间创建系统用户cloudera-scm,这是通过执行`useradd`命令完成的[^4]。这样的配置有助于维护集群中的权限边界和服务账户隔离。 最后,在处理CDH相关安装包时,验证其完整性也是重要的一环,例如计算CDH parcel文件的SHA1校验码并将其保存在一个单独的`.sha`文件中[^5]。 ```bash sha1sum CDH-6.2.0-1.cdh6.2.0.p0.967373-el7.parcel | awk '{ print $1 }' > CDH-6.2.0-1.cdh6.2.0.p0.967373-el7.parcel.sha ``` 以上命令展示了如何生成一个CDH parcel文件的SHA1校验码文件,这对于确保下载的软件包未被篡改至关重要。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值