This user hasn't shared any profile information

Posts by haifeng

Oracle drop all user tables

for c in (select table_name from user_tables) loop
execute immediate ('drop table '||c.table_name||' cascade constraints');
end loop;

Linux虚拟机登陆界面显示DHCP IP地址


Ref url: http://offbytwo.com/2008/05/09/show-ip-address-of-vm-as-console-pre-login-message.html

# copy /etc/issue to /etc/issue-standard

cp /etc/issue /etc/issue-standard


/sbin/ifconfig | grep "inet addr" | grep -v "" | awk '{ print $2 }' | awk -F: '{ print $2 }'



if [ "$METHOD" = loopback ]; then
    exit 0
# Only run from ifup.
if [ "$MODE" != start ]; then
    exit 0
cp /etc/issue-standard /etc/issue
echo VM IP Address: $IPADDR >> /etc/issue



Docker Build过程中出错的解决办法


My dockerfile


FROM ubuntu:latest
MAINTAINER Haifeng Wang <hfwang att yahoo.com>


# Postgresql DB
RUN echo “deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main” >> /etc/apt/sources.list.d/pgdg.list
RUN apt-get install -y wget
RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O – | sudo apt-key add –

RUN apt-get update
RUN apt-get upgrade -y

RUN apt-get install -y postgresql postgresql-contrib
RUN /etc/init.d/postgresql start
RUN mkdir -p /opt/postgresql/tongueval
RUN chown postgres:postgres /opt/postgresql/tongueval
USER postgres
RUN psql –command “CREATE TABLESPACE tongueval LOCATION ‘/opt/postgres/tongueval’;”
RUN psql –command “CREATE USER tongueval WITH PASSWORD ‘password’;”
RUN psql –command “CREATE DATABASE tongueval OWNER=tongueval template=template0 encoding=’UTF-8′ TABLESPACE=tongueval;”
RUN echo “host all all md5” >> /etc/postgresql/9.5/main/pg_hba.conf

Then I run docker build for my image, “docker build .”

Step 12 : USER postgres

—> Using cache

—> 3dd84f680f22

Step 13 : RUN psql –command “CREATE TABLESPACE tongueval LOCATION ‘/opt/postgres/tongueval’;”

—> Running in 3b90f5e2499e

psql: could not connect to server: Connection refused

Is the server running locally and accepting

connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

The command ‘/bin/sh -c psql –command “CREATE TABLESPACE tongueval LOCATION ‘/opt/postgres/tongueval’;”‘ returned a non-zero code: 2

To try the SQL script failed during the build process, http://stackoverflow.com/questions/26220957/how-can-i-inspect-the-file-system-of-a-failed-docker-build

docker run -ti –rm 3dd84f680f22

CMUSphinx 定制语料库


