IDEA2024 Mac版本闪退修复

Mac在关闭SIP后使用IDEA2024以后得版本会出现闪退。症状就是产生错误日志显示如下内容:


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0x0000000105f0835c, pid=22537, tid=7171
#
# JRE version:  (21.0.6+8) (build )
# Java VM: OpenJDK 64-Bit Server VM (21.0.6+8-b631.39, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# V  [libjvm.dylib+0x45c35c]  CodeHeap::allocate(unsigned long)+0x1a4
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
#

期初以为是配置文件冲突,或者无限试用补丁的缘故导致的,但是清理了全部idea文件后问题依旧,于是在idea官方论坛翻到了一个这样的帖子回复:

这才知道这个问题只出在关闭了SIP后的mac系统上,并且可以通过执行:

sudo nvram boot-args="-v ipc_control_port_options=0" 

另外我试了idea2025.1-EAP版本这个版本没有问题,说明官方处理问题的速度着实慢了。输入命令后重启即可解决问题IDEA可以正常运行了。

群晖DS918+将M2接口SSD挂载成存储

群晖官方只支持将M2接口的SSD作为存储空间的缓存来使用,但是这样我觉得太浪费,毕竟自动管理的缓存在用户少的时候命中率很低不如我直接在SSD上创建存储空间直接用于VMM或者存储需要高速读写的文件,毕竟这M2接口的SSD读写速度上GB/s。不过官方并不支持我直接在M2接口的SSD上创建存储空间,空间管理里面无法选择M2硬盘进行存储空间,存储池的创建。不过群晖的系统是基于Linux并且开放了SSH,既然如此那里理论上只要硬盘能被linux识别就肯定有办法挂载,至少也可以挂载到一个文件夹进行直接读写。
基于以上想法经过几个小时研究我最终成功的将硬盘挂载到指定文件夹实现了读写,并且最后也成功的将M2设置成了群辉的存储空间并安装了VMM虚拟机。
一、先说说怎么实现对M2硬盘的读写
链接群辉的SSH(怎么打开和链接SSH请看官们自行百度),然后直接提权到root执行

sudo su


然后输入登录密码即可取得系统的最高权限root权限,后续操作都需要在root下进行
然后查看m2硬盘是否被系统直接识别为硬盘存储设备

fdisk -l |grep Disk


可以看到会出现很多存储设备,找到名为 /dev/nvme开头的设备我的群晖里识别到的名称叫做 /dev/nvme0n1使用的插槽为第一个插槽,可能插在第二个插槽会识别为 /dev/nvme0n2
既然能在存储设备里看到m2硬盘那么后续就简单了,直接执行

mkfs.btrfs -f /dev/nvme0n1


将设备格式化为btrfs格式
然后群晖的控制面板里创建一个共享文件夹,我直接在第一个存储空间创建了一个叫FlashDisk的共享文件夹,于是执行挂载

mount /dev/nvme0n1 /volume1/FlashDisk


执行完挂载命令后就可以在直接在群晖中操作FlashDisk文件夹,此时FlashDisk文件夹的所有文件实际都是存储在m2硬盘上的。

以上就完成了最基础的能直接读写SSD的配置,但是我没有止步于此,进一步研究群晖的系统
在刚刚查看存储设备的时候我发现群晖的系统里出现了多个/dev/md开头的设备,懂linux的朋友应该都知道这是什么设备,这个就是linux的软raid设备,也就是系统创建的raid
但是我根本没创建raid啊,我总共装了4个普通硬盘每个盘都使用Basic模式创建,但是奇怪的是出现么md0 md1 md2 md3 md4 md5 这六个软raid,进一步看看这些raid到底是什么
别使用

mdadm -D /dev/md0 

mdadm -D /dev/md1

命令查看,发现这2个raid同时使用了4块硬盘上的第一个分区组件了raid1,大小为2.4g和2g

