通知设置 新通知
银河麒麟4.0.2 SP3系统可执行文件报权限不够
智慧运维 chris 发表了文章 1 个评论 145 次浏览 2021-02-01 11:31

现象
root@Kylin:~# cat aa.sh
echo 1
root@Kylin:~# bash aa.sh
bash: aa.sh: 权限不够
root@Kylin:~# ls -l aa.sh
-rw-r--r-- 1 root root 7 2月 1 10:14 aa.sh
root@Kylin:~# chmod +x aa.sh
root@Kylin:~# bash aa.sh
bash: aa.sh: 权限不够
root@Kylin:~# cat aa.sh
echo 1
root@Kylin:~# bash aa.sh
bash: aa.sh: 权限不够
root@Kylin:~# ls -l aa.sh
-rw-r--r-- 1 root root 7 2月 1 10:14 aa.sh
root@Kylin:~# chmod +x aa.sh
root@Kylin:~# bash aa.sh
bash: aa.sh: 权限不够
如上所示,写了一个简单的Shell脚本,直接bash解释报权限错误,一般权限错误是没有执行权限什么的,但是如上给了权限还是报错。
因为也没有怎么深入使用过银河麒麟的操作系统,然后就上网查询了一下,是因为默认有个Kysec
麒麟安全管理工具。
解决方案
方案一 : 通过图形桌面关闭执行控制
方案二: 通过命令设置麒麟系统安全状态为Softmode
root@Kylin:~# getstatus
KySec status: Normal
exec control: on
file protect: on
kmod protect: on
three admin : off
root@Kylin:~# setstatus Softmode
root@Kylin:~# getstatus
KySec status: Softmode
exec control: on
file protect: on
kmod protect: on
three admin : off
root@Kylin:~# bash aa.sh
1
设置开机启动设置:
root@Kylin:~# echo "setstatus Softmode" >> /lib/lsb/init-functions
方案三: 单独设置个别文件权限
oot@Kylin:~# setstatus Normal
root@Kylin:~# bash aa.sh
bash: aa.sh: 权限不够
root@Kylin:~# kysec_set -n exectl -v trusted aa.sh
root@Kylin:~# bash aa.sh
1
kysec_set man手册
kysec_set(8) System Manager's Manual kysec_set(8)
NAME
kysec_set - set kysec label for specfied path(s)
SYNOPSIS
kysec_set [ -n part ] [ -r ] -v value path1 ..
DESCRIPTION
kysec_set set the kysec label of specified files or directories to
value. Kysec label is composed of three parts: identify part, pro‐
tect part and exectl part.
when not used with -n option, kysec label should be in such format:
"identify:protect:exectl". Set the new value to 'none' to clear the
corresponding part of kysec label.
for identify part, these values are valid:
secadm commands for secadm
audadm commands for auditadm
for exectl part, these values are valid:
unknown unknown files
original original system files
verified verified 3rd party files
kysoft software installer
trusted trusted files
for protect part, only readonly is valid.
OPTIONS
-n set specified part of kysec labels. part can be exectl,
userid or protect.
-r process labels recursively, only usable for directories.
-v the new label value
EE ALSO
getstatus(8), setstatus(8), kysec_get(8)
kysec_set(8)
Centos下升级OpenSSL版本
智慧运维 chris 发表了文章 0 个评论 194 次浏览 2020-12-20 15:28

1. 安装依赖
yum -y install perl perl-devel gcc gcc-c++
2. 升级
查看当前版本:
[root@centos7 src]$ openssl version
OpenSSL 1.0.2k-fips
下载新版本
当前最新版本是OpenSSL_1_1_1c(2019年7月5日),请到下面页面下载。
官网下载地址: https://www.openssl.org/source/
Github地址:https://github.com/openssl/openssl/releases
这里下载到/usr/local/src目录:
[root@centos7 ~]$ cd /usr/local/src
[root@centos7 src]$ wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1c.tar.gz
[root@centos7 src]$ tar xzvf ./OpenSSL_1_1_1c.tar.gz
[root@centos7 src]$ cd openssl-OpenSSL_1_1_1c/
接下来执行编译操作:
[root@centos7 src]$ ./config
如果没有安装Perl 5,执行config会有提示没有安装,需要先进行安装,执行yum install perl
。
接下来依次执行下面的命令:
[root@centos7 src]$ make
[root@centos7 src]$ make test
[root@centos7 src]$ sudo make install
替换新旧版本:
[root@centos7 src]$ mv /usr/bin/openssl /usr/bin/oldopenssl
[root@centos7 src]$ ln -s /usr/local/bin/openssl /usr/bin/openssl
如果执行openssl version
报下面错误:
[root@localhost openssl-OpenSSL_1_1_1c]$ openssl version
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
则执行下面命令解决:
[root@centos7 src]$ sudo ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/
[root@centos7 src]$ sudo ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/
然后查看当前版本:
[root@centos7 openssl-OpenSSL_1_1_1c]$ openssl version
OpenSSL 1.1.1c 28 May 2019
常见错误
错误:begin failed–compilation aborted at .././test/run_tests.pl
解决:sudo yum install perl-devel
错误:Parse errors: No plan found in TAP output
解决:yum install perl-Test-Simple
Centos系统下升级git命令版本
智慧运维 Rock 发表了文章 0 个评论 167 次浏览 2020-12-15 15:45

