2018年3月

29日去了阿里云深圳“驱动数字中国”听“阿里云支持与服务专场”

等了几天,盼到了。

坐地铁5号线,在“会展中心”站下,会场就在附近,好找。

yunxi-sz-1.jpg

先是在签到处说了身份证号码和手机号,妹纸说找不到信息,但可以现场报名,妹纸问有没有名片,我说没有。扫一下屏幕的二维码,现场提交个人信息,其中有“就职公司”之类的,我“发挥”一下,填了“安群网”,职位是“老总”,打印出来的二维码上,真有“安群网”,但可能顾及我的面子,“老总”的职位没打印出来。

之后呢,人多,所以坐扶手楼梯到了6楼,找到“文厅”,听“阿里云支持与服务专场”的演讲。

yunxi-sz-3.jpg

我在后边找一个“安静”的位坐下。听着大佬们讲,不时有人捧着手机拍屏幕上显示的演讲稿内容,但我仿佛是因为没睡午觉,眼前的PPT越来越模糊,声音慢慢变远,眼皮懒懒地想合上。瞌睡中,一个帅小伙说是卓游的技术总监,讲了阿里云适合他们业务的原因,挺不错的。四点多时,会场结束,我差不多最后,出门时,一个妹纸问,“你的牌牌呢?”,我从裤兜里掏出带有二维码的参会卡片,被“滴”了之后,换到了一本“hello world”的笔记(第二天送给小张了)。

yunxi-sz-5.jpg

我是特意穿着阿里云“more than just cloud”去的,但签到处的妹纸穿的是新版的"hello YunQi",在离开下扶手楼梯时看到两个提着AOC设备的哥们也是老版的"just cloud",再凑一个,可以上场打“吃鸡”游戏了。

yunxi-sz-4.jpg

在CentOS6 系统里为 postfix 配置外部smtp服务器发邮件

1.yum update # 更新软件
2.hostname erow.org # 设置主机名
3.vi /etc/postfix/main.cf # 编辑 postfix 配置文件,设置 myhostname = erow.org
4.yum install stunnel # 安装 stunnel 软件,目的是转发465端口数据
5.vi /etc/stunnel/stunnel.conf # 编辑 stunnel 配置文件,内容如下:

[smtp-tls-wrapper]
accept = 11125
client = yes
connect = smtp.mxhichina.com:465

6.vi /etc/rc.d/init.d/stunnel # 编辑 stunnel 启动配置文件,内容如下:

#!/bin/bash
#
# Init Script to run stunnel in daemon mode at boot time.
#
# Author: Riccardo Riva - RPM S.r.l.
# Revision 1.0 - 2010 November, 11

#====================================================================
# Run level information:
#
# chkconfig: 2345 99 99
# description: Secure Tunnel
# processname: stunnel
#
# Run "/sbin/chkconfig --add stunnel" to add the Run levels.
# This will setup the symlinks and set the process to run at boot.
#====================================================================

#====================================================================
# Paths and variables and system checks.

# Source function library
. /etc/rc.d/init.d/functions

# Check that networking is up.
#
[ ${NETWORKING} ="yes" ] || exit 0

# Path to the executable.
#
SEXE=/usr/bin/stunnel

# Path to the configuration file.
#
CONF=/etc/stunnel/stunnel.conf

# Check the configuration file exists.
#
if [ ! -f $CONF ] ; then
echo "The configuration file cannot be found!"
exit 0
fi

# Path to the lock file.
#
LOCK_FILE=/var/lock/subsys/stunnel

#====================================================================

# Run controls:

prog=$"stunnel"

RETVAL=0

# Start stunnel as daemon.
#
start() {
if [ -f $LOCK_FILE ]; then
echo "stunnel is already running!"
exit 0
else
echo -n $"Starting $prog: "
$SEXE $CONF
fi

RETVAL=$?
[ $RETVAL -eq 0 ] && success
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}