/dev/md0:
Version : 0.90
Creation Time : Wed Oct 17 22:48:44 2018
Raid Level : raid1
Array Size : 2490176 (2.37 GiB 2.55 GB)
Used Dev Size : 2490176 (2.37 GiB 2.55 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Sat Oct 27 11:02:08 2018
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

UUID : c5db6689:b4344136:3017a5a8:c86610be
Events : 0.1982

Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
2 8 33 2 active sync /dev/sdc1
3 8 49 3 active sync /dev/sdd1

然后在查看 md2 md3 md4 md5这4个软raid就比较简单了直接对应了我安装硬盘的大小,不过都使用的是第三个分区。
进一步使用fdisk -l查看详细存储设备信息
可以看到sda到sdd 4块硬盘各自都有3个分区,而且前2个分区的大小一致,分区的类型为 linux raid

Device Start End Sectors Size Type
/dev/sdc1 2048 4982527 4980480 2.4G Linux RAID
/dev/sdc2 4982528 9176831 4194304 2G Linux RAID
/dev/sdc3 9437184 7813832351 7804395168 3.6T Linux RAID

Disk /dev/sdd: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xc7051d67

Device Boot Start End Sectors Size Id Type
/dev/sdd1 2048 4982527 4980480 2.4G fd Linux raid autodetect
/dev/sdd2 4982528 9176831 4194304 2G fd Linux raid autodetect
/dev/sdd3 9437184 3906824351 3897387168 1.8T fd Linux raid autodetect

经过分析我大胆的推测群晖自动创建了md0和md1并且这2个软raid应该是存储系统和配置数据的并且每插入一块硬盘群晖都会给硬盘分3个区前2个加入到md0 md1 第三个分区就是存储用户自己的文件的。系统根目录分别由volume1 – volume4 这4个文件夹,经过上面的命令也能看到 实际分别对应md2-md5这四个设备

既然如此我们大致应该能推测出群晖的存储空间创建过程应该是 将硬盘配置成raid,然后把软raid挂载到根目录下的volume文件夹下这样一个过程。既然如此我们只要将m2硬盘照葫芦画票不就能识别成存储空间了?
我们卸载掉之前的挂载使用

umount /volume1/FlashDisk

如果提示失败的话直接重启
然后我们执行

fdisk /dev/nvme0n1

对m2硬盘进行分区,具体分区过程输入n 然后输入分区编号先用1 输入起始位置照着看到的其它分区来第一个分区2048开始,然后结束为止4982527,完成后分2 3这2个分区,注意3的结束为止不要输入不输入默认就是表示使用剩余的全部。
做完分区开始输入T然后输入1表示操作第一个分区,然后输入fd 依次吧 2 3分区都做这个操作,意思是将分区类型调整为linux raid
最后输入w保存分区
分区完毕 开始创建raid

mdadm --create /dev/md6 --level=1 --raid-devices=1 /dev/nvme0n1p3 --force
mdadm -C -v /dev/md6 -l 1 -n 1 /dev/nvme0n1p3 --force (7.0系统)

这样一个新的叫做md6的软raid就创建好了
格式化md6

mkfs.btrfs -f /dev/md6


然后创建volume5目录

mkdir /volume5


挂载md5到/volume5

mount /dev/md6 /volume5


经过这一系列操作m2硬盘已经成为存储空间了,但是这是去群晖的存储空间管理里面查看并没有新的存储空间出现
别着急重启群晖,然后再打开存储空间会有惊喜 PS:我探索的时候就没重启,没看到存储空间很绝望准备暂时放弃,到了晚上想重启一下让系统自动解除所有挂载,但是重启后惊奇的发现成功了识别成存储空间了。

将ssd增加到2个系统分区加速系统

向raid增加磁盘

mdadm /dev/md0 -a /dev/nvme0n1p1
mdadm /dev/md1 -a /dev/nvme0n1p2

修改磁盘激活数量

mdadm -G /dev/md0 -n 5 --force
mdadm -G /dev/md1 -n 5 --force

解决MySQL大量TIME_WAIT状态连接

netstat -anp |awk ‘{print $6}’|sort|uniq -c |sort -rn
netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more

使用netstat -an查看系统连接状态时发现存在大量TIME_WAIT连接,均为mysql。然后google了一下,下面贴出解决办法。
[root@blog~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:43389 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43388 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43387 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43382 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43381 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43380 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43379 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:43378 127.0.0.1:3306 TIME_WAIT
tcp 0 0 127.0.0.1:11211 127.0.0.1:38792 ESTABLISHED
tcp 0 0 127.0.0.1:11211 127.0.0.1:38799 ESTABLISHED

解决办法
#vi /etc/sysctl.conf,在文件最后加入如下内容
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
#sysctl -p //使修改内核生效

选项解释
net.ipv4.tcp_syncookies = 1 //表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭.
net.ipv4.tcp_tw_reuse = 1 //表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭.
net.ipv4.tcp_tw_recycle = 1 //表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭.
net.ipv4.tcp_fin_timeout //修改系統默认TIMEOUT时间.

参考文献 http://blogold.chinaunix.net/u3/93926/showart_1873546.html

gitlab安装

1. 安装依赖软件
yum -y install policycoreutils openssh-server openssh-clients postfix
2.设置postfix开机自启,并启动,postfix支持gitlab发信功能
systemctl enable postfix && systemctl start postfix
3.下载gitlab安装包,然后安装
centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
我的是centos7,所以我在https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7中找了个gitlab8.0.0版本,建议下载一个比较新的版本,我这里选了一个比较旧的版本仅仅是实验
下载rpm包并安装:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
4.修改gitlab配置文件指定服务器ip和自定义端口:
vi /etc/gitlab/gitlab.rb
external_url 改为自己的域名和端口号
nginx[‘listen_port’] = 10080

gitlab-ctl reconfigure
gitlab-ctl restart

【汉化】
git clone https://gitlab.com/larryli/gitlab.git
git diff origin/8-8-stable origin/8-8-zh > /tmp/8.8.diff
cd /opt/gitlab/embedded/service/gitlab-rails
git apply /tmp/8.8.diff
gitlab-ctl restart

pods安装和使用方法

rm -rf /usr/local/Cellar
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
brew doctor
brew update
brew install ruby

sudo gem update —system
sudo gem install cocoapods

pod search AFNetworking
pod install
pod update

Centos 7.0 安装lnmp环境

【MySql 5.6】:

[php]
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
成功安装之后重启mysql服务
service mysqld restart
初次安装mysql是root账户是没有密码的
设置密码的方法
mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password(‘mypasswd’);
mysql> exit
[/php]

【nginx】

[php]
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl–devel
wget http://nginx.org/download/nginx-1.7.4.tar.gz
tar -zxvf nginx-1.7.4.tar.gz
cd nginx-1.7.4
./configure \
–prefix=/usr/local/nginx \
–with-http_realip_module \
–with-http_sub_module \
–with-http_gzip_static_module \
–with-http_stub_status_module \
–with-pcre
make
make install
[/php]

【php】:

[php]
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64

yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64

yum install php55w-fpm
yum install php56w-fpm
yum install php70w-fpm
[/php]

【php-fpm配置】

[php]
groupadd www-data
useradd -g www-data www-data
编辑/etc/php-fpm.d/www.conf
listen.owner = www-data
listen.group = www-data www-data
listen.mode = 0666
[/php]

【配置nginx脚本】

[php]
[Unit]
Description=nginx – high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

放到/usr/lib/systemd/system/nginx.service

执行
systemctl daemon-reload

添加自启动
systemctl enable nginx.service
systemctl enable mysqld.service
systemctl enable php-fpm.service
[/php]

【禁用IPv6】

[php]
编辑文件
vi /etc/default/grub
在第5行加入:ipv6.disable=1
修改后如下
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

执行命令
grub2-mkconfig -o /boot/grub2/grub.cfg

验证
可以再次运行ifconfig
[/php]

【nginx基本 带thinkphp rewirte】

[php]
#worker_processes 1;
user www-data;
worker_processes 8;

error_log /usr/local/nginx/logs/nginx_error.log crit;
worker_rlimit_nofile 65535;

pid /run/nginx.pid;

events {
use epoll;
worker_connections 65535;
}

http {
include mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;

fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6].(?!.*SV1)";

server_tokens off;
#limit_zone limit $binary_remote_addr 10m;

log_format access ‘$remote_addr – $remote_user [$time_local] "$http_host $request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" $http_x_forwarded_for’;

server {
listen 80;
server_name localhost;

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location / {
root html;
index index.html index.htmi index.php;
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?s=$1 last;
rewrite ^/$ /index.php last;
break;
}
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)\??([\=a-z0-9]+)?$
{
access_log off;
expires 30d;
}

location ~ .*\.(js|css)\??([\=a-z0-9]+)?$
{
access_log off;
expires 30d;
}

location ~ /\.ht
{
deny all;
}
}
}
[/php]

