HackToday Walk Blog


  • Home

  • Tags

  • Archives

  • Search

JVM default locale的问题

Posted on 2013-04-01

前几天调试一个问题,搜集了一些关于JVM locale资料介绍,总结如下:

  1. Windows 7

Before Java 7
对于java 7之前的JVM的default locale和操作系统format的设置相关,
具体配置在,控制面板–》地区和语言–》Formats

Java 7
java7 采用根据windows 7中的display language
具体配置在,控制面板–》地区和语言–》keyboards and language
一般的系统如果没装Language Interface Pack,这个不会显示。具体可以点击里面的 How do I get additional display languages?
参看微软的说明

  1. Linux的配置,

简单,分为永久设置 和 登录会话临时设置,

vi /etc/sysconfig/i18n 修改如下

1
LANG="zh_CN.UTF-8"

临时,export LANG=zh_CN.UTF-8

  1. 怎么确认JVM的default locale,
1
2
3
4
5
6
7
8
import java.util.Locale;


public class LocaleTest {
public static void main(String[] args) {
System.out.println(Locale.getDefault());
}
}

参考资料:

http://stefanhendriks.wordpress.com/2012/02/
http://stackoverflow.com/questions/7107972/java-7-default-locale
http://stackoverflow.com/questions/10707238/locale-getdefault-returns-en-always
http://blog.ej-technologies.com/2011/12/default-locale-changes-in-java-7.html

PKI token 不工作的解决

Posted on 2013-03-13

在keystone设置PKI的token方式下,出现一个奇怪的问题, keystone自己能工作,但是其他的service 比如 glance,
nova 就是不能正常使用,起初怀疑是conf文件的参数配置问题,后来经过多次尝试,终于发现问题的原因在于PKI的
keystone-signing有错误了,我原来用过一次其他的设置 /etc/keystone/ssl/, 后来又改变了,所以都混乱了。

解决办法:

  1. 找到对应的keystone的keystone-signing, 删除掉,重新启动keystone。 因为我的glance用的是这个,所以必须重启glance

  2. nova的如果设置了,删除掉对应的keystone-signing-nova/

这样nova, glance的都能在PKI的token下工作了。

FC iSCSI FCoe NAS 存储比较

Posted on 2013-03-10

前言: 了解存储相关的协议,技术和区别对于理解云计算中的存储虚拟化具有重要意义,所以整理了相关的资料,给出了大概的介绍,如果要了解更多知识,可以参看后面附上的文献。

基于FC的存储
FC最初的设计是基于高性能,低延迟,无损的数据通信。一般应用到企业级对数据读写性能要求较高的环境中。

基于以太网的存储:
iSCSI和各种NAS协议, 主要利用了现有的以太网架构。

FC

1
2
3
高性能, 4GB/s 8GB/s
稳定性
硬件HBA卡支持

iSCSI

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
iSCSI借助IP协议来完成SCSI命令和数据的封包,发送。相比较FC,
1)增加了封包的处理流程和时间
2)受限于以太网的低速 1Gbps

iSCSI相比SCSI和SAS突破了传输距离(server到storage)的限制。

iSCSI的结构如下:

iSCSI Initiator <---> TCP connection <----> iSCSI target
iSCSI technology can use a hardware initiator, a host bus adapter (HBA), or a
software initiator to issue requests to target devices

有软件,硬件实现

FcoE:
主要是实现通过以太网来传送FC的帧,为了实现FC的无损传送,对现有的以太网协议传送进行了改进和扩展
聚合以太网和FC,减少机器不同adapte,线缆的数量
需要相应的软件,硬件支持

NAS

1
2
3
4
5
NAS协议比如 NFS,CIFS,相比iSCSI的不同在于,
iSCSI封装的是block-level的data
NFS则是基于file级别的访问,所以相对iSCSI而言增加了文件系统一级的处理,

软件实现

参考:
http://en.wikipedia.org/wiki/ISCSI#Software_initiator
http://www.redbooks.ibm.com/redpapers/pdfs/redp4493.pdf
http://www.lsi.com/downloads/public/sas%20switch/sas%20switch%20common%20files/channel_hostinterfacepositioningguide_pg_120310.pdf
http://www.cisco.com/en/US/netsol/ns1060/index.html
http://www.vmware.com/files/pdf/techpaper/Storage_Protocol_Comparison.pdf

