归档文章: Linux

用ssh 进行端口影射

ssh

-g Allows remote hosts to connect to local forwarded ports.

-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be
forwarded to the given host and port on the remote side. This
works by allocating a socket to listen to port on the local side,
optionally bound to the specified bind_address. Whenever a con-
nection is made to this port, the connection is forwarded over
the secure channel, and a connection is made to host port
hostport from the remote machine. Port forwardings can also be
specified in the configuration file. IPv6 addresses can be spec-
ified with an alternative syntax:
[bind_address/]port/host/hostport or by enclosing the address in
square brackets. Only the superuser can forward privileged
ports. By default, the local port is bound in accordance with
the GatewayPorts setting. However, an explicit bind_address may
be used to bind the connection to a specific address. The
bind_address of localhost” indicates that the listening port
be bound for local use only, while an empty address or ‘*’ indi-
cates that the port should be available from all interfaces.

ssh -gL [bind_address:]port:host:hostport host

这样就可以forward到host上的某个端口上了.
如果退出了该ssh连接,则取消了该”服务”

nfs mount的时候非常慢,input/ouput error

客户端没有开启portmap服务.
如果不想开启portmap服务,则mount的时候加上-o nolock 的参数.

length of the string in linux shell

加速Linux程序编译

项目越来越大,每次需要重新编译整个项目都是一件很浪费时间的事情。Research了一下,找到以下可以帮助提高速度的方法,总结一下。

  tmpfs: 解决IO瓶颈,充分利用本机内存资源

  make -j: 充分利用本机计算资源

  distcc: 利用多台计算机资源

  ccache: 减少重复编译相同代码的时间
  tmpfs
更多…

nginx负载均衡和lvs负载均衡的比较分析(nginx vs lvs)

转自 http://www.sudone.com/nginx/nginx_vs_lvs.html
lvs和nginx都可以用作多机负载的方案,它们各有优缺,在生产环境中需要好好分析实际情况并加以利用。

首先提醒,做技术切不可人云亦云,我云即你云;同时也不可太趋向保守,过于相信旧有方式而等别人来帮你做垫被测试。把所有即时听说到的好东西加以钻研,从而提高自己对技术的认知和水平,乃是一个好习惯。

下面来分析一下两者:
更多…

如何开启linux远程桌面(enable remote desktop in linux)

以rhel 作为例子.
1. yum install vnc-server
2. run command “vncserver”
3. first time to run vncserver, you should configure the password for the remote access.
4. vi /root/.vnc/xstartup

5. restart the vnc server.
6. now you can use vnc comnand(inlinux) or vncviewer (in windows) to connect the remote linux desktop.

linux远程桌面 vncserver

1. vncserver (初次运行,会配置密码)
2. 启动后,就可以用vncviewer连接了。
3. 如果想使用gnome桌面,则需要在/root/.vnc/xstartup 里面,倒数第二行加入 gnome-session gnome&
4. 重新启动vncserver。

Multipath 配置

1.
安装device-mapper-multipath
需要device-mapper 和 sysfs-devel
2.
配置文件
/etc/multipath.conf
/etc/scsi_id.conf

修改scsi_id.conf
vendor=”iSCSI”,options=-p 0x80
vendor 填写scsi设备得供应商,options iscsi 用 –p 0x80 ,但好像此参数检测到所有iscsi盘唯一标识均一样,

/etc/multipath.conf
默认得配置
defaults {

multipath_tool “/sbin/multipath -v0″
udev_dir /dev
polling_interval 10
default_selector “round-robin 0″
default_path_grouping_policy multibus
default_getuid_callout “/sbin/scsi_id -g -u -s /block/%n”
default_prio_callout “/bin/true”
default_features “0”
rr_wmin_io 100
failback immediate
}

屏蔽得设备
devnode_blacklist {
devnode “^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*”
devnode “^hd[a-z][[0-9]*]”
devnode “^hda[0-9]*”
devnode “^cciss!c[0-9]d[0-9]*[p[0-9]*]”
}

multipath –d 可以查看能够创建得multipath,但不更改mapper
multipath –ll 查看multipath 拓扑结构
multipath –F 删除所有未用得multipath设备
开启服务 service multipathd start 会根据配置文件自动配置或者手动运行multipath来控制。

创建受限制的linux用户

1.创建一个受限用户组(如ifconfig)
2.创建一个受限用户(如ifconfig)
3.修改用户密码
3.修改/etc/passwd
更改此用户的登陆后的HOME路径,和登陆的shell (自己任意指定)
ifconfig:x : 510 : 500 : /home/users/ifconfig : /bin/bash 更多…

Manualy create a vmfs volume

to align VMFS volumes, the alignment will be done at ESX server level using fdisk and at the VM level. This is because both the ESX Server and the clients will put MBRs on the LUNs. The ESX must align the VMFS volume, and the client systems must align their virtual disks.
To align the ESX server: 更多…