centos开启swap
os:centos6
type:vps
1. 创建用于交换分区的文件
2. 设置交换分区文件
3. 立即启用交换分区文件
4. 设置开机时自启用swap分区,需要修改文件/etc/fstab中的swap行,添加记录。
dd if=/dev/zero of=/data/swap bs=1M count=4096 mkswap /data/swap swapon /data/swap /data/swap swap swap defaults 0 0
os:centos6
type:vps
1. 创建用于交换分区的文件
2. 设置交换分区文件
3. 立即启用交换分区文件
4. 设置开机时自启用swap分区,需要修改文件/etc/fstab中的swap行,添加记录。
dd if=/dev/zero of=/data/swap bs=1M count=4096 mkswap /data/swap swapon /data/swap /data/swap swap swap defaults 0 0
update user set Host='%' where Host ='127.0.0.1';
flush privileges;
原文:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html#sec-Introduction_to_firewalld1
参考译文:http://blog.csdn.net/steveguoshao/article/details/45999645
firewall-cmd --state
firewall-cmd --get-zones
firewall-cmd --zone=public --list-all
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
如何实现自动备份数据路里面所有业务表的功能:
#!/bin/bash echo "Dump mysql databases..." DB_USER=xxx DB_PASSWORD=xxx DB_LIST=$(echo "show databases;" | mysql -u${DB_USER} -p${DB_PASSWORD}) for db in ${DB_LIST} do if [ $db != "Database" ] && [ $db != "mysql" ] && [ $db != "phpmyadmin" ] && [ $db != "information_schema" ] && [ $db != "performance_schema" ]; then echo " backup "$db mysqldump -u${DB_USER} -p${DB_PASSWORD} $db > ./$db.sql fi done
错误:Perl module Authen::PAM needed for PAM is not installed
解决:yum install perl-Authen-PAM
错误:PAM test failed - maybe /etc/pam.d/webmin does not exist
解决:这个是要创建webmin的pam配置。这里我们可以直接copy sshd的配置
vs code 使用 调试F5时,提示如下:
Failed to continue: "Cannot find Delve debugger. Ensure it is in your GOPATH/bin
or PATH
."
根据提示缺少“Delve debugger”
解决:
go get github.com/derekparker/delve/cmd/dlv
如果把读书比多银海拾贝,这本书就是沙粒中一颗精致优美的贝壳。
本书很精薄,我基本上是一口气读完的,从晚上9点多到临晨1点多。
全书讲述了主人公木村,因执念绿色种植苹果的理念,被人当作傻子,最终经历8年的执着和等待,最终获得成功的故事。
故事里面不光有木村的执着,还有生动鲜活的果园风光,虫鸟与风草。文章细致描写了绿色种植理念的起因和主人公实际操作后面临的真实果园处境,采用第三视角和第一视角口述的方式交叉推进,显得真实而生动。
当主人公经历8年的辛苦,孤独,嘲讽,最终看到开花结果,而他的岳父母去世的时候,我的眼眶湿润了,有多少奋斗的人能等到亲人共享的时刻。
当因为自己的执念而让妻子和孩子受苦时,木村的心里苦不甘言,只能默默承受,恰似无数正在奋斗的人们。
最终执念和傻得到了回报,而我经历了一次难得的心灵旅程。
人生难得执念,主人公的成功也不必介怀,真实的人生,大部分人面临的最终可能是失败。
but:
人生只有一次,这种执念傻瓜的经历,又何尝不是一种幸福和境界?
完整内容地址:https://moonbingbing.gitbooks.io/openresty-best-practices/content/index.html
决定在动手之前先把这本书浅读一遍,磨刀不误砍柴工。
这里记录的都是我自己的理解和观点,或者需要强调的知识点,并不代表书的详细内容,详细还是请参见原文。
OS:CentOS Linux release 7.1.1503 (Core)
openresty:1.9.15.1
除非你要修改源码,如果只是运行官方的包,官方建议优先考虑预编译包,centos 系统支持如下:
版本号 | 支持的体系结构 |
---|---|
5.x | x86_64, i386 |
6.x | x86_64, i386 |
7.x | x86_64 |
你可以在你的 CentOS 系统中添加 openresty 资源库,这样就可以方便的安装我们的包,以后也可以更新(通过 yum update 命令)。添加资源库,你只用创建一个名为 /etc/yum.repos.d/OpenResty.repo 的文件,内容如下:
[openresty] name=Official OpenResty Repository baseurl=https://copr-be.cloud.fedoraproject.org/results/openresty/openresty/epel-$releasever-$basearch/ skip_if_unavailable=True gpgcheck=1 gpgkey=https://copr-be.cloud.fedoraproject.org/results/openresty/openresty/pubkey.gpg enabled=1 enabled_metadata=1
sudo yum --disablerepo="*" --enablerepo="openresty" list available
Loaded plugins: fastestmirror openresty | 3.5 kB 00:00 openresty/7/x86_64/primary_db | 32 kB 00:01 Determining fastest mirrors Available Packages openresty.x86_64 1.9.15.1-16.el7.centos openresty openresty-debug.x86_64 1.9.15.1-7.el7.centos openresty openresty-debug-debuginfo.x86_64 1.9.15.1-7.el7.centos openresty openresty-debuginfo.x86_64 1.9.15.1-16.el7.centos openresty openresty-doc.noarch 1.9.15.1-16.el7.centos openresty openresty-openssl.x86_64 1.0.2h-3.el7.centos openresty openresty-openssl-debug.x86_64 1.0.2h-4.el7.centos openresty openresty-openssl-debug-debuginfo.x86_64 1.0.2h-4.el7.centos openresty openresty-openssl-debug-devel.x86_64 1.0.2h-4.el7.centos openresty openresty-openssl-debuginfo.x86_64 1.0.2h-3.el7.centos openresty openresty-openssl-devel.x86_64 1.0.2h-3.el7.centos openresty openresty-resty.noarch 1.9.15.1-16.el7.centos openresty openresty-valgrind.x86_64 1.9.15.1-6.el7.centos openresty openresty-valgrind-debuginfo.x86_64 1.9.15.1-6.el7.centos openresty perl-Lemplate.noarch 0.07-3.el7.centos openresty perl-Test-Nginx.noarch 0.25-3.el7.centos openresty
关于openresty的rpm包的介绍见这里:http://openresty.org/cn/rpm-packages.html
按照文档的说明,我们暂时只需要安装openresty,openresty-resty,openresty-doc三个包就可以了
yum install openresty yum install openresty-resty yum install openresty-doc
sudo /sbin/service openresty start
stop, restart, 和 reload 这些指令也是支持的。
默认网站实例是加载在/usr/local/openresty/nginx/ 目录下的,如果要改变成自定义的目录使用 -p 选项:
sudo openresty -p /opt/my-fancy-app/
这个命令实测,是需要手动创建目录的,记得要先停止openresty。
在centos7下面,防火墙由iptables变更为firewalld,测试时需要增加相应的80端口,或者暂时关闭防火墙。
配置firewalld 使用firewall-cmd,默认需要安装:
yum install firewalld firewalld-config
查看当前开放zone,端口,服务:
firewall-cmd --get-active-zones firewall-cmd --zone=public --list-ports firewall-cmd --zone=public --list-service
增加80端口:
firewall-cmd --zone=public --add-port=80/tcp
添加openresty的开机自启动:
chkconfig --add openresty chkconfig openresty on
由于centos已经用systemD代替了systemV,系统不再有rc-local服务了,所以我们也不能简单添加rc.local了(网上流传的给增加运行权限的,在本机验证不成功)。标准的做法就是创建新的任务,通过chkconfig来启动了。
因为firewallD的规则是不能保存的,所以我们要放到开机自启动脚本中。
安装libreswan时遇到如下的错误:
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/state.c:800: undefined reference to event_free'
init_event_base':
server.o: In function
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/server.c:582: undefined reference to evthread_make_base_notifiable'
pluto_event_new':
server.o: In function
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/server.c:442: undefined reference to event_new'
pluto_event_free':
server.o: In function
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/server.c:588: undefined reference to event_free'
event_free'
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/server.c:589: undefined reference to
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/server.c:590: undefined reference to event_free'
event_free'
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/server.c:591: undefined reference to
timer.o: In function delete_pluto_event':
event_free'
/data/l2tp/l2tp/libreswan-3.17/programs/pluto/timer.c:814: undefined reference to
ikev2_parent.o:/data/l2tp/l2tp/libreswan-3.17/programs/pluto/ikev2_parent.c:2704: more undefined references to event_free' follow
evthread_set_condition_callbacks'
/usr/local/lib/libevent_pthreads.so: undefined reference to
/usr/local/lib/libevent_pthreads.so: undefined reference to event_mm_malloc_'
event_mm_free_'
/usr/local/lib/libevent_pthreads.so: undefined reference to
/usr/local/lib/libevent_pthreads.so: undefined reference to evthread_set_id_callback'
evthread_set_lock_callbacks'
/usr/local/lib/libevent_pthreads.so: undefined reference to
collect2: ld returned 1 exit status
make[3]: *** [pluto] Error 1
make[3]: Leaving directory /data/l2tp/l2tp/libreswan-3.17/OBJ.linux.x86_64/programs/pluto'
/data/l2tp/l2tp/libreswan-3.17/programs/pluto'
make[2]: *** [local-base] Error 2
make[2]: Leaving directory
make[1]: *** [all] Error 2
make[1]: Leaving directory `/data/l2tp/l2tp/libreswan-3.17/programs'
make: *** [all] Error 2
libreswan-3.17 install failed.
问题分析:
1. 检查libreswan的版本和代码包的正确性,去官网下载比对,确认下载是最新的代码。
2. 查看日志,根据event_free关键词,判断出问题的应该是libevent库,所以确认libevent,发现已经按照说明成功下载了libevent2了。
3. 继续查找日志细节:
---> Package libevent2.x86_64 0:2.0.21-2.el6 will be installed
--> Processing Conflict: libevent2-devel-2.0.21-2.el6.x86_64 conflicts libevent-devel
--> Finished Dependency Resolution
Error: libevent2-devel conflicts with libevent-devel-1.4.13-4.el6.x8664
从上面的提示看到是libevent2跟系统默认自带的libevent冲突了
解决:
yum remove libevent-devel-1.4.13-4.el6.x86_64
yum install libevent2-devel