centos2

----------ps -ewf显示全部进程,ps -a|grep ss指的是显示ss关键字的全部进程。top是动态显示进程。php

---------cat直接将文件内容显示在终端上。html

---------查看linux系统版本信息cat /etc/*release。
linux

---------从一台Linux机子拷贝recovery.conf.sample到192.168.59.128机子:scp recovery.conf.sample root@192.168.59.128:/home/pg93/test_repgit

---------ll 列出文件权限d表示是文件夹r表示可读w表示可行x表示可执行。(ll -t。是按照时间降序)web

---------netstat -anp|grep ss指的是显示包括ss关键字的全部服务端口。sql

----------文件重命名:mv aaa bbb。(mv就是这个意思)。chrome

----------解压tar -jxvf aaa.tar数据库

-----------查看文件abc.txt大小单位MB:du -sh /home/abc.txtubuntu

--------------快速搜索文本grep -r xxx /usr/local/yyy 。搜索目录yyy下的全部文件内容中含有关键字xxx的文件,并列出来。
centos

-----------查找文件或者文件夹的名字中含有recovery.conf关键字的:find -name recovery.conf。

-----------查看软件是否被安装:rpm -qa|grep readl。查看含有关键字readl的包是否被安装。

-----------在网上搜索含有readl的包yum search readl

----------查看一个包的路径:which psql

-----------显示当前路径:pwd

-----------改变pg93用户的环境变量:cd /home/pg93  vi .bash_profile 修改便可,完了以后须要执行source /home/pg93/.bash_profile,例如:

 

export PGPORT=1921
export PGDATA=/pgdata/pg_root
export LANG=en_US.utf8
export PGHOME=/home/pg93/pgsql
export
LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres
export PGHOST=$PGDATA
alias rm='rm -i'
alias ll='ls -lh'
export PGDATABASE=digoal

 

 

-----------修改防火墙ipstables:vi /etc/sysconfig/iptables,容许或限制端口。




登录postgresql数据库后若是想:

--------------查看数据库全部参数:show all;

--------------查看表/视图等的详细信息:\d+ pg_stat_activity。(查看pg_stat_activity视图的详细信息,包括SQL语句的组成)

--------------切换查看SQL输出内容的方式(水平/垂直):\x

--------------查看有哪些表空间:\db

--------------请求一个checkpoint点:checkpoint;(将脏数据flush一下文件)

---------------强行将一个xlog:select pg_switch_xlog();(归档日志切换到下一个日志能够)

--------------查看表空间大小: select pg_size_pretty(pg_tablespace_size('pg_default')); 。pg_default是表空间名

--------------查看所的状态:select relation::regclass,* from pg_locks;(relation::regclass为table/index...)

--------------查看索引:\di

---------------查看当期那数据库链接的pid:select pg_backend_pid();

---------------查看数据库有安装有哪些中间件。\dx

---------------查看数据库有关键字page的全部函数。\df *page*

---------------查看当前的事务ID(XID):select txid_current();

---------------查看role:\du

---------------查看pg进程所占内存大小ps -eo pid,user,pmem,rssize,cmd --sort rssize|grep 172.0.0.1

---------------查看表bb的大小:select pg_relation_size('bb');

---------------查看relation的行锁:select * from pgrowlocks('a');(查看a表的行级锁,须要create extension pgrowlocks;)

---------------查看锁: select * from pg_locks ;

---------------查看类型:select pg_typeof(234);--integer

---------------查看表foo所对应的的文件位置:select pg_relation_filepath('foo') ;

---------------查看所欲系统表:http://www.php100.com/manual/PostgreSQL8/(中文)http://www.postgresql.org/docs/9.3/interactive/catalogs.html(英文)

---------------查看一个表的全部tuple(行)在PAGE(页)中的位置:select ctid, xmin, xmax, * from testtb;(可使用create extension pageinspect;查看PAGE的内容http://blog.163.com/digoal@126/blog/static/16387704020114273265960/

ctid:内容是(哪个PAGE,属于此PAGE下的第几个)

xmin:插入此tuple的XID(事务ID)
xmax:更新(UPDATE/DELETE)此tuple的XID(事务ID)


--------------两个普通会话间事务等待

 

 

事务1:update testtb set info='aaaa' where id=1;
事务2:update testtb set info='bbbb' where id=1;
此时事务2会等待被事务1的提交,而后事务2才会提交,而后覆盖事务1提交的容。

-------------两个会话间使用repeatable read

 

 

事务1:update testtb set info='aaaa' where id=1;
事务2:update testtb set info='bbbb' where id=1;
此时事务2会等待事务1提交,而后会报错 ERROR:  could not serialize access due to concurrent update

-------------两个会话间使用repeatable read,一个使用read committed

 

 

事务1:update testtb set info='aaaa' where id=1;(repeatable read)
事务2:update testtb set info='bbbb' where id=1; (read committed)
此时事务2会等待事务1提交,而后用事务2提交后结果覆盖事务1。
事务1:update testtb set info='bbbb' where id=1; (read committed)
事务2:update testtb set info='aaaa' where id=1;(repeatable read)
此时事务2会等待事务1提交,而后会报错 ERROR:  could not serialize access due to concurrent update

-------------两个会话间都使用read committed

 

 

事务1:update testtb set info='aaaa' where id=1;(read committed)
事务2:update testtb set info='bbbb' where id=1; (read committed)
此时事务2会等待事务1提交,而后用事务2提交后结果覆盖事务1。

-------------Serializable(串行隔离)

 

 

事务1:update testtb set info='777777777' where id=1;(Serializable)
事务2:update testtb set info='888888888' where id=2;(Serializable)
此时事务2会等待事务1提交,而后会报错ERROR:  could not serialize access due to read/write dependencies among transactions
虽然更新表testtb的是两个不一样的tuple到那时也会报错的缘由是尚未给表testtb创建索引。串行隔离会锁住与之相关SQL语句相关执行计划的内容。
参看:http://pan.baidu.com/disk/home#dir/path=%2F%E6%95%B0%E6%8D%AE%E5%BA%93%2Fpostgresql%2FPostgreSQL%209.3%20%E5%9F%B9%E8%AE%AD%E8%A7%86%E9%A2%91 下的PostgreSQL 9.3 培训 - D3.pdf,而后全部‘Serializable’便可。


----------通常事务的互锁,SERIALIZABLE事务的互锁,repeatable read,read committed事务的互锁都是同样,以下:参考 http://blog.163.com/digoal@126/blog/static/16387704020113811711716/

 

 

事务1:update a set id=id+2 where id=55;
事务2:update b set id=id+2 where id=55;
事务1:update b set id=id+2 where id=55;------此时会等待事务2结束
事务2:update a set id=id+2 where id=55;------此时会等待事务1结束
而后等待1毫秒(在postgresql.conf设置deadlock_timeout参数)后会报错 DETAIL:  Process 2847 waits for ShareLock on transaction 1897; blocked by process 2845.
Process 2845 waits for ShareLock on transaction 1899; blocked by process 2847.
HINT:  See server log for query details.



--------------在安装postgresql的时候须要依赖一个flex,readline-devl: yum -y install flex , yum -y install readline-devel, yum -y install zlib-devel

--------------在安装postgresql的时候可使用gmake word,gmake install-world这样会将postgresql全部的contrib下的包编译并安装。

--------------postgresql各个中间件project下载http://git.postgresql.org/gitweb/

--------------pgfincore使用说明http://francs3.blog.163.com/blog/static/4057672720107541611270/  http://villemain.org/projects/pgfincore  http://blog.163.com/digoal@126/blog/static/1638770402011630102117658/  http://blog.csdn.net/wanghai__/article/details/6547786

--------------postgresql.conf配置文件参数说明:

 

tcp_keepalives_count==>tcp_keepcnt关闭一个非活跃链接以前进行探测的最大次数,默认为 8 次(0表示系统默认值)
tcp_keepalives_idle==>tcp_keepidle对一个链接进行有效性探测以前运行的最大非活跃时间间隔,默认值为 14400(即 2 个小时)(0表示系统默认值)
tcp_keepalives_interval==>tcp_keepintvl两个探测的时间间隔,默认值为 150 即 75 秒(0表示系统默认值)
authentication_timeout==>客户端链接数据库时的认证时长
max_prepared_transactions==>一个数据库能够同时开启几个事务停留在磁盘上。(0表示数据库将关闭此特性)
work_mem==>排序操做内存大小(DISTINCT,ORDER BY,MERGE会用到排序)
temp_buffers==>每一个数据库的私有内存,临时表使用。
maintenance_work_mem==>每一个数据库的私有内存,VACUUM,CREATE INDEX,ALTER TABLE等操做所用内存
max_stack_depth==>一个链接数据库的进程锁使用的栈大小。
max_fsm_relations==>FSM跟踪的表和索引的个数的上限,每一个表和索引在FSM中占7个字节的存储空间
max_fsm_pages==>FSM中跟踪的数据块的个数的上限(FSM指的是数据块剩余的可用空间存放到一个MAP中,能够内存碎片的VACUUM)
max_files_per_process==>每一个数据库进程可以打开的文件的数目
vacuum_cost_delay==>VACUUM进程的睡眠时间

--------------postgres除了wal日志觉得ia,若是还须要输出csv日志,则postgresql.conf的配置须要修改一下几个地方:

 

 

log_destination = 'csvlog'
logging_collector = on
log_directory = '/home/postgres/pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
----------------------初始化数据库initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W

 

----------------------启动数据库pg_ctl start -D $PGDATA

----------------------登录数据库psql -h localhost -p 1999 -U  postgres postgres

----------------------中止数据库pg_ctl stop -m fast|

----------------------重启数据库pg_ctl restart





下载vmware,能够安装多种操做系统(linux,unix,window等)

 

vmware workstation10的许可证密钥

 

MA491-6NL5Q-AZAM0-ZH0N2-AAJ5A
5A6F6-88247-XZH59-HL0Q6-8CD2V
HF6QX-20187-2Z391-522NH-9AELT
5F29M-48312-8ZDF9-A8A5K-2AM0Z

 

下载centos系统地址:

http://isoredirect.centos.org/centos/6.5/isos/ (CentOS系统镜像有两个,安装系统只用到第一个镜像即CentOS-6.x-i386-bin-DVD1.iso(32位)或者CentOS-6.x-x86_64-bin-DVD1.iso(64位),第二个镜像是系统自带软件安装包)

BinDVD版——就是普通安装版,需安装到计算机硬盘才能用,bin通常都比较大,并且包含大量的经常使用软件,安装时无需再在线下载(大部分状况)。
LiveDVD版——就是一个光盘CentOS系统,可经过光盘启动电脑,启动出CentOS系统,也有图形界面,也有终端。也能够安装到计算机,可是有些内容可能还须要再次到网站下载(自动)。
LiveCD版——相比LiveDVD是个精简的光盘CentOS系统。体积更小,便于维护使用。

----------------外网访问VMware的linux虚拟机

 

http://blog.csdn.net/hpwzd/article/details/7363694

VMware虚拟机的端口映射

使用NAT上网的linux虚拟机是和主机共享一个ip的,此时外网访问这个ip是访问你的主机,而不是你的linux虚拟机!所以此时须要对VMware虚拟机作一个端口映射!

具体方法以下:

a、VMware下Edit->Virtual Network Editor->VMnet8->NAT Setting->Add开始设置端口映射。

b、Host port 为要映射到主机的主机端口

   Type     依状况而定

   Virtual machine IP Address 为linux虚拟机的IP地址(超级权限,ifconfig可查看)

   Virtual machine port       为要映射到主机的虚拟机端口

c、举例:将linux虚拟机的ssh端口22映射到主机的6000端口,外界访问时直接访问主机地址的6000端口即访问linux虚拟机的22端口。其余的依样画葫芦便可!

注意须要开放防火墙对相应端口。好比端口22和5432:

less /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

 

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT


------------------------下载securecrt7而后链接linux系统

window下cmd测试链接ssh/ssh2:ssh honglianglu@192.168.59.128。(其中192.168.59.128是vmware的虚拟机中一个ubuntu的ip)。

在使用securecrt登录linux的时候会报password authentication failed. please verify that the username and password are correct错误。无需更改配置须要从新启动一下window主机便可。

对于ubuntu来讲默认没有安装ssh,须要sudo apt-get install openssh-server安装一下。而后sudo /etc/init.d/ssh start(或者service ssh start)启动。查看启动是否成功ps -e |grep ssh。

背景颜色设置:Options->Global Options...->Terminal->Appearance->Advanced->Monochrome->Edit->而后参见下图:


中文乱码解决方案:Options->Session Options->Appearance->Font->新宋体 字符集:中文GB2312 ->Character encoding 为UTF-8。

复制黏贴快捷键的设置:Options->Global Options...->Terminal,而后选中Mouse那一栏中的Paste on right button,而后肯定便可。在使用的时候使用鼠标在securecrt中鼠标左键选中一部份内容,而后点击鼠标右键,便可直接黏贴到secureCRT中。

-------------securecrt上传下载:
安装lrzsz:yum -y install lrzsz。rz:上传;sz:下载。
-----------home键和end键将光标移至行首/行尾:

相关文章
相关标签/搜索