SAS 和 SATA 比较

Posted on 2013-03-10

SAS和SATA有相似的技术点,都是对传统的并行接口进行了改进,SCSI, ATA

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

应用领域 容量 性能 可靠性 价格

SAS 服务器 (企业级) 最高都达到 4TB 6GB/s 1.4 million hour MTBF 高
可持续顺序
数据速率 182 MB/s



SATA 桌面,工作站 同上 3GB/s, 6GB/s 1.2 million hour MTBF 低
可持续顺序
数据速率 171 MB/s


SAS drive cables can extend up to six times the length of SATA drive cables, and SAS drives are dual ported while SATA drives can only
communicate via one port

参考资料:

  1. http://blog.lewan.com/2009/09/14/sas-vs-sata-differences-technology-and-cost/
  2. http://download.intel.com/design/iio/docs/31512701.pdf
  3. http://www.wdc.com/en/products/products.aspx?id=580
  4. http://www.wdc.com/en/products/products.aspx?id=30

经典storage 示意图

Posted on 2013-03-09

SINA的一篇slide里有一个很形象的storage方案说明,采用了饮用机为原型,很有意思。
(图片来源 SINA sides)

原文地址,请参看:
http://www.snia.org/sites/default/education/tutorials/2012/fall/green/SW_Green%20Storage_Big_Picture_9-12.pdf

Sublime 快捷配置

Posted on 2013-03-04

最近使用了sublime,前段时间编辑encoding中含有GBK,后来打开发现有问题了,到网上搜索发现,sublime有强大的package安装和管理功能,根据官方的说明,非常容易安装配置。

  1. 安装

如果防火墙禁止了对应的应用,那么方式1就无法安装

Installation is through the Sublime Text 2 console.

方式2,手动安装

a. Click the Preferences > Browse Packages… menu entry
b. Browse up a folder and then into the Installed Packages folder
c. Download Package Control.sublime-package from link:
https://sublime.wbond.net/Package%20Control.sublime-package
and copy it into the Installed Packages directory
d. Restart Sublime Text

  1. 使用

ctrl + shift +p 命令行模式,输入

Install Package

回车,就可以看到列出的所有package

  1. 选择packages,安装下面两个就可以解决切换相应编码的问题了

ConvertToUTF8

GBK Encoding Support”

其他的很多插件有待各位自己摸索………..

参考资料:

  1. http://www.fuzhaopeng.com/2012/sublime-text-2-with-gb2312-gbk-support/
  2. http://wbond.net/sublime_packages/package_control/installation

keystone v3 API的新特征

Posted on 2013-02-24

keystone的v3 API与v2.0相比有很大的不同,从API的请求格式到response的返回结果都有差别,主要几点如下:

  1. 引入了domain的概念,domain是在project,user, group之上抽象出的一个概念,是指

container for projects, users and groups

  1. v3中用project代替了以前的v2.0的tenant概念

  2. v3的验证/auth/tokens,相比v2.0的/tokens,token的ID不再在body中包含,而是在返回header中的X-Subject-Token

  3. v3还在验证上引入plugin方式,

1
2
3
4
[auth]
methods = password,token
password = keystone.auth.methods.password.Password
token = keystone.auth.methods.token.Token

可以添加自己的plugin来对keystone自己的auth方式进行定制化,关于auth这一部分:因为token有scoped和non-scoped的区别:

1
2
3
4
5
6
7
8
9
10
11
12
13
Scoped
1. project
If a project is specified by name, then the domain of the project must also be specified in order to uniquely identify the project
2. domain
Alternatively, a domain name may be used to uniquely identify the project.

A token scoped to a project will also have a service catalog, along with the user's roles applicable to the project. Example response:
A token scoped to a domain will also have a service catalog along with the user's roles applicable to the domain. Example response:


Non-scoped
1. user
If the user is specified by name, then the domain of the user must also be specified in order to uniquely identify the user

