danted + redsocks + iptables/nftables全局socks5代理配置
1、danted
安装
1 | $ sudo apt install dante-server |
配置/etc/danted.conf
1 | logoutput: syslog /var/log/sockd.log stdout |
References:
[1]
1、danted
安装
1 | $ sudo apt install dante-server |
配置/etc/danted.conf
1 | logoutput: syslog /var/log/sockd.log stdout |
References:
[1]
sshfs可以通过ssh和sftp协议来安全的在本地挂载远程文件系统,比NFS更方便的是无需更改防火墙设置,只要能使用ssh访问远程主机就可以了。
sshfs使用fuse在用户空间挂载远程文件系统,debian系统直接安装sshfs包,为了方便挂载,最好配置使用公私钥对来访问远程ssh主机,特别是fstab文件不支持ssh的密码访问方式。
挂载远程文件系统:
1 | $ sshfs user@host:/mnt/data/reis_dump/ /mnt/hwy06_reisdb_bak/ -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 |
也支持直接使用ssh别名
1 | $ sshfs hwy-reisdb-3:/mnt/data/reis_dump/ /mnt/hwy06_reisdb_bak/ -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 |
支持断线重连和心跳保持
具体的sshfs选项参见man
还有一个fuse文件系统挂载选项allow_other影响挂载的sshfs文件系统访问权限,如果允许除挂载用户之外的其他用户访问文件系统,需要指定此选项,并且需要修改fuse配置文件/etc/fuse.conf,打开user_allow_other选项
1 | # Allow non-root users to specify the allow_other or allow_root mount options. |
还可以写入fstab,开机可以自动挂载sshfs
/etc/fstab
1 | user@host:/var/www/ /var/www/ fuse.sshfs defaults,_netdev,allow_other,follow_symlinks,identityfile=/home/user/.ssh/id_rsa,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 0 0 |
在这里,_netdev挂载选项指定挂载sshfs需要有网络支持,follow_symlinks是sshfs的选项,支持符号链接,identityfile选项是ssh的选项,指定登录凭证,也可以通过.ssh/config配置别名来指定登录选项。
注意:
ssh长时间连接会超时,导致出现类似错误提示:
1 | client_loop: send disconnect: Broken pipe |
可以在ssh服务器/etc/ssh/sshd_config中打开客户端心跳探测:
1 | ClientAliveInterval 30 |
30秒发送一个心跳探测,超过3次没有回应断开连接。
References:
[1]SSHFS: Mounting a remote file system over SSH
[2]SSHFS
客户端连接失败,提示ORA-19815,alert.log有以下提示:
Errors in file /u01/app/oracle/admin/orcl/bdump/orcl_arc0_2734.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 2147483648 bytes is 100.00% used, and has 0 remaining bytes available.
Wed Jun 24 09:02:21 2020
You have following choices to free up space from flash recovery area:
查看磁盘空间还有很多剩余空间,是因为默认的归档目标设置为USE_DB_RECOVERY_FILE_DEST,并且flash_recovery_area的最大尺寸设置为了2GB(db_recovery_file_dest_size= 2147483648),可以有多种方法来解决此问题,通过设置RMAN归档保持策略来自动删除过期的日志文件。也可以使用RMAN DELETE来删除日志文件。
比如删除系统时间1天以前的归档日志
1 | RMAN>delete archivelog all completed before 'sysdate-1'; |
如果使用操作系统命令直接删除归档文件,并不能真正释放空间,还需要执行:
1 | $ rman target / |
cassandra集群以前运行于本地机房,现在需要扩展到云端,云主机添加为集群的新数据中心。因为并不是公有云,所有没有启动SSL认证和加密。
本地机房与云机房通过专线连接,并且本地只有两个互联ip地址可用。本地机房原集群内节点只使用私有网络地址,无法被云端访问。云端主机使用私有地址,云平台将私有地址映射到专线可以访问的“公有地址”,这里并不是真正的“公有地址”,仍然是一个大的私有网络,不过本地机房和云机房通过这些地址可以互访,所有这里也叫做“公有地址”
因此集群的本地机房节点通过NAT映射,将私有地址的7000和9042端口映射到公有地址,从而可以被云主机访问,同时做了端口回流,保证本地机房其他机器也可以通过公有地址访问节点。
如果不做或不能做端口回流,应该也可以使用iptables/nftables在集群内节点以及需要访问集群的客户机器上添加nat转换规则,从公有ip转换到对应的私有ip,这个没试。
这样本地机房和云机房的节点都有私有地址和映射后的公有地址,cassandra集群节点需要使用公有地址进行互访,但cassandra都无法直接监听公有地址。这需要配置cassandra.yaml,设置listen_address和rpc_address为私有地址,设置broadcast_address和broadcast_rpc_address为公有ip地址,但是listen_on_broadcast_address设置为false,因为各个节点并不能在公有ip上监听。这样当跨数据中心时使用公有ip通讯,但在本地网络内部可以使用私有网络。
cassandra-rackdc.properties配置文件可以打开prefer_local选项,这样可以优先使用本地网络,降低网络延迟。
配置实例:
1 | listen_address: 192.168.136.250 |
这样本地数据中心和云数据中心就可以通过公有ip相互通讯了。
备注:rpc并不是必须的,只使用cql是可行的。
References:
[1]Using multiple network interfaces
因为某云在某个网络内没有debian安装源,所以只能使用本地源。
debian支持的软件包很多,amd64架构的dvd iso竟然有16张之多,bd格式iso则只有4张,这里使用dvd格式的iso。
首先,下载debian 10.1.0 amd64架构的dvd iso,http方式只能下载前三个iso,下载其他iso需要使用jigdo方式即时下载在线制作iso文件。
debian系统安装jigdo-file使用jigdo-lite命令,输入iso的jigdo文件url即可下载制作iso镜像。debian 10.1.0 dvd iso的jigdo下载地址在此。
因为需要安装的包postgresql-11-postgis-2.5不在前三张dvd,所以使用jigdo下载了第四张dvd镜像。
然后,将四张dvd iso分别挂载到/media目录的挂载点:
1 | # mount /path/to/debian-10.1.0-amd64-DVD-1.iso /media/cdrom1/ |
也可以添加到/etc/fstab:
1 | /srv/debsrcs/debian-10.1.0-amd64-DVD-1.iso/media/cdrom1udf,iso9660 loop 0 0 |
然后
1 | # mount -a |
编辑/etc/apt/sources.list文件,添加如下行:
1 | deb \[ trusted=yes \] file:/media/cdrom1/ buster main contrib |
最后,apt update后正常安装软件即可,如果要安装的软件还是找不到,可能需要下载更多的dvd iso镜像。
使用rman convert database将oracle 10g 10.2.0.4 for windows x64环境下的数据库转换到oracle 10g 10.2.0.4 for linux x64环境下。
**注意:**无法使用standby备库来进行转换。
1、以只读方式打开数据库
1 | SQL> shutdown immediate |
2、检查可转换性和标示外部对象。
使用DBMS_TDB.CHECK_DB检查数据库状态,是否可以顺利转换到目标平台:
1 | SQL> set serveroutput on |
DBMS_TDB.CHECK_DB返回TRUE表示可以转换到目标平台,返回FALSE则不可以,同时会输出不可已转换的原因。
使用DBMS_TDB.CHECK_EXTERNAL标识外部对象。
1 | SQL> set serveroutput on |
如果有外部对象会在输出中显示出来。
3、转换数据库
可以在源数据库,也可以在目标数据库进行数据文件的转换。这里选择在目标数据库进行数据文件转换,这样可以减少源数据库的停止服务时间。
在源数据库执行rman convert database:
1 | $ rman target sys/passwd@dbinst |
命令执行完成会生成一个transport脚本用于在目标平台上创建数据库,一个pfile文件包含源数据库相同的参数配置,还生成一个convert脚本用于在目标平台上转换数据文件。
注意:在windows平台上只能使用windows系统路径名,包括FORMAT参数使用的路径,在linux平台上做数据库转换时,根据linux平台上oracle数据库的目录结构布局来相应修改生成的convertscript.rman,pfile和transportscript.sql。
3.1 convertscript.rman
生成的转换脚本类似如下:
1 | RUN { |
根据目标平台文件系统布局,修改为:
1 | RUN { |
/mnt/data/database目录下为从源库直接拷贝过来待转换的数据文件,转换完成的数据文件存储到/u01/oradata/orcl/目录下。
3.2 pfile
生成的INIT文件:
1 | # Please change the values of the following parameters: |
相应修改为:
1 | # Please change the values of the following parameters: |
3.3 transportscript.sql
生成的建库脚本:
1 | -- The following commands will create a new control file and use it |
相应修改为:
1 | STARTUP NOMOUNT PFILE='/u01/app/oracle/admin/orcl/pfile/INIT_00V216EA_1_0.ORA' |
3.4 实施转换
首先,将源数据库的数据文件全部拷贝到目标数据库(因为只拷贝数据文件,可以从standby备库拷贝),然后根据数据文件所在的路径相应的修改convert脚本,然后使用rman执行转换脚本,转换后的数据文件存储在format指定的位置。
目标平台必须要有一个已经存在的数据库,因为rman需要连接到target数据库才能工作:
1 | $ rman target / nocatalog |
然后,根据目标平台环境修改生成的pfile文件参数
最后,执行transportscript.sql生成目标数据库。使用utlirp.sql和utlrp.sql脚本重新编译目标平台数据的PL/SQL模块。
先关闭已有的数据库,oracle实例每次只能启动一个数据库:
1 | $ sqlplus / as sysdba; |
脚本最后最自动调用utlirp.sql和utlrp.sql编译模块。
其中遇到了错误:
1 | ORA-27102: out of memory |
是因为内核参数kernel.shmall设置为了2097152,oracle最大只能使用2097152*4096=8GB的系统内存,而INIT文件中设置的SGA大小超过了10GB,重新设置kernel.shmall为4194304可以最大允许16GB,问题解决。
数据库的sys用户是由本地密码文件验证的,数据库转换时并没有涉及到sys用户,因此需要本地重新为sys用户新建一个密码文件:
1 | $ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=passwd_for_sys force=y |
至此,数据库转换完成,最后以OPEN RESETLOGS方式打开新数据库。
References:
[1]15 RMAN Cross-Platform Transportable Databases and Tablespaces
[2]使用RMAN Convert Database命令实现跨平台的数据库迁移
oracle 10g已经太老了,直接在debian buster上安装是不可以的。但可以迂回一下,先在debian squeeze上安装,然后将安装好的oracle文件打包拷贝到debian buster相同的目录结构下,并且使用相同的用户和组权限。
一、安装
1、安装squeeze及支持组件
下载squeeze最后的版本6.0.10,脱机安装完毕后,编辑/etc/apt/sources.list使用以下源:
1 | deb http://archive.debian.org/debian squeeze main contrib non-free |
其他镜像源都已不可用,只有此归档源可以。
安装支持组件
1 | $ sudo apt-get install build-essential ia32-libs ia32-libs-dev libc6 libc6-i386 libc6-dev libc6-dev-i386 rpm libstdc++5 libaio1 gcc-multilib xauth unzip |
创建符号链接
1 | # ln -sf /usr/bin/awk /bin/awk |
2、创建用户和组
1 | # groupadd oinstall |
3、修改内核参数
添加文件/etc/sysctl.d/oracle.conf:
1 | fs.file-max = 65536 |
4、修改资源限制
添加文件/etc/security/limits.d/oracle.conf:
1 | oracle soft nproc 2047 |
5、准备目录结构
1 | #mkdir -p /u01/app/oracle |
从其他用户主目录拷贝.profile,.bashrc,.bash_logout文件到oracle用户主目录
6、安装10.2.0.1
通过X11 forward远程安装,安装路径设定为/u01/app/oracle/product/10.2.0/db_1
只安装软件,不创建数据库,忽略ins_emdb.mk错误继续安装
1 | $ ssh -XC oracle@host |
7、升级10.2.0.4
1 | $ unzip p6810189_10204_Linux-x86-64.zip |
升级时选择同一个实例,即OraDb10g_home1
二、移植
1、在squeeze上打包
1 | $ tar zcvf /tmp/oracle.tar.gz /u01 |
2、buster上创建用户组
1 | #groupadd oinstall |
3、准备目录结构
1 | #mkdir -p /u01/app/oracle |
4、buster上还原oracle
将oracle.tar.gz和oracle_conf.tar.gz拷贝到/tmp目录,以oracle用户执行
1 | $ tar zxvf /tmp/oracle.tar.gz -C / |
以root用户执行:
1 | # tar zxvf /tmp/oracle_conf.tar.gz -C / |
5、oracle用户配置
.bashrc添加如下环境变量
1 | export ORACLE_SID=orcl |
安装完成,经测试可以正常创建数据库,正常使用。
References:
[1]OracleDB
The Linux terminals that are provided by the console device drivers include line-mode terminals, block-mode terminals, and full-screen mode terminals.
On a full-screen mode terminal, pressing any key immediately results in data being sent to the terminal. Also, terminal output can be positioned anywhere on the screen. This feature facilitates advanced interactive capability for terminal-based applications like the vi editor. It works in raw mode default,can set to cbreak mode also.
On a line-mode terminal, the user first types a full line, and then presses Enter to indicate that the line is complete. The device driver then issues a read to get the completed line, adds a new line, and hands over the input to the generic TTY routines. It works in cooked mode default.
The terminal that is provided by the 3270 terminal device driver is a traditional IBM® mainframe block-mode terminal. Block-mode terminals provide full-screen output support and users can type input in predefined fields on the screen. Other than on typical full-screen mode terminals, no input is passed on until the user presses Enter. The terminal that is provided by the 3270 terminal device driver provides limited support for full-screen applications. For example, the ned editor is supported, but not vi.
References:
[1]Terminal mode
[2]Confusion about raw vs. cooked terminal modes?
[3]cooked mode
[4]What goes into the terminal’s ‘cbreak’ and ‘raw’ modes
References:
[1]Get OS X System Info from the Command Line