有些软件的自动安装依赖于git的版本,而且大多数Centos服务器上的git要么是1.7.1或者就是1.8.x,如果要大面积升级的话,还是用yum包管理器直接升级比较方便.
1. 获取安装源
1.1 Centos6
wget http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
rpm -ivh wandisco-git-release-6-1.noarch.rpm
1.2 Centos7
wget http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
rpm -ivh wandisco-git-release-7-1.noarch.rpm
# 或者
wget http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
rpm -ivh wandisco-git-release-7-2.noarch.rpm
2. 安装git 2.x
yum install git -y
3. 验证
[root@linux-chromium rock]# git --version
git version 2.22.0
可以看到git
已经升级到2.22.0
的版本了, Centos6还可以利用如下源升级:
wget https://centos6.iuscommunity.org/ius-release.rpm
rpm -ivh ius-release.rpm
yum install git2u -y
PostgreSQL编译安装常见报错整理
智慧运维 chris 发表了文章 1 个评论 202 次浏览 2020-12-07 00:29

PostgreSQL源码安装时如果相关依赖包缺失会导致编译失败,以下是常见的依赖包缺失问题,及解决办法。
依赖安装:
yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++ openssl-devel cmake
问题1:
checking for flags to link embedded Perl... Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).BEGIN failed--compilation aborted.
configure: error: could not determine flags for linking embedded Perl.This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not installed.
解决:
yum install perl-ExtUtils-Embed
问题2:
configure: error: readline library not found If you have readline already installed, see config.log for details on the failure.
It is possible the compiler isn't looking in the proper directory. Use --without-readline to disable readline support.
解决:
yum install readline readline-devel
问题3:
checking for inflate in -lz... no configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the failure. It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.
解决:
yum install zlib zlib-devel
问题4:
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL
解决:
yum -y install opensll openssl-devel
问题5:
checking for pam_start in -lpam... no
configure: error: library 'pam' is required for PAM
解决:
yum -y install pam pam-devel
问题6:
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support
解决:
yum -y install libxml2 libxml2-devel
问题7:
checking for xsltCleanupGlobals in -lxslt... no
configure: error: library 'xslt' is required for XSLT support
解决:
yum -y install libxslt libxslt-devel
问题8:
checking for ldap.h... no
configure: error: header file is required for LDAP
解决:
yum -y install openldap openldap-devel
问题9:
checking for Python.h... no
configure: error: header file is required for Python
解决:
yum -y install python-devel
问题10:
Error when bootstrapping CMake: Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
解决:
yum -y install gcc-c++
插件报错:
2020-05-06 06:17:12.624 UTC [1] FATAL: could not access file "pglogical": No such file or directory
2020-05-06 06:17:12.624 UTC [1] LOG: database system is shut down
解决参考: https://www.cnblogs.com/lottu/p/10972773.html , pg_pathman: https://www.cnblogs.com/guoxiangyue/p/10894467.html
常见系统glibc版本列表
智慧运维 chris 发表了文章 0 个评论 109 次浏览 2020-11-24 22:54

操作系统 | 操作系统位数 | Glibc版本 |
---|---|---|
Centos4.0 | 32bit | ldd (GNU libc) 2.3.4 |
Centos5.0 | 32bit | ldd (GNU libc) 2.5 |
Centos3.1 | 64bit | ldd (GNU libc) 2.3.2 |
Centos3.3 | 64bit | ldd (GNU libc) 2.3.2 |
Centos4.0 | 64bit | ldd (GNU libc) 2.3.4 |
Centos5.0 | 64bit | ldd (GNU libc) 2.5 |
Centos6.0 | 64bit | ldd (GNU libc) 2.12 |
Centos6.5 | 64bit | ldd (GNU libc) 2.12 |
Centos7.* | 64bit | ldd (GNU libc) 2.17 |
Redhat6.5 | 64bit | ldd (GNU libc) 2.12 |
Redhat7.0 | 64bit | ldd (GNU libc) 2.17 |
Redhat7.3 | 64bit | ldd (GNU libc) 2.17 |
Debian6.0 | 32bit | ldd (Debian EGLIBC 2.11.3-4) 2.11.3 |
Debian7.0 | 32bit | ldd (Debian EGLIBC 2.13-38+deb7u12) 2.13 |
Debian7.0 | 64bit | ldd (Debian EGLIBC 2.13-38+deb7u12) 2.13 |
Suse9.0 | 32bit | ldd (GNU libc) 2.3.5 |
Suse9.1 | 64bit | ldd (GNU libc) 2.3.3 |
Suse10.0 | 32bit | ldd (GNU libc) 2.4 |
Suse10.0 | 64bit | ldd (GNU libc) 2.3.5 |
Suse11.0 | 64bit | ldd (GNU libc) 2.11.1 |
Suse12.0 | 64bit | ldd (GNU libc) 2.19 |
OpenSuse42 | 64bit | ldd (GNU libc) 2.19 |
fedora22 | 64bit | ldd (GNU libc) 2.22 |
ubuntu12 | 64bit | ldd (Ubuntu EGLIBC 2.15-0ubuntu10.6) 2.15 |
ubuntu14 | 64bit | ldd (Ubuntu EGLIBC 2.19-0ubuntu6.9) 2.19 |
Asianux Server 3 | 64bit | ldd (GNU libc) 2.5 |
Power Linux 6.5 | 64bit | ldd (GNU libc) 2.12 |
Power Linux7.3 | 64bit | ldd (GNU libc) 2.17 |
以后在补充一些常见系统过得Glibc版本。
linux下LD_LIBRARY_PATH介绍
智慧运维 chris 发表了文章 0 个评论 119 次浏览 2020-11-24 00:39