【VSFTP】
[php]
yum install vsftpd pam* db4* -y
useradd ftpuser -s /sbin/nologin
vi /etc/vsftpd/vsftpd.conf
[/php]

[php]
anonymous_enable=YES –> anonymous_enable=NO //不允许匿名用户访问,默认是允许。
#chroot_list_enable=YES –> chroot_list_enable=YES //不允许FTP用户离开自己主目录,默认是被注释掉的。
#chroot_list_file=/etc/vsftpd/chroot_list –> chroot_list_file=/etc/vsftpd/chroot_list
vi /etc/vsftpd/chroot_list 直接wq

local_enable=YES //允许本地用户访问,默认就是YES,不用改
write_enable=YES //允许写入,默认是YES,不用改
local_umask=022 //上传后文件的权限掩码,不用改
dirmessage_enable=YES //开启目录标语,默认是YES,开不开无所谓,我是默认就行
xferlog_enable=YES //开启日志,默认是YES,不用改
connect_from_port_20=YES //设定连接端口20,不用改
xferlog_std_format=YES //设定vsftpd的服务日志保存路径,不用改
(这步后面要有几个操作才能运行,也就是touch这个文件(见第五步),因为它本身不存在,而且还要给文件写入的权限)
#idle_session_timeout=600 –> idle_session_timeout=600 //会话超时,客户端连接到ftp但未操作,默认被注释掉,可根据个人情况修改
#async_abor_enable=YES –> async_abor_enable=YES //支持异步传输功能,默认是注释掉的,去掉注释
#ascii_upload_enable=YES –> ascii_upload_enable=YES //支持ASCII模式的下载功能,默认是注释掉的,去掉注释
#ascii_download_enable=YES –> ascii_download_enable=YES //支持ASCII模式的上传功能,默认是注释掉的,去掉注释
#ftpd_banner=Welcome to blah FTP service //FTP的登录欢迎语,本身是被注释掉的,去不去都行
#chroot_local_user=YES –> chroot_local_user=YES //禁止本地用户登出自己的FTP主目录,本身被注释掉,去掉注释
pam_service_name=vsftpd //设定pam服务下vsftpdd的验证配置文件名,不用改
userlist_enable=YES //拒绝登录用户名单,不用改
TCP_wrappers=YES //限制主机对VSFTP服务器的访问,不用改(通过/etc/hosts.deny和/etc/hosts.allow这两个文件来配置)

