0%

man useradd里有一句话:

useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead

也就是说useradd是一个低层次的用户添加工具,适合高阶用户使用,而在简单的场合适合使用adduser来添加用户,adduser添加用户时系统有step by step的用户提示来交互时的添加用户,使用比较简单,无需指定复杂的命令行选项。

那么说,useradd适用于非交互式场景,比如在脚本中创建用户,而adduser更适用于交互式场景

===
[erq]

PostgreSQL执行外部sql脚本有两种方式:
一种是在bash命令行上为psql命令用-f选项或重定向指定sql脚本

1
$ psql -U username -d dbname -f /path/to/script.sql

1
$ psql -U username -d dbname < /path/to/script.sql

另一种是在psql命令行上用\i命令执行sql脚本

1
=# \\i /path/to/script.sql

mac os x的bash切换到名字含有空格的目录时,可以使用单引号包围目录名,此时自动完成是正常的,也可以使用backslash反斜杠来转义空格,但此时无法自动完成,只能手工输入。#不如linux好用#

tomcat 7+依赖于SecureRandom为其session id及其他事项生成随机数,但由于JRE等各方面的因素,可能会导致tomcat启动特别缓慢。
catalina.out里会有类似如下提示

1
2
3
...
INFO: Creation of SecureRandom instance for session ID generation using \[SHA1PRNG\] took \[586,623\] milliseconds.
...

通过配置JRE使用非阻塞的熵源,可以解决此问题,但因随机性下降会降低系统安全性。

为JRE添加如下属性

1
-Djava.security.egd=file:/dev/./urandom

比如可以在/etc/default/tomcat8中的添加:

1
JAVA_OPTS="-Djava.awt.headless=true -Xmx1280m -XX:+UseConcMarkSweepGC -Djava.security.egd=file:/dev/./urandom"

References:
[1]How do I make Tomcat startup faster?

===
[erq]

应用程序启动时有如下错误提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
ERROR \[localhost-startStop-1\] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomikosUserTransaction' defined in ServletContext resource \[/WEB-INF/conf/spring-servlet.xml.bak\]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'transactionTimeout' threw exception; nested exception is com.atomikos.icatch.SysException: Error in init(): /var/lib/tomcat8/./tm.out.lck
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java: 1506)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1241)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1154)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4969)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1703)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'transactionTimeout' threw exception; nested exception is com.atomikos.icatch.SysException: Error in init(): /var/lib/tomcat8/./tm.out.lck
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java: 1502)
... 33 more

这是因为默认情况下,atomikos要在/var/lib/tomcat8目录下生成其日志和锁文件,而/var/lib/tomcat8文件夹的所有者和组都是root,无法写入,所以初始化失败。

解决方法有二,最简单粗暴的就是将/var/lib/tomcat8目录的所有者和组都更改为tomcat8.

另一个方法是classpath中添加atomikos配置文件,将其输出文件目录配置到tomcat8有权限写入的目录中,比如/var/log/tomcat8

1
2
3
4
5
6
7
com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.log_base_name = jdbc
com.atomikos.icatch.log_base_dir = /var/log/tomcat8 # 日志文件输出目录
com.atomikos.icatch.output_dir = /var/log/tomcat8 # 文件输出目录
com.atomikos.icatch.tm_unique_name = com.atomikos.spring.jdbc.tm
com.atomikos.icatch.serializable_logging=false
com.atomikos.icatch.max_timeout=2000000

===
[erq]

几个意思相近又有区别的词语:
crew 全体船员; 全体乘务员;全体工作人员
staff 全体职员; 全体管理人员;
faculty 全体教员
crowd 一群,人群

查看oracle job的运行状态,可以查询这几张系统视图ALL_SCHEDULER_JOB_LOG/DBA_SCHEDULER_JOB_LOG和dba_scheduler_job_run_details

1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python3

import tkinter

#from tkinter import *

tk = tkinter
root = tk.Tk()
label = tk.Label(root, text="hello tkinter")
label.pack()
root.mainloop()

===
[erq]

The keyword SNAPSHOT is supported in place of MATERIALIZED VIEW for backward compatibility.
也就是以前叫“快照”,现在叫“物化视图”了。