BMTD 's Yard of Fun

Technology, Sports, Music, Chinese Essays

Browsing Posts in Uncategorized

在DC碰到了一群美国的新纳粹分子在示威游行. 这群"国家社会主义运动"(NSM, Natiional Socialism Movement)的家伙身穿黑衣,举着纳粹十字标志口呼"Go USA!" , 还一边行希特勒式挥臂礼…虽然人数很少大约只有百多人但是大批警察严阵以待. 这种组织也允许存在并在国会游行, 米国式的自由…

这个组织的总部好像在密西根.


开路的骑警

引来不少围观者. 不少人是来DC的游客,以为碰到了3K党.

7. reverse proxy/cache

reverse proxy又称http accelerator是在web server 前面加一道proxy, 所有request先经过proxy, 如果是在proxy缓存内的内容则不用经过web server直接就从缓存取出内容返回给用户的浏览器, 否则转给后面的web server.这样大大减轻了web server 的负担,从而使web server可以专注与处理动态页面,而可以缓存的静态页面则由更加快速轻便的proxy直接返回给用户, 从而提高了系统的总体处理能力和响应速度.

老牌open source proxy 软件Squid就可以用来做reverse proxy/http accelerator.

Apache 的mod_proxy 和mod_cache也可以结合起来达到相同功能.

squid 稳定版本现在是2.6和3.0. 2.6尚不支持http 1.1. 2.5问题较多,建议不要使用.

有一个比较新的开源软件 varnish是专门的reverse proxy软件, 从架构和原理来说性能很好并且非常灵活, 通过一种简单而功能强大的编程语言VCL定制你的policy;问题是对于新手掌握VCL并写出安全而又符合自己需要的control script不是意见容易的事. 我试用了varnish一阵,可能是自己的VCL写的有问题, 在performance上还不如squid, 而且一不小心还会出错…所以暂时放到一边,有时间再慢慢研究. 但是长远来说, varnish在这个领域非常有潜力.

除了caching, reverse proxy 还可以用于集成不同平台的后台web server, 甚至用于作load balancing.


8. PHP opcode cache/accelerator/opcode optimizer

所谓php opcode cache, 就是把编译后的php opcode 缓存起来, 从而不必每个请求都编译一边, 大大提高了php的执行效率.

open source中APC, Turke MMCache(eAccelerator的前身)/eAccelerator是老牌的; 其中eAccelerator在众多评测中声誉甚佳, 并且还有 opcode优化, cache压缩以及很好的管理界面等优点. 但在海归网的服务器上, 或许是设置或者海归网应用本身的原因, eAccelerator的表现实在是强差人意,甚至还不如不用.

对几种opcode cache反复试用的结果, xcache的效果最好, 切切实实地加快了PHP的执行速度. 在网上搜索一下, Xcache的用户满意度都很高。 xcache目前还没有opcode 优化功能, 期望在这方面能更进一步。

9. data cache

对于server side的缓存,一般来说可以有几级cache:

用户请求–>reverse cache, 若命中, 则直接返回
否则 –> web server ;
查询数据首先查 data cache; 若命中则不用查询数据库
否则查询数据库–>DBMS首先查自己的query_cache, 若命中则直接返回结果不用到磁盘上进行查询

这里说的是data caching.

由于php web applicaiton基本上来说是一种shared-nothing的架构, 每次请求是与其他请求基本是互不相干的, 不像J2EE或.NET一样数据可以缓存在内存里(比如jaba servlet或asp.net的session), 所以缺省是无法在内存里缓存数据的而是每次请求都得重新查询一遍数据库; 为了减少或简化数据库的访问(因这往往是瓶颈), 一般的数据缓存方法有:

–数据存储在文件里
— 数据存储在数据库表里:把耗费资源的复杂查询或计算的结果放到简单的数据库表中供以后重用,
— 数据存在 shared memory里, 从而多个php进程在多次请求间可以共享.
— 数据存在专门的caching服务中.

从性能来说,存贮在shared memory里是最快的.