LD_LIBRARY_PATH
是Linux环境变量名,该环境变量主要用于指定查找共享库(动态链接库)时除了默认路径之外的其他路径。
非常多的软件没有root权限安装会比较困难,主要就是因为各种系统库文件,也就是LD_LIBRARY_PATH
这个环境变量里面的文件。比如前面我提到的lancet软件需要的库文件如下:
-llzma -lbz2 -lz -ldl -lpthread -lcurl -lcrypto -lbamtools
可以使用 ls /usr/lib |grep lib 查看自己是否有需要的库文件,当然还需查看其它库文件目录:echo $LD_LIBRARY_PATH 里面一般可以看到七八个已经定义好的库文件搜索路径。
当执行函数动态链接.so时,如果此文件不在缺省目录下 /lib和/usr/lib,那么就需要指定环境变量LD_LIBRARY_PATH 假如现在需要在已有的环境变量上添加新的路径名,则采用如下方式: LD_LIBRARY_PATH=NEWDIRS:$LD_LIBRARY_PATH
(newdirs是新的路径串), 实例如下:
export LD_LIBRARY_PATH=/export/apps/anaconda2/2.4.1/lib/:$LD_LIBRARY_PATH
一般报错:
/usr/bin/ld: cannot find -llzma
collect2: error: ld returned 1 exit status
make[1]: *** [lancet] Error 1
make[1]: Leaving directory `/home/bobo/biosoft/lancet/lancet/src'
cp: cannot stat `lancet': No such file or directory
其实就是gcc编辑器找不到我们系统的liblzma这个库文件,就是我们的LD_LIBRARY_PATH定义的所有路径里面都没有这个liblzma这个库文件。
验证gcc编辑器能否找到指定库文件的方法是:
gcc -llzma --verbose
需要找到系统的库文件地址
事实上,我们的机器肯定是有这个库文件的,只不过是不在LD_LIBRARY_PATH定义的所有路径里面,简单查找如下:
locate liblzma
/export/apps/anaconda2/2.4.1/lib/liblzma.a
/export/apps/anaconda2/2.4.1/lib/liblzma.la
/export/apps/anaconda2/2.4.1/lib/liblzma.so
/export/apps/anaconda2/2.4.1/lib/liblzma.so.5
/export/apps/anaconda2/2.4.1/lib/liblzma.so.5.0.5
为了解决我,我们需要添加:
export LD_LIBRARY_PATH=/export/apps/anaconda2/4.0.0/lib/:$LD_LIBRARY_PATH
export LIBRARY_PATH=/export/apps/anaconda2/4.0.0/lib/:$LIBRARY_PATH
为什么修改LD_LIBRARY_PATH呢
因为运行时动态库的搜索路径的先后顺序是:
1.编译目标代码时指定的动态库搜索路径;
2.环境变量LD_LIBRARY_PATH指定的动态库搜索路径;
3.配置文件/etc/ld.so.conf中指定的动态库搜索路径;
4.默认的动态库搜索路径/lib和/usr/lib;
这个顺序是compile gcc时写在程序内的,通常软件源代码自带的动态库不会太多,而我们的/lib和/usr/lib只有root权限才可以修改,而且配置文件/etc/ld.so.conf也是root的事情,我们只好对LD_LIBRARY_PATH进行操作啦。
永久性添加
每次我使用该软件都需要临时修改库文件,因为上面的方法是临时设置环境变量 LD_LIBRARY_PATH ,重启或打开新的 Shell 之后,一切设置将不复存在。
为了让这种方法更完美一些,可以将该 LD_LIBRARY_PATH 的 export 语句写到系统文件中,例如 /etc/profile、/etc/export、~/.bashrc 或者 ~/.bash_profile 等等,取决于你正在使用的操
虽然LD_LIBRARY_PATH很方便,但是还是推荐大家在编译的时候指定-rpath来执行相对路径来找到动态链接库文件。