//添加
pam_service_name=vsftpd
userlist_file=/etc/vsftpd/vsftpd/user_list
tcp_wrappers=YES
guest_enable=YES
guest_username=ftpuser
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vconf
[/php]

[php]
touch /var/log/vsftpd.log //日志文件
chown vsftpdadmin.vsftpdadmin /var/log/vsftpd.log //属于vsftpdadmin这个宿主
mkdir /etc/vsftpd/vconf/
touch /etc/vsftpd/vconf/vir_user
vi /etc/vsftpd/vconf/vir_user
virtualuser //用户名
12345678 //密码
注意:第一行用户名,第二行是上一行用户名的密码,其他人的以此类推

db_load -T -t hash -f /etc/vsftpd/vconf/vir_user /etc/vsftpd/vconf/vir_user.db
chmod 600 /etc/vsftpd/vconf/vir_user.db
chmod 600 /etc/vsftpd/vconf/vir_user

清空/etc/pam.d/vsftpd
echo "auth required pam_userdb.so db=/etc/vsftpd/vconf/vir_user" >> /etc/pam.d/vsftpd
echo "account required pam_userdb.so db=/etc/vsftpd/vconf/vir_user" >> /etc/pam.d/vsftpd
[/php]

[php]
touch /etc/vsftpd/vconf/virtualuser
vim /etc/vsftpd/vconf/virtualuser