如果只有一台服务器, 那么可以利用eaccelerator/xcache提供的功能–除了cache php opcode之外, 这些工具也都提供了直接cache应用程序数据到内存里的功能. 例如, 使用xcache的 API很简单:

 if (xcache_isset("my_key")) {
    //从cache取出数据
    $data = xcache_get("my_key);
    ...
} else {
    ....
    //把数据存到cache里
     xcache_set("my_key", $new_data, 3600); // save data for 1 hour
}

但是如果是多台web server, 很多时候就无法在本地机器的内存里cache数据了,因为会有数据一致性的问题。这种情况下一个很好的解决方法是使用memcached.

memcached 是开源的分布式caching 服务,支持几乎所有主要编程语言,客户端接口包括php/java/puthon/ruby/.net/perl/c 等。客户通过tcp/ip协议访问memcached缓存。最早是live journel网站为了解决多服务器数据缓存问题开发的,现在在许多著名的大流量网站上被使用,例如facebook, wikimedia, slashdot, sourceforge等等。

php的memcached 接口是一个zend extension需要下载编译; 当然还需要下载安装memcached 本身。

10. easy traffic limiting with iptables, 禁止 hotlinks etc

这个本来跟服务器性能无关,但是由于经常网站变得很慢是由于一些网站蜘蛛(有些是搜索引擎,有些是些恶意蜘蛛或者到处乱抓网站内容的)无休止频繁的扫网站,搞得服务器不堪重负。 一般简单的方法是在apache里禁止user agent 或者禁止ip, 但效果不好。用iptables的recents模块可以在ip层对client进行限速。

举个例子, 以下这两条iptables规则:

iptables -I INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set

iptables -I INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 600 --hitcount 2 -j DROP

的意思是说, 任何用户不能在600秒内访问本机器的web server (tcp 80端口)平均超过2 次。若超过则请求将被丢掉(客户端的表现就是服务器没响应)。

也就是说, 来自同一个ip的蜘蛛或恶意攻击者将无法在短时间内对服务器发起大量连接请求导致服务器瘫痪。

另外, 由于直接在别的网站链接本站的图片会导致服务器流量过大, 降低服务器性能, 有时被迫在apache里禁止无本地referer的访问图像请求。 不过现在海龟网的图像文件已经转移到了另一个server上也就没有这个限制了。

匆匆草就,先睡了。 以后有时间再瞎聊下scalability与availabilty。

LAMP网站建设 之性能优化篇(上)

开源的LAMP (linux/Apache/Mysql/PHP) 平台是流行的web application platform,不少网站,包括海归网都是建立在此平台上.

在帮助海归网正式转移到LAMP平台之前, 笔者虽然长期做网站设计和开发方面的工作,但主要是在J2EE 或者 ASP.NET /ASP方面的应用, 具体是在application 层面, 架构设计主要考虑功能/可扩充性和scalability, 而网站反应速度/性能方面一般不是问题–或者流量不大,或者硬件架构足够强(hardware load balancer, cluster, dedicated web/middle tier/DB tier/team等). 在海归网, 让我有机会在LAMP环境下接触和学习到许多以前做应用或自己玩操作系统时难以接触到的问题– 除了系统和网络管理外, 有许多是关于性能优化和scalability方面的.

在这篇里分享一点积攒的LAMP环境下PHP网站的性能优化经验. (谢谢老狼和海归网提供的给我一个发挥点业余爱好的机会); 以后有时间谈谈scalability/availability等.

有许多中小网站都和海归网一样只有一台服务器(海归网有一台dedictaed的dell, 更多更差的网站shared hosting的则是几十几百个网站公用一台server), 而这台服务器需要身兼web server, application server,database server, firewall等等所有一切功能…在网站建设的初期只能在有限的硬件条件下最大限度地进行优化充分利用所有的资源保证基本的功能/性能和稳定性.

1. 编译php/apache/mysql 时的优化选项

一般来说, 用不着自己编译这些东西,直接下载binary packages就可以了–无论是debian 的apt-get 还是redhat的rpm /yum. 但是这些现成的安装包编译时一般并未根据你的服务器硬件配置做优化, 而通过选择合适的C编译器 flags 和其他选项,自己编译往往能使总体性能提高几个到几十个百分点.

推荐在编译之前, 设置 CFLAGS 环境变量:

export CFLAGS="-march=pentium4 -O2 -pipe -msse2 -mfpmath=sse,387 -mmmx -fomit-frame-pointer"

-march , -msse2, -mfpmath, -mmmx 等都是根据自己的服务器CPU类型做的设置; 海归网服务器是个xeon CPU所以用上述标记; 老一些的GCC 编译器还可以加上 -prefer-nopix

一般linux用户都知道, 下载源代码后标准的编译安装过程是:

./configure [options]
make
make install

在运行./configure 时注意尽量避免编译自己不需要的模块或功能以免编译出来的东西过于臃肿.

./configure 时最好不要enable pix, 而是用 –disable-pix选项;


2. 软件版本

linux 核心版本最好在2.6以上, 因为在虚存/线程管理等关键功能上比2.4有了很大的改善,对系统性能影响较大.

有些版本的php/apache/mysql有比较严重的bug,导致系统严重不稳定. 比如 mysql 5.1.11会导致数据库表/索引频繁崩溃;最新的php5.2.5和php5.2.6 development snapshot 似乎有memory leak, 导致系统内存很快被用光服务器奇慢无比甚至死机等等.We learned it the hard way :(

3. 使用google的tcmalloc 内存分配函数代替libc里的标准malloc.

google的开源性能优化工具包 perftool 被证明对提高应用程序性能确有帮助. tcmalloc是其中一个, 与标准的malloc相比, 在内存的分配上效率很高; 编译mysql时建议使用tcmalloc库–
简单来说, 只要在./configure 后生成的Makefile里改一下, 在连接库的那行最后面加上 -ltcmalloc即可.

如果已经使用的是已编译的binary,或者只想简单测试一下tcmalloc的效果, 可以用LD_PRELOAD环境变量制定运行时使用tcmalloc库; 例如在mysqld_safe里加入

export LD_PRELOAD=/usr/local/lib/libtcmalloc.so

确定程序是否使用tcmalloc库可以用lsof命令:

lsof -n| grep tcmalloc

我的经验是使用tcmalloc后mysql的性能确实得到了提高,但在php和apache上没什么效果.

4. PHP config

一个是打开 zlib_compression开关,这样网页内容被传输到浏览器之前会先被压缩,从而减少网站流量并且加快page load速度.

当然也可以不在php里压缩.而是在apache里用mod_deflate.

5. Apache config

MPM: apache标准MPM是prefork, 起一大堆进程每个进程处理一个请求. 如果可行, 尽量使用apache worker MPM, 多线程模式可以减少apache内存使用提高性能. 最新的event mpm在worker mpm的基础上进一步提高了性能,但是目前(截至apache 2.2.8)尚处于实验阶段不推荐在production使用.

使用worker mpm要求编译apache时使用worker mpm选项, 并且php需要编译成thread-safe的,链接到mysql的thread-safe client library.

httpd.conf里一些影响性能的设置(不一一解释了, apache在线文档里都有):
— mpm的设置
— keep alive: 大部分设成 on 比较好; 个别网站设成off更好;这个需要自己测试
— keep alive time out: 1-2 秒.
— maxkeepaliveRequest: 设成比较大的数目, 比如 1000或2000.
— extended server status: disable
— allow override: 设成不允许 (也就是说尽量避免每个目录下的.htaccess文件)
— HostnameLookups Off
–LogLevel: 在production box上设成 error或crit

尽量少用mod_rewrite

除了用apache worker MPM + mod_php, 另一种常见的apache配置是用apache+ mod_fastCGI + php-fcgi; 使用fast CGI 的apache进程可以重用,另外还有安全上的一些特点.

顺便提一句, 虽然apache在web server里最有名, 但性能方面并不怎么样, 相比一些其他open source产品来说体积庞大臃肿占内存速度又慢. lighttpd是一个日渐流行的http server, 速度较apache快效率更高. 许多其他的基于scripting language的web app 例如ruby/python/perl都以lighttpd+fast cgi的模式运行.


6. mysql tunning

–mysql storage engine的选择: 最流行的是MyISAM 和INNODB. 前者是mysql初期的主要engine, 至今仍大量使用,优点是查询速度很快,并且具有全文检索等别的engine没有的功能. 但是不支持事务处理(transaction), 写操作效率也不高. innodb支持transaction和其他一些现代关系数据库的功能. 这个完全根据你的网站应用的需要了…如果涉及到ecommerce之类最好使用innodb.

–mysql 的一些系统参数的优化:

query_cache_size: 这个很重要; 太小了每个sql都得到硬盘数据库里找一次, 太大了占用内存过多影响系统其他部分. 另外query cache里相关的记录若被修改则所有cache的查询结果都会被清除.

此外, myisam 的 key_buffer, table_open_cache, sort_buffer_size, thread_cache_size, thread_concurrency, tmp_table_size,max_heap_table_size,join_buffer_size, max_connections等都影响performance. 此外.对于IINNODB, 还有一个很重要的参数是innodb_buffer_pool_size.

有一个简单的perl script可以帮助你调节上述参数: ( http://rackerhacker.com/mysqltuner/ ) .

对许多web 应用来说, 数据库往往是性能的瓶颈; 而数据库性能最常见的问题是索引问题–sql 查询/join字段不通过索引导致full table scan…可以在mysql的启动参数上加上 log-slow-queries 选项记录所有执行速度太慢的sql 语句. 甚至打开log-queries-not-using-indexes 记录所有没有使用索引的sql…然后根据情况解决: 或者给相关字段加上索引, 或者优化/改写应用程序里的sql语句.

一时写不完, 等下半篇再说说reverse proxy/ opcode cache/ data caching 等.

MP3 ID3 tag自动转码工具

老版本ID3 tag的标准本来只支持ISO-8859-1,也就是只能用西方拉丁字母。新的ID3 tag还支持Utf-16, 所以中文啊越南文之类的都能支持了。

问题是许多网上的mp3歌曲id3 tag编码很不规范。。。拿我来说吧,我有7000多首中文mp3。。。而这些中文歌曲的Id3编码是五花八门:

Gb2312/big5/big5hkjcs 甚至utf-8都有,还有很多根本没有tag而是把作者和歌名都放在文件名上。 这样听歌的时候就比较头痛了--在播放器里不知道现在听的是什么歌, 哪个歌手、专辑等。浏览、搜索歌曲也很不方便。在windows还好点,因为许多windows上的jukebox支持GBK编码能看不少繁体字,但到了苹果的OSX上就无法忍受了:OSX只支持unicode, itunes严格只支持ISO-8859-1和UTF-16.

查了一下网上,有些工具但没法满足我的要求:或者只能一次转几个文件--我几千个文件在几百个目录里怎么搞啊,或者一次只支持一种编码的转换--这有个问题:比如用gb2312来转,会把用big5/utf-8码的文件tag弄坏了。

所以只好自己动手写个小utility了。。。

这是个简单python script, 基于一位在英国的澳洲华人写的开源pytagger library (http://www.liquidx.net/pytagger/) , 以及他的tagencoder程序。

pytagger被我稍微改动了一下增强robustness.

下载: 点击下载

用法:

–下载后把文件后缀改为 .tar.gz (或.tgz)

--系统需求:需要在机器上有python. unix/linux一般都有,windows自己去python.org下载安装就行了。

在命令行敲:

python ConvertMp3.py < 目录名>

-- 自动 将该目录下以及所有子目录下所有.mp3 和.mp2文件的ID3 tag转换成 UTF-16.

— 如果id3 tag的"title"/"artist"空白, 自动根据文件名和路径填上。

可能的enhancement: 自动根据网上的音乐识别服务鉴别mp3的信息并填写tags. 注意不是指CDDB一类识别CD tracks的,而是根据声学曲线识别音乐(acoustics recognition)的musicBrainz一类服务。但是目前musicBrainz里中文歌曲信息太少所以效果估计不好。

在最近的西藏事件上,西方国家中跳得最欢的竟然是德国–德国新闻报道中歪曲事实行为是这些国家里最严重的, 简直令人瞠目结舌,而一般德国人对西藏也有者着异乎寻常的关心: 2008年3月21日,德国在全国九百二十一个城市升起了da 赖的雪山狮子旗。一般来说给人印象严谨理性的德国人这次为什么在西藏问题上如此起劲呢?德国人的西藏情节其中一个重要的原因是– 有不少人认为德国人的祖先起源于西藏的纯种雅利安人。

当年的纳粹就曾为这个传说先后两次派探险队进入西藏考察,希望找到雅利安人的遗迹证明与日尔曼人的同源,并且找到地球的轴心扭转在二战战场上的颓势。而探险队(SS)的首领就是海因里希·哈勒 . 正是这个人写了一本书讲述他在西藏七年的生活, 以及他成为大赖的亲密朋友兼家庭教师的经历 ; 在以前‘西脏流亡政府“的网页上还有他与达赖的合影。然而,他在书中并没有提及他是纳粹,以及奉命寻找地球轴心的实事。 这本书后来被好莱坞拍成著名电影”西藏七年", 由著名影星不辣的皮特 (Brad Pitt)主演, 成为西方普通人对西藏印象的主要来源。电影里男主人公由纳粹军官被改成了奥地利的一位普通登山家(哈勒本人确实是奥地利人), 当年大赖治下的西藏得到充分浪漫化, 以对比影片中中国军队和ZF之残暴.

回到德国这里, 关于雅利安人种的起源, 以及纳粹在这方面的理论以及与大赖之间的密切关系, 这里有几个英文链接:

http://www.gnosticliberationfront.com/story_of_hans_hoerbiger.htm

http://www.newspiritualbible.com/index2

虽然希特勒早已消亡,但是今日德国人异常激动的举动,让人不得不相信, 纳粹的这套西藏与德国人同源的理论在德国深入人心, 在今天的德国依然大有市场。

附 1:

引用:

在第二次世界大战前后,中国的西藏远离战区,躲过了战火与硝烟,但并没有躲过纳粹德国的视线。1938年和1943年,经希特勒批准,纳粹党卫军头子希姆莱亲自组建了两支探险队,他们深入西藏,寻找“日耳曼民族的祖先”———亚特兰蒂斯神族存在的证据,寻找能改变时间、打造“不死军团”的“地球轴心”。1945年,苏军攻克柏林后,内务人民委员会(“克格勃”前身)军官在德国帝国大厦的地下室里,发现了一名被枪杀的西藏喇嘛。这一切都使纳粹在西藏的秘密行动成为二战中一个难解的谜团。
  希姆莱想打造神族部队
  1933年,希特勒在德国掌权后,大肆鼓吹种族优越论,称人类每700年进化一次,最终目的是将雅利安人(在纳粹语言中,雅利安人有时指非犹太血统的白种人,更多是单指日耳曼人)这样的“优秀”人种进化为具有超常能力的新人类。希特勒手下的纳粹党卫军头子希姆莱也是一个彻头彻尾的种族主义者。他在组建党卫军之初,便明确规定,只征召那些身高在5英尺9英寸(1英尺=0.3米,1英寸=2.5厘米)以上、金发碧眼、受过良好教育、具有纯正雅利安血统的年轻人。在选拔党卫军军官时,一个最基本的条件是要求被选拔者能够证明自己的家族自1750年以来未曾与其他种族通婚。为印证元首的理论,希姆莱在1935 年,组建了一个服务于纳粹教义的“祖先遗产学会”,网罗了包括医学家、探险家、考古学家甚至江湖术士、精神病患者在内的各色“专家”,对人种、血统、古代宗教、古代遗址、神话传说等进行考察研究。到战争结束时,该学会已发展成为一个拥有40个部门的庞大机构,它不仅对犹太人进行活体实验,还通过占卜、占星等手段指导德军的军事行动。
  在欧洲,长期流传着一个关于亚特兰蒂斯(大西洲)的传说。在传说中,亚特兰蒂斯大陆无比富有,那里的人是具有超凡能力的神族。有关它的文字描述,最早出现在古希腊哲学家柏拉图于公元前350年撰写的《对话录》中。他写道:“1.2万年前,地中海西方遥远的大西洋上,有一个令人惊奇的大陆。它被无数黄金与白银装饰着,出产一种闪闪发光的金属———山铜。它有设备完好的港口及船只,还有能够载人飞翔的物体。”亚特兰蒂斯的势力远及非洲大陆,在一次大地震后,这块大陆沉入海底,一些亚特兰蒂斯人乘船逃离,最后在中国西藏和印度落脚。这些亚特兰蒂斯人的后代曾在中亚创建过灿烂文明,后来他们中的一部分人向西北和南方迁移,分别成为雅利安人和印度人的祖先。一些纳粹专家宣称亚特兰蒂斯文明确实存在,并认为雅利安人只是因为后来与凡人结合才失去了祖先的神力。希姆莱对这个神话传说深信不疑,他相信,一旦证明雅利安人的祖先是神,只要借助选择性繁殖等种族净化手段,便能创造出具有超常能力的、所向无敌的雅利安神族部队。

  详细调查藏族人的体貌特征
  为了寻访先祖遗民,1938年,希姆莱奉命派遣以博物学家恩斯特·塞弗尔和人类学家布鲁诺·贝尔格为首的“德国党卫军塞弗尔考察队”奔赴西藏,这支队伍的其他成员还包括植物学家、昆虫学家和地球物理学家。这些纳粹分子拍摄的纪录片《西藏秘密》显示,他们受到了不了解他们目的的当地领主的款待。但是,这群心怀叵测的党卫军成员并没有忘记他们此行的任务。贝尔格测量了很多西藏人头部的尺寸,并将这些人的头发与其他人种的头发样本进行比对;他们还通过被测者眼球的颜色来判断其种族纯净程度;为保留数据,这些纳粹分子用生石膏对十几个藏族人进行了面部和手的翻模,制作了这些人头部、脸部、耳朵和手的石膏模型。
  这次考察中,队员们还从当地人口中得知有一个名叫沙姆巴拉的洞穴,据说那里隐藏着蕴含无穷能量的“地球轴心”,谁能找到它,就可以得到一种生物场的保护,做到“刀枪不入”,并能够任意控制时间和事件的变化。1939年8月,考察队回到德国,受到希姆莱的热烈欢迎。希姆莱向塞弗尔颁发了“党卫军荣誉剑”。1943年1月,纳粹在慕尼黑大学设立了以瑞典考古学家斯文·赫定的名字命名的考古与人类学学院———斯文·赫定学院,塞弗尔经希姆莱推荐,被任命为首任院长。与塞弗尔同行的贝尔格也被希姆莱提升为党卫军高级军官。由此可见,纳粹分子的第一次西藏探险活动,受到了纳粹高层的充分肯定。

  寻找“地球轴心”
  1941年12月底,在苏联战场上的德国军队以损失50万人、1300辆坦克、2500门火炮的沉重代价,在莫斯科会战中遭到惨败。同年冬,百万德军又在斯大林格勒战役中陷入被动。面对些坏消息,希特勒和他的总参谋部一筹莫展。
  此时,希姆莱也在为如何摆脱军事上的被动处境冥思苦想。他一方面组织江湖术士通过在大西洋地图上悬挂吊锤的荒唐办法,来寻找盟军舰队。另一方面,他想到了那个在遥远东方的“地球轴心”。此后,希姆莱面见希特勒,提出派遣一支特别行动小分队,前往西藏沙姆巴拉洞穴,找到那个能够控制全世界的“地球轴心”,然后派数千名空降兵到那里,打造一个“不死军团”;与此同时,可以颠倒“地球轴心”,使德国回到1939年,改正当初犯下的错误,重新发动战争。为此,希姆莱与希特勒密谈了6个小时,还向希特勒递交了一份2000页的报告,其中的一张地图标出了沙姆巴拉的大体位置。
  1943年1月,由海因里希·哈勒率领的纳粹五人探险小组秘密启程赴藏。曾是职业登山运动员的哈勒是一名出生在奥地利的铁杆纳粹分子,早在1933年就加入了纳粹党。1938年德奥合并后,他又加入党卫军。在一次瑞士举行的登山比赛中,哈勒一举夺冠,充分展示了雅利安人的“优秀品质”,受到希特勒的亲自接见并与其合影留念。哈勒等人的旅程并不顺利,1943年5月,他们在印度被英军逮捕。在几次越狱失败后,哈勒等人总算成功逃出战俘营。开始,他们打算投奔日军,但后来还是决定继续执行寻找“地球轴心”的使命。由于当时的英国印度总督派驻西藏的官员理查德森对德国人采取了宽容的政策,冒充德国商品推销员的哈勒开始了他在西藏的七年之旅。没有人能够说清哈勒和他的探险小组都去了什么地方;有荒唐的传说称他们最终找到了“地球轴心”,但不知道怎样操纵它。也没有人说得清哈勒手下的3个同伴去了哪里,因为直到战争结束时,哈勒的探险小组中只剩下他和希姆莱的心腹彼得·奥夫施奈特。1948年,哈勒在拉萨成为达赖喇嘛的私人教师和政治顾问。1951年西藏和平解放时,哈勒仓皇逃往印度,为逃避审判,他选择了定居列支敦士登。此后,哈勒与达赖长期保持着密切联系。 1977年,当一些知情者揭露了哈勒的纳粹分子身份后,达赖竟然在一个记者招待会上公开为他的这位“恩师”辩护说:“我当然知道海因里希·哈勒的德国背景,而且是在德国因为第二次世界大战作为忏悔人站在全世界面前的时候。但是,我们总是被‘咬输了的狗’所感动,并因此认为,德国人在40年代末已经受到盟军的足够惩罚。”后来,哈勒撰写了回忆录《西藏七年》,但在书中并没有透露他受希姆莱之命秘密寻找“地球轴心”,以及他纳粹分子的真实身份。
  目前,按照德国官方的说法,纳粹第一次进入西藏所拍的纪录片在1945年秋天的科隆大火中被烧毁。哈勒1951年从拉萨回到奥地利时随身携带的大量档案被英国人没收,哈勒本人也已死去。纳粹进入西藏的档案保密级别较高,按德国、英国和美国的规定,有可能在2044年后解密,也有可能永远尘封在历史中

附2:


引用:
Of Lamas and Nazis: The SS in Tibet–1938-39

[CP-List] Of Lamas and Nazis: The SS in Tibet–1938-39
Jeffrey St. Clair sitka@home.com
Mon, 19 Mar 2001 08:08:37 -0800

Hitler and the Himalayas
The SS Mission to Tibet 1938-39
ALEX McKAY

Of all the exotic images that the West has ever projected
onto Tibet, that of the Nazi expedition, and its search for
the pure remnants of the Aryan race, remains the most
bizarre.

On the nineteenth of January, 1939, five members of the
Waffen-SS, Heinrich Himmler’s feared Nazi shock troops,
passed through the ancient, arched gateway that led into the
sacred city of Lhasa. Like many Europeans, they carried with
them idealized and unrealistic views of Tibet, projecting,
as Orville Schell remarks in his book Virtual Tibet, "a
fabulous skein of fantasy around this distant, unknown
land." The projections of the Nazi expedition, however, did
not include the now familiar search for Shangri-La, the
hidden land in which a uniquely perfect and peaceful social
system held a blueprint to counter the transgressions that
plague the rest of humankind. Rather, the perfection sought
by the Nazis was an idea of racial perfection that would
justify their views on world history and German supremacy.

What brings about this odd juxtaposition of Tibetan lamas
and SS officers on the eve of World War II is a strange
story of secret societies, occultism, racial pseudo-science,
and political intrigue. They were, in fact, on a diplomatic
and quasi-scientific mission to establish relations between
Nazi Germany and Tibet and to search for lost remnants of an
imagined Aryan race hidden somewhere on the Tibetan plateau.
As such, they were a far-flung ex<x>pression of Hitler’s most
paranoid and bizarre theories on ethnicity and domination.
And while the Tibetans were completely unaware of Hitler’s
racist agenda, the 1939 mission to Tibet remains a
cautionary tale about how foreign ideas, symbols, and
terminology can be horribly misused. Some Nazi militarists
imagined Tibet as a potential ba<x>se for attacking British
India, and hoped that this mission would lead to some form
of alliance with the Tibetans. In that they were partly
successful. The mission was received by the Reting Regent
(who had led Tibet since the death of the Thirteenth Dalai
Lama in 1933), and it did succeed in persuading the Regent
to correspond with Adolf Hitler. But the Germans were also
interested in Tibet for another reason. Nazi leaders such as
Heinrich Himmler believed that Tibet might harbor the last
of the original Aryan tribes, the legendary forefathers of
the German race, whose leaders possessed supernatural powers
that the Nazis could use to conquer the world.

This was the age of European expansion, and numerous
theories provided ideological justification for imperialism
and colonialism. In Germany the idea of an Aryan or "master"
race found resonance with rabid nationalism, the idea of the
German superman distilled from the philosophy of friedrich
Nietzsche, and Wagner’s operatic celebrations of Nordic
sagas and Teutonic mythology. Long before the 1939 mission
to Tibet, the Nazis had borrowed Asian symbols and language
and used them for their own ends. A number of prominent
articles of Nazi rhetoric and symbolism originated in the
language and religions of Asia. The term "Aryan", for
example, comes from the Sanskrit word arya, meaning noble.
In the Vedas, the most ancient Hindu sc<x>riptures, the term
describes a race of light-skinned people from Central Asia
who conquered and subjugated the darker-skinned (or
Dravidian) peoples of the Indian subcontinent. Linguistic
evidence does support the multidirectional migration of a
central Asian people, now referred to as Indo-Europeans,
into much of India and Europe at some point between 2000 and
1500 B.C.E., although it is unclear whether these
Indo-Europeans were identical with the Aryans of the Vedas.

So much for responsible scholarship. In the hands of late
nineteenth- and early twentieth-century European jingoists
and occultists such as Joseph Arthur de Gobineau, these
ideas about Indo-Europeans and light-skinned Aryans were
transformed into a twisted myth of Nordic and later
exclusively German racial superiority. The German
identification with the Indo-Europeans and Aryans of the
second millennium B.C.E. gave historical precedence to
Germany’s imperial "place in the sun" and the idea that
ethnic Germans were racially entitled to conquest and
mastery. It also aided in fomenting anti-Semitism and
xenophobia, as Jews, Gypsies, and other minorities did not
share in the Aryan German’s perceived heritage as members of
a dominant race. Ideas about an Aryan or master race began
to appear in the popular media in the late nineteenth
century. In the 1890s, E. B. Lytton, a Rosicrucian, wrote a
best-selling novel around the idea of a cosmic energy
(particularly strong in the female sex), which he called
"Vril." Later he wrote of a Vril society, consisting of a
race of super-beings that would emerge from their
underground hiding-places to rule the world. His fantasies
coincided with a great interest in the occult, particularly
among the upper classes, with numerous secret societies
founded to propagate these ideas. They ranged from those
devoted to the Holy Grail to those who followed the sex and
drugs mysticism of Alastair Crowley, and many seem to have
had a vague affinity for Buddhist and Hindu beliefs.

Members of the German SS expedition. Inner circle, left to
right: Krause, Wienert, Beger, Geer, Schaefer. photo
courtesy Alex McKay

General Haushofer, a follower of Gurdjieff and later one of
Hitler’s main patrons, founded one such society. Its aim was
to explore the origins of the Aryan race, and Haushofer
named it the Vril Society, after Lytton’s fictional
creation. Its members practiced meditation to awaken the
powers of Vril, the feminine cosmic energy. The Vril Society
claimed to have l<x>inks to Tibetan masters, apparently drawing
on the ideas of Madame Blavatsky, the Theosophist who
claimed to be in telepathic contact with spiritual masters
in Tibet. In Germany, this blend of ancient myths and
nineteenth-century scientific theories began to evolve into
a belief that the Germans were the purest manifestation of
the inherently superior Aryan race, whose destiny was to
rule the world. These ideas were given scientific weight by
ill-founded theories of eugenics and racist ethnography.
Around 1919, the Vril Society gave way to the Thule Society
(Thule Gesellschaft), which was founded in Munich by Baron
Rudolf von Sebottendorf, a follower of Blavatsky. The Thule
Society drew on the traditions of various orders such as the
Jesuits, the Knights Templar, the Order of the Golden Dawn,
and the Sufis. It promoted the myth of Thule, a legendary
island in the frozen northlands that had been the home of a
master race, the original Aryans. As in the legend of
Atlantis (with which it is sometimes identified), the
inhabitants of Thule were forced to flee from some
catastrophe that destroyed their world. But the survivors
had retained their magical powers and were hidden from the
world, perhaps in secret tunnels in Tibet, where they might
be contacted and subsequently bestow their powers on their
Aryan descendants.

Such ideas might have remained harmless, but the Thule
Society added a strong right-wing, anti-Semitic political
ideology to the Vril Society mythology. They formed an
active opposition to the local Socialist government in
Munich and engaged in street battles and political
assassinations. As their symbol, along with the dagger and
the oak leaves, they adopted the swastika, which had been
used by earlier German neo-pagan groups. The appeal of the
swastika symbol to the Thule Society seems to have been
largely in its dramatic strength rather than its cultural or
mystical significance. They believed it was an original
Aryan symbol, although it was actually used by numerous
unconnected cultures throughout history. Beyond the adoption
of the swastika, it is difficult to judge the extent to
which either Tibet or Buddhism played a part in Thule
Society ideology Vril Society founder General Haushofer, who
remained active in the Thule Society, had been a German
military attache in Japan. There he may have acquired some
knowledge of Zen Buddhism, which was then the dominant faith
among the Japanese military. Other Thule Society members,
however, could only have read early German studies of
Buddhism, and those studies tended to construct the idea of
a pure, original Buddhism that had been lost, and a
degenerate Buddhism that survived, much polluted by
primitive local beliefs. It seems that Buddhism was little
more than a poorly understood and exotic element in the
Society’s loose collection of beliefs, and had little real
influence on the Thule ideology. But Tibet occupied a much
stronger position in their mythology, being imagined as the
likely home of the survivors of the mythic Thule race.

Here an SS anthropologist measures a Tibetan woman’s head.
Some German scientists believed that Aryan features were
reflected in the dimensions of the skull. (C)Transmit Films
GMBH

The importance of the Thule Society can be seen from the
fact that its members included Nazi leaders Rudolf Hess
(Hitler’s deputy), Heinrich Himmler, and almost certainly
Hitler himself. But while Hitler was at least nominally a
Catholic, Himmler enthusiastically embraced the aims and
beliefs of the Thule Society. He adopted a range of
neo-pagan ideas and believed himself to be a reincarnation
of a tenth-century Germanic king. Himmler seems to have been
strongly attracted to the possibility that Tibet might prove
to be the refuge of the original Aryans and their superhuman
powers. By the time Hitler wrote Mein Kampf in the 1920s,
the myth of the Aryan race was fully developed. In Chapter
XI, "Race and People," he expressed concern over what he
perceived as the mixing of pure Aryan blood with that of
inferior peoples. In his view, the pure Aryan Germanic races
had been corrupted by prolonged contact with Jewish people.
He lamented that northern Europe had been "Judaized" and
that the German’s originally pure blood had been tainted by
prolonged contact with Jewish people, who, he claimed, lie
"in wait for hours on end, satanically glaring at and spying
on the unsuspicious girl whom he plans to seduce,
adulterating her blood and removing her from the bosom of
her people." For Hitler, the only solution to this mingling
of Aryan and Jewish blood was for the tainted Germans to
find the wellsprings of Aryan blood. It may happen that in
the course of history such a people will come into contact a
second time, and even oftener, with the original founders of
their culture and may not even remember that distant
association. A new cultural wave flows in and lasts until
the blood of its standard-bearers becomes once again
adulterated by intermixture with the originally conquered
race. In the search for "contact a second time" with the
Aryans, Tibet-long isolated, mysterious, and remote-seemed a
likely candidate.