环境:Mac OSX,v10.11.2;Homebrew已经安装好(http://brew.sh/)



  • cmusphinxbase
  • pocketsphinx
  • sphinxtrain
  • CMU-Cam_Toolkit_v2 (http://www.speech.cs.cmu.edu/SLM/)


  • tar  zxvf <tool>.tar.gz
  • configure
  • make
  • make install
    • 注: CMU-Cam_Toolkit_v2 只需要在src目录下执行make install,编译后命令安装到../bin目录
    • CMU-Cam_Toolkit_v2编译及命令参考
    • 编译过程中缺少的依赖包可以使用brew命令安装


RHEL mount remote windows share


[root@r6x ~]#lsmod | grep cifs

[root@r6x ~]# modprobe cifs

[root@r6x ~]# lsmod | grep cifs

[root@r6x ~]# mount -t cifs //garfield.local/fusion /mnt/garfield/ -o username=fusion,password=mypass

An Ansible playbook

- name: Jmeter test
 hosts: "{{host}}"
 # REMOTE_HOSTS, replace the value in jmeter.properties. jmeter_servers, come from ansible-playbook arguments. Format: Master:port;Slave1:port;Slave2:port...
 REMOTE_HOSTS: "{{jmeter_slaves}}"
 # JMETER_MASTER, jmeter master server, also ansible master
 JMETER_MASTER: "{{jmeter_master}}"
 # HOSTS, bb appservers. bb_hosts, come from arguments
 HOSTS: "{{bb_hosts}}"
 # PORT, bb service port
 PORT: "{{bb_port}}"
 # PROTOCOL, http or https
 PROTOCOL: "{{bb_protocol}}"
 # THREADS, jmeter thread count
 THREADS: "{{jmeter_threads}}"
 # RAMPUP, whether rampup server
 RAMPUP: "{{is_rampup}}"
 # LOOPS, jmeter loop count for test plan
 LOOPS: "{{jmeter_loops}}"
 # TEST_ENTRY, which jmx file to be run
 TEST_ENTRY: "{{jmeter_test_entry}}"
 # USERS_PATH, user data file
 USERS_PATH: "{{user_data_file}}"
 GIT_REPO: "https://github.com/scm/perf/jmeter-ultra-acceptance.git"
 GIT_BRANCH: "{{git_branch}}"
 FUSION_HOME: "{{fusion_home}}"
 - name: clean up previous git cloned files
 file: path={{FUSION_HOME}}/stage/jmeter-ultra-acceptance state=absent
 - name: clone code from stash repository
 git: repo={{GIT_REPO}}
 - name: Generate jmeter properties file
 template: src={{FUSION_HOME}}/stage/jmeter-ultra-acceptance/src/jmeter/jmeter.properties.template 
 - name: Generate user config file
 template: src={{FUSION_HOME}}/stage/jmeter-ultra-acceptance/src/jmeter/config/acceptance_user_config.properties.template
 - name: Check previous Jmeter process
 shell: ps -ef|grep gradle|grep -v grep| awk '{ print $2 }'
 register: ps_result
 - name: Kill all previous gradlew process
 shell: kill -9 `ps -ef|grep gradle|grep -v grep| awk '{ print $2 }'`
 when: ps_result.stdout|default("") != ""
 - name: Check lsof of jmeter-ultra-acceptance folder
 shell: lsof |grep /usr/local/fusion/stage/jmeter-ultra-acceptance |cut -b 11-16
 register: lsof_result
 - name: Kill all process which is using jmeter-ultra-acceptance
 shell: kill -9 `lsof |grep /usr/local/fusion/stage/jmeter-ultra-acceptance |cut -b 11-16`
 when: lsof_result.stdout|default("") != ""
 - name: Start slave jmeter server
 shell: "cd {{FUSION_HOME}}/stage/jmeter-ultra-acceptance/ && {{FUSION_HOME}}/stage/jmeter-ultra-acceptance/gradlew
 -PtestEntry={{TEST_ENTRY}} "
 when: ansible_hostname != "{{JMETER_MASTER}}"
 async: 1000
 poll: 0 
 - name: Slave status check
 wait_for: port=1099 delay=5 timeout=30
 when: ansible_hostname != "{{JMETER_MASTER}}"
 - name: Start Master jmeter server
 shell: "cd {{FUSION_HOME}}/stage/jmeter-ultra-acceptance/ && {{FUSION_HOME}}/stage/jmeter-ultra-acceptance/gradlew
 when: ansible_hostname == "{{JMETER_MASTER}}"
 async: 1000
 poll: 0
 register: jmeter_master_process 
 - name: Jmeter master process status check
 async_status: jid={{ jmeter_master_process.ansible_job_id }}
 register: job_result
 until: job_result.finished
 retries: 30
 when: ansible_hostname == "{{JMETER_MASTER}}"

Setup SQLServer 2008 DB mirroring




Principle server main.db.local
Mirror server mirror.db.local


Steps on build SQL Server mirroring

  1. Jion Windows servers into same Domain/Active directory
    • Active Directory or Domain is not necessary. BUT DB service and Agent service must run with same account, which means, the account name and password MUST be same.
    • Without Domain/AD, we need specify DNS suffix on all DB servers, and add all “computer name + DNS suffix” into hosts file for all DB servers. restart servers after changes.
      dnssuffix” />

      # hosts file  main.db.local  mirror.db.local
  2. Turn off firewall, or let TCP port 5022 and 1433 reachable for other servers. Check with command “telnet <other_server> 5022”. (更多…)

Openconnect 自动检查并重新连接VPN server(Reconnect)


Shell script

请修改里面的IP地址“192.168.0”,密码值“mYPaSsW0rd”以及用户名和VPN server。其中,IP地址是连接VPN后得到的IP地址。

/sbin/ifconfig |grep "192.169.0" 2>&1>/dev/null
if [ $? -ne 0 ]; then
  /usr/bin/killall openconnect 2>&1 >/dev/null
  echo  mYPaSsW0rd| /usr/sbin/openconnect -b --user=someone --no-cert-check --key-password-from-fsid --disable-ipv6 --passwd-on-stdin VPN.MYSERVER.COM 2>&1 > /dev/null


Crontab task

运行命令 crontab -e来编辑添加定时任务,添加如下行,每1分钟运行一次连接检查


* * * * * /bin/bash /usr/local/bin/vpn_reconnect


Investigation on “too many open files”


Tomcat server, limitation for user is 4096. java service will become no response after started up or runs for day(s).

In log file, found lots of “too many open files”.


lsof | grep java  | wc -l

more than 5000 opened file for the user.

lsof |grep java | grep protocol | wc -l

count for command is 1321

java      30758   bbuser 4714u     sock                0,6       0t0 1366904313 can't identify protocol

The number keep growing if run above command several minutes later, and eat up limitation for the user.


Root cause for this case:

There are over 39000 users need to be synchronized to other servers. The sync task will be run each minutes, and such amount of users cannot be completed in one minute. The task is asynchronous.


第 1 页,共 3 页123
haifeng's RSS Feed
Go to Top