输入:
local_root=/home/virtualuser //虚拟用户的个人目录路径
anonymous_enable=NO
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
idle_session_timeout=600
data_connection_timeout=120
max_clients=10
max_per_ip=5
local_max_rate=1048576 //本地用户的最大传输速度,单位是Byts/s,我设定的是10M
[/php]

[php]
chmod a-w 目录地址
禁止chroot根目录的写权限vsftp 2.3.5强制安全策略
[/php]

CentOS防SYN攻击

netstat -anp |awk ‘{print $6}’|sort|uniq -c |sort -rn
172 ESTABLISHED

  59 CONNECTED

  589 SYN_RECV

  15 STREAM

SYN居然这么高,继续追查是那些ip发出的SYN:

[root@tweb ~]# netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
首先说一下SYN的攻击原理:

  在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手建立一个连接。

  第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状态,等待服务器确认;

  第二次握手:服务器收到syn包,必须确认客户的SYN(ack=j+1),同时自己也发送一个SYN包(syn=k),即SYN+ACK包,此时服务器进入SYN_RECV状态;

  第三次握手:客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1),此包发送完毕,客户端和服务器进入ESTABLISHED状态,完成三次握手。 完成三次握手,客户端与服务器开始传送数据.

如果用户与服务器发起连接请求只进行到第二次握手而不再响应服务器,服务器就会不停地等待用户的确认,如果过多这样的连接就会把服务器端的连接队列占满就会导致正常的用户无法建立连接。所以我们直接从SYN的连接上进行如下改动:

  查看linux默认的syn配置:

 [root@web ~]# sysctl -a | grep _syn
net.ipv4.tcp_max_syn_backlog = 1024

  net.ipv4.tcp_syncookies = 1

  net.ipv4.tcp_synack_retries = 5

  net.ipv4.tcp_syn_retries = 5

  tcp_max_syn_backlog 是SYN队列的长度,加大SYN队列长度可以容纳更多等待连接的网络连接数。tcp_syncookies是一个开关,是否打开SYN Cookie 功能,该功能可以防止部分SYN攻击。tcp_synack_retries和tcp_syn_retries定义SYN 的重试连接次数,将默认的参数减小来控制SYN连接次数的尽量少。

  以下是我修改后的参数,可以根据自己服务器的实际情况进行修改:

复制代码
[root@web ~]# more /etc/rc.d/rc.local
  #!/bin/sh
  # This script will be executed *after* all the other init scripts.
  # You can put your own initialization stuff in here if you don’t
  # want to do the full Sys V style init stuff.
  touch /var/lock/subsys/local
  ulimit -HSn 65535
  /usr/local/apache2/bin/apachectl start
  #####
  sysctl -w net.ipv4.tcp_max_syn_backlog=2048
  sysctl -w net.ipv4.tcp_syncookies=1
  sysctl -w net.ipv4.tcp_synack_retries=3
  sysctl -w net.ipv4.tcp_syn_retries=3
复制代码
为了不重启服务器而使配置立即生效,可以执行

#sysctl -w net.ipv4.tcp_max_syn_backlog=2048
  #sysctl -w net.ipv4.tcp_syncookies=1
  #sysctl -w net.ipv4.tcp_synack_retries=3
  #sysctl -w net.ipv4.tcp_syn_retries=3
也有的人喜欢用访问控制列表来防止SYN的攻击,在一定程度上减缓了syn的攻击:

  Syn 洪水攻击

#iptables -A INPUT -p tcp –syn -m limit –limit 1/s -j ACCEPT
  –limit 1/s 限制syn并发数每秒1次
防端口扫描

 # iptables -A FORWARD -p tcp –tcp-flags SYN,ACK,FIN,RST RST -m limit –limit 1/s -j ACCEPT
死亡之ping

# iptables -A FORWARD -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
#>iptables-save >/etc/sysconfig/iptables
进行查看,#iptables -L

ACCEPT tcp — anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 1/sec burst 5

ACCEPT tcp — anywhere anywhere tcp flags:FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5

ACCEPT icmp — anywhere anywhere icmp echo-request limit: avg 1/sec burst 5