因为社区的开发方式,keystoneclient的开发和keystone并不是完全同步,加上keystone的v3还没有完全开发完毕,
所以现在用的keystoneclient还不完全支持v3 keystone。如果你要提前用keystoneclient,那就需要修改其中v3的client的代码

5.兼容性

为了让v2.0 的scheme迁移到v3,v2.0会默认的使用(keystone,conf)

1
# default_domain_id = default

更多的参考资料,可以参看:

  1. v3 API design https://etherpad.openstack.org/grizzly-keystone-v3api

  2. v3 API doc https://github.com/openstack/identity-api/blob/master/openstack-identity-api/src/markdown/identity-api-v3.md

Redhat 6.3 openstack的cinder安装配置

Posted on 2013-01-31

cinder 配置 安装:

1) 下载source code
2) pip install
3) yum install scsi-target-utils
4) yum install iscsi-initiator-utils.x86_64 (这两个相当于ubuntu下的 open-iscsi和tgt)
5) edit cinder config file
normally it includes :
database config
keystone access config
volumes config
message queue config
also enable cinder api in nova.conf

6) edit
/etc/lvm/lvm.conf
Add volume_list entry to /etc/lvm/lvm.conf to keep LVM from activating logical volumes created in VMs.
volume_list = [“VolGroup”, “cinder-volumes” ]

volume_list should include your os related volume group.

7)add volumes dir in /etc/tgt/targets.conf

include /var/lib/cinder/volumes/*

8) restart tgtd service

9) init cinder db
cinder-manage db sync

10) test if cinder works

10.1 create one test loop file and mount it

dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=2G

losetup /dev/loop2 cinder-volumes

10.2 init pv and create vg
pvcreate /dev/loop2

vgcreate cinder-volumes /dev/loop2

10.3 check if volume is created
pvscan

10.4 restart cinder service:
cinder api, scheduler, volume

10.5 use cinder to create volume
cinder create –display_name test 1

10.6 verify volume created successfully
cinder list

volume should in “available” status

OpenStack Grizzly 源码安装中遇到的几个问题

Posted on 2013-01-31

Grizzly Update

问题1:

When you keystone endpoint-list, hit issue,
(ENVOSTest)[root@localhost bin]# keystone endpoint-list
Failed to load keyring modules.

it missing keyring lib in python, use pip install to fix it.

pip install keyring

Blog http://blog.dynamichosting.biz/category/openstack/ seems not work with yum ways

问题2: 问题已经解决,

由于@wuwenxiang “PKI需要Openssl加密token,估计你没有在配置目录加上ssl的密钥”

[signing]

#token_format = PKI
把PKI改成UUID

refer:https://gist.github.com/4070200
否则会出现problem fulfilling your request. Command ‘openssl’ returned non-zero

问题3:

openstack bug
NameError: global name ‘service_ref’ is not defined
https://bugs.launchpad.net/nova/+bug/1102596

sudo 执行时的变量设置保留

Posted on 2012-12-26

现象:

我们在linux下使用sudo命令的时候,经常发现缺少一些变量,导致程序执行报错.

比如python程序fly,当前的用户是tom, 执行fly需要sudo权限执行,那么直接
sudo fly 会报错,缺少相应的模块,
只是因为对应的pythonpath的设置缺少,但是如果你仅仅export当前环境,执行sudo还是会报错,

原因:

问题就在于sudo的执行使得的环境变量进行了重置,所以相应的执行环境中无法找到对应的pythonpath,

解决:

简单的一种方法是,修改/etc/sudoers文件, 添加如下的设置

Defaults env_keep += PYTHONPATH

这里的PYTHONPATH只要是tom用户可以看到就行,比如你在~/.bashrc或profile中设置类似的变量。

参考资料:

  1. http://superuser.com/questions/232231/how-do-i-make-sudo-preserve-my-environment-variables
  2. http://stackoverflow.com/questions/7969540/pythonpath-not-working-for-sudo-on-gnu-linux-works-for-root
1…151617…26

Kai Qiang Wu

This is a place for thinking and writing

253 posts
32 tags
GitHub
© 2020 Kai Qiang Wu
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
Visitor Total Visit