From 8853fb21b4381fcf296940dd1eacdc9ad7917880 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E6=B5=B7?=
i654PMJTd~ zcxBTe=Vw;e=c{qUQqr}a8;L+WXI6`|JBvumh?&(xATM#8Lii{3x|7ts&RCDp5~+(_ z%;3UW(&Z+cJ^jcU^Tx>XsGlYAr7qDH?{BPJti@(VCOcy!;(oH}C<-Eetnki+yf7&pDOr%Pgwmpv|K=*ZUAE>acTqP83 zx{1gN#1@r>DvHpMtvnwA7{(2LIo*f5Qx}v=JeI=+tl^JYNu*}03%5!8?-5Bz;WgO; zB8a1s794&M%FWYi2E<`|OPR$bBcG=gMh}q1CQl)TlW(IA5G%XVD~1SKl<>6FS6A`o zwE|i4W__Q}F^5j3w&ZNSQ4Cgn@5Yt`Ff_V&zs4wY1sz6q&dchh6oGW-wndRHxcE Giyfv9Otft@LLs zN kvUElGLFz)NHX}Kj5FA z-#-40KxTscC~Bcrmw22AmCSNO0*d%v%5@GT0P1f)A;tzd6~g39#a`qz#<~^tzei#^ z8T{gZM5~b+rnFR!lMxtMp RI* zInweQ_03`Igabc2&vd6=2plV;-xNobky`laW9-un&TtBaZN(TWYaxw LjubzR zd!MKryQr{#B8YRjapZnKHTY$UevA|;kTaYcL`Yk}Yf1+eE^!q1P*@IL>Rjl{=$#%o z(_Vs2C@nQQUGv343wS&6NNrIXmz)e6WX&{XtMtpkUp4UjcYexNsl5eNJ1OzUhOBy? zt?#X`MKGrTqM-Q-Z!Wm^-n6p2x>>VhzKQ~cH30cq>q6@3lAn@cvC+`7GaUpP$c-H1 zIgg#C4chqWVx%hazZKnY)$}92=RBgL(a3`ne=a(W5wv9B6((o^xCJP`Eu<66X02M# zaEl$BMW!h5SVA3jdJ}LVb_g?{vrkKWD(}t4Dp>k9VN9905w@;;5FaPL?3hExFcUHd zrDSC|pt9WR!GM4|2`VgN<*u6}af+3JovK0TOVq??O7@5<3K>lQzNQ~j0js$-gyB(q z5#m {n?a%iCSN8=ft%GpNT(NB0kZOWFxZ+@k zL>*rUJmNk`nMQPGs#E$|3g_H^5UShm+|z>BF)FOOmlvm`{wzKd@8b8B+v{N3Y^3GK zy})Q4p*F$ZN9a$k9z9;E#B8IY3)nEgOzHiTujn+vUajT;Qp+)QRIEaunLgt71(4iy z?HR{O%GHx}wtK2)(beF|Y4t%b6q+}i0^YSy@&HA*we+6g3_pNu;mqGh6!41;Lo!nI zp(W0p!^p~*_qBjV;ARpfOTP0Rfd{E)ZkN#e$TPd0nL%n&80-3oqQV0ZvTIfs;y0dc z^BwnG6y%i|#}nX0U}}@Tn49ugILU=0EDN_U84b{rChOv9%sVw^cp$9| N&?O=-*@ZJJ<=wfett5O}6 z=u*tJ_Eq-8u5bM;hQ!|L)Q+ucp}ZRER+VxT(N? 6w@@w4Gg~C*~>fQNkkTjR{!~&ECb|m`}hRjb<>bEH0 z6jlsmGjM@B?P2PB0v)I|QAPUgTL&VQo=4@g8jn Mp0f(nj|m7-CWNOWthozj{Rlly&e371cN9N$aP3 zTEZrcN7Wn{7bH>paocbkiv9IbV`DsZPY4-N~d2D?= FdNhY} zy}2j9A*|+@qI0mA*N2(WmWR1^3@Ccm7E6Ry)_nThK4OTXaj7en6aHi^& n@X{ crH@PRrXR}2DADQk z=?6V(xzp~Je){7+;hU;x#Nq#dz4I{+X$gpGm`fJ}gn$^c;^EUqkN8nsgP%fVt^WC^ z|L>mUJ+6;%R$5(9^tya)PKs@o M} p>x-l4)92co;-`$?VXZZ15&Pv^M5?bYBFsHTW6x+bG2ko?oBfu#&NEh{ zCiUxeV#VSrj aBDq+4P!6Fv;w!%iBB;5#J9M<%)+H9k0fj+vXjahsbu zqNZfLq%zjHztE!$U8-qEo}f?4ZP5-DN_UMi7t)M+fG;@@@!M|5d99odkfV6oCo&j_ z2MIPzuoe)zR8m|fnX+Hy+`MO)DOve}Mifdp`UaG*pR)fnEOGnHr$TBb4$eDBRAHhh zKu@Y&R`T;ANxyCvi$V#^LxxaU2-IV)h-VaT21%@T-Yv#M+f+&(PIP`JAk!v{g-+tC zzELA^`8>5$q?)_W1h&j`R(M;icRm RZ%nB=66+IvHR zvc*??*&xKmPUzWQ)56350c+O@hPKYhVa4={Yq^}EWF#?%ysDV>Q%*q@x`A?%pS*7M zg`Op?)dpT;t}PtD9SQa(=S({7O?`!5= MSwMtg+;tpKzN_2VaNsmKc)USO!D7G2ND2 zx`F%^y;%+yY}mRl+s5#r{2yjkZ%Z_@3jjK2$MT+!YM!FKSgDMAQ7calC;^Mb3X0zf zlZ;9_b!B`gPG<)1nd>+2IzCW`dWpw%=hhuU--7#LHTb#uPnOwK=)zw+C%03Of(! z{8iy)qPO1U;v&OaPHH?2wj;dZJE5ubZ1$GLE*>Q=$PJZ-5ot3}ONsWsC|UhvAEp_x zER7bSy1;E5eZrL7b-*SXjfQ&9eo@SER6+5Q@MiSo!z$`5`|F|kPD0Qt=_peI5-FP8 z)fL|r!`sU$FPaL+#~oq+y&6Yhf%JKWa Ocp&E|XT19q)$Va+SxEScZUhp;&u%wa>a5x3`v>cVl#?BLSyo1zGe=tnMgRu}I# zKD;f6pHF;uoJ?6_#A0yeuygnth}z(3+9U1CYa|I|K1K(V5 gU$q=^>O#bW)j8KxM)iW8}fmE!BT5haj5i|!EnC$#7YnSyGDAv zS}GrPxTstNwqdQalV#?kZ8Qrbul~$c!dPv(FBn(qFVYAo{0_))5GnQ5BMf7jbE!V2 zoZeY(C?FZbi$Jz3mSt7cLa_r?Yr^3@3ZEFI7XfotM8r7D@^nk;&R59$7kv%-g2`mU z_}18$|Kz*lI;it2S5;9gxSqo40aAq_JrO4)e6`N1kk}FCtloeTW|HoIU6|+g?eCZ8 xP@TB&G~+yu!a V260Lb$lb(HlA>}VRYC><{{iY-QLg|1 literal 0 HcmV?d00001 From a74e8ca3f2823e97a5a706ef780c5fcf0f04af58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B5=B7?= Date: Fri, 18 Aug 2023 17:08:45 +0800 Subject: [PATCH 03/11] first commit datasophon-init --- datasophon-init/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datasophon-init/README.md b/datasophon-init/README.md index a55f2017..37b5a203 100644 --- a/datasophon-init/README.md +++ b/datasophon-init/README.md @@ -20,7 +20,7 @@ # dataSophon-init使用说明 前言:当前版本是根据centos8.5和openEuler-22.03进行开发适配的,其它类型和版本的操作系统目前没有进行详细的测试验证可能存在兼容性问题,需要对shell脚本和本地YUM离线安装包进行适配 1、将datasophon-init整个目录的内容放到规划的集群主节点的/data目录下(mkdir /data); -2、将packages.tar.gz 离线依赖库移到主节点的 /data/datasophon-init下并解压; +2、将packages.tar.gz 离线依赖库移到主节点的 /data/datasophon-init下并解压;链接:https://pan.baidu.com/s/1iqudVwDgg2x_OO35VLkkSg 提取码:6zrz 3、在未连接互联网的情况下预备安装datasophon的服务器已经配置好离线yum源,能够通过yum命令安装依赖包(此步骤为必须,因为初始化脚本中使用了"yum -y install xxxx"的方式安装依赖,如果没有yum源会导致安装失败 ); 离线YUM源配置方法(Ps:能连公网的用户就不用配置离线yum源了,直接配置为公共的源,该步骤都是在主节点上操作): 配置脚本为:init-private-yum-library-${initOS}.sh From 159afb60697e7b79b1d747e15f540eedf1ac681f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B5=B7?= Date: Fri, 18 Aug 2023 17:14:35 +0800 Subject: [PATCH 04/11] first commit datasophon-init2 --- datasophon-init/bin/init-Cython.sh | 30 + datasophon-init/bin/init-add-hadoop-user.sh | 38 + datasophon-init/bin/init-allhosts.sh | 59 ++ datasophon-init/bin/init-chmod-dev-null.sh | 26 + datasophon-init/bin/init-cleanBuff-async.sh | 34 + datasophon-init/bin/init-cleanBuff.sh | 15 + datasophon-init/bin/init-close-swap.sh | 41 + .../bin/init-close-transparent-hugepage.sh | 27 + datasophon-init/bin/init-cyrus-sasl.sh | 21 + datasophon-init/bin/init-ecdsa.sh | 30 + datasophon-init/bin/init-expect.sh | 44 + datasophon-init/bin/init-gcc-c++.sh | 30 + datasophon-init/bin/init-hostIp-txt.sh | 43 + datasophon-init/bin/init-hostname.sh | 30 + datasophon-init/bin/init-java-policy.sh | 26 + datasophon-init/bin/init-jdk.sh | 108 +++ datasophon-init/bin/init-krb5-devel.sh | 36 + datasophon-init/bin/init-libtool.sh | 28 + datasophon-init/bin/init-libxslt-devel.sh | 27 + datasophon-init/bin/init-mysql-8.sh | 127 +++ datasophon-init/bin/init-mysql-datasophon.sh | 74 ++ datasophon-init/bin/init-mysql-devel.sh | 28 + datasophon-init/bin/init-nmap.sh | 27 + datasophon-init/bin/init-ntp-chrony-server.sh | 105 +++ datasophon-init/bin/init-ntp-chrony-slave.sh | 59 ++ datasophon-init/bin/init-ntp_enable.sh | 28 + datasophon-init/bin/init-openssl-devel.sh | 28 + datasophon-init/bin/init-perl-JSON.sh | 28 + .../bin/init-private-yum-library-centos8.sh | 114 +++ .../bin/init-private-yum-library-openEuler.sh | 103 +++ datasophon-init/bin/init-psmisc.sh | 28 + datasophon-init/bin/init-pssh.sh | 52 ++ datasophon-init/bin/init-pytest_runner.sh | 26 + datasophon-init/bin/init-python-rpm-macros.sh | 31 + .../bin/init-python-srpm-macros.sh | 31 + .../bin/init-python2-rpm-macros.sh | 31 + datasophon-init/bin/init-python36-devel.sh | 31 + datasophon-init/bin/init-redhat-lsb.sh | 31 + datasophon-init/bin/init-six.sh | 31 + datasophon-init/bin/init-sourceSSHHostname.sh | 2 + datasophon-init/bin/init-ssh-copy-key.sh | 70 ++ datasophon-init/bin/init-ssh-gen-key.sh | 74 ++ datasophon-init/bin/init-ssh-hadoop.sh | 36 + datasophon-init/bin/init-sshpackage.sh | 37 + datasophon-init/bin/init-sshpass.sh | 37 + datasophon-init/bin/init-stop-firewall.sh | 35 + datasophon-init/bin/init-stop-selinux.sh | 38 + datasophon-init/bin/init-system-conf.sh | 83 ++ datasophon-init/bin/init-test.sh | 32 + datasophon-init/bin/init-tmp_pid.sh | 27 + datasophon-init/bin/init-websocket_client.sh | 32 + datasophon-init/bin/init-xdg-utils.sh | 30 + .../bin/init-yum-hosts-mapping-centos8.sh | 56 ++ .../bin/init-yum-hosts-mapping-openEuler.sh | 49 ++ .../config/init-host-info-add.properties | 21 + .../config/init-host-info.properties | 15 + datasophon-init/config/init.properties | 36 + datasophon-init/sbin/init.sh | 831 ++++++++++++++++++ 58 files changed, 3247 insertions(+) create mode 100644 datasophon-init/bin/init-Cython.sh create mode 100644 datasophon-init/bin/init-add-hadoop-user.sh create mode 100644 datasophon-init/bin/init-allhosts.sh create mode 100644 datasophon-init/bin/init-chmod-dev-null.sh create mode 100644 datasophon-init/bin/init-cleanBuff-async.sh create mode 100644 datasophon-init/bin/init-cleanBuff.sh create mode 100644 datasophon-init/bin/init-close-swap.sh create mode 100644 datasophon-init/bin/init-close-transparent-hugepage.sh create mode 100644 datasophon-init/bin/init-cyrus-sasl.sh create mode 100644 datasophon-init/bin/init-ecdsa.sh create mode 100644 datasophon-init/bin/init-expect.sh create mode 100644 datasophon-init/bin/init-gcc-c++.sh create mode 100644 datasophon-init/bin/init-hostIp-txt.sh create mode 100644 datasophon-init/bin/init-hostname.sh create mode 100644 datasophon-init/bin/init-java-policy.sh create mode 100644 datasophon-init/bin/init-jdk.sh create mode 100644 datasophon-init/bin/init-krb5-devel.sh create mode 100644 datasophon-init/bin/init-libtool.sh create mode 100644 datasophon-init/bin/init-libxslt-devel.sh create mode 100644 datasophon-init/bin/init-mysql-8.sh create mode 100644 datasophon-init/bin/init-mysql-datasophon.sh create mode 100644 datasophon-init/bin/init-mysql-devel.sh create mode 100644 datasophon-init/bin/init-nmap.sh create mode 100644 datasophon-init/bin/init-ntp-chrony-server.sh create mode 100644 datasophon-init/bin/init-ntp-chrony-slave.sh create mode 100644 datasophon-init/bin/init-ntp_enable.sh create mode 100644 datasophon-init/bin/init-openssl-devel.sh create mode 100644 datasophon-init/bin/init-perl-JSON.sh create mode 100644 datasophon-init/bin/init-private-yum-library-centos8.sh create mode 100644 datasophon-init/bin/init-private-yum-library-openEuler.sh create mode 100644 datasophon-init/bin/init-psmisc.sh create mode 100644 datasophon-init/bin/init-pssh.sh create mode 100644 datasophon-init/bin/init-pytest_runner.sh create mode 100644 datasophon-init/bin/init-python-rpm-macros.sh create mode 100644 datasophon-init/bin/init-python-srpm-macros.sh create mode 100644 datasophon-init/bin/init-python2-rpm-macros.sh create mode 100644 datasophon-init/bin/init-python36-devel.sh create mode 100644 datasophon-init/bin/init-redhat-lsb.sh create mode 100644 datasophon-init/bin/init-six.sh create mode 100644 datasophon-init/bin/init-sourceSSHHostname.sh create mode 100644 datasophon-init/bin/init-ssh-copy-key.sh create mode 100644 datasophon-init/bin/init-ssh-gen-key.sh create mode 100644 datasophon-init/bin/init-ssh-hadoop.sh create mode 100644 datasophon-init/bin/init-sshpackage.sh create mode 100644 datasophon-init/bin/init-sshpass.sh create mode 100644 datasophon-init/bin/init-stop-firewall.sh create mode 100644 datasophon-init/bin/init-stop-selinux.sh create mode 100644 datasophon-init/bin/init-system-conf.sh create mode 100644 datasophon-init/bin/init-test.sh create mode 100644 datasophon-init/bin/init-tmp_pid.sh create mode 100644 datasophon-init/bin/init-websocket_client.sh create mode 100644 datasophon-init/bin/init-xdg-utils.sh create mode 100644 datasophon-init/bin/init-yum-hosts-mapping-centos8.sh create mode 100644 datasophon-init/bin/init-yum-hosts-mapping-openEuler.sh create mode 100644 datasophon-init/config/init-host-info-add.properties create mode 100644 datasophon-init/config/init-host-info.properties create mode 100644 datasophon-init/config/init.properties create mode 100644 datasophon-init/sbin/init.sh diff --git a/datasophon-init/bin/init-Cython.sh b/datasophon-init/bin/init-Cython.sh new file mode 100644 index 00000000..77b2e412 --- /dev/null +++ b/datasophon-init/bin/init-Cython.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +CYTHON_FOLDER_NAME=Cython-0.20 +CYTHON_TAR_NAME=Cython-0.20.tar.gz +tar -zxvf ${PACKAGES_PATH}/${CYTHON_TAR_NAME} -C ${PACKAGES_PATH} +cd ${PACKAGES_PATH}/${CYTHON_FOLDER_NAME} +python3 setup.py install +cd ${INIT_BIN_PATH} +echo "Cython install successfully" diff --git a/datasophon-init/bin/init-add-hadoop-user.sh b/datasophon-init/bin/init-add-hadoop-user.sh new file mode 100644 index 00000000..8fd7c45b --- /dev/null +++ b/datasophon-init/bin/init-add-hadoop-user.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# example: sh init-ssh-gen-key.sh + +filePath=$1 +GROUP=hadoop +USER=hadoop + +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +egrep "^$GROUP" /etc/group >&/dev/null +if [ $? -ne 0 ]; then + groupadd $GROUP + echo "Successfully added GROUP: hadoop" +fi +egrep "^$USER" /etc/passwd >&/dev/null +if [ $? -ne 0 ]; then + useradd -g ${USER} ${USER} + echo "Successfully added USER: hadoop passwd: hadoop" +fi + +echo "init-add-hadoop-user.sh." +echo "Done." diff --git a/datasophon-init/bin/init-allhosts.sh b/datasophon-init/bin/init-allhosts.sh new file mode 100644 index 00000000..9e3ac0bc --- /dev/null +++ b/datasophon-init/bin/init-allhosts.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +hostAllInfoPath="$1" +initAllHostNums="$2" + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +REPAIR_PATH=$(dirname "${BASE_PATH}") +echo "REPAIR_PATH: ${REPAIR_PATH}" + +sed -i '/#modify etc hosts start/,/#modify etc hosts end/d' /etc/hosts +modifyHosts() { + cat /etc/hosts | grep yum + if [ $? -eq 0 ]; then + sed -i '/#modify yum mapping hosts start/i\#modify etc hosts start' /etc/hosts + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + hostname=$(prop "dataSophon.ssh.port.hostname.${i}") # password + echo "ip: ${ip}" + echo "${ip} ${hostname}" + sed -i '/#modify yum mapping hosts start/i '${ip}' '${hostname}'' /etc/hosts + done + sed -i '/#modify yum mapping hosts start/i\#modify etc hosts end' /etc/hosts + else + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + echo "#modify etc hosts start" >>/etc/hosts + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + hostname=$(prop "dataSophon.ssh.port.hostname.${i}") # password + echo "ip: ${ip}" + echo "${ip} ${hostname}" + echo "${ip} ${hostname}" >>/etc/hosts + done + echo "#modify etc hosts end" >>/etc/hosts + fi + +} + +modifyHosts +sed -i 's/^[^#].*[0-9]-[0-9]/#&/g' /etc/hosts + +echo "init-hosts.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-chmod-dev-null.sh b/datasophon-init/bin/init-chmod-dev-null.sh new file mode 100644 index 00000000..2bbfece2 --- /dev/null +++ b/datasophon-init/bin/init-chmod-dev-null.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# example: sh init-expect.sh +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +rm -rf /dev/null && mknod -m 0666 /dev/null c 1 3 +echo "INIT-chmod-dev-null.sh." +echo "Done." + diff --git a/datasophon-init/bin/init-cleanBuff-async.sh b/datasophon-init/bin/init-cleanBuff-async.sh new file mode 100644 index 00000000..18039100 --- /dev/null +++ b/datasophon-init/bin/init-cleanBuff-async.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi + +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" + +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +echo "BASE_PATH: ${BASE_PATH}" + +BIN_PATH=$(dirname "${BASE_PATH}")/bin +SCRIPTS_PATH=$(dirname "${BASE_PATH}")/scripts + +echo "SCRIPTS_PATH: $SCRIPTS_PATH" + +nohup sh ${INIT_BIN_PATH}/init-cleanBuff.sh >/dev/null 2>&1 & +#nohup sh $SCRIPTS_PATH/repair-cleanBuff.sh & diff --git a/datasophon-init/bin/init-cleanBuff.sh b/datasophon-init/bin/init-cleanBuff.sh new file mode 100644 index 00000000..a244fe8c --- /dev/null +++ b/datasophon-init/bin/init-cleanBuff.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "sync" +sync +sync +sync + +echo "sleep" +sleep 10 + +echo 1 >/proc/sys/vm/drop_caches +echo 2 >/proc/sys/vm/drop_caches +echo 3 >/proc/sys/vm/drop_caches + +echo "done" diff --git a/datasophon-init/bin/init-close-swap.sh b/datasophon-init/bin/init-close-swap.sh new file mode 100644 index 00000000..33492f7d --- /dev/null +++ b/datasophon-init/bin/init-close-swap.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +#swapoff /dev/centos/swap + +# /etc/fstab +# /dev/mapper/centos-swap swap swap defaults 0 0 +sed -ri 's/.*swap.*/#&/' /etc/fstab + +echo 0 >/proc/sys/vm/swappiness + +SWAP_STR=$(cat /etc/sysctl.conf | grep vm.swappiness) +if [ -z "${SWAP_STR}" ]; then + echo "vm.swappiness=0" >>/etc/sysctl.conf +else + sed -i '/vm.swappiness/d' /etc/sysctl.conf + echo "vm.swappiness=0" >>/etc/sysctl.conf +fi + +sysctl vm.swappiness=0 +swapoff -a && swapon -a +sysctl -p + +echo "Swap is closed." +echo "init-close-swap.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-close-transparent-hugepage.sh b/datasophon-init/bin/init-close-transparent-hugepage.sh new file mode 100644 index 00000000..a51cfb2d --- /dev/null +++ b/datasophon-init/bin/init-close-transparent-hugepage.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +echo never >/sys/kernel/mm/transparent_hugepage/enabled +echo never >/sys/kernel/mm/transparent_hugepage/defrag +cat /sys/kernel/mm/transparent_hugepage/defrag +cat /sys/kernel/mm/transparent_hugepage/enabled +echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >>/etc/rc.d/rc.local +echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >>/etc/rc.d/rc.local +echo "transparent_hugepage is closed." +echo "init-close-transparent-hugepage.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-cyrus-sasl.sh b/datasophon-init/bin/init-cyrus-sasl.sh new file mode 100644 index 00000000..c554b4db --- /dev/null +++ b/datasophon-init/bin/init-cyrus-sasl.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +yum -y install cyrus-sasl* + +echo "cyrus-sasl install successfully" diff --git a/datasophon-init/bin/init-ecdsa.sh b/datasophon-init/bin/init-ecdsa.sh new file mode 100644 index 00000000..757cfce8 --- /dev/null +++ b/datasophon-init/bin/init-ecdsa.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +ECDSA_FOLDER_NAME=ecdsa-0.14.1 +ECDSA_TAR_NAME=ecdsa-0.14.1.tar.gz +tar -zxvf ${PACKAGES_PATH}/${ECDSA_TAR_NAME} -C ${PACKAGES_PATH} +cd ${PACKAGES_PATH}/${ECDSA_FOLDER_NAME} +python3 setup.py install +cd ${INIT_PATH} +echo "ecdsa install successfully" diff --git a/datasophon-init/bin/init-expect.sh b/datasophon-init/bin/init-expect.sh new file mode 100644 index 00000000..fb6a3388 --- /dev/null +++ b/datasophon-init/bin/init-expect.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# example: sh init-expect.sh +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +EXPECT_FOLDER_NAME=expect +EXPECT_TAR_NAME=expect.tar.gz +#存在python3-pexpect-4.3.1-3 导致判断不准确,直接安装 +#rpm -qa | grep expect-5 +#if [ "$?" == "0" ]; then +# echo "expect exists" +#else +# yum -y install expect +# rpm -qa | grep expect-5.45 +# if [ "$?" == "0" ]; then +# echo "expect exists" +# echo "init-expect.sh finished." +# echo "Done." +# fi +#fi + +yum -y install expect +echo "init-expect.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-gcc-c++.sh b/datasophon-init/bin/init-gcc-c++.sh new file mode 100644 index 00000000..f94f7956 --- /dev/null +++ b/datasophon-init/bin/init-gcc-c++.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +GCC_FOLDER_NAME=gcc-c++ +GCC_TAR_NAME=gcc-c++.tar.gz +rpm -qa | grep gcc-c++ +if [ "$?" == "0" ]; then + echo "rpm -qa | grep gcc-c++ exists" +else + yum -y install gcc-c++ + rpm -qa | grep gcc-c++ + if [ "$?" == "0" ]; then + echo "gcc-c++ install successfully" + fi +fi diff --git a/datasophon-init/bin/init-hostIp-txt.sh b/datasophon-init/bin/init-hostIp-txt.sh new file mode 100644 index 00000000..6951fc84 --- /dev/null +++ b/datasophon-init/bin/init-hostIp-txt.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# example: sh init-expect.sh +#TXT for initializing the cluster IP address list + +hostAllInfoPath="$1" +initAllHostNums="$2" +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 +} +for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") + echo "ip: ${ip}" + echo "port: ${port}" + echo -e "root@${ip}:${port}" >>${INIT_BIN_PATH}/tmp_scp_host_info.txt +done + +echo "init-hostIp-txt.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-hostname.sh b/datasophon-init/bin/init-hostname.sh new file mode 100644 index 00000000..526f6a83 --- /dev/null +++ b/datasophon-init/bin/init-hostname.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +hostname=$1 +modifyHostname() { + echo "${hostname}" >/etc/hostname + echo "HOSTNAME=${hostname}" >/etc/sysconfig/network + echo "NOZEROCONF=yes" >>/etc/sysconfig/network + hostnamectl set-hostname ${hostname} + hostnamectl set-hostname --static ${hostname} +} + +modifyHostname + +echo "init-hostname.sh finished." diff --git a/datasophon-init/bin/init-java-policy.sh b/datasophon-init/bin/init-java-policy.sh new file mode 100644 index 00000000..4b60ed7c --- /dev/null +++ b/datasophon-init/bin/init-java-policy.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BBASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +ETC_HOST=/etc/hosts +source /etc/profile +sed -i '/modify java policy start/,/modify java policy end/d' ${JAVA_HOME}/jre/lib/security/java.policy +sed -i '/grant {/a\//modify java policy end' ${JAVA_HOME}/jre/lib/security/java.policy +sed -i '/modify java policy end/i\//modify java policy start' ${JAVA_HOME}/jre/lib/security/java.policy +sed -i '/modify java policy end/i\permission javax.management.MBeanTrustPermission "register";' ${JAVA_HOME}/jre/lib/security/java.policy +echo "init-java-policy.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-jdk.sh b/datasophon-init/bin/init-jdk.sh new file mode 100644 index 00000000..965a2f12 --- /dev/null +++ b/datasophon-init/bin/init-jdk.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +# example: sh init-jdk.sh +# instal and config jdk env +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +JDK_FOLDER_PATH=/usr/java +source /etc/profile +mkdir -p /usr/java +JDK_PATH_NAME="jdk1.8.0_333" +JDK_VERSION="1.8" +BASH_PROFILE_PATH="/root/.bash_profile" +BASHRC_PATH="/root/.bashrc" +ETC_PROFILE_PATH="/etc/profile" +JDK_TAR_NAME="jdk-8u333-linux-x64.tar.gz" + +jdkAvailable=$(java -version 2>&1 | awk 'NR==1{gsub(/"/,"");print $3}') +result=$(echo $jdkAvailable | grep $JDK_VERSION) +if [[ "$result" != "" ]]; then + echo "JDK installed.............................." +else + echo "JDK not installed.............................." + echo "JDK environment already sets" + pid="sed -i '/export JAVA_HOME/d' /etc/profile" + eval $pid + pid="sed -i '/export CLASSPATH/d' /etc/profile" + eval $pid + pid="sed -i '/source \/etc\/profile/d' /root/.bash_profile" + eval $pid + pid="sed -i '/source \/etc\/profile/d' /root/.bashrc" + eval $pid + pid="sed -i '/source \/etc\/profile/d' /home/hadoop/.bash_profile" + eval $pid + pid="sed -i '/source \/etc\/profile/d' /home/hadoop/.bashrc" + eval $pid + echo "Prepare to Install JDK..." + sleep 2s + mkdir -p ${JDK_FOLDER_PATH} + tar -zxvf ${PACKAGES_PATH}/${JDK_TAR_NAME} -C ${JDK_FOLDER_PATH} + JAVA_HOME="${JDK_FOLDER_PATH}/${JDK_PATH_NAME}" + JRE_HOME="${JDK_FOLDER_PATH}/${JDK_PATH_NAME}/jre" + JAVA_SOURCE_ENV="source /etc/profile" + echo "export JAVA_HOME=$JAVA_HOME" >>/etc/profile + echo "export JRE_HOME=$JRE_HOME" >>/etc/profile + echo "export CLASSPATH=.:\$JRE_HOME/lib/rt.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar" >>/etc/profile + echo "export PATH=\$PATH:\$JAVA_HOME/bin" >>/etc/profile + echo ${JAVA_SOURCE_ENV} >>~/.bash_profile + echo ${JAVA_SOURCE_ENV} >>~/.bashrc + echo "Prepare to config BCPROV..." + JAVA_SECURITY_DIR="${JAVA_HOME}/jre/lib/security/java.security" + JAVA_BCPROV_DIR="${JAVA_HOME}/jre/lib/ext/" + JAVA_BCPROV_JAR="${PACKAGES_PATH}/bcprov-jdk15on-1.68.jar" + + JAVA_SECURITY_ARGS_ARR[0]="security.provider.1=sun.security.provider.Sun" + JAVA_SECURITY_ARGS_ARR[1]="security.provider.2=sun.security.rsa.SunRsaSign" + JAVA_SECURITY_ARGS_ARR[2]="security.provider.3=com.sun.net.ssl.internal.ssl.Provider" + JAVA_SECURITY_ARGS_ARR[3]="security.provider.4=com.sun.crypto.provider.SunJCE" + JAVA_SECURITY_ARGS_ARR[4]="security.provider.5=sun.security.jgss.SunProvider" + JAVA_SECURITY_ARGS_ARR[5]="security.provider.6=com.sun.security.sasl.Provider" + JAVA_SECURITY_ARGS_ARR[6]="security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI" + JAVA_SECURITY_ARGS_ARR[7]="security.provider.8=sun.security.smartcardio.SunPCSC" + JAVA_SECURITY_ARGS_ARR[8]="security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider" + + for element in ${JAVA_SECURITY_ARGS_ARR[@]}; do + JAVA_SECURITY_ARGS="${JAVA_SECURITY_ARGS}${element}\n" + done + + echo -e ${JAVA_SECURITY_ARGS} >>${JAVA_SECURITY_DIR} + cp -a ${JAVA_BCPROV_JAR} ${JAVA_BCPROV_DIR} + + echo "BCPROV Installed." + + echo "If you need to effect the environment variable in the current session, do it manually: " + source ${BASH_PROFILE_PATH} + source ${BASHRC_PATH} + source ${ETC_PROFILE_PATH} + jdk2=$(grep -n "export JAVA_HOME=.*" /home/hadoop/.bash_profile | cut -f1 -d':') + if [ -n "$jdk2" ]; then + echo "JDK HADOOP environment exists" + else + echo ${JAVA_SOURCE_ENV} >>/home/hadoop/.bash_profile + echo ${JAVA_SOURCE_ENV} >>/home/hadoop/.bashrc + echo "JDK HADOOP environment sets successfully" + fi + echo "JDK install successfully" + source /etc/profile +fi +echo "INIT-init-jdk.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-krb5-devel.sh b/datasophon-init/bin/init-krb5-devel.sh new file mode 100644 index 00000000..11e8d2ef --- /dev/null +++ b/datasophon-init/bin/init-krb5-devel.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +echo "${PACKAGES_PATH}" +KRB5_FOLDER_NAME=krb5-devel +KRB5_TAR_NAME=krb5-devel.tar.gz +rpm -qa | grep krb5-devel +if [ "$?" == "0" ]; then + echo "rpm -qa | grep krb5-devel exists" +else + yum -y install krb5-devel + rpm -qa | grep krb5-devel + if [ "$?" == "0" ]; then + echo "krb5-devel install successfully" + fi +fi diff --git a/datasophon-init/bin/init-libtool.sh b/datasophon-init/bin/init-libtool.sh new file mode 100644 index 00000000..4cd938af --- /dev/null +++ b/datasophon-init/bin/init-libtool.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +rpm -qa | grep libtool +if [ "$?" == "0" ]; then + echo "rpm -qa | grep libtool exists" +else + yum -y install libtool + rpm -qa | grep libtool + if [ "$?" == "0" ]; then + echo "libtool install successfully" + fi +fi diff --git a/datasophon-init/bin/init-libxslt-devel.sh b/datasophon-init/bin/init-libxslt-devel.sh new file mode 100644 index 00000000..c2fad548 --- /dev/null +++ b/datasophon-init/bin/init-libxslt-devel.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +rpm -qa | grep libxslt-devel +if [ "$?" == "0" ]; then + echo "libxslt-devel exists" +else + yum -y install libxslt-devel + rpm -qa | grep libxslt-devel + if [ "$?" == "0" ]; then + echo "libxslt_devel install successfully" + fi +fi diff --git a/datasophon-init/bin/init-mysql-8.sh b/datasophon-init/bin/init-mysql-8.sh new file mode 100644 index 00000000..20410214 --- /dev/null +++ b/datasophon-init/bin/init-mysql-8.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +num1="$1" +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +rpm -qa | grep zlib-devel +if [ "$?" == "0" ]; then + echo "zlib-devel exists" +else + yum -y install zlib-devel + rpm -qa | grep zlib-devel + if [ "$?" == "0" ]; then + echo "zlib-devel install successfully" + fi +fi + +rpm -qa | grep bzip2-devel +if [ "$?" == "0" ]; then + echo "bzip2-devel exists" +else + yum -y install bzip2-devel + rpm -qa | grep bzip2-devel + if [ "$?" == "0" ]; then + echo "bzip2-devel install successfully" + fi +fi + +rpm -qa | grep openssl-devel +if [ "$?" == "0" ]; then + echo "openssl-devel exists" +else + yum -y install openssl-devel + rpm -qa | grep openssl-devel + if [ "$?" == "0" ]; then + echo "openssl-devel install successfully" + fi +fi + +rpm -qa | grep ncurses-devel +if [ "$?" == "0" ]; then + echo "ncurses-devel exists" +else + yum -y install ncurses-devel + rpm -qa | grep ncurses-devel + if [ "$?" == "0" ]; then + echo "ncurses-devel install successfully" + fi +fi + +MYSQL_FOLDER_NAME=mysql-community-8.0.28.el8.x86_64 +MYSQL_TAR_NAME=mysql-community-8.0.28.el8.x86_64.tar.gz + +echo "mysql start install mysql-community-8.0.28-1.el8.x86_64........." +tar -zxvf ${PACKAGES_PATH}/${MYSQL_TAR_NAME} -C ${PACKAGES_PATH} +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-common-8.0.28-1.el8.x86_64.rpm +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-libs-8.0.28-1.el8.x86_64.rpm +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-devel-8.0.28-1.el8.x86_64.rpm +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-client-8.0.28-1.el8.x86_64.rpm +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm +rpm -ivh ${PACKAGES_PATH}/${MYSQL_FOLDER_NAME}/mysql-community-server-8.0.28-1.el8.x86_64.rpm + +mysqld --initialize --user=mysql +systemctl start mysqld +systemctl enable mysqld +sleep 2 +echo "${num1}" + +if [ $(systemctl status mysqld | grep running | wc -l) -eq 1 ]; then + echo "mysql在运行" + tmp_passwd=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}') + echo "临时密码:${tmp_passwd}" + #mysql -uroot -p"${tmp_passwd}" --connect-expired-password -e "ALTER USER 'root'@'%' IDENTIFIED BY '${num1}';" + #mysql -uroot -p"${num1}" -e "ALTER USER 'root'@'%' IDENTIFIED BY '${num1}' PASSWORD EXPIRE NEVER;" + #mysql -uroot -p"${num1}" -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '${num1}';" + #mysql -uroot -p"${num1}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" + #mysql -uroot -p"${num1}" -e "FLUSH PRIVILEGES;" + + /usr/bin/mysqladmin -uroot -p''$tmp_passwd'' password ''$num1'' + mysql -uroot -p''$num1'' -e "update mysql.user set host='%' where user ='root';" + mysql -uroot -p''$num1'' -e "FLUSH PRIVILEGES;" + mysql -uroot -p''$num1'' -e "ALTER USER 'root'@'%' IDENTIFIED BY '$num1' PASSWORD EXPIRE NEVER;" + echo "num1:'$num1'" + mysql -uroot -p''$num1'' -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '$num1';" + mysql -uroot -p''$num1'' -e "FLUSH PRIVILEGES;" + + cat >/etc/my.cnf < /etc/chrony.conf < /etc/chrony.conf < /etc/chrony.conf < /etc/yum.repos.d/dataSophon.repo < >${initLogDir}/installSingle_$(date +%Y%m%d).log + systemctl stop httpd + systemctl start httpd + +else + echo "init httpd begin." + yum install httpd + cat /etc/httpd/conf/httpd.conf | grep 'Listen 8000' + sed -i 's/Listen 80/Listen 8000/g' /etc/httpd/conf/httpd.conf + sed -i '/ServerName yum.dataSophon.cn:8000/d' /etc/httpd/conf/httpd.conf + sed -i '/#ServerName/a ServerName yum.dataSophon.cn:8000' /etc/httpd/conf/httpd.conf + systemctl start httpd + systemctl enable httpd + echo "init httpd finished." +fi +unlink /var/www/html/centos +ln -s /data/private-yum-library/repo/centos/ /var/www/html/ +#unlink /var/www/html/epel +#ln -s /data/datasophon-init/private-yum-library/epel/ /var/www/html/ +sed -i '/#modify yum mapping hosts start/,/#modify yum mapping hosts end/d' /etc/hosts +modifyYumHosts() { + echo "#modify yum mapping hosts start" >>/etc/hosts + echo "${ip} yum.dataSophon.cn" >>/etc/hosts + echo "#modify yum mapping hosts end" >>/etc/hosts + source /etc/profile + source /root/.bash_profile +} +modifyYumHosts + +rm /etc/yum.repos.d/dataSophon.repo + +cat >/etc/yum.repos.d/dataSophon.repo < /etc/yum.repos.d/dataSophon.repo < >${initLogDir}/installSingle_$(date +%Y%m%d).log + systemctl stop httpd + systemctl start httpd + +else + echo "init httpd begin." + yum install httpd + cat /etc/httpd/conf/httpd.conf | grep 'Listen 8000' + sed -i 's/Listen 80/Listen 8000/g' /etc/httpd/conf/httpd.conf + sed -i '/ServerName yum.dataSophon.cn:8000/d' /etc/httpd/conf/httpd.conf + sed -i '/#ServerName/a ServerName yum.dataSophon.cn:8000' /etc/httpd/conf/httpd.conf + systemctl start httpd + systemctl enable httpd + echo "init httpd finished." +fi + +unlink /var/www/html/repo +ln -s /data/private-yum-library/repo /var/www/html/ +#unlink /var/www/html/epol +#ln -s /data/datasophon-init/private-yum-library/epol /var/www/html/ +sed -i '/#modify yum mapping hosts start/,/#modify yum mapping hosts end/d' /etc/hosts +modifyYumHosts() { + echo "#modify yum mapping hosts start" >>/etc/hosts + echo "${ip} yum.dataSophon.cn" >>/etc/hosts + echo "#modify yum mapping hosts end" >>/etc/hosts + source /etc/profile + source /root/.bash_profile +} +modifyYumHosts + +rm /etc/yum.repos.d/dataSophon.repo + +cat >/etc/yum.repos.d/dataSophon.repo < ~/.ssh/config diff --git a/datasophon-init/bin/init-ssh-copy-key.sh b/datasophon-init/bin/init-ssh-copy-key.sh new file mode 100644 index 00000000..ab69fbe0 --- /dev/null +++ b/datasophon-init/bin/init-ssh-copy-key.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# example: sh init-ssh-gen-key.sh + +filePath=$1 +INITAllHostNums=$2 +port=$3 +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +removeSSHAsk() { + sed -i '/^#.*UseDNS no/s/^#//g' /etc/ssh/sshd_config + sed -i '/^#.*StrictHostKeyChecking ask/s/^#//g' /etc/ssh/ssh_config + sed -i '/StrictHostKeyChecking ask/s/ask/no/g' /etc/ssh/ssh_config +} +copyKeyConfig() { + # authorized_keys + # known_hosts + # scp -r /root/.ssh/ root@192.168.216.20:/root/ + + user=root + sshDir="/${user}/.ssh" + + function prop { + [ -f "${filePath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${filePath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${INITAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo $ip + echo $pwd + echo $port + /usr/bin/expect <<-EOF +set timeout -1 +spawn scp -P${port} -r $sshDir/ $user@$ip:/${user}/ +expect { + "yes/no" { send "yes\r"; exp_continue } + "password:" { send "$pwd\r" } + } + expect eof + EOF + done + echo -e "\nFinish copy ssh config." +} + +removeSSHAsk +copyKeyConfig + +echo "init-ssh-copy-key.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-ssh-gen-key.sh b/datasophon-init/bin/init-ssh-gen-key.sh new file mode 100644 index 00000000..8c7a1019 --- /dev/null +++ b/datasophon-init/bin/init-ssh-gen-key.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# example: sh init-ssh-gen-key.sh + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +sh ${INIT_BIN_PATH}/init-sshpackage.sh +sh ${INIT_BIN_PATH}/init-expect.sh + +removeSSHAsk() { + echo "begin removeSSHAsk....." + sed -i '/^#.*UseDNS no/s/^#//g' /etc/ssh/sshd_config + sed -i '/^#.*StrictHostKeyChecking ask/s/^#//g' /etc/ssh/ssh_config + sed -i '/StrictHostKeyChecking ask/s/ask/no/g' /etc/ssh/ssh_config +} + + +keygenConfig(){ +# ssh-keygen -t rsa +sshPath=/root/.ssh +if [ ! -r "${sshPath}/id_rsa.pub" ]; then +echo "id_rsa.pub nonexistent creating......" +/usr/bin/expect <<-EOF +set timeout 10 +spawn ssh-keygen -t rsa +expect { + "Enter file in which to save the key (/root/.ssh/id_rsa): " { send "\r"; exp_continue } + "Overwrite (y/n)? " { send "y\r"; exp_continue } + "Enter passphrase (empty for no passphrase): " { send "\r"; exp_continue } + "Enter same passphrase again: " { send "\r" } + } + expect eof + EOF + +wait +echo "Finish ssh-keygen -t rsa." +else +echo "id_rsa.pub exists" +fi +} + +configAuthorizedKeys(){ + user=root + sshDir="/${user}/.ssh" + cat ${sshDir}/id_rsa.pub >> ${sshDir}/authorized_keys +} +removeSSHAsk +keygenConfig +configAuthorizedKeys + +echo "init-ssh-gen-key.sh finished." +echo "Done." + + + + diff --git a/datasophon-init/bin/init-ssh-hadoop.sh b/datasophon-init/bin/init-ssh-hadoop.sh new file mode 100644 index 00000000..765252ca --- /dev/null +++ b/datasophon-init/bin/init-ssh-hadoop.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# example: sh init-ssh-gen-key.sh + +filePath=$1 +initAllHostNums="$2" +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +DATASOPHON_PATH=$(dirname "${INIT_PATH}") +echo "DATASOPHON_PATH: ${DATASOPHON_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +sshHadoopDir=/home/hadoop/.ssh/ +rm -rf ${INIT_BIN_PATH}/tmp_scp_host_info.txt +bash ${INIT_BIN_PATH}/init-hostIp-txt.sh ${filePath} ${initAllHostNums} + +pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-add-hadoop-user.sh +pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i "mkdir -p /home/hadoop/" +pscp.pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -r /root/.ssh /home/hadoop/ +pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i "chown hadoop:hadoop -R '${sshHadoopDir}'" +echo "repair init-ssh-hadoop.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-sshpackage.sh b/datasophon-init/bin/init-sshpackage.sh new file mode 100644 index 00000000..66c7a7bc --- /dev/null +++ b/datasophon-init/bin/init-sshpackage.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + +SSH_FOLDER_NAME=ssh +SSH_TAR_NAME=ssh.tar.gz + +ssh_rpm=$(rpm -qa | grep openssh) +if [[ "$?" == "0" ]]; then + echo "ssh exists" +else + yum -y install openssh + echo "ssh-install finished." +fi + +echo "init-sshpackage.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-sshpass.sh b/datasophon-init/bin/init-sshpass.sh new file mode 100644 index 00000000..91e186ce --- /dev/null +++ b/datasophon-init/bin/init-sshpass.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +echo "${PACKAGES_PATH}" +SSHPASS_FOLDER_NAME=sshpass + +SSHPASS_TAR_NAME=sshpass.tar.gz +rpm -qa | grep sshpass +if [ "$?" == "0" ]; then + echo "sshpass exists" +else + yum -y install sshpass + rpm -qa | grep sshpass + if [ "$?" == "0" ]; then + echo "init sshpass install successfully" + fi +fi diff --git a/datasophon-init/bin/init-stop-firewall.sh b/datasophon-init/bin/init-stop-firewall.sh new file mode 100644 index 00000000..03777a2c --- /dev/null +++ b/datasophon-init/bin/init-stop-firewall.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# example: sh init-stop-firewall.sh +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +DATASOPHON_PATH=$(dirname "${INIT_PATH}") +echo "DATASOPHON_PATH: ${DATASOPHON_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +FIREWALL_STATUS=`firewall-cmd --state` +if [[ ${FIREWALL_STATUS} == "running" ]] +then + echo "Closing firewall." + systemctl stop firewalld.service + systemctl disable firewalld.service + echo "Firewall closed." +else + echo "Firewall closed." +fi +echo "init-stop-firewall.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-stop-selinux.sh b/datasophon-init/bin/init-stop-selinux.sh new file mode 100644 index 00000000..f8b7d411 --- /dev/null +++ b/datasophon-init/bin/init-stop-selinux.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# example: sh init-stop-firewall.sh +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" + + +SELINUX_STATUS=`getenforce` +SELINUX_CONFIG_PATH="/etc/selinux/config" +if [[ ${SELINUX_STATUS} == "Enforcing" ]] +then + echo "Closing SELINUX." + setenforce 0 + echo "Disabling SELINUX." + sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" ${SELINUX_CONFIG_PATH} + echo "SELINUX closed." +else + echo "SELINUX closed." +fi + +echo "init-stop-selinux.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-system-conf.sh b/datasophon-init/bin/init-system-conf.sh new file mode 100644 index 00000000..7688c6ae --- /dev/null +++ b/datasophon-init/bin/init-system-conf.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# example: sh init-system-conf.sh +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + + +# vi /etc/systemd/system.conf +# DefaultLimitNOFILE=102400000 +# DefaultLimitNPROC=102400000 +sed -i '/DefaultLimitNOFILE=/d' /etc/systemd/system.conf +sed -i '/DefaultLimitNPROC=/d' /etc/systemd/system.conf + +cat << EOF >> /etc/systemd/system.conf +DefaultLimitNOFILE=1024000 +DefaultLimitNPROC=1024000 +EOF + +# vi /etc/security/limits.conf +#* soft fsize unlimited +#* hard fsize unlimited +#* soft cpu unlimited +#* hard cpu unlimited +#* soft as unlimited +#* hard as unlimited +#* soft nofile 10240000 +#* hard nofile 10240000 +#* soft nproc 10240000 +#* hard nproc 10240000 + +sed -i '/* soft fsize/d' /etc/security/limits.conf +sed -i '/* hard fsize/d' /etc/security/limits.conf +sed -i '/* soft cpu/d' /etc/security/limits.conf +sed -i '/* hard cpu/d' /etc/security/limits.conf +sed -i '/* soft as/d' /etc/security/limits.conf +sed -i '/* hard as/d' /etc/security/limits.conf +sed -i '/* soft nofile/d' /etc/security/limits.conf +sed -i '/* hard nofile/d' /etc/security/limits.conf +sed -i '/* soft nproc/d' /etc/security/limits.conf +sed -i '/* hard nproc/d' /etc/security/limits.conf + +cat << EOF >> /etc/security/limits.conf +* soft fsize unlimited +* hard fsize unlimited +* soft cpu unlimited +* hard cpu unlimited +* soft as unlimited +* hard as unlimited +* soft nofile 1048576 +* hard nofile 1048576 +* soft nproc unlimited +* hard nproc unlimited +EOF + +# vi /etc/security/limits.d/20-nproc.conf +#* soft nproc 102400000 +#root soft nproc unlimited + +cat << EOF > /etc/security/limits.d/20-nproc.conf +# Default limit for number of user's processes to prevent +# accidental fork bombs. +# See rhbz #432903 for reasoning. + +* soft nproc unlimited +root soft nproc unlimited +EOF + +echo "kernel.pid_max=1000000" >> /etc/sysctl.conf +sysctl -p + +echo "init-system-conf finished." +echo "Done." diff --git a/datasophon-init/bin/init-test.sh b/datasophon-init/bin/init-test.sh new file mode 100644 index 00000000..d01dcb98 --- /dev/null +++ b/datasophon-init/bin/init-test.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +num1="$1" +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +INIT_SQL_PATH=${INIT_PATH}/sql +echo "INIT_SQL_PATH: ${INIT_SQL_PATH}" +#mysql -udatasophon -p'datasophon' <${INIT_SQL_PATH}/V1.1.0_DDL.sql; +#mysql -udatasophon -p'datasophon' <${INIT_SQL_PATH}/V1.1.0_DML.sql; + +mysql -udatasophon -p'datasophon' < > /usr/lib/tmpfiles.d/tmp.conf + echo "x /tmp/hsperfdata*/*" >> /usr/lib/tmpfiles.d/tmp.conf + echo "X /tmp/hsperfdata*" >> /usr/lib/tmpfiles.d/tmp.conf +} + +modifyHostname + +echo "init-tmp_pid.sh finished." diff --git a/datasophon-init/bin/init-websocket_client.sh b/datasophon-init/bin/init-websocket_client.sh new file mode 100644 index 00000000..dccbb7d2 --- /dev/null +++ b/datasophon-init/bin/init-websocket_client.sh @@ -0,0 +1,32 @@ +#!/bin/bash + + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +echo "${PACKAGES_PATH}" +WEBSOCKET_CLIENT_FOLDER_NAME=websocket_client-0.54.0 +WEBSOCKET_CLIENT_TAR_NAME=websocket_client-0.54.0.tar.gz + tar -zxvf ${PACKAGES_PATH}/${WEBSOCKET_CLIENT_TAR_NAME} -C ${PACKAGES_PATH} + cd ${PACKAGES_PATH}/${WEBSOCKET_CLIENT_FOLDER_NAME} + python3 setup.py install + cd ${INIT_PATH} + echo "websocket_client install successfully" + + diff --git a/datasophon-init/bin/init-xdg-utils.sh b/datasophon-init/bin/init-xdg-utils.sh new file mode 100644 index 00000000..a8a2fb19 --- /dev/null +++ b/datasophon-init/bin/init-xdg-utils.sh @@ -0,0 +1,30 @@ +#!/bin/bash + + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +XDG_FOLDER_NAME=xdg-utils +XDG_TAR_NAME=xdg-utils.tar.gz +rpm -qa | grep xdg-utils +if [ "$?" == "0" ]; then +echo "rpm -qa | grep xdg-utils exists" +else + yum -y install xdg-utils + rpm -qa | grep xdg-utils + if [ "$?" == "0" ]; then + echo "xdg-utils install successfully" + fi +fi + diff --git a/datasophon-init/bin/init-yum-hosts-mapping-centos8.sh b/datasophon-init/bin/init-yum-hosts-mapping-centos8.sh new file mode 100644 index 00000000..dc6ef2eb --- /dev/null +++ b/datasophon-init/bin/init-yum-hosts-mapping-centos8.sh @@ -0,0 +1,56 @@ +#!/bin/bash +ip="$1" +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +rm -rf /etc/yum.repos.d/backup +mkdir -p /etc/yum.repos.d/backup +mv `find /etc/yum.repos.d/ -name "*.repo"` /etc/yum.repos.d/backup + +sed -i '/#modify yum mapping hosts start/,/#modify yum mapping hosts end/d' /etc/hosts +modifyYumHosts(){ +echo "#modify yum mapping hosts start" >> /etc/hosts +echo "${ip} yum.dataSophon.cn" >> /etc/hosts +echo "#modify yum mapping hosts end" >> /etc/hosts +} +modifyYumHosts +cat > /etc/yum.repos.d/dataSophon.repo << EOF +#centos8的基础repo包在iso镜像文件的BaseOS和AppStream下 +[dataSophon-base] +name=dataSophon-base +baseurl=http://yum.dataSophon.cn:8000/centos/8/x86_64/BaseOS/ +gpgcheck=0 +enable=1 + +[dataSophon-AppStream] +name=dataSophon-AppStream +baseurl=http://yum.dataSophon.cn:8000/centos/8/x86_64/AppStream/ +gpgcheck=0 +enabled=1 + +#初始化只包含从iso镜像中拷贝出来的基础repo源,如不能满足需求可以再次基础上配置epol扩展包YUM源 +#[dataSophon-epel] +#name=dataSophon-epel +#baseurl=http://yum.dataSophon.cn:8000/epel/8/x86_64/ +#enabled=1 +#gpgcheck=0 +EOF + +yum clean all + +yum makecache +echo "init-yum-hosts-mapping.sh finished." +echo "Done." +echo "yum repolist:" +echo "$(yum repolist)" diff --git a/datasophon-init/bin/init-yum-hosts-mapping-openEuler.sh b/datasophon-init/bin/init-yum-hosts-mapping-openEuler.sh new file mode 100644 index 00000000..56811f4c --- /dev/null +++ b/datasophon-init/bin/init-yum-hosts-mapping-openEuler.sh @@ -0,0 +1,49 @@ +#!/bin/bash +ip="$1" +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ] +then + BASE_DIR=`dirname $(readlink $0)` +else + BASE_DIR=`dirname $0` +fi +BASE_PATH=$(cd ${BASE_DIR}; pwd) +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" + +rm -rf /etc/yum.repos.d/backup +mkdir -p /etc/yum.repos.d/backup +mv `find /etc/yum.repos.d/ -name "*.repo"` /etc/yum.repos.d/backup + +sed -i '/#modify yum mapping hosts start/,/#modify yum mapping hosts end/d' /etc/hosts +modifyYumHosts(){ +echo "#modify yum mapping hosts start" >> /etc/hosts +echo "${ip} yum.dataSophon.cn" >> /etc/hosts +echo "#modify yum mapping hosts end" >> /etc/hosts +} +modifyYumHosts +cat > /etc/yum.repos.d/dataSophon.repo << EOF +[dataSophon-base] +name=dataSophon-base +baseurl=http://yum.dataSophon.cn:8000/repo/ +gpgcheck=0 +enable=1 + +#初始化只包含从iso镜像中拷贝出来的基础repo源,如不能满足需求可以再次基础上配置epol扩展包YUM源 +#[dataSophon-epel] +#name=dataSophon-epel +#baseurl=http://yum.dataSophon.cn:8000/epel/ +#enabled=1 +#gpgcheck=0 +EOF + +yum clean all + +yum makecache +echo "init-yum-hosts-mapping.sh finished." +echo "Done." +echo "yum repolist:" +echo "$(yum repolist)" diff --git a/datasophon-init/config/init-host-info-add.properties b/datasophon-init/config/init-host-info-add.properties new file mode 100644 index 00000000..290e51b3 --- /dev/null +++ b/datasophon-init/config/init-host-info-add.properties @@ -0,0 +1,21 @@ +# 1.Please provide the information of added hosts needed to be inited in the format specified below +# 2.dataSophon.ip.i(eg:i=1,2,3.....): +# 3.dataSophon.password.i: +# 4.dataSophon.ssh.port.i: +# 5.dataSophon.ssh.port.hostname.i: +dataSophon.ip.1=127.0.0.1(need to change) +dataSophon.password.1=your-node-root-password(need to change) +dataSophon.ssh.port.1=22 +dataSophon.ssh.port.hostname.1=your-node-hostname(need to change) + +dataSophon.ip.2=127.0.0.1(need to change) +dataSophon.password.2=your-node-root-password(need to change) +dataSophon.ssh.port.2=22 +dataSophon.ssh.port.hostname.2=your-node-hostname(need to change) + + +dataSophon.ip.3=127.0.0.1(need to change) +dataSophon.password.3=your-node-root-password(need to change) +dataSophon.ssh.port.3=22 +dataSophon.ssh.port.hostname.3=your-node-hostname(need to change) + diff --git a/datasophon-init/config/init-host-info.properties b/datasophon-init/config/init-host-info.properties new file mode 100644 index 00000000..8ec64aef --- /dev/null +++ b/datasophon-init/config/init-host-info.properties @@ -0,0 +1,15 @@ +# 1.Please provide the information of hosts needed to be inited in the format specified below +# 2.dataSophon.ip.i(eg:i=1,2,3.....): +# 3.dataSophon.password.i: +# 4.dataSophon.ssh.port.i: +# 5.dataSophon.ssh.port.hostname.i: +dataSophon.ip.1=172.31.51.160 +dataSophon.password.1=max@123!@# +dataSophon.ssh.port.1=22 +dataSophon.ssh.port.hostname.1=dataSophon01 + +dataSophon.ip.2=172.31.51.161 +dataSophon.password.2=max@123!@# +dataSophon.ssh.port.2=22 +dataSophon.ssh.port.hostname.2=dataSophon02 + diff --git a/datasophon-init/config/init.properties b/datasophon-init/config/init.properties new file mode 100644 index 00000000..6c0b7403 --- /dev/null +++ b/datasophon-init/config/init.properties @@ -0,0 +1,36 @@ + +# Whether to configure the local offline yum source true:need/false:needless +yum.repo.need=true +# Set the YUM source host IP +yum.repo.host.ip=172.31.51.160 + +#The Host information for installing the NMAP service +nmap.server.ip=172.31.51.160 +nmap.server.port=22 +nmap.server.password=max@123!@# + +# The Host information for installing the NTP service(Master) +ntp.master.ip=172.31.51.160 + +# Install MySQL machine node information +mysql.ip=172.31.51.160 +mysql.host.ssh.port=22 +mysql.host.ssh.password=max@123!@# + +# Set the MYSQL database login password +mysql.password=datasophon123 + +# The total number of machines needed to be init. +init.host.num=2 + +# The total number of added machines needed to be init. +init.add.host.num=0 + +# Common Settings. +init.log.dir=./logs + +# server operating system Settings : openEuler/centos8/centos7...... +init.os=openEuler + + + diff --git a/datasophon-init/sbin/init.sh b/datasophon-init/sbin/init.sh new file mode 100644 index 00000000..a7d3aea7 --- /dev/null +++ b/datasophon-init/sbin/init.sh @@ -0,0 +1,831 @@ +#!/bin/bash +Action="$1" + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +BASE_DIR=$(dirname $0) + +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) +echo "Bash Path: ${BASE_PATH}" +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +DATASOPHON_PATH=$(dirname "${INIT_PATH}") +echo "DATASOPHON_PATH: ${DATASOPHON_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_CONFIG_PATH=${INIT_PATH}/config +echo "INIT_CONFIG_PATH: ${INIT_CONFIG_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +hostAllInfoPath=${INIT_CONFIG_PATH}/init-host-info.properties +echo "hostAllInfoPath: ${hostAllInfoPath}" +hostSingleInfoPath=${INIT_CONFIG_PATH}/init-host-info-add.properties +echo "hostSingleInfoPath: ${hostSingleInfoPath}" +FilePath=${INIT_CONFIG_PATH}/init.properties +echo "FilePath: ${FilePath}" +JDK_PATH=/opt/module +smallTimeOut=300 +middleTimeOut=600 +longTimeOut=1200 + +function prop { + [ -f "$FilePath" ] && grep -P "^\s*[^#]?${1}=.*$" $FilePath | cut -d'=' -f2 +} + +ntpMasterIP=$(prop "ntp.master.ip") +mysqlIP=$(prop "mysql.ip") +mysqlPort=$(prop "mysql.host.ssh.port") +mysqlHostSshPassword=$(prop "mysql.host.ssh.password") +mysqlPassword=$(prop "mysql.password") +nmapServerIp=$(prop "nmap.server.ip") +nmapServerPort=$(prop "nmap.server.port") +nmapServerPassword=$(prop "nmap.server.password") +initLogDir=$(prop "init.log.dir") +yumRepoIp=$(prop "yum.repo.host.ip") +yumRepoNeed=$(prop "yum.repo.need") +initAllHostNums=$(prop "init.host.num") +initSingleHostNums=$(prop "init.add.host.num") +initOS=$(prop "init.os") + +echo "yumRepoIp: ${yumRepoIp}" + +initALL() { + + function network() { + local timeout=8 + local target=www.baidu.com + local ret_code=$(curl -I -s --connect-timeout ${timeout} -m 20 ${target} -w %{http_code} | tail -n1) + if [ "x$ret_code" = "x200" ]; then + return 1 + else + return 0 + fi + return 0 + } + + network + if [ $? -eq 0 ]; then + echo -e "\033[31m 由于机器没有联网,请自行检查设置正确的机器时间! \033[0m" + echo -e "\033[31m 由于机器没有联网,请自行设置好离线yum源! \033[0m" + read -p "Please confirm whether the time displayed by the machine is correct(yes/no):" isCorrect + if [ "$isCorrect" = "yes" ]; then + echo "机器时间设置正常,请进行如下环境初始化操作" + else + echo "机器时间不正确,请设置正确时间后,再进行 DataSophon 初始化环境操作" + exit + fi + else + echo "机器可以联网,无需自行检查系统时间是否正常" + fi + rm -rf ${INIT_BIN_PATH}/tmp_scp_host_info.txt + rm -rf ${INIT_BIN_PATH}/1.txt + rm -rf ${initLogDir}/installAllSuccess_$(date +%Y%m%d).log + + bash ${INIT_BIN_PATH}/init-stop-firewall.sh + bash ${INIT_BIN_PATH}/init-stop-selinux.sh + + if [ "${yumRepoNeed}" == "true" ]; then + #如果文件不存在 + if [ ! -d "/data/private-yum-library" ]; then + echo "没有发现private-yum-library 离线yum资源目录,请确认是否正确配置离线yum源资源包......." + else + mv /etc/yum.repos.d/backup/* /etc/yum.repos.d + mkdir -p /etc/yum.repos.d/backup + mv $(find /etc/yum.repos.d/ -name "*.repo") /etc/yum.repos.d/backup + bash ${INIT_BIN_PATH}/init-private-yum-library-${initOS}.sh ${yumRepoIp} + fi + echo "yum repolist:" + echo "$(yum repolist)" + fi + + secretFreeAllLogin + checkSecretFreeAllLogin + + #Distribution resource pack 分发资源包 + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i "mkdir -p '${DATASOPHON_PATH}'" + echo "Distribution resource pack start_time:$(date '+%Y%m%d %H:%M:%S')" + pscp.pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -r ${INIT_PATH} ${DATASOPHON_PATH} + + #close all Firewall + echo "closeAllFirewall start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllFirewall_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-stop-firewall.sh >>${initLogDir}/closeAllFirewall_$(date +%Y%m%d).log + echo "closeAllFirewall end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllFirewall_$(date +%Y%m%d).log + checkCloseAllFirewall + + #close all selinux + echo "closeAllSelinux start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllSelinux_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-stop-selinux.sh >>${initLogDir}/closeAllSelinux_$(date +%Y%m%d).log + echo "closeAllSelinux end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllSelinux_$(date +%Y%m%d).log + + #close all Swap + echo "closeAllSwap start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllSwap_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-close-swap.sh >>${initLogDir}/closeAllSwap_$(date +%Y%m%d).log + echo "closeAllSwap end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllSwap_$(date +%Y%m%d).log + checkcloseAllSwap + + #configure all slave node yum source + #因为安装配置yum离线源会涉及到服务器操作系统的版本问题,不同版本的操作系统离线源不同,完全自动化配置工作量巨大,由用户自己配置好 + if [ "${yumRepoNeed}" == "true" ]; then + if [ ! -d "/data/private-yum-library" ]; then + echo "没有发现private-yum-library目录,请确认是否正确配置离线yum源资源包......." + else + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-yum-hosts-mapping-${initOS}.sh ${yumRepoIp} >>${initLogDir}/modifyYumRepo_$(date +%Y%m%d).log + fi + fi + + #optimiz system conf + echo "modifyAllSystemConf start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifyAllSystemConf_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-system-conf.sh >>${initLogDir}/modifyAllSystemConf_$(date +%Y%m%d).log + echo "modifyAllSystemConf end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifyAllSystemConf_$(date +%Y%m%d).log + + #Configure all hostname + setAllHostname + checkHostName + + #Configure all hosts + echo "modifyAllhostRelation start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifyAllhostRelation_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-allhosts.sh ${hostAllInfoPath} ${initAllHostNums} >>${initLogDir}/modifyAllhostRelation_$(date +%Y%m%d).log + echo "modifyAllhostRelation end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifyAllhostRelation_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-sourceSSHHostname.sh + installServerNmap + + #Configure NTP + initAllNtpChronyService + checkNtpChronyService + + #Configurelibxslt_devel + echo "installAlllibxsltdevel start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAlllibxsltdevel_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-libxslt-devel.sh >>${initLogDir}/installAlllibxsltdevel_$(date +%Y%m%d).log + echo "installAlllibxsltdevel end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAlllibxsltdevel_$(date +%Y%m%d).log + checkLibxsltDevel + #Configure Psmisc + echo "installAllpsmisc start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllpsmisc_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-psmisc.sh >>${initLogDir}/installAllpsmisc_$(date +%Y%m%d).log + echo "installAllpsmisc end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllpsmisc_$(date +%Y%m%d).log + checkPsmisc + + echo "installAllPerlJSON start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllPerlJSON_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-perl-JSON.sh >>${initLogDir}/installAllPerlJSON_$(date +%Y%m%d).log + echo "installAllPerlJSON end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllPerlJSON_$(date +%Y%m%d).log + + #Configure Mysql and DataSophon data + initMysqlDataSophon + initMysqlDevel + + #Configure Disable transparent-hugepage + echo "closeAllTransparentHugepage start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllTransparentHugepage_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-close-transparent-hugepage.sh >>${initLogDir}/closeAllTransparentHugepage_$(date +%Y%m%d).log + echo "closeAllTransparentHugepage start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllTransparentHugepage_$(date +%Y%m%d).log + checkTransparentHugepage + + #Configure JDK + echo "installAllJDK start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-jdk.sh >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log + echo "installAllJDK end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log + checkJDK + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-java-policy.sh >>${initLogDir}/modifyJavaPolicy_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-tmp_pid.sh + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-xdg-utils.sh >>${initLogDir}/installXdg_$(date +%Y%m%d).log + checkXdg + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-gcc-c++.sh >>${initLogDir}/installGccC++_$(date +%Y%m%d).log + checkGccC + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-openssl-devel.sh >>${initLogDir}/installOpensslDevel_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-libtool.sh >>${initLogDir}/installLibtool_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-krb5-devel.sh >>${initLogDir}/installKrb5Devel_$(date +%Y%m%d).log + checkKrb5Devel + + #redhat-lsb 配置 和python环境配置暂不需要 + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${middleTimeOut} -i bash ${INIT_BIN_PATH}/init-redhat-lsb.sh >>${initLogDir}/installRedhatLsb_$(date +%Y%m%d).log + #checkRedhatLsb + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-python2-rpm-macros.sh >>${initLogDir}/installPython2Macros_$(date +%Y%m%d).log + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-python-srpm-macros.sh >>${initLogDir}/installPythonSrpmMacros_$(date +%Y%m%d).log + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-python-rpm-macros.sh >>${initLogDir}/installPythonMacros_$(date +%Y%m%d).log + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-init-python-devel.sh >> ${initLogDir}/installPythonDevel_`date +%Y%m%d`.log + #checkPythonDevel + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-cyrus-sasl.sh >>${initLogDir}/installCyrusSasl_$(date +%Y%m%d).log + #checkCyrusSasl + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-python36-devel.sh >>${initLogDir}/installPython36Devel_$(date +%Y%m%d).log + #checkPython36Devel + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-Cython.sh >>${initLogDir}/installCython_$(date +%Y%m%d).log + #checkCython + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-six.sh >>${initLogDir}/installSix_$(date +%Y%m%d).log + #checkSix + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-websocket_client.sh >>${initLogDir}/installWebsocketClient_$(date +%Y%m%d).log + #checkWebsocketClient + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-ecdsa.sh >>${initLogDir}/installEcdsa_$(date +%Y%m%d).log + #checkecdsa + + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-pytest_runner.sh >>${initLogDir}/installPytestRunner_$(date +%Y%m%d).log + #checkPytestRunner + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-ntp_enable.sh >>${initLogDir}/installSingleNtpEnable_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-chmod-dev-null.sh >>${initLogDir}/chmodDevNull_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-cleanBuff-async.sh >>${initLogDir}/cleanBuff_$(date +%Y%m%d).log + rm -rf ${INIT_BIN_PATH}/tmp_scp_host_info.txt + rm -rf ${INIT_BIN_PATH}/1.txt + initsource + source /etc/profile + source /root/.bash_profile + echo "The DataSophon deployment environment of all nodes has been inited successfully . Please proceed to the next step" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log + cat ${initLogDir}/installAllSuccess_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllSuccess_$(date +%Y%m%d).log + +} + +initsource() { + source /etc/profile + source /root/.bash_profile + echo $(java -version) +} + +testFun() { + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-java-policy.sh >>${initLogDir}/modifyJavaPolicy_$(date +%Y%m%d).log +} + +#免密登录 +secretFreeAllLogin() { + echo "secretFreeAllLogin........................" + mkdir -p ${initLogDir} + echo "secretFreeAllLogin start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + rpm -qa | grep openssh + if [[ "$?" == "0" ]]; then + echo "ssh exists" >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + echo "${INIT_BIN_PATH}" + else + bash ${INIT_BIN_PATH}/init-sshpackage.sh >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + fi + rpm -qa | grep sshpass + if [[ "$?" == "0" ]]; then + echo "sshpass exists" >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + else + bash ${INIT_BIN_PATH}/init-sshpass.sh >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + fi + rpm -qa | grep pssh + if [[ "$?" == "0" ]]; then + echo "pssh exists" >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + else + bash ${INIT_BIN_PATH}/init-pssh.sh ${initOS} >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + fi + + bash ${INIT_BIN_PATH}/init-expect.sh + + bash ${INIT_BIN_PATH}/init-ssh-gen-key.sh >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + bash ${INIT_BIN_PATH}/init-ssh-copy-key.sh ${hostAllInfoPath} ${initAllHostNums} ${nmapServerPort} >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + bash ${INIT_BIN_PATH}/init-ssh-hadoop.sh ${hostAllInfoPath} ${initAllHostNums} >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log + echo "secretFreeAllLogin end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/secretFreeAllLogin_$(date +%Y%m%d).log +} + +#检查免密登录 +checkSecretFreeAllLogin() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${pwd}" + echo "${hostAllInfoPath}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'ls' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' free login failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' free login failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: All free login links have been init successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查所有的swap是否关闭 +checkcloseAllSwap() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'cat /etc/sysctl.conf | grep vm.swappiness=0' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' close swap failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' close swap failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: All closing swap links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查所有的Firewall是否关闭 +checkCloseAllFirewall() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'firewall-cmd --state' >${initLogDir}/checkCloseAllFirewall.log + cat ${initLogDir}/checkCloseAllFirewall.log | grep running + if [ $? -eq 0 ]; then + echo "ERROR: '${ip}' close firewall failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' close firewall failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + else + echo "${ip} close firewall successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + fi + done + echo "SUCCESS: All closing firewall links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#设置所有的的hostname +setAllHostname() { + echo "setAllHostname start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/setAllHostname_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + hostname=$(prop "dataSophon.ssh.port.hostname.${i}") + + echo "root@${ip}:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/setAllHostname_$(date +%Y%m%d).log + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} bash ${INIT_BIN_PATH}/init-hostname.sh ${hostname} >${initLogDir}/setAllHostname_$(date +%Y%m%d).log + done + echo "setAllHostname end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/setAllHostname_$(date +%Y%m%d).log +} + +#检查设置所有的的hostname +checkHostName() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + hostname=$(prop "dataSophon.ssh.port.hostname.${i}") # hostname + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'hostname' >${initLogDir}/checkHostName.log + cat ${initLogDir}/checkHostName.log | grep "${hostname}" + if [ $? -eq 0 ]; then + echo "${ip} set hostname successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set hostname failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set hostname failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: set hostname links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#安装nmap +installServerNmap() { + echo "installServerNmap start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installServerNmap_$(date +%Y%m%d).log + echo "root@${ip}:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installServerNmap_$(date +%Y%m%d).log + sshpass -p'${nmapServerPassword}' ssh -P${nmapServerPort} -o StrictHostKeyChecking=no root@${nmapServerIp} bash ${INIT_BIN_PATH}/init-nmap.sh >${initLogDir}/installServerNmap_$(date +%Y%m%d).log + echo "installServerNmap end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installServerNmap_$(date +%Y%m%d).log +} + +#初始化配置安装Ntp服务 +initAllNtpChronyService() { + echo "initAllNtpChronyService start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initAllNtpChronyService_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + if [ "${ntpMasterIP}" = "${ip}" ]; then + echo "masterntp" + echo "root@${ip}:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initAllNtpChronyService_$(date +%Y%m%d).log + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} bash ${INIT_BIN_PATH}/init-ntp-chrony-server.sh >${initLogDir}/initAllNtpChronyService_$(date +%Y%m%d).log + else + echo "slaventp" + echo "root@${ip}:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initAllNtpChronyService_$(date +%Y%m%d).log + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} bash ${INIT_BIN_PATH}/init-ntp-chrony-slave.sh ${ntpMasterIP} >${initLogDir}/initAllNtpChronyService_$(date +%Y%m%d).log + fi + done + echo "initAllNtpChronyService end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initAllNtpChronyService_$(date +%Y%m%d).log +} + +#检查配置安装的Ntp服务 +checkNtpChronyService() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep chrony-' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set ntp failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set ntp failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set ntp Chrony have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查配置安装的libxslt-devel +checkLibxsltDevel() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep libxslt-devel' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set libxslt devel failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set libxslt devel failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set libxslt devel have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查配置安装的Psmisc +checkPsmisc() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep psmisc' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set psmisc failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set psmisc failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set psmisc have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#配置安装mysql8以及初始化DataSophon数据库 +initMysqlDataSophon() { + echo "initMysqlDataSophon start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initMysqlDataSophon_$(date +%Y%m%d).log + echo "${mysqlIP}" >>${initLogDir}/initMysqlDataSophon_$(date +%Y%m%d).log + sshpass -p'${mysqlHostSshPassword}' ssh -P${mysqlPort} -o StrictHostKeyChecking=no root@${mysqlIP} bash ${INIT_BIN_PATH}/init-mysql-datasophon.sh $mysqlPassword >${initLogDir}/initMysqlDataSophon_$(date +%Y%m%d).log + echo "initMysqlDataSophon end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initMysqlDataSophon_$(date +%Y%m%d).log +} + +#配置安装mysql-devel +initMysqlDevel() { + rm -rf ${INIT_BIN_PATH}/m.txt + echo "initMysqlDevel start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initMysqlDevel_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + + if [ "${mysqlIP}" = "${ip}" ]; then + echo "already install mysql" + else + echo -e "root@${ip}:${port}" >>${INIT_BIN_PATH}/m.txt + fi + done + echo "root@${ip}:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initMysqlDevel_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/m.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-mysql-devel.sh >>${initLogDir}/initMysqlDevel_$(date +%Y%m%d).log + #pssh -h ${INIT_BIN_PATH}/m.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-mysql-client.sh >> ${initLogDir}/initMysqlDevel_`date +%Y%m%d`.log + rm -rf ${INIT_BIN_PATH}/m.txt + echo "initMysqlDevel end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/initMysqlDevel_$(date +%Y%m%d).log +} + +#检查配置配置安装Cython +checkCython() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'pip3 list | grep Cython' >${initLogDir}/checkCython.log + cat ${initLogDir}/checkCython.log | grep Cython + if [ $? -eq 0 ]; then + echo "${ip} set Cython successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set Cython failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set Cython failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set Cython links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} +#检查配置配置安装Six +checkSix() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'pip3 list | grep six' >${initLogDir}/checkSix.log + cat ${initLogDir}/checkSix.log | grep six + if [ $? -eq 0 ]; then + echo "${ip} set Six successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set Six failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set Six failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set Six links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查配置安装WebsocketClient +checkWebsocketClient() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'pip3 list | grep websocket-client' >${initLogDir}/checkWebsocketClient.log + cat ${initLogDir}/checkWebsocketClient.log | grep websocket-client + if [ $? -eq 0 ]; then + echo "${ip} set websocket-client successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set websocket-client failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set websocket-client failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set websocket-client links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#配置禁止透明大页 +checkTransparentHugepage() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'cat /sys/kernel/mm/transparent_hugepage/enabled | grep [never]' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' close transparent_hugepage failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' close transparent_hugepage failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: All transparent_hugepage links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查配置安装的jdk环境 +checkJDK() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'source /etc/profile ; java -version' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set jdk failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set jdk failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set JDK links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查配置安装的xdg-utils +checkXdg() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep xdg-utils' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set xdg-utils failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set xdg-utils failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set xdg-utils links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +#检查配置安装的redhat-lsb +checkRedhatLsb() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep redhat-lsb' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set redhat-lsb failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set redhat-lsb failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set redhat-lsb links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +checkecdsa() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'pip3 list | grep ecdsa' >${initLogDir}/checkecdsa.log + cat ${initLogDir}/checkecdsa.log | grep ecdsa + if [ $? -eq 0 ]; then + echo "${ip} set ecdsa successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set ecdsa failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set ecdsa failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set ecdsa links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +checkPytestRunner() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'pip3 list | grep pytest-runner' >${initLogDir}/checkPytestRunner.log + cat ${initLogDir}/checkPytestRunner.log | grep pytest-runner + if [ $? -eq 0 ]; then + echo "${ip} set pytest-runner successfully" >>${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set pytest-runner failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set pytest-runner failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set pytest-runner links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +checkGccC() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep gcc-c++' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set gcc-c++ failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set gcc-c++ failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set gcc-c++ links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +checkKrb5Devel() { + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep krb5-devel' >${initLogDir}/installAll_$(date +%Y%m%d).log + else + echo "ERROR: '${ip}' set krb5-devel failed" >>${initLogDir}/installAll_$(date +%Y%m%d).log + echo "ERROR: '${ip}' set krb5-devel failed" >>${initLogDir}/installAllError_$(date +%Y%m%d).log + cat ${initLogDir}/installAllError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installAllError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: Set krb5-devel links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log +} + +if [ "$Action" = "initAll" ]; then + initALL + echo "initALL....................." +fi +if [ "$Action" = "secretFreeAllLogin" ]; then + secretFreeAllLogin +fi +if [ "$Action" = "checkcloseAllSwap" ]; then + checkcloseAllSwap +fi + +if [ "$Action" = "testFun" ]; then + testFun +fi From 617701e08d13955c9b3631a54c161dda724b4476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B5=B7?= Date: Fri, 18 Aug 2023 17:20:49 +0800 Subject: [PATCH 05/11] first commit logs --- .../sbin/logs/installAll_20230818.log | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 datasophon-init/sbin/logs/installAll_20230818.log diff --git a/datasophon-init/sbin/logs/installAll_20230818.log b/datasophon-init/sbin/logs/installAll_20230818.log new file mode 100644 index 00000000..e35f8c8a --- /dev/null +++ b/datasophon-init/sbin/logs/installAll_20230818.log @@ -0,0 +1,22 @@ +172.31.51.160 free login successfully +172.31.51.161 free login successfully +172.31.51.160 close firewall successfully +172.31.51.161 close firewall successfully +172.31.51.160 close swap successfully +172.31.51.161 close swap successfully +172.31.51.160 set hostname successfully +172.31.51.161 set hostname successfully +172.31.51.160 set ntp successfully +172.31.51.161 set ntp successfully +172.31.51.160 set libxslt devel successfully +172.31.51.161 set libxslt devel successfully +172.31.51.160 set psmisc successfully +172.31.51.161 set psmisc successfully +172.31.51.160 close transparent_hugepage successfully +172.31.51.161 close transparent_hugepage successfully +172.31.51.160 set jdk successfully +172.31.51.161 set jdk successfully +172.31.51.160 set xdg-utils successfully +172.31.51.161 set xdg-utils successfully +172.31.51.160 set krb5-devel successfully +172.31.51.161 set krb5-devel successfully From 2ea4654477395696375f7e6e9b86734eec574a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B5=B7?= Date: Fri, 18 Aug 2023 17:32:02 +0800 Subject: [PATCH 06/11] commit README.md --- datasophon-init/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/datasophon-init/README.md b/datasophon-init/README.md index 37b5a203..38a4b6d3 100644 --- a/datasophon-init/README.md +++ b/datasophon-init/README.md @@ -71,6 +71,7 @@ drwxr-xr-x 2 root root 70 8月 7 10:54 sql ### init.properties 说明 +yum.repo.need:填写是否需要部署私有化yum源(true:需要/false:不需要,如服务器不能连接外网必须部署私有化yum源) yum.repo.host.ip:填写即将部署私有化yum源的节点的内网IP(即执行init脚本的节点IP,推荐在主节点上进行) namp.server.ip=:填写未来要部署的datasophon管理端的节点内网IP namp.server.port:填写未来要部署的datasophon管理端节点的SSH端口号,默认22 @@ -82,7 +83,8 @@ mysql.host.ssh.password: 填写未来要部署mysql数据库的节点服务器 mysql.password: 填写未来要部署mysql数据库的root密码,这个密码不要有特殊字符比如‘,’、‘$’等,可在初始化完成之后再自行设置高复杂度密码 init.host.num: 填写未来要初始化的服务器数量 init.add.host.num: 填写未来要初始化的新增服务器节点数量,全量初始化时无需修改 -init.log.dir=./logs :设置初始化服务器环境时日志存放目录 +init.log.dir :设置初始化服务器环境时日志存放目录 +init.os :填写服务器操作系统类型openEuler/centos8/centos7...... ### init-host-info.properties 说明 @@ -101,13 +103,13 @@ dataSophon.ssh.port.hostname.i=dataSophon0 #预备安装dataSophon集群的节 PS:执行的 cd /data/datasophon-init/sbin -bash init.sh initAll +bash init.sh initAll (等待程序执行完毕,中间需要有一次确认服务器时间的确认项需要选择) source /etc/profile 当执行完 bash init.sh initAll 之后,会看到有下面输出很多的日志,因为需要配置本地离线yum源以及安装mysql8、jdk等整个过程需要一定的时间,可以查看log目录下的安装日志 其中mysql初始化的数据库默认为datasophon,初始化过程中会自动创建用户"datasophon"密码为"datasophon" -##当前初始化模块支持的操作系统版本为:CentOS-8.5.2111-x86_64 +##当前初始化模块支持的操作系统版本为:CentOS-8.5.2111-x86_64、openEuler-22.03 ##当前初始化模块支持的mysql为:mysql-community-8.0.28 ##自动安装的JDK为:jdk-8u333 From 269fc9a74e43a4109eed7fe2708d0cb0407d1c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B5=B7?= Date: Mon, 21 Aug 2023 09:11:53 +0800 Subject: [PATCH 07/11] README.md format optimization --- datasophon-init/README.md | 140 +++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/datasophon-init/README.md b/datasophon-init/README.md index 38a4b6d3..60467d9f 100644 --- a/datasophon-init/README.md +++ b/datasophon-init/README.md @@ -16,82 +16,82 @@ English - 觉得不错的话,star fork下,欢迎社区开发者共建DataSophon
-# dataSophon-init使用说明 -前言:当前版本是根据centos8.5和openEuler-22.03进行开发适配的,其它类型和版本的操作系统目前没有进行详细的测试验证可能存在兼容性问题,需要对shell脚本和本地YUM离线安装包进行适配 -1、将datasophon-init整个目录的内容放到规划的集群主节点的/data目录下(mkdir /data); -2、将packages.tar.gz 离线依赖库移到主节点的 /data/datasophon-init下并解压;链接:https://pan.baidu.com/s/1iqudVwDgg2x_OO35VLkkSg 提取码:6zrz -3、在未连接互联网的情况下预备安装datasophon的服务器已经配置好离线yum源,能够通过yum命令安装依赖包(此步骤为必须,因为初始化脚本中使用了"yum -y install xxxx"的方式安装依赖,如果没有yum源会导致安装失败 ); - 离线YUM源配置方法(Ps:能连公网的用户就不用配置离线yum源了,直接配置为公共的源,该步骤都是在主节点上操作): - 配置脚本为:init-private-yum-library-${initOS}.sh - ①首先创建目录 'mkdir -p /data/private-yum-library_temp'然后将和操作系统匹配的操作系统iso文件移动到/data/目录下; - ②在/data目录下创建private-yum-library目录:'mkdir -p /data/private-yum-library'; - ③执行挂载操作系统命令:mount -o loop /data/openEuler-22.03-LTS-SP2-everything-x86_64-dvd.iso /data/private-yum-library_temp - 这种挂载重启服务器之后会失效,所以我们挂载完成后将ios内的文件全部拷贝出来做离线yum源用; - ④在private-yum-library目录下创建两个子目录 repo 和 epel; - ⑤将private-yum-library_temp目录下的文件全部拷贝到/data/private-yum-library/repo目录下:cp -r /data/private-yum-library_temp/* /data/private-yum-library/repo - 另外不同操作系统挂载后所产生的目录不同,比如centos8的repo有两个BaseOS和AppStream; - ⑥将原本的yum源的配置文件进行备份 :mkdir -p /etc/yum.repos.d/bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak - ⑦剩下的工作就交给脚本工具自己去处理了,epel目录是为了给需要自行配置离线eprl源的用户准备的,如果能配置epel建议进行配置,因为很多操作系统额外的很多工具包都在对应的epel中 - -4、集群NTP时钟默认使用Chrony,如使用其它的方式请自行安装配置,并将sbin/init.sh 脚本中的 initALL() 方法中的‘initAllNtpChronyService’ 和 ‘checkNtpChronyService’方法注释掉避免重复安装; -5、脚本的初始化需要用到python环境,主要用到pssh进行集群间的命令执行控制,目前packages目录中pssh.tar.gz中已经内置了三个安装包 - pssh-2.3.1-5.el7.noarch.rpm 需要python2.7的支持 - pssh-2.3.1-29.el8.noarch.rpm 需要python3.6的支持 - pssh-2.3.4-1.el9.noarch.rpm 需要python3.9的支持 - Centos7和8中的repo中已经存在对应的rpm格式的pssh包了,目前openEuler22.03中还没有pssh相关的安装包 +觉得不错的话,star fork下,欢迎社区开发者共建DataSophon
+ +# dataSophon-init使用说明 + +前言:当前版本是根据centos8.5和openEuler-22.03进行开发适配的,其它类型和版本的操作系统目前没有进行详细的测试验证可能存在兼容性问题,需要对shell脚本和本地YUM离线安装包进行适配 +1、将datasophon-init整个目录的内容放到规划的集群主节点的/data目录下(mkdir /data); +2、将packages.tar.gz 离线依赖库移到主节点的 /data/datasophon-init下并解压;下载链接:https://pan.baidu.com/s/1iqudVwDgg2x_OO35VLkkSg 提取码:6zrz +3、在未连接互联网的情况下预备安装datasophon的服务器已经配置好离线yum源,能够通过yum命令安装依赖包(此步骤为必须,因为初始化脚本中使用了"yum -y install xxxx"的方式安装依赖,如果没有yum源会导致安装失败 ); +离线YUM源配置方法(Ps:能连公网的用户就不用配置离线yum源了,直接配置为公共的源,该步骤都是在主节点上操作): + 详情可查看配置脚本:init-private-yum-library-${initOS}.sh + ①首先创建目录 'mkdir -p /data/private-yum-library_temp'然后将和操作系统匹配的操作系统iso文件移动到/data/目录下; + ②在/data目录下创建private-yum-library目录:'mkdir -p /data/private-yum-library'; + ③执行挂载操作系统命令:mount -o loop /data/openEuler-22.03-LTS-SP2-everything-x86_64-dvd.iso /data/private-yum-library_temp,这种挂载重启服务器之后会失效,所以我们挂载完成后将ios内的文件全部拷贝出来做离线yum源用; + ④在private-yum-library目录下创建两个子目录 repo 和 epel; + ⑤将private-yum-library_temp目录下的文件全部拷贝到/data/private-yum-library/repo目录下:cp -r /data/private-yum-library_temp/* /data/private-yum-library/repo,另外不同操作系统挂载后所产生的目录不同,比如centos8的repo有两个BaseOS和AppStream; + ⑥将原本的yum源的配置文件进行备份 :mkdir -p /etc/yum.repos.d/bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak; + ⑦剩下的工作就交给脚本工具自己去处理了,epel目录是为了给需要自行配置离线eprl源的用户准备的,如果能配置epel建议进行配置,因为很多操作系统额外的很多工具包都在对应的epel中; + +4、集群NTP时钟默认使用Chrony,如使用其它的方式请自行安装配置,并将sbin/init.sh 脚本中的 initALL() 方法中的‘initAllNtpChronyService’ 和 ‘checkNtpChronyService’方法注释掉避免重复安装; +5、脚本的初始化需要用到python环境,主要用到pssh进行集群间的命令执行控制,目前packages目录中pssh.tar.gz中已经内置了三个安装包: + pssh-2.3.1-5.el7.noarch.rpm 需要python2.7的支持; + pssh-2.3.1-29.el8.noarch.rpm 需要python3.6的支持; + pssh-2.3.4-1.el9.noarch.rpm 需要python3.9的支持; + Centos7和8中的repo中已经存在对应的rpm格式的pssh包了,目前openEuler22.03中还没有pssh相关的安装包, 其它版本pssh的rpm包下载工具地址:http://rpmfind.net/linux/rpm2html/search.php?query=pssh,可以根据操作系统和python版本进行适配 -6、服务器操作系统的iso文件建议使用everything版本的,这样包含的依赖包更全一点; +6、服务器操作系统的iso文件建议使用everything版本的,这样包含的依赖包更全一点; -dataSophon-init目录结构如下: -[root@localhost datasophon-init]# ls -l -总用量 8 -drwxr-xr-x 2 root root 4096 8月 10 17:09 bin -drwxr-xr-x 2 root root 99 7月 28 16:10 config -drwxr-xr-x 8 root root 4096 8月 9 13:47 packages -drwxr-xr-x 2 root root 189 7月 27 11:35 remove -drwxr-xr-x 3 root root 50 8月 10 20:02 sbin -drwxr-xr-x 2 root root 70 8月 7 10:54 sql +# dataSophon-init目录结构如下: +[root@localhost datasophon-init]# ls -l +总用量 8 +drwxr-xr-x 2 root root 4096 8月 10 17:09 bin +drwxr-xr-x 2 root root 99 7月 28 16:10 config +drwxr-xr-x 8 root root 4096 8月 9 13:47 packages +drwxr-xr-x 2 root root 189 7月 27 11:35 remove +drwxr-xr-x 3 root root 50 8月 10 20:02 sbin +drwxr-xr-x 2 root root 70 8月 7 10:54 sql -上面的各个目录解释如下: +## 上面的各个目录解释如下: -* bin:datasophon 服务器集群环境配置初始化程序脚本(单个模块初始化脚本所在目录,无需手动管理) -* config:datasophon 服务器集群环境一键初始化所需配置文件目录,需要用户手动修改 -* packages:初始化过程需要的依赖安装包存放目录 -* remove:卸载环境脚本 -* sbin:一键初始化环境脚本所在目录 -* sql:datasophon数据库初始化sql脚本所在目录 +* bin:datasophon 服务器集群环境配置初始化程序脚本(单个模块初始化脚本所在目录,无需手动管理); +* config:datasophon 服务器集群环境一键初始化所需配置文件目录,需要用户手动修改; +* packages:初始化过程需要的依赖安装包存放目录; +* remove:卸载环境脚本; +* sbin:一键初始化环境脚本所在目录; +* sql:datasophon数据库初始化sql脚本所在目录; -在 config 目录下面有三个配置文件: -* init.properties:主要配置私有化 yum 源安装节点信息、namp 安装节点信息、mysql 数据库安装节点信息、修复机器总数,以及修复模块日志存放位置。用户根据需要自行修改相关配置项; +### 在 config 目录下面有三个配置文件: +* init.properties:主要配置私有化 yum 源安装节点信息、namp 安装节点信息、mysql 数据库安装节点信息、修复机器总数、服务器操作系统类型、以及修复模块日志存放位置。用户根据需要自行修改相关配置项; * init-host-info.properties:节点全量修复,需要配置此文件,具体配置所有节点内网 Ip、密码、端口号以及主机名; * init-host-info-add.properties:集群新增节点时,需要配置此文件,具体配置新增节点内网 Ip、密码、端口号以及主机名; ### init.properties 说明 -yum.repo.need:填写是否需要部署私有化yum源(true:需要/false:不需要,如服务器不能连接外网必须部署私有化yum源) -yum.repo.host.ip:填写即将部署私有化yum源的节点的内网IP(即执行init脚本的节点IP,推荐在主节点上进行) -namp.server.ip=:填写未来要部署的datasophon管理端的节点内网IP -namp.server.port:填写未来要部署的datasophon管理端节点的SSH端口号,默认22 -namp.server.password:填写未来要部署的datasophon管理端节点的密码,这个密码最好不要有特殊字符比如‘,’、‘$’等 -ntp.master.ip: 填写未来要部署ntp时钟同步的主节点服务器IP(推荐主节点) -mysql.ip: 填写未来要部署mysql数据库的节点服务器IP(推荐主节点) -mysql.host.ssh.port: 填写未来要部署mysql数据库的节点服务器SSH端口,默认为22 -mysql.host.ssh.password: 填写未来要部署mysql数据库的节点服务器的密码 -mysql.password: 填写未来要部署mysql数据库的root密码,这个密码不要有特殊字符比如‘,’、‘$’等,可在初始化完成之后再自行设置高复杂度密码 -init.host.num: 填写未来要初始化的服务器数量 -init.add.host.num: 填写未来要初始化的新增服务器节点数量,全量初始化时无需修改 -init.log.dir :设置初始化服务器环境时日志存放目录 -init.os :填写服务器操作系统类型openEuler/centos8/centos7...... +* yum.repo.need:填写是否需要部署私有化yum源(true:需要/false:不需要,如服务器不能连接外网必须部署私有化yum源); +* yum.repo.host.ip:填写即将部署私有化yum源的节点的内网IP(即执行init脚本的节点IP,推荐在主节点上进行); +* namp.server.ip=:填写未来要部署的datasophon管理端的节点内网IP; +* namp.server.port:填写未来要部署的datasophon管理端节点的SSH端口号,默认22; +* namp.server.password:填写未来要部署的datasophon管理端节点的密码,这个密码最好不要有特殊字符比如‘,’、‘$’等; +* ntp.master.ip: 填写未来要部署ntp时钟同步的主节点服务器IP(推荐主节点); +* mysql.ip: 填写未来要部署mysql数据库的节点服务器IP(推荐主节点); +* mysql.host.ssh.port: 填写未来要部署mysql数据库的节点服务器SSH端口,默认为22; +* mysql.host.ssh.password: 填写未来要部署mysql数据库的节点服务器的密码; +* mysql.password: 填写未来要部署mysql数据库的root密码,这个密码不要有特殊字符比如‘,’、‘$’等,可在初始化完成之后再自行设置高复杂度密码; +* init.host.num: 填写未来要初始化的服务器数量; +* init.add.host.num: 填写未来要初始化的新增服务器节点数量,全量初始化时无需修改; +* init.log.dir :设置初始化服务器环境时日志存放目录; +* init.os :填写服务器操作系统类型openEuler/centos8/centos7......; ### init-host-info.properties 说明 -dataSophon.ip.i=172.31.51.194 #预备安装dataSophon集群的节点内网IP(i表示1-n的取值,n为集群节点数量) -dataSophon.password.i=xxxxx #预备安装dataSophon集群的节点的登录密码 -dataSophon.ssh.port.i=22 #预备安装dataSophon集群的节点的SSH端口默认22 -dataSophon.ssh.port.hostname.i=dataSophon0 #预备安装dataSophon集群的节点的主机名 +* dataSophon.ip.i=172.31.51.194 #预备安装dataSophon集群的节点内网IP(i表示1-n的取值,n为集群节点数量); +* dataSophon.password.i=xxxxx #预备安装dataSophon集群的节点的登录密码; +* dataSophon.ssh.port.i=22 #预备安装dataSophon集群的节点的SSH端口默认22; +* dataSophon.ssh.port.hostname.i=dataSophon01 #预备安装dataSophon集群的节点的主机名; ## 全量初始化流程 @@ -99,19 +99,19 @@ dataSophon.ssh.port.hostname.i=dataSophon0 #预备安装dataSophon集群的节 ![img](website/static/img/Initialization-process.png) ### 执行初始化脚本 + 完成上述步骤后,执行如下命令即可开始一键初始化任务。 -PS:执行的 -cd /data/datasophon-init/sbin -bash init.sh initAll (等待程序执行完毕,中间需要有一次确认服务器时间的确认项需要选择) -source /etc/profile +cd /data/datasophon-init/sbin +bash init.sh initAll (等待程序执行完毕,中间需要有一次确认服务器时间的确认项需要选择) +source /etc/profile -当执行完 bash init.sh initAll 之后,会看到有下面输出很多的日志,因为需要配置本地离线yum源以及安装mysql8、jdk等整个过程需要一定的时间,可以查看log目录下的安装日志 -其中mysql初始化的数据库默认为datasophon,初始化过程中会自动创建用户"datasophon"密码为"datasophon" +当执行完 bash init.sh initAll 之后,会看到有下面输出很多的日志,因为需要配置本地离线yum源以及安装mysql8、jdk等整个过程需要一定的时间,可以查看log目录下的安装日志 +其中mysql初始化的数据库默认为datasophon,初始化过程中会自动创建用户"datasophon"密码为"datasophon" -##当前初始化模块支持的操作系统版本为:CentOS-8.5.2111-x86_64、openEuler-22.03 -##当前初始化模块支持的mysql为:mysql-community-8.0.28 -##自动安装的JDK为:jdk-8u333 +#### 当前初始化模块支持的操作系统版本为:CentOS-8.5.2111-x86_64、openEuler-22.03 +####当前初始化模块支持的mysql为:mysql-community-8.0.28 +####自动安装的JDK为:jdk-8u333 From a16544a594414832fcae684d8a702b9009a14699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B5=B7?=Date: Tue, 22 Aug 2023 15:57:18 +0800 Subject: [PATCH 08/11] =?UTF-8?q?Added=20the=20node=20initialization=20cap?= =?UTF-8?q?ability=20README.md=20file=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datasophon-init/README.md | 21 +- datasophon-init/bin/init-singlehosts.sh | 62 +++ datasophon-init/bin/init-ssh-hadoop.sh | 1 - datasophon-init/sbin/init.sh | 498 +++++++++++++++++++++++- 4 files changed, 573 insertions(+), 9 deletions(-) create mode 100644 datasophon-init/bin/init-singlehosts.sh diff --git a/datasophon-init/README.md b/datasophon-init/README.md index 60467d9f..3ac00662 100644 --- a/datasophon-init/README.md +++ b/datasophon-init/README.md @@ -93,6 +93,13 @@ drwxr-xr-x 2 root root 70 8月 7 10:54 sql * dataSophon.ssh.port.i=22 #预备安装dataSophon集群的节点的SSH端口默认22; * dataSophon.ssh.port.hostname.i=dataSophon01 #预备安装dataSophon集群的节点的主机名; +### init-host-info-add.properties 说明 + +* dataSophon.ip.i=172.31.51.162 #预备新增dataSophon集群的节点内网IP(i表示1-n的取值,n为集群节点数量); +* dataSophon.password.i=xxxxx #预备新增安装dataSophon集群的节点的登录密码; +* dataSophon.ssh.port.i=22 #预备新增安装dataSophon集群的节点的SSH端口默认22; +* dataSophon.ssh.port.hostname.i=dataSophon05 #预备新增安装dataSophon集群的节点的主机名; + ## 全量初始化流程 @@ -104,14 +111,24 @@ drwxr-xr-x 2 root root 70 8月 7 10:54 sql cd /data/datasophon-init/sbin bash init.sh initAll (等待程序执行完毕,中间需要有一次确认服务器时间的确认项需要选择) -source /etc/profile +PS:执行完毕之后如果服务器的终端未关闭,可能会出现一些命令无效的情况,此时需要手动在终端执行 ‘source /etc/profile ’使环境变量生效,或者关闭终端重新打开 当执行完 bash init.sh initAll 之后,会看到有下面输出很多的日志,因为需要配置本地离线yum源以及安装mysql8、jdk等整个过程需要一定的时间,可以查看log目录下的安装日志 其中mysql初始化的数据库默认为datasophon,初始化过程中会自动创建用户"datasophon"密码为"datasophon" #### 当前初始化模块支持的操作系统版本为:CentOS-8.5.2111-x86_64、openEuler-22.03 ####当前初始化模块支持的mysql为:mysql-community-8.0.28 -####自动安装的JDK为:jdk-8u333 +####自动安装的JDK为:jdk-8u333(jdk在安装datasophon的时候会自动配置,初始化工具不会再次进行重复配置) + + +## 新增节点初始化流程 + +将config/init.properties文件中的'init.add.host.num'参数修改为即将新增加的节点的实际数量,只支持整数; +编辑config/init-host-info-add.properties,将文件中的指定信息按照既定格式进行修改,主要包括新增节点的ip、password、sshport、hostname; +完成上述步骤后,执行如下命令即可开始一键初始化任务。 +cd /data/datasophon-init/sbin +bash init.sh initSingleNode (等待程序执行完毕,中间需要有一次确认服务器时间的确认项需要选择) +PS:执行完毕之后如果服务器的终端未关闭,可能会出现一些命令无效的情况,此时需要手动在终端执行 ‘source /etc/profile ’使环境变量生效,或者关闭终端重新打开 diff --git a/datasophon-init/bin/init-singlehosts.sh b/datasophon-init/bin/init-singlehosts.sh new file mode 100644 index 00000000..0deb3838 --- /dev/null +++ b/datasophon-init/bin/init-singlehosts.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +hostAllInfoPath="$1" +initAllHostNums="$2" + +if [ $UID -ne 0 ]; then + echo Non root user. Please run as root. + exit 1 +fi +if [ -L $0 ]; then + BASE_DIR=$(dirname $(readlink $0)) +else + BASE_DIR=$(dirname $0) +fi +BASE_PATH=$( + cd ${BASE_DIR} + pwd +) + +INIT_PATH=$(dirname "${BASE_PATH}") +echo "INIT_PATH: ${INIT_PATH}" +INIT_BIN_PATH=${INIT_PATH}/bin +echo "INIT_BIN_PATH: ${INIT_BIN_PATH}" +INIT_SBIN_PATH=${INIT_PATH}/sbin +echo "INIT_SBIN_PATH: ${INIT_SBIN_PATH}" +PACKAGES_PATH=${INIT_PATH}/packages +echo "PACKAGES_PATH: ${PACKAGES_PATH}" +ETC_HOST=/etc/hosts +sed -i '/#modify etc hosts start/,/#modify etc hosts end/d' /etc/hosts +modifyHosts() { + cat /etc/hosts | grep yum + if [ $? -eq 0 ]; then + sed -i '/#modify yum mapping hosts start/i\#modify etc hosts start' /etc/hosts + while read line || [[ -n ${line} ]]; do + ip=$(echo $line | cut -d " " -f1) + port=$(echo $line | cut -d " " -f3) + hostname=$(echo $line | cut -d " " -f4) + echo "ip: ${ip}" + echo "port: ${port}" + echo "resule:${ip} ${hostname}" + sed -i '/#modify yum mapping hosts start/i '${ip}' '${hostname}'' /etc/hosts + done <${hostAllInfoPath} + sed -i '/#modify yum mapping hosts start/i\#modify etc hosts end' /etc/hosts + else + echo "#modify etc hosts start" >>/etc/hosts + while read line || [[ -n ${line} ]]; do + ip=$(echo $line | cut -d " " -f1) + port=$(echo $line | cut -d " " -f3) + hostname=$(echo $line | cut -d " " -f4) + echo "ip: ${ip}" + echo "port: ${port}" + echo "${ip} ${hostname}" >>/etc/hosts + done <${hostAllInfoPath} + echo "#modify etc hosts end" >>/etc/hosts + fi +} + +modifyHosts +sed -i 's/^[^#].*[0-9]-[0-9]/#&/g' /etc/hosts + +echo "init-singlehosts.sh finished." +echo "Done." diff --git a/datasophon-init/bin/init-ssh-hadoop.sh b/datasophon-init/bin/init-ssh-hadoop.sh index 765252ca..9b5c08b1 100644 --- a/datasophon-init/bin/init-ssh-hadoop.sh +++ b/datasophon-init/bin/init-ssh-hadoop.sh @@ -27,7 +27,6 @@ echo "PACKAGES_PATH: ${PACKAGES_PATH}" sshHadoopDir=/home/hadoop/.ssh/ rm -rf ${INIT_BIN_PATH}/tmp_scp_host_info.txt bash ${INIT_BIN_PATH}/init-hostIp-txt.sh ${filePath} ${initAllHostNums} - pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-add-hadoop-user.sh pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i "mkdir -p /home/hadoop/" pscp.pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -r /root/.ssh /home/hadoop/ diff --git a/datasophon-init/sbin/init.sh b/datasophon-init/sbin/init.sh index a7d3aea7..ff2dbaa3 100644 --- a/datasophon-init/sbin/init.sh +++ b/datasophon-init/sbin/init.sh @@ -56,6 +56,7 @@ initOS=$(prop "init.os") echo "yumRepoIp: ${yumRepoIp}" +#初始化所有节点 initALL() { function network() { @@ -186,11 +187,11 @@ initALL() { echo "closeAllTransparentHugepage start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeAllTransparentHugepage_$(date +%Y%m%d).log checkTransparentHugepage - #Configure JDK - echo "installAllJDK start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log - pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-jdk.sh >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log - echo "installAllJDK end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log - checkJDK + #Configure JDK(datasophon在安装的时候会自动安装jdk,这里不在重复安装) + #echo "installAllJDK start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-jdk.sh >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log + #echo "installAllJDK end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installAllJDK_$(date +%Y%m%d).log + #checkJDK pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-java-policy.sh >>${initLogDir}/modifyJavaPolicy_$(date +%Y%m%d).log pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-tmp_pid.sh @@ -253,6 +254,116 @@ initALL() { } +#初始化新增加的单节点 +initSingleNode() { + mkdir -p ${initLogDir}/logs + rm -rf ${INIT_BIN_PATH}/tmp_scp_host_info.txt + rm -rf ${INIT_BIN_PATH}/1.txt + rm -rf ${initLogDir}/installSingleSuccess_$(date +%Y%m%d).log + + secretFreeSingleNodeLogin + checkSecretFreeSingleNodeLogin + + #Distribution resource pack 分发资源包 + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i "mkdir -p '${DATASOPHON_PATH}'" + echo "Distribution resource pack start_time:$(date '+%Y%m%d %H:%M:%S')" + pscp.pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -r ${INIT_PATH} ${DATASOPHON_PATH} + + #close all Firewall + echo "closeSingleNodeFirewall start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeFirewall_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-stop-firewall.sh >>${initLogDir}/closeSingleNodeFirewall_$(date +%Y%m%d).log + echo "closeSingleNodeFirewall end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeFirewall_$(date +%Y%m%d).log + checkCloseSingleNodeFirewall + + #close all selinux + echo "closeSingleNodeSelinux start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeSelinux_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-stop-selinux.sh >>${initLogDir}/closeSingleNodeSelinux_$(date +%Y%m%d).log + echo "closeSingleNodeSelinux end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeSelinux_$(date +%Y%m%d).log + + #close all Swap + echo "closeSingleNodeSwap start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeSwap_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-close-swap.sh >>${initLogDir}/closeSingleNodeSwap_$(date +%Y%m%d).log + echo "closeSingleNodeSwap end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeSwap_$(date +%Y%m%d).log + checkCloseSingleNodeSwap + + #configure all slave node yum source + #因为安装配置yum离线源会涉及到服务器操作系统的版本问题,不同版本的操作系统离线源不同,完全自动化配置工作量巨大,由用户自己配置好 + if [ "${yumRepoNeed}" == "true" ]; then + if [ ! -d "/data/private-yum-library" ]; then + echo "没有发现private-yum-library目录,请确认是否正确配置离线yum源资源包......." + else + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-yum-hosts-mapping-${initOS}.sh ${yumRepoIp} >>${initLogDir}/modifySingleNodeYumRepo_$(date +%Y%m%d).log + fi + fi + + echo "modifySingleNodeSystemConf start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifySingleNodeSystemConf_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-system-conf.sh >>${initLogDir}/modifySingleNodeSystemConf_$(date +%Y%m%d).log + echo "modifySingleNodeSystemConf end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifySingleNodeSystemConf_$(date +%Y%m%d).log + + setSingleNodeHostname + checkSingleNodeHostName + + modifySingleNodeHostRelation + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-sourceSSHHostname.sh + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-ntp-chrony-slave.sh ${ntpMasterIP} + checkSingleNodeNtpService + + echo "installSingleNodelibxsltdevel start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodelibxsltdevel_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-libxslt-devel.sh >>${initLogDir}/installSingleNodelibxsltdevel_$(date +%Y%m%d).log + echo "installSingleNodelibxsltdevel end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodelibxsltdevel_$(date +%Y%m%d).log + checkSingleNodeLibxsltDevel + + echo "installSingleNodepsmisc start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodepsmisc_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-psmisc.sh >>${initLogDir}/installSingleNodepsmisc_$(date +%Y%m%d).log + echo "installSingleNodepsmisc end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodepsmisc_$(date +%Y%m%d).log + checkSingleNodePsmisc + + echo "installSingleNodePerlJSON start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodePerlJSON_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-perl-JSON.sh >>${initLogDir}/installSingleNodePerlJSON_$(date +%Y%m%d).log + echo "installSingleNodePerlJSON end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodePerlJSON_$(date +%Y%m%d).log + + echo "closeSingleNodeTransparentHugepage start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeTransparentHugepage_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-close-transparent-hugepage.sh >>${initLogDir}/closeSingleNodeTransparentHugepage_$(date +%Y%m%d).log + echo "closeSingleNodeTransparentHugepage start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/closeSingleNodeTransparentHugepage_$(date +%Y%m%d).log + checkSingleNodeTransparentHugepage + + #datasophon在安装的时候会自动安装jdk,这里不在重复安装 + #echo "installSingleNodeJDK start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodeJDK_$(date +%Y%m%d).log + #pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-jdk.sh >>${initLogDir}/installSingleNodeJDK_$(date +%Y%m%d).log + #echo "installSingleNodeJDK end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/installSingleNodeJDK_$(date +%Y%m%d).log + #checkSingleNodeJDK + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-java-policy.sh >>${initLogDir}/modifySingleNodeJavaPolicy_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-tmp_pid.sh + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-xdg-utils.sh >>${initLogDir}/installSingleNodeXdg_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-gcc-c++.sh >>${initLogDir}/installSingleNodeGccC++_$(date +%Y%m%d).log + checkSingleNodeGccC + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-openssl-devel.sh >>${initLogDir}/installSingleNodeOpensslDevel_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -t ${smallTimeOut} -i bash ${INIT_BIN_PATH}/init-libtool.sh >>${initLogDir}/installSingleNodeLibtool_$(date +%Y%m%d).log + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-krb5-devel.sh >>${initLogDir}/installSingleNodeKrb5Devel_$(date +%Y%m%d).log + checkSingleNodeKrb5Devel + + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-ntp_enable.sh >>${initLogDir}/installSingleNodeNtpEnable_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-chmod-dev-null.sh >>${initLogDir}/initSingleNodeChmodDevNull_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-cleanBuff-async.sh >>${initLogDir}/initSingleNodeCleanBuff_$(date +%Y%m%d).log + rm -rf ${INIT_BIN_PATH}/tmp_scp_host_info.txt + rm -rf ${INIT_BIN_PATH}/1.txt + initsource + source /etc/profile + source /root/.bash_profile + echo "The DataSophon deployment environment of added nodes has been inited successfully . Please proceed to the next step" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log + +} + initsource() { source /etc/profile source /root/.bash_profile @@ -263,6 +374,7 @@ testFun() { pssh -h ${INIT_BIN_PATH}/tmp_scp_host_info.txt -i bash ${INIT_BIN_PATH}/init-java-policy.sh >>${initLogDir}/modifyJavaPolicy_$(date +%Y%m%d).log } +#---------------------------initAll fun start-------------------------------# #免密登录 secretFreeAllLogin() { echo "secretFreeAllLogin........................" @@ -814,10 +926,384 @@ checkKrb5Devel() { done echo "SUCCESS: Set krb5-devel links have been inited successfully" >>${initLogDir}/installAllSuccess_$(date +%Y%m%d).log } +#---------------------------initAll fun end-------------------------------# + +#---------------------------init add Single node fun strat-------------------------------# + +secretFreeSingleNodeLogin() { + echo "secretFreeSingleNodeLogin start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/secretFreeSingleNodeLogin_$(date +%Y%m%d).log + bash ${INIT_BIN_PATH}/init-ssh-copy-key.sh ${hostSingleInfoPath} ${initSingleHostNums} ${nampServerPort} >>${initLogDir}/secretFreeSingleNodeLogin_$(date +%Y%m%d).log + bash ${INIT_BIN_PATH}/init-ssh-hadoop.sh ${hostSingleInfoPath} ${initSingleHostNums} >>${initLogDir}/secretFreeSingleNodeLogin_$(date +%Y%m%d).log + echo "secretFreeSingleNodeLogin end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/secretFreeSingleNodeLogin_$(date +%Y%m%d).log +} + +checkSecretFreeSingleNodeLogin() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + echo "${BASE_PATH}" + echo "${pwd}" + echo "${hostSingleInfoPath}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'ls' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' free login failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' free login failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added free login links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +checkCloseSingleNodeFirewall() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'firewall-cmd --state' >${initLogDir}/checkCloseSingleNodeFirewall.log + cat ${initLogDir}/checkCloseSingleNodeFirewall.log | grep running + if [ $? -eq 0 ]; then + echo "ERROR: The added '${ip}' close firewall failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' close firewall failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + else + echo "The added ${ip} close firewall successfully" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + fi + done + echo "SUCCESS:The added closing firewall links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +checkCloseSingleNodeSwap() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'cat /etc/sysctl.conf | grep vm.swappiness=0' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' close swap failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' close swap failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added closing swap links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +setSingleNodeHostname() { + echo "setSingleNodeHostname start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/setSingleNodeHostname_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + hostname=$(prop "dataSophon.ssh.port.hostname.${i}") + echo "${ip}" + echo "${pwd}" + echo "${port}" + echo "${BASE_PATH}" + echo "root@${ip}:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/setSingleNodeHostname_$(date +%Y%m%d).log + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} bash ${INIT_BIN_PATH}/init-hostname.sh ${hostname} >${initLogDir}/setSingleNodeHostname_$(date +%Y%m%d).log + done + echo "setSingleNodeHostname start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/setSingleNodeHostname_$(date +%Y%m%d).log +} + +checkSingleNodeHostName() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + hostname=$(prop "dataSophon.ssh.port.hostname.${i}") # hostname + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'hostname' >${initLogDir}/checkHostName.log + cat ${initLogDir}/checkHostName.log | grep "${hostname}" + if [ $? -eq 0 ]; then + echo "The added ${ip} hostname sets successfully" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' hostname failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' hostname failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added hostname links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +modifySingleNodeHostRelation() { + rm -rf ${INIT_BIN_PATH}/tmp_host_info.txt + rm -rf ${INIT_BIN_PATH}/tmp_host_all_info.txt + initTotalHostNums=$(expr $initAllHostNums + $initSingleHostNums) + echo "modifySingleNodeHostRelation start_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifySingleNodeHostRelation_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ipSingle=$(prop "dataSophon.ip.${i}") #ip + passwordSingle=$(prop "dataSophon.password.${i}") # password + portSingle=$(prop "dataSophon.ssh.port.${i}") # port + hostnameSingle=$(prop "dataSophon.ssh.port.hostname.${i}") + echo "${ip}" + echo "${pwd}" + echo "${port}" + echo "${BASE_PATH}" + echo -e "${ipSingle} ${passwordSingle} ${portSingle} ${hostnameSingle}" >>${INIT_BIN_PATH}/tmp_host_all_info.txt + echo "${ipSingle} ${passwordSingle} ${portSingle} ${hostnameSingle}" >>${initLogDir}/modifySingleNodeHostRelation_$(date +%Y%m%d).log + done + + function prop { + [ -f "${hostAllInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostAllInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initAllHostNums}; i++)); do + ipAll=$(prop "dataSophon.ip.${i}") #ip + passwordAll=$(prop "dataSophon.password.${i}") # password + portAll=$(prop "dataSophon.ssh.port.${i}") # port + hostnameAll=$(prop "dataSophon.ssh.port.hostname.${i}") + echo "${ip}" + echo "${pwd}" + echo "${port}" + echo "${BASE_PATH}" + echo -e "${ipAll} ${passwordAll} ${portAll} ${hostnameAll}" >>${INIT_BIN_PATH}/tmp_host_all_info.txt + echo "${ipAll} ${passwordAll} ${portAll} ${hostnameAll}" >>${initLogDir}/modifySingleNodeHostRelation_$(date +%Y%m%d).log + done + hostInfoPath=${INIT_BIN_PATH}/tmp_host_all_info.txt + while read line || [[ -n ${line} ]]; do + ip=$(echo $line | cut -d " " -f1) + port=$(echo $line | cut -d " " -f3) + echo -e "root@${ip}:${port}" >>${INIT_BIN_PATH}/tmp_host_info.txt + done <${hostInfoPath} + pscp.pssh -h ${INIT_BIN_PATH}/tmp_host_info.txt ${INIT_BIN_PATH}/tmp_host_all_info.txt ${INIT_BIN_PATH}/ + echo "${hostInfoPath} ${initTotalHostNums}" >>${initLogDir}/modifySingleNodeHostRelation_$(date +%Y%m%d).log + pssh -h ${INIT_BIN_PATH}/tmp_host_info.txt -i bash ${INIT_BIN_PATH}/init-singlehosts.sh ${hostInfoPath} ${initTotalHostNums} >>${initLogDir}/modifySingleNodeHostRelation_$(date +%Y%m%d).log + echo "modifySingleNodeHostRelation end_time:$(date '+%Y%m%d %H:%M:%S')" >>${initLogDir}/modifySingleNodeHostRelation_$(date +%Y%m%d).log + rm -rf ${INIT_BIN_PATH}/tmp_host_info.txt + rm -rf ${INIT_BIN_PATH}/tmp_host_all_info.txt +} + +checkSingleNodeNtpService() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep chrony-' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' set ntp failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' set ntp failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS:The added nodes ntp have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +checkSingleNodeLibxsltDevel() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep libxslt-devel' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' set libxslt devel failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' set libxslt devel failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS:The added nodes Set libxslt devel have been inited successfully" >>${initLogDir}/installSingleSuccess_$(date +%Y%m%d).log +} + +checkSingleNodePsmisc() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep psmisc' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' set psmisc failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' set psmisc failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added nodes set psmisc have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +checkSingleNodeTransparentHugepage() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'cat /sys/kernel/mm/transparent_hugepage/enabled | grep [never]' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' close transparent_hugepage failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' close transparent_hugepage failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added nodes transparent_hugepage links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +checkSingleNodeJDK() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'source /etc/profile ; java -version' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' set jdk failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' set jdk failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added nodes set JDK links have been inited successfully" >>${initLogDir}/installSingleodeSuccess_$(date +%Y%m%d).log +} + +checkSingleNodeGccC() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep gcc-c++' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' set gcc-c++ failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' set gcc-c++ failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added nodes set gcc-c++ links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +checkSingleNodeKrb5Devel() { + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + function prop { + [ -f "${hostSingleInfoPath}" ] && grep -P "^\s*[^#]?${1}=.*$" ${hostSingleInfoPath} | cut -d'=' -f2 + } + for ((i = 1; i <= ${initSingleHostNums}; i++)); do + ip=$(prop "dataSophon.ip.${i}") #ip + pwd=$(prop "dataSophon.password.${i}") # password + port=$(prop "dataSophon.ssh.port.${i}") # port + echo "${ip}" + echo "${pwd}" + echo "${port}" + sshpass -p'${pwd}' ssh -P${port} -o StrictHostKeyChecking=no root@${ip} 'rpm -qa | grep krb5-devel' >${initLogDir}/installSingleNode_$(date +%Y%m%d).log + else + echo "ERROR: The added '${ip}' set krb5-devel failed" >>${initLogDir}/installSingleNode_$(date +%Y%m%d).log + echo "ERROR: The added '${ip}' set krb5-devel failed" >>${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + cat ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + rm -rf ${initLogDir}/installSingleNodeError_$(date +%Y%m%d).log + exit + fi + done + echo "SUCCESS: The added nodes set krb5-devel links have been inited successfully" >>${initLogDir}/installSingleNodeSuccess_$(date +%Y%m%d).log +} + +#---------------------------init add Single node fun end-------------------------------# if [ "$Action" = "initAll" ]; then initALL - echo "initALL....................." + echo "initAll....................." +fi +if [ "$Action" = "initSingleNode" ]; then + initSingleNode fi if [ "$Action" = "secretFreeAllLogin" ]; then secretFreeAllLogin From 991e1625242765a7fd313d308d5e753db1f62a55 Mon Sep 17 00:00:00 2001 From: liu-hai Date: Wed, 30 Aug 2023 17:15:59 +0800 Subject: [PATCH 09/11] =?UTF-8?q?[Improvement][Api]=20https://github.com/d?= =?UTF-8?q?atavane/datasophon/issues/364=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/assembly.xml | 13 ++++++ .../java/com/datasophon/common/Constants.java | 3 ++ .../datasophon/common/utils/HostUtils.java | 18 ++++++++ .../api/master/DispatcherWorkerActor.java | 44 +++++++++++++++++-- .../api/master/HostConnectActor.java | 30 +++++++++---- .../api/utils/ExecuteShellScriptUtils.java | 25 +++++++++++ scripts/dispatcher-worker.sh | 30 +++++++++++++ 7 files changed, 151 insertions(+), 12 deletions(-) create mode 100644 datasophon-service/src/main/java/com/datasophon/api/utils/ExecuteShellScriptUtils.java create mode 100644 scripts/dispatcher-worker.sh diff --git a/datasophon-api/src/main/resources/assembly.xml b/datasophon-api/src/main/resources/assembly.xml index 93a70431..a8a20fbd 100644 --- a/datasophon-api/src/main/resources/assembly.xml +++ b/datasophon-api/src/main/resources/assembly.xml @@ -96,6 +96,19 @@ unix + ++ ${basedir}/../scripts ++ +*.sh +0755 +0755 +true +scripts + +unix +diff --git a/datasophon-common/src/main/java/com/datasophon/common/Constants.java b/datasophon-common/src/main/java/com/datasophon/common/Constants.java index 6de4c347..0b0c449b 100644 --- a/datasophon-common/src/main/java/com/datasophon/common/Constants.java +++ b/datasophon-common/src/main/java/com/datasophon/common/Constants.java @@ -47,6 +47,7 @@ public final class Constants { public static final String WORKER_PACKAGE_NAME = "datasophon-worker.tar.gz"; public static final String WORKER_SCRIPT_PATH = INSTALL_PATH + "/datasophon-worker/script/"; public static final String WORKER_PATH = INSTALL_PATH + "/datasophon-worker"; + public static final String SHELL_SCRIPT_PATH = "/scripts"; public static final String CLUSTER_ID = "cluster_id"; public static final String MANAGED = "managed"; @@ -255,4 +256,6 @@ private Constants() { * root user */ public static final String ROOT = "root"; + + public static final String DISPATCHER_WORK = "dispatcher-worker.sh"; } diff --git a/datasophon-common/src/main/java/com/datasophon/common/utils/HostUtils.java b/datasophon-common/src/main/java/com/datasophon/common/utils/HostUtils.java index 92e4fc33..55932f6d 100644 --- a/datasophon-common/src/main/java/com/datasophon/common/utils/HostUtils.java +++ b/datasophon-common/src/main/java/com/datasophon/common/utils/HostUtils.java @@ -84,4 +84,22 @@ public static String getIp(String hostName) { } } + public static String getLocalIp() { + try { + InetAddress ip = InetAddress.getLocalHost(); + return ip.getHostAddress(); + } catch (UnknownHostException e) { + throw new RuntimeException(e); + } + } + + public static String getLocalHostName() { + try { + InetAddress ip = InetAddress.getLocalHost(); + return ip.getHostName(); + } catch (UnknownHostException e) { + throw new RuntimeException(e); + } + } + } diff --git a/datasophon-service/src/main/java/com/datasophon/api/master/DispatcherWorkerActor.java b/datasophon-service/src/main/java/com/datasophon/api/master/DispatcherWorkerActor.java index fc02741c..5cad4a10 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/master/DispatcherWorkerActor.java +++ b/datasophon-service/src/main/java/com/datasophon/api/master/DispatcherWorkerActor.java @@ -19,17 +19,23 @@ package com.datasophon.api.master; +import cn.hutool.core.io.FileUtil; import com.datasophon.api.master.handler.host.CheckWorkerMd5Handler; import com.datasophon.api.master.handler.host.DecompressWorkerHandler; import com.datasophon.api.master.handler.host.DispatcherWorkerHandlerChain; import com.datasophon.api.master.handler.host.InstallJDKHandler; import com.datasophon.api.master.handler.host.StartWorkerHandler; import com.datasophon.api.master.handler.host.UploadWorkerHandler; +import com.datasophon.api.utils.CommonUtils; +import com.datasophon.api.utils.ExecuteShellScriptUtils; import com.datasophon.api.utils.MessageResolverUtils; import com.datasophon.api.utils.MinaUtils; +import com.datasophon.common.Constants; import com.datasophon.common.command.DispatcherHostAgentCommand; +import com.datasophon.common.enums.InstallState; import com.datasophon.common.model.HostInfo; +import com.datasophon.common.utils.HostUtils; import org.apache.sshd.client.session.ClientSession; import scala.Option; @@ -40,6 +46,8 @@ import akka.actor.UntypedActor; import cn.hutool.core.util.ObjectUtil; +import java.nio.charset.Charset; + public class DispatcherWorkerActor extends UntypedActor { private static final Logger logger = LoggerFactory.getLogger(DispatcherWorkerActor.class); @@ -54,6 +62,8 @@ public void preRestart(Throwable reason, Option