再次进行查看syn连接:

[root@web ~]# netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
  20 10.92.10.220
  1 125.43.36.199
明显SYN连接数已经下来了

升级MAC OS X自带的SVN客户端

出现问题:Xcode以及Mac系统自带的SVN版本基本都是1.6,由于日常开发中使用的SVN版本都是1.7以上的,因此需要升级svn版本。【说明:使用1.6版本的SVN客户端checkout的代码,使用1.7版本的客户端的时候,可能会出一些版本不兼容的问题,解决办法是切入到代码工程所在根目录,执行$ svn upgrade 命令进行转换或者,把之前检出的代码全部删掉,重新checkout。】

解决方案:
1、下载最新版的Mac版SVN客户端
到http://www.wandisco.com下载最新的Mac版SVN客户端,地址:http://www.wandisco.com/subversion/download/thankyou?f=subversion-binaries/1.7/Subversion-1.7.9_10.8.x.pkg
如果你的操作系统不是10.8请自己在下载页面选择一个合适的版本。
下载得到文件:Subversion-1.7.9_10.8.x.pkg。

2、安装最新版SVN客户端
点击刚才下载得到的文件开始安装,程序会默认安装到/opt/subversion下面。

3、替换Mac OS X自带的SVN客户端
使用如下命令可以找到Mac OS X自带的SVN客户端所在的目录
$ which svn
/usr/bin/svn
我们可以看一下这些文件
$ ls /usr/bin/svn*
/usr/bin/svn /usr/bin/svndumpfilter /usr/bin/svnrdump /usr/bin/svnsync
/usr/bin/svnadmin /usr/bin/svnlook /usr/bin/svnserve /usr/bin/svnversion
接下来我们删除这些旧版本的SVN程序,如果你有点点不放心,建议备份一下。
$ sudo rm -rf /usr/bin/svn*
接下来我们创建一些链接
$ sudo ln -s /opt/subversion/bin/svn* /usr/bin/
下一步需要重启终端以检测是否安装成功。输入以下命令检测一下,如果你看到下面的信息,则说明已经升级成功
$ svn –version
svn, version 1.7.9 (r1462340)
compiled Apr 3 2013, 13:49:20
Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
– handles ‘http’ scheme
– handles ‘https’ scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
– with Cyrus SASL authentication
– handles ‘svn’ scheme
* ra_local : Module for accessing a repository on local disk.
– handles ‘file’ scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
– handles ‘http’ scheme
– handles ‘https’ scheme

4、替换Xcode自带的SVN客户端
我之前以为Xcode直接调用操作系统自带的SVN客户端,更新了操作系统自带的SVN客户端之后,在Xcode里直接使用SVN,发现竟然还是1.6的!所以我们还需要升级Xcode的SVN客户端。
我当前Xcode版本是5.0,SVN客户端位于“/Applications/Xcode.app/Contents/Developer/usr/bin”目录下
$ ls /Applications/Xcode.app/Contents/Developer/usr/bin/svn*
/Applications/Xcode.app/Contents/Developer/usr/bin/svn
/Applications/Xcode.app/Contents/Developer/usr/bin/svnadmin
/Applications/Xcode.app/Contents/Developer/usr/bin/svndumpfilter
/Applications/Xcode.app/Contents/Developer/usr/bin/svnlook
/Applications/Xcode.app/Contents/Developer/usr/bin/svnrdump
/Applications/Xcode.app/Contents/Developer/usr/bin/svnserve
/Applications/Xcode.app/Contents/Developer/usr/bin/svnsync
/Applications/Xcode.app/Contents/Developer/usr/bin/svnversion
接下来我们删除这些旧版本的SVN程序,如果你有点点不放心,建议备份一下。
$ sudo rm -rf /Applications/Xcode.app/Contents/Developer/usr/bin/svn*
创建链接
$sudo ln -s /opt/subversion/bin/svn* /Applications/Xcode.app/Contents/Developer/usr/bin/
当然,如果你想和Xcode一样,直接把这些文件复制到Xcode下面也可以
$ sudo cp /opt/subversion/bin/svn* /Applications/Xcode.app/Contents/Developer/usr/bin/