# Stop stunnel.
#
stop() {
if [ ! -f $LOCK_FILE ]; then
echo "stunnel is not running!"
exit 0

else

echo -n $"Shutting down $prog: "
killproc stunnel
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f $LOCK_FILE
echo
return $RETVAL

fi
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $LOCK_FILE ]; then
stop
start
RETVAL=$?
fi
;;
status)
status stunnel
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac

exit $RETVAL

#--- End of file ---

7.chkconfig stunnel on # 启用 stunnel 服务
8.chmod +x /etc/init.d/stunnel # 为 stunnel 配置文件,添加执行权限
9.service stunnel start # 启动 stunnel 服务
10.mkdir /etc/postfix/sasl # 创建 sasl 目录
11.vi /etc/postfix/sasl/sasl_passwd # 创建邮箱账户登录信息配置文件,内容如下:

[localhost]:11125 postmaster@erwo.org:password

12.postmap /etc/postfix/sasl/sasl_passwd # 生成postfix密码配置文件
13.chmod 600 /etc/postfix/sasl/* # 为了保护smtp的登录信息,需要修改上边两个文件为root用户只读写
14.vi /etc/postfix/main.cf # 修改 /etc/postfix/main.cf 文件,修改 relayhost = [localhost]:11125 , 添加SMTP信息:

relayhost = [localhost]:11125

#### SMTP
# Enable SASL authentication
smtp_sasl_auth_enable = yes
# Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
# Location of sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enable STARTTLS encryption
# smtp_tls_security_level = encrypt
# Location of CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_generic_maps = hash:/etc/postfix/generic

15.因为多数免费邮箱限定发信人是登录名(如postmaster@erwo.org),所以在 /etc/postfix/generic 文件里填写可能发信的地址,如:apache

apache postmaster@erwo.org

16.postconf -e 'smtp_host_lookup = dns, native' # 设置postfix dns解析
17./etc/init.d/postfix restart # 重启postfix
18.tail /var/log/maillog # 如有错误,可查看日志

参考:https://randomcentos.wordpress.com/2015/04/21/installing-stunnel-client-on-centos-6-6/

在Debian 9里vi(m)用鼠标远程选定复制文本

场景:日常用ssh远程登录到Debian,用vi来查看配置文件或日志文件,如nginx的,需要复制一些文本内容。

过程:

  1. Debian 8 系统里,vi 命令是 vi “原版”程序

    [root@iZj6c8af]# whereis vi
    vi: /bin/vi /usr/share/man/man1/vi.1.gz
    [root@iZj6c8af]# ls -l /bin/vi
    -rwxr-xr-x. 1 root root 907248 Jul 24  2015 /bin/vi
    [root@iZj6c8af]#
  2. 但在Debian 9系统里,vi命令是指向 vim 了

    root@AY130221:~# whereis vi
    vi: /usr/bin/vi /usr/share/man/man1/vi.1.gz
    root@AY130221:~# ls -l /usr/bin/vi
    lrwxrwxrwx 1 root root 20 Oct 25 14:08 /usr/bin/vi -> /etc/alternatives/vi
    root@AY130221:~# ls -l /etc/alternatives/vi
    lrwxrwxrwx 1 root root 18 Oct 25 14:11 /etc/alternatives/vi -> /usr/bin/vim.basic
  3. vim 相对于 vi 来说,可以提供额外的一些功能,如语法高亮显示等。对于本人的使用习惯,默认的vim配置,当用鼠标选中两个或多个字符时,会自动进入可视化(VISUAL),在vim程序中复制和粘贴,不是复制到本地
  4. vi ~/.vimrc # 创建个人的vim配置文件
  5. syntax on # 添加这行内容,目的是增加语言高亮显示功能,但清除在vim中鼠标选定等功能
  6. 再次运行vi测试,可以在ssh里用鼠标选定和复制文本内容到本地了

参考: