Oracle on Ubuntu Linux

http://blogs.oracle.com/toxophily/entry/installing_oracle_11g_db_on

http://www.linuxidc.com/Linux/2011-03/32807.htm

http://www.pythian.com/news/13291/installing-oracle-11gr2-enterprise-edition-on-ubuntu-10-04-lucid-lynx/

https://forums.oracle.com/forums/thread.jspa?threadID=954055

1.

Update Packages

apt-get update
apt-get update

apt-get install elfutils libaio1 libaio-dev libstdc++6-4.4-dev numactl pdksh sysstat unixODBC-dev unixODBC build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm

2.

Create Groups

groupadd oinstall
groupadd dba
groupadd nobody

usermod -g nobody nobody

3.

Create / Update oracle User

useradd -s /bin/bash -m -g oinstall -G dba oracle

passwd oracle

4.

The following command is required to successfully run the installer.

xhost local:oracle

5.

Configure Limits for oracle

sudo gedit /etc/security/limits.conf

Add :

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

6.

Configure System

sudo gedit /etc/sysctl.conf

Add :

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304

7.

Make Directories

mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory

8.

Link command to location expected by oracle installer

ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename

9

Run Installer

I assume here that the user has previously installed the oracle database. If not simply follow the default options when the database installer executes.

./runInstaller

https://localhost:1158/em

Invalid source path ‘../stage/Components/oracle.jdk/1.5.0.17.0/1/DataFiles’ specified for unzip.

问题,第二张盘没有解压

http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

http://www.oracle.com/technetwork/developer-tools/jdev/overview/index.html

mysql 123456

自启动

Post Install

Add the following to /etc/profile

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export
PATH=$PATH:$ORACLE_HOME/bin

Start Script

Create /etc/init.d/oracledb with the following contents:

#!/bin/bash
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab
#
export ORACLE_OWNR=oracle
export ORACLE_OWNER=oracle
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo “Oracle startup: cannot start”
exit 1
fi

case “$1” in
start)
# Oracle listener and instance startup
echo -n “Starting Oracle: “
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/lsnrctl start”
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/dbstart $ORACLE_HOME”
touch /var/lock/oracle
echo “OK”
;;
stop)
# Oracle listener and instance shutdown
echo -n “Shutdown Oracle: “
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/lsnrctl stop”
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/dbshut $ORACLE_HOME”
rm -f /var/lock/oracle
echo “OK”
;;
reload|restart)
$0 stop
$0 start
;;
\*)
echo “Usage: `basename $0` start|stop|restart|reload”
exit 1
esac

exit 0

Execute :

cd /etc/init.d
update-rc.d oracledb defaults 99

The above will create links within the rc\*.d directories.

TNS:net service name is incorrectly specified

http://space.itpub.net/519536/viewspace-672034

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC=(
(SID_NAME=orcl)
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1/)
)
)
)

NL-00303: syntax error in NV string

alert.log文件位置
unix下在:$ORACLE_BASE/admin/sid/bdump下
windows:%ORACLE_BASE%/admin/sid/bdump下

在使用emctl的时候碰到了ulimit: 25: bad number.的错误
这是因为Ubuntu默认把/bin/sh指向了dash,通过修改emctl脚本的头部,将/bin/sh改成/bin/bash即解决问题。

emctl stop dbconsole

Linux: User limit of inotify watches reached.

I get inotify watches limit reached when I debug with my application in Play framework 2.5:
java.io.IOException: User limit of inotify watches reached
at sun.nio.fs.LinuxWatchService$Poller.implRegister(LinuxWatchService.java:264)
at sun.nio.fs.AbstractPoller.processRequests(AbstractPoller.java:260)
at sun.nio.fs.LinuxWatchService$Poller.run(LinuxWatchService.java:329)
at java.lang.Thread.run(Thread.java:745)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.io.IOException: User limit of inotify watches reached
[error] Total time: 4 s, completed 2016-3-29 14:32:25

Step1. cat /proc/sys/fs/inotify/max_user_watches
Step2.
sudo sysctl fs.inotify.max_user_watches=524288
Step3.
vi /etc/sysctl.conf add line below
fs.inotify.max_user_watches=524288

1. Kernel inotify watch limit reached
http://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached
2. Activator Active Stocks starter application fails to run with java.io.IOException?http://stackoverflow.com/questions/27204152/activator-active-stocks-starter-application-fails-to-run-with-java-io-ioexceptio
3.

Linux 下 zip 文件解压乱码如何解决?

记指令就需要重复使用,以前处理过,又搜了一遍。先用unzip -O cp936吧。:)

知乎上的答案:
由于zip格式中并没有指定编码格式,Windows下生成的zip文件中的编码是GBK/GB2312等,因此,导致这些zip文件在Linux下解压时出现乱码问题,因为Linux下的默认编码是UTF8。
目前网上流传一种unzip -O cp936的方法,但一些unzip是没有-O这个选项的。
我使用的版本 unzip 6.0 debian modified 版本有这个选项
我发现另外两种解决方案可用。
python方案
此方案目前来看非常完美。

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import zipfile

#print “Processing File ” + sys.argv[1]

file=zipfile.ZipFile(sys.argv[1],”r”);
for name in file.namelist():
utf8name=name.decode(‘gbk’)
# print “Extracting ” + utf8name
pathname = os.path.dirname(utf8name)
if not os.path.exists(pathname) and pathname!= “”:
os.makedirs(pathname)
data = file.read(name)
if not os.path.exists(utf8name):
fo = open(utf8name, “w”)
fo.write(data)
fo.close
file.close()
Windows 用户屏蔽两条 print 语句,Linux 用户不用屏蔽

7z方案
需要安装p7zip和convmv,在Fedora下的命令是

su -c ‘yum install p7zip convmv’
在ubuntu下的安装命令是

sudo apt-get install p7zip convmv
安装完之后,就可以用7za和convmv两个命令完成解压缩任务。

LANG=C 7za x your-zip-file.zip
convmv -f GBK -t utf8 –notest -r .
第一条命令用于解压缩,而LANG=C表示以US-ASCII这样的编码输出文件名,如果没有这个语言设置,它同样会输出乱码,只不过是UTF8格式的乱码(convmv会忽略这样的乱码)。
第二条命令是将GBK编码的文件名转化为UTF8编码,-r表示递归访问目录,即对当前目录中所有文件进行转换。

作者:Latm Ake
链接:Linux 下 zip 文件解压乱码如何解决?
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

Linux命令行proxy设置方式

最近访问amazonws有点问题,需要在命令行下解决proxy的设置问题。
http_proxy=http://:/
ftp_proxy=ftp://:/
all_proxy=socks://:/
ALL_PROXY=socks://:/
socks_proxy=socks://:/
https_proxy=https://:/
no_proxy=localhost,127.0.0.0/8,::1

如果你要在jvm里指定的话,可以指定命令行:
-Dhttp.proxyHost=proxyname
-Dhttp.proxyPort=80
-Dhttps.proxyHost=proxyname
-Dhttps.proxyPort=80

来源:
1. can not ping google using proxy
3. TypeSafe Activator 1.3.2 – Corporate proxy
4.

Python 2.7.9+gevent

Python 2.7.9+gevent会出问题。
如果你使用gevent 1.0 ,比如你使用Ubuntu 14.10,使用apt-get安装的缺省版本就是它,报的错误是:global name SSLContext not defined.这个路线我现在还没有分析。
如果你使用gevent 1.0.1,同样在Ubuntu 14.10,使用sudo easy_install -U gevent,安装的版本是目前gevent的最新版本1.0.1。提示的错误是:global name sslwrap not defined。

根据Debian的bug report,这个问题已经出现好长时间了。

Google的解决方案如下:
1. https://gist.github.com/ellimilial/5ef1d1917e00970d4457

sudo apt-get install python-dev cython git python-pip
sudo pip install git+git://github.com/ellimilial/gevent.git@master

not work。因为网络的原故,从github直接这么安装着实是慢得要死。

2. https://github.com/gevent/gevent/issues/477
这里面提供的代码经过测试是好用的,前提是使用gevent的最新1.0.1版本。

gist地址:https://gist.github.com/zz/af7d9efa539999757950

代码如下:

# Re-add sslwrap to Python 2.7.9
import inspect
__ssl__ = __import__('ssl')

try:
    _ssl = __ssl__._ssl
except AttributeError:
    _ssl = __ssl__._ssl2

def new_sslwrap(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=__ssl__.CERT_NONE,  ssl_version=__ssl__.PROTOCOL_SSLv23, ca_certs=None, ciphers=None):
    context = __ssl__.SSLContext(ssl_version)
    context.verify_mode = cert_reqs or __ssl__.CERT_NONE
    if ca_certs:
        context.load_verify_locations(ca_certs)
    if certfile:
        context.load_cert_chain(certfile, keyfile)
    if ciphers:
        context.set_ciphers(ciphers)

    caller_self = inspect.currentframe().f_back.f_locals['self']
    return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)

if not hasattr(_ssl, 'sslwrap'):
    _ssl.sslwrap = new_sslwrap

考虑到使用方便,可以使用下面代码(因为这条import当时忘记了,结果又重新修改了一下)

# Re-add sslwrap to Python 2.7.9
import inspect

def new_sslwrap(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=__ssl__.CERT_NONE,  ssl_version=__ssl__.PROTOCOL_SSLv23, ca_certs=None, ciphers=None):
    context = __ssl__.SSLContext(ssl_version)
    context.verify_mode = cert_reqs or __ssl__.CERT_NONE
    if ca_certs:
        context.load_verify_locations(ca_certs)
    if certfile:
        context.load_cert_chain(certfile, keyfile)
    if ciphers:
        context.set_ciphers(ciphers)

    caller_self = inspect.currentframe().f_back.f_locals['self']
    return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)

if not hasattr(_ssl, 'sslwrap'):
    _ssl.sslwrap = new_sslwrap

加到这段代码之下:

try:
    _ssl = __ssl__._ssl
except AttributeError:
    _ssl = __ssl__._ssl2

修改文件的位置:/usr/local/lib/python2.7/dist-packages/gevent-1.0.1-py2.7-linux-x86_64.egg/gevent
文件名:ssl.py

记得Ubuntu下使用gksu来应用权限。

此记。
———-
为什么会遇到这个问题:之前一篇文章说使用gevent速度会快些。已经加上了,速度什么的没有体会,反倒让这个问题折腾了,太喜爱技术的问题,以后还是